package com.engine.salary.service.impl; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; import com.engine.salary.constant.SalaryDefaultTenantConstant; import com.engine.salary.entity.push.param.PushSettingItemSaveParam; import com.engine.salary.entity.push.param.PushSettingSaveParam; import com.engine.salary.entity.push.po.PushSettingItemPO; import com.engine.salary.entity.push.po.PushSettingPO; import com.engine.salary.exception.SalaryRunTimeException; import com.engine.salary.mapper.push.PushSettingItemMapper; import com.engine.salary.mapper.push.PushSettingMapper; import com.engine.salary.service.PushService; import com.engine.salary.service.TaxAgentService; import com.engine.salary.util.db.IdGenerator; import com.engine.salary.util.db.MapperProxyFactory; import com.engine.salary.util.valid.ValidUtil; import weaver.hrm.User; import java.util.Date; /** * 推送服务 *

Copyright: Copyright (c) 2024

*

Company: 泛微软件

* * @author qiantao * @version 1.0 **/ public class PushServiceImpl extends Service implements PushService { private PushSettingMapper getPushSettingMapper() { return MapperProxyFactory.getProxy(PushSettingMapper.class); } private PushSettingItemMapper getPushSettingItemMapper() { return MapperProxyFactory.getProxy(PushSettingItemMapper.class); } private TaxAgentService getTaxAgentService(User user) { return ServiceUtil.getService(TaxAgentServiceImpl.class, user); } @Override public PushSettingPO save(PushSettingSaveParam param) { ValidUtil.doValidator(param); Date now = new Date(); Long id = param.getId(); PushSettingPO po; if (id == null) { po = PushSettingPO.builder() .id(IdGenerator.generate()) .able(param.getAble()) .name(param.getName()) .salarySobIds(param.getSalarySobIds()) .modeId(param.getModeId()) .modeName(param.getModeName()) .tableName(param.getTableName()) .creator((long) user.getUID()) .createTime(now) .updateTime(now) .deleteType(0) .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) .build(); getPushSettingMapper().insertIgnoreNull(po); } else { po = getPushSettingMapper().getById(id); if (po == null) { throw new SalaryRunTimeException("推送配置不存在!"); } po.setAble(param.getAble()); po.setAble(param.getAble()); po.setName(param.getName()); po.setSalarySobIds(param.getSalarySobIds()); po.setModeId(param.getModeId()); po.setModeName(param.getModeName()); po.setTableName(param.getTableName()); po.setUpdateTime(now); getPushSettingMapper().update(po); } return po; } @Override public PushSettingItemPO saveItem(PushSettingItemSaveParam param) { ValidUtil.doValidator(param); Date now = new Date(); Long id = param.getId(); PushSettingItemPO po; if (id == null) { po = PushSettingItemPO.builder() .id(IdGenerator.generate()) .settingId(param.getSettingId()) .item(param.getItem()) .itemName(param.getItemName()) .source(param.getSource().getValue()) .fieldName(param.getFieldName()) .fieldType(param.getFieldType().getValue()) .creator((long) user.getUID()) .createTime(now) .updateTime(now) .deleteType(0) .tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY) .build(); getPushSettingItemMapper().insertIgnoreNull(po); } else { po = getPushSettingItemMapper().getById(id); if (po == null) { throw new SalaryRunTimeException("推送配置明细不存在!"); } po.setSettingId(param.getSettingId()); po.setItem(param.getItem()); po.setItemName(param.getItemName()); po.setSource(param.getSource().getValue()); po.setFieldName(param.getFieldName()); po.setFieldType(param.getFieldType().getValue()); po.setUpdateTime(now); getPushSettingItemMapper().update(po); } return po; } }