Commit 0caeff84 authored by huyuchen's avatar huyuchen

huych-入职登记商险待办提交

parent cf541ed7
......@@ -55,4 +55,13 @@ public interface TEmployeePreLogService extends IService<TEmployeePreLog> {
void saveModifyAndUpdateInsurance(String empPreId, EmployeeRegistrationPre oldInfo
, EmployeeRegistrationPre newInfo, YifuUser user, Map<String, TEmployeeInsurancePre> oldMap);
/**
* @Description: 添加日志并修改商险list
* @Author: huych
* @Date: 2025/4/11 18:12
* @return: void
**/
void saveUpdateInsurance(String empPreId, EmployeeRegistrationPre oldInfo
, EmployeeRegistrationPre newInfo,String userId, String nickName,Map<String, TEmployeeInsurancePre> oldMap);
}
......@@ -256,7 +256,34 @@ public class EmployeeRegistrationPreServiceImpl extends ServiceImpl<EmployeeRegi
baseMapper.deleteById(preExit);
}
baseMapper.insert(pre);
Map<String, TEmployeeInsurancePre> oldMap = new HashMap<>();
if (Common.isNotNull(preExit)) {
if (Common.isNotNull(preVo.getServerItem()) && preVo.getServerItem().contains("商险")) {
List<TEmployeeInsurancePreVo> newList = preVo.getEmployeeInsurancePreVos();
String newKey;
Map<String,String> map = new HashMap<>();
if (null != newList && !newList.isEmpty()) {
for (TEmployeeInsurancePreVo preVo1 : newList) {
newKey = this.getPreFiveKey(preVo1);
map.put(newKey,"1");
}
}
// 查原商险,来对比
R<EmployeePreLogListVo> sdr = HttpDaprUtil.invokeMethodPost(daprInsurancesProperties.getAppUrl(), daprInsurancesProperties.getAppId()
, "/temployeeinsurancepre/inner/getListByEmpPreId", preExit.getId(), EmployeePreLogListVo.class, SecurityConstants.FROM_IN);
List<TEmployeeInsurancePre> oldList = null;
if (sdr != null && sdr.getData() != null && sdr.getData().getPreList() != null && !sdr.getData().getPreList().isEmpty()) {
oldList = sdr.getData().getPreList();
}
if (null != oldList && !oldList.isEmpty()) {
for (TEmployeeInsurancePre oldInsurance : oldList) {
// 1:判断是否变更 商险待办 的项目
if (null != map.get(this.getFiveKey(oldInsurance))) {
oldMap.put(oldInsurance.getId(), oldInsurance);
}
}
}
}
String natureItemBefore = null;
String natureItemAfter = null;
String contractItemBefore = null;
......@@ -352,8 +379,9 @@ public class EmployeeRegistrationPreServiceImpl extends ServiceImpl<EmployeeRegi
if (null != contractXfAfter) {
pre.setContractSubName(contractXfAfter);
}
tEmployeeLogService.saveModificationRecord(CommonConstants.dingleDigitIntArray[4],
pre.getId(), "", preExit, pre, pre.getCreateBy(), pre.getCreateName());
// 添加日志并修改商险list
tEmployeePreLogService.saveUpdateInsurance(preExit.getId(), preExit
, pre, preVo.getCreateBy(),preVo.getCreateName(), oldMap);
}
if (Common.isNotNull(preVo.getExpectedCollectionTime())) {
// 事务提交后触发调度
......@@ -707,6 +735,21 @@ public class EmployeeRegistrationPreServiceImpl extends ServiceImpl<EmployeeRegi
+ isNullToEmpty(insurancePreVo.getPolicyStart()) + CommonConstants.DOWN_LINE_STRING + isNullToEmpty(insurancePreVo.getPolicyEnd());
}
/**
* @param insurancePreVo
* @Description: 获取5个字段构成的关键字
* @Author: hgw
* @Date: 2025/4/9 11:23
* @return: java.lang.String
**/
private String getPreFiveKey(TEmployeeInsurancePreVo insurancePreVo) {
// 1:重复性判断
return isNullToEmpty(insurancePreVo.getBuyStandard()) + CommonConstants.DOWN_LINE_STRING
+ isNullToEmpty(insurancePreVo.getInsuranceTypeName()) + CommonConstants.DOWN_LINE_STRING
+ isNullToEmpty(insurancePreVo.getInsuranceCompanyName()) + CommonConstants.DOWN_LINE_STRING
+ isNullToEmpty(insurancePreVo.getPolicyStart()) + CommonConstants.DOWN_LINE_STRING + isNullToEmpty(insurancePreVo.getPolicyEnd());
}
/**
* @param str
* @Description: 空转化为空字符
......
......@@ -260,6 +260,84 @@ public class TEmployeePreLogServiceImpl extends ServiceImpl<TEmployeePreLogMappe
}
}
@Override
public void saveUpdateInsurance(String empPreId, EmployeeRegistrationPre oldInfo
, EmployeeRegistrationPre newInfo, String userId, String nickName, Map<String, TEmployeeInsurancePre> oldMap) {
try {
//比较记录不影响业务逻辑,用try套住
//比较差异
String differenceKey = HrEquator.comparisonValue(oldInfo, newInfo);
//如果有差异保存差异
List<TEmployeeInsurancePre> newList = newInfo.getInsurancePreList();
String diffTitle = null;
String logId = String.valueOf(UUID.randomUUID()).replaceAll("-", "");
// 要保存的明细
List<TEmployeePreLogDetail> detailList = new ArrayList<>();
// 档案信息修改
TEmployeePreLogDetail detailEmpLog = null;
if (Common.isNotNull(differenceKey) && !"insurancePreList".equals(differenceKey)) {
differenceKey = differenceKey.replace("insurancePreList","");
diffTitle = "档案信息";
detailEmpLog = new TEmployeePreLogDetail();
detailEmpLog.setModelType(CommonConstants.TWO_STRING);
detailEmpLog.setType(CommonConstants.ONE_STRING);
this.setPreLogBaseInfo(empPreId, oldInfo, newInfo, userId, nickName, differenceKey, logId, detailEmpLog);
detailList.add(detailEmpLog);
}
if (newList != null && !newList.isEmpty()) {
// 是否修改了商险
boolean isModifyInsurance = false;
TEmployeeInsurancePre oldInsurance;
String differenceInsuranceKey;
TEmployeePreLogDetail detailInsuranceLog;
for (TEmployeeInsurancePre newInsurance : newList) {
differenceInsuranceKey = null;
// 2:修改有老ID
if (Common.isNotNull(newInsurance.getId())) {
oldInsurance = oldMap.get(newInsurance.getId());
if (oldInsurance != null) {
differenceInsuranceKey = HrEquator.comparisonValue(oldInsurance, newInsurance);
}
if (Common.isNotNull(differenceInsuranceKey) || oldInsurance == null) {
detailInsuranceLog = new TEmployeePreLogDetail();
detailInsuranceLog.setModelType(CommonConstants.TWO_STRING);
detailInsuranceLog.setType(CommonConstants.TWO_STRING);
this.setPreLogBaseInfo(empPreId, oldInsurance, newInsurance, userId, nickName, differenceInsuranceKey, logId, detailInsuranceLog);
isModifyInsurance = true;
detailList.add(detailInsuranceLog);
}
}
}
// 如果变更了
if (isModifyInsurance) {
if (Common.isNotNull(diffTitle)) {
diffTitle += "、商险信息";
} else {
diffTitle = "商险信息";
}
}
}
// 有修改,则加日志
if (Common.isNotNull(diffTitle)) {
TEmployeePreLog empPreLog = new TEmployeePreLog();
empPreLog.setId(logId);
empPreLog.setPreId(empPreId);
empPreLog.setDiffTitle(diffTitle);
empPreLog.setCreateTime(LocalDateTime.now());
if (Common.isNotNull(userId) && Common.isNotNull(nickName)) {
empPreLog.setCreateBy(userId);
empPreLog.setCreateName(nickName);
}
baseMapper.insert(empPreLog);
if (!detailList.isEmpty()) {
tEmployeePreLogDetailService.saveBatch(detailList);
}
}
} catch (Exception e) {
log.error(JSON.toJSON(newInfo) + "插入修改记录报错>>>", e);
}
}
/**
* @Description: 填充基本信息
* @Author: hgw
......@@ -284,4 +362,26 @@ public class TEmployeePreLogServiceImpl extends ServiceImpl<TEmployeePreLogMappe
}
}
/**
* @Description: 填充基本信息
* @Author: huyc
* @Date: 2025/4/11 10:49
* @return: void
**/
private void setPreLogBaseInfo(String empPreId, Object oldInfo, Object newInfo
, String userId, String nickName, String differenceKey, String logId, TEmployeePreLogDetail detailEmpLog) {
detailEmpLog.setPreId(empPreId);
detailEmpLog.setPreLogId(logId);
detailEmpLog.setDifferenceInfo(differenceKey);
detailEmpLog.setCreateTime(LocalDateTime.now());
detailEmpLog.setCreateBy(userId);
detailEmpLog.setCreateName(nickName);
if (Common.isNotNull(oldInfo)) {
detailEmpLog.setOldInfo(JSON.toJSONString(oldInfo, features));
}
if (Common.isNotNull(newInfo)) {
detailEmpLog.setNewInfo(JSON.toJSONString(newInfo, features));
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment