Commit 322f714a authored by hongguangwu's avatar hongguangwu

MVP1.7.17-模板优化

parent 1c39ce53
...@@ -79,106 +79,114 @@ public class FascServiceImpl extends ServiceImpl<FddContractInfoMapper, FddContr ...@@ -79,106 +79,114 @@ public class FascServiceImpl extends ServiceImpl<FddContractInfoMapper, FddContr
} }
List<TFascCompany> companyList = tFascCompanyService.getTFascCompanyAllList(); List<TFascCompany> companyList = tFascCompanyService.getTFascCompanyAllList();
if (companyList != null && !companyList.isEmpty()) { if (companyList != null && !companyList.isEmpty()) {
// templateName 签署任务模板名称
List<TFascTemplate> tList = new ArrayList<>();
List<SignTemplateListInfo> listSubList;
List<TFascTemplate> tempList = new ArrayList<>();
List<TFascTemplateDetail> detailList = new ArrayList<>();
List<TFascTemplateDetail> detailSubList;
for (TFascCompany company : companyList) { for (TFascCompany company : companyList) {
listSubList = fascUtil.getTemplateList(templateName, tFascPushLogService, company);
if (listSubList != null && !listSubList.isEmpty()) {
detailSubList = new ArrayList<>();
fascUtil.getTemplateDetailList(listSubList, tempList, detailSubList, tFascPushLogService, company);
if (!tempList.isEmpty() && !detailSubList.isEmpty()) {
tList.addAll(tempList);
detailList.addAll(detailSubList);
}
}
}
// templateName 签署任务模板名称 // 拉取到数据再更新:
List<SignTemplateListInfo> list = fascUtil.getTemplateList(templateName, tFascPushLogService, company); if (!tList.isEmpty() && !detailList.isEmpty()) {
if (list != null && !list.isEmpty()) { String editContent1 = "定时任务同步,拉取到数据";
List<TFascTemplate> tList = new ArrayList<>(); String editContent2 = "定时任务同步,法大大无该数据";
List<TFascTemplateDetail> detailList = new ArrayList<>(); if (!"-1".equals(userId)) {
fascUtil.getTemplateDetailList(list, tList, detailList, tFascPushLogService, company); editContent1 = "手动拉取任务同步,拉取到数据";
// 拉取到数据再更新: editContent2 = "手动拉取任务同步,法大大无该数据";
if (!tList.isEmpty() && !detailList.isEmpty()) { }
String editContent1 = "定时任务同步,拉取到数据"; List<TFascTemplate> updateMain = new ArrayList<>();
String editContent2 = "定时任务同步,法大大无该数据"; List<TFascTemplateDetail> updateDetail = new ArrayList<>();
if (!"-1".equals(userId)) {
editContent1 = "手动拉取任务同步,拉取到数据";
editContent2 = "手动拉取任务同步,法大大无该数据";
}
List<TFascTemplate> updateMain = new ArrayList<>();
List<TFascTemplateDetail> updateDetail = new ArrayList<>();
List<TFascTemplate> allMain = tFascTemplateService.getTFascTemplateListAll(null); List<TFascTemplate> allMain = tFascTemplateService.getTFascTemplateListAll(null);
List<TFascTemplateDetail> allDetail = tFascTemplateDetailService.getTFascTemplateDetailList(null); List<TFascTemplateDetail> allDetail = tFascTemplateDetailService.getTFascTemplateDetailList(null);
List<TFascEditLog> logList = new ArrayList<>(); List<TFascEditLog> logList = new ArrayList<>();
if (allMain == null || allMain.isEmpty()) { if (allMain == null || allMain.isEmpty()) {
// 都是新的: // 都是新的:
tFascTemplateService.saveBatch(tList); tFascTemplateService.saveBatch(tList);
tFascTemplateDetailService.saveOrUpdateBatch(detailList); tFascTemplateDetailService.saveOrUpdateBatch(detailList);
for (TFascTemplate t : tList) { for (TFascTemplate t : tList) {
this.addFascLogToList(t.getId(), CommonConstants.ONE_STRING, editContent1, logList, userId, userName); this.addFascLogToList(t.getId(), CommonConstants.ONE_STRING, editContent1, logList, userId, userName);
} }
for (TFascTemplateDetail t : detailList) { for (TFascTemplateDetail t : detailList) {
this.addFascLogToList(t.getId(), CommonConstants.TWO_STRING, editContent1, logList, userId, userName); this.addFascLogToList(t.getId(), CommonConstants.TWO_STRING, editContent1, logList, userId, userName);
} }
} else {
// 混合老新数据
Map<String, TFascTemplate> oldMainMap = new HashMap<>();
Map<String, TFascTemplateDetail> oldDetailMap = new HashMap<>();
for (TFascTemplate t : allMain) {
oldMainMap.put(t.getSignTemplateId(), t);
}
for (TFascTemplateDetail t : allDetail) {
oldDetailMap.put(t.getSignTemplateId() + CommonConstants.DOWN_LINE_STRING + t.getFascFieldId(), t);
}
// 主表:
TFascTemplate oldMain;
String logId;
for (TFascTemplate t : tList) {
oldMain = oldMainMap.get(t.getSignTemplateId());
if (oldMain != null) {
t.setId(oldMain.getId());
} else { } else {
// 混合老新数据 logId = String.valueOf(UUID.randomUUID()).replaceAll("-", "");
Map<String, TFascTemplate> oldMainMap = new HashMap<>(); t.setId(logId);
Map<String, TFascTemplateDetail> oldDetailMap = new HashMap<>();
for (TFascTemplate t : allMain) {
oldMainMap.put(t.getSignTemplateId(), t);
}
for (TFascTemplateDetail t : allDetail) {
oldDetailMap.put(t.getSignTemplateId() + CommonConstants.DOWN_LINE_STRING + t.getFascFieldId(), t);
}
// 主表:
TFascTemplate oldMain;
String logId;
for (TFascTemplate t : tList) {
oldMain = oldMainMap.get(t.getSignTemplateId());
if (oldMain != null) {
t.setId(oldMain.getId());
} else {
logId = String.valueOf(UUID.randomUUID()).replaceAll("-", "");
t.setId(logId);
}
this.addFascLogToList(t.getId(), CommonConstants.ONE_STRING, editContent1, logList, userId, userName);
updateMain.add(t);
oldMainMap.remove(t.getSignTemplateId());
}
for (TFascTemplate t : oldMainMap.values()) {
this.addFascLogToList(t.getId(), CommonConstants.ONE_STRING, editContent2, logList, userId, userName);
t.setDeleteFlag(CommonConstants.DELETE_FLAG);
updateMain.add(t);
}
// 映射表:
TFascTemplateDetail oldDetail;
for (TFascTemplateDetail t : detailList) {
oldDetail = oldDetailMap.get(t.getSignTemplateId() + CommonConstants.DOWN_LINE_STRING + t.getFascFieldId());
if (oldDetail != null) {
t.setId(oldDetail.getId());
t.setHrField(oldDetail.getHrField());
t.setHrFieldId(oldDetail.getHrFieldId());
} else {
logId = String.valueOf(UUID.randomUUID()).replaceAll("-", "");
t.setId(logId);
}
this.addFascLogToList(t.getId(), CommonConstants.TWO_STRING, editContent1, logList, userId, userName);
updateDetail.add(t);
oldDetailMap.remove(t.getSignTemplateId() + CommonConstants.DOWN_LINE_STRING + t.getFascFieldId());
}
for (TFascTemplateDetail t : oldDetailMap.values()) {
this.addFascLogToList(t.getId(), CommonConstants.TWO_STRING, editContent2, logList, userId, userName);
t.setDeleteFlag(CommonConstants.DELETE_FLAG);
updateDetail.add(t);
}
} }
// 更新日志 this.addFascLogToList(t.getId(), CommonConstants.ONE_STRING, editContent1, logList, userId, userName);
if (!logList.isEmpty()) { updateMain.add(t);
tFascEditLogService.saveBatch(logList); oldMainMap.remove(t.getSignTemplateId());
} }
// 更新模板 for (TFascTemplate t : oldMainMap.values()) {
if (!updateMain.isEmpty()) { this.addFascLogToList(t.getId(), CommonConstants.ONE_STRING, editContent2, logList, userId, userName);
tFascTemplateService.saveOrUpdateBatch(updateMain); t.setDeleteFlag(CommonConstants.DELETE_FLAG);
} updateMain.add(t);
// 更新模板映射 }
if (!updateDetail.isEmpty()) { // 映射表:
tFascTemplateDetailService.saveOrUpdateBatch(updateDetail); TFascTemplateDetail oldDetail;
for (TFascTemplateDetail t : detailList) {
oldDetail = oldDetailMap.get(t.getSignTemplateId() + CommonConstants.DOWN_LINE_STRING + t.getFascFieldId());
if (oldDetail != null) {
t.setId(oldDetail.getId());
t.setHrField(oldDetail.getHrField());
t.setHrFieldId(oldDetail.getHrFieldId());
} else {
logId = String.valueOf(UUID.randomUUID()).replaceAll("-", "");
t.setId(logId);
} }
// 重新刷新主模板表的必填是否已填 this.addFascLogToList(t.getId(), CommonConstants.TWO_STRING, editContent1, logList, userId, userName);
tFascTemplateDetailService.initFascTemplateIsMust(null); updateDetail.add(t);
oldDetailMap.remove(t.getSignTemplateId() + CommonConstants.DOWN_LINE_STRING + t.getFascFieldId());
} }
for (TFascTemplateDetail t : oldDetailMap.values()) {
this.addFascLogToList(t.getId(), CommonConstants.TWO_STRING, editContent2, logList, userId, userName);
t.setDeleteFlag(CommonConstants.DELETE_FLAG);
updateDetail.add(t);
}
}
// 更新日志
if (!logList.isEmpty()) {
tFascEditLogService.saveBatch(logList);
}
// 更新模板
if (!updateMain.isEmpty()) {
tFascTemplateService.saveOrUpdateBatch(updateMain);
}
// 更新模板映射
if (!updateDetail.isEmpty()) {
tFascTemplateDetailService.saveOrUpdateBatch(updateDetail);
} }
// 重新刷新主模板表的必填是否已填
tFascTemplateDetailService.initFascTemplateIsMust(null);
} }
} }
return R.ok(); return R.ok();
......
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