Commit 322f714a authored by hongguangwu's avatar hongguangwu

MVP1.7.17-模板优化

parent 1c39ce53
......@@ -79,106 +79,114 @@ public class FascServiceImpl extends ServiceImpl<FddContractInfoMapper, FddContr
}
List<TFascCompany> companyList = tFascCompanyService.getTFascCompanyAllList();
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) {
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 (list != null && !list.isEmpty()) {
List<TFascTemplate> tList = new ArrayList<>();
List<TFascTemplateDetail> detailList = new ArrayList<>();
fascUtil.getTemplateDetailList(list, tList, detailList, tFascPushLogService, company);
// 拉取到数据再更新:
if (!tList.isEmpty() && !detailList.isEmpty()) {
String editContent1 = "定时任务同步,拉取到数据";
String editContent2 = "定时任务同步,法大大无该数据";
if (!"-1".equals(userId)) {
editContent1 = "手动拉取任务同步,拉取到数据";
editContent2 = "手动拉取任务同步,法大大无该数据";
}
List<TFascTemplate> updateMain = new ArrayList<>();
List<TFascTemplateDetail> updateDetail = new ArrayList<>();
// 拉取到数据再更新:
if (!tList.isEmpty() && !detailList.isEmpty()) {
String editContent1 = "定时任务同步,拉取到数据";
String editContent2 = "定时任务同步,法大大无该数据";
if (!"-1".equals(userId)) {
editContent1 = "手动拉取任务同步,拉取到数据";
editContent2 = "手动拉取任务同步,法大大无该数据";
}
List<TFascTemplate> updateMain = new ArrayList<>();
List<TFascTemplateDetail> updateDetail = new ArrayList<>();
List<TFascTemplate> allMain = tFascTemplateService.getTFascTemplateListAll(null);
List<TFascTemplateDetail> allDetail = tFascTemplateDetailService.getTFascTemplateDetailList(null);
List<TFascEditLog> logList = new ArrayList<>();
if (allMain == null || allMain.isEmpty()) {
// 都是新的:
tFascTemplateService.saveBatch(tList);
tFascTemplateDetailService.saveOrUpdateBatch(detailList);
for (TFascTemplate t : tList) {
this.addFascLogToList(t.getId(), CommonConstants.ONE_STRING, editContent1, logList, userId, userName);
}
for (TFascTemplateDetail t : detailList) {
this.addFascLogToList(t.getId(), CommonConstants.TWO_STRING, editContent1, logList, userId, userName);
}
List<TFascTemplate> allMain = tFascTemplateService.getTFascTemplateListAll(null);
List<TFascTemplateDetail> allDetail = tFascTemplateDetailService.getTFascTemplateDetailList(null);
List<TFascEditLog> logList = new ArrayList<>();
if (allMain == null || allMain.isEmpty()) {
// 都是新的:
tFascTemplateService.saveBatch(tList);
tFascTemplateDetailService.saveOrUpdateBatch(detailList);
for (TFascTemplate t : tList) {
this.addFascLogToList(t.getId(), CommonConstants.ONE_STRING, editContent1, logList, userId, userName);
}
for (TFascTemplateDetail t : detailList) {
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 {
// 混合老新数据
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 {
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);
}
logId = String.valueOf(UUID.randomUUID()).replaceAll("-", "");
t.setId(logId);
}
// 更新日志
if (!logList.isEmpty()) {
tFascEditLogService.saveBatch(logList);
}
// 更新模板
if (!updateMain.isEmpty()) {
tFascTemplateService.saveOrUpdateBatch(updateMain);
}
// 更新模板映射
if (!updateDetail.isEmpty()) {
tFascTemplateDetailService.saveOrUpdateBatch(updateDetail);
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);
}
// 重新刷新主模板表的必填是否已填
tFascTemplateDetailService.initFascTemplateIsMust(null);
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);
}
}
// 更新日志
if (!logList.isEmpty()) {
tFascEditLogService.saveBatch(logList);
}
// 更新模板
if (!updateMain.isEmpty()) {
tFascTemplateService.saveOrUpdateBatch(updateMain);
}
// 更新模板映射
if (!updateDetail.isEmpty()) {
tFascTemplateDetailService.saveOrUpdateBatch(updateDetail);
}
// 重新刷新主模板表的必填是否已填
tFascTemplateDetailService.initFascTemplateIsMust(null);
}
}
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