|
@@ -177,27 +177,47 @@ public class CompanyInfoController {
|
|
|
|
|
|
try {
|
|
|
int affectCount = 0;
|
|
|
- CompanyInfo companyInfo = new CompanyInfo();
|
|
|
- PojoUtils.map(companyInfoDTO, companyInfo);
|
|
|
+ CompanyInfo srcCompany = companyInfoService.get(companyInfoDTO.getId());
|
|
|
+
|
|
|
+ CompanyInfo destCompany = new CompanyInfo();
|
|
|
+ PojoUtils.map(companyInfoDTO, destCompany);
|
|
|
|
|
|
//上级单位code
|
|
|
- if (StringUtils.isNotEmpty(companyInfo.getParentId())){
|
|
|
- CompanyInfo parent = companyInfoService.get(companyInfo.getParentId());
|
|
|
- companyInfo.setCode(parent.getCode() + "," + companyInfo.getId());
|
|
|
+ if (StringUtils.isNotEmpty(destCompany.getParentId())){
|
|
|
+ CompanyInfo parent = companyInfoService.get(destCompany.getParentId());
|
|
|
+ destCompany.setCode(parent.getCode() + "," + destCompany.getId());
|
|
|
}
|
|
|
else{
|
|
|
- companyInfo.setCode(companyInfo.getId());
|
|
|
+ destCompany.setCode(destCompany.getId());
|
|
|
}
|
|
|
|
|
|
- companyInfo.setUpdateBy(subject);
|
|
|
- companyInfo.setUpdateTime(new Date());
|
|
|
- companyInfoService.update(companyInfo);
|
|
|
- map.put("companyInfo",companyInfo);
|
|
|
+ String newCode = destCompany.getCode();
|
|
|
+ String oldCode = srcCompany.getCode();
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(oldCode) && !oldCode.equals(newCode)) {
|
|
|
+ companyInfoService.updateCode(oldCode,newCode);
|
|
|
+// List<CompanyInfo> children = companyInfoService.findByCompanyCode(oldCode + "%");
|
|
|
+//
|
|
|
+// for (CompanyInfo child : children) {
|
|
|
+// child.setCode(newCode + child.getCode().substring(oldCode.length()));
|
|
|
+// child.setUpdateTime(new Date());
|
|
|
+// child.setUpdateBy(subject);
|
|
|
+//
|
|
|
+// companyInfoService.update(child);
|
|
|
+// }
|
|
|
+ }
|
|
|
+
|
|
|
+ destCompany.setUpdateBy(subject);
|
|
|
+ destCompany.setUpdateTime(new Date());
|
|
|
+ companyInfoService.update(destCompany);
|
|
|
+
|
|
|
+ map.put("companyInfo",destCompany);
|
|
|
+
|
|
|
affectCount++;
|
|
|
|
|
|
CompanyPosition companyPosition = new CompanyPosition();
|
|
|
Map<String,Object> searchParams1 = new HashMap<>();
|
|
|
- searchParams1.put("companyId",companyInfo.getId());
|
|
|
+ searchParams1.put("companyId",destCompany.getId());
|
|
|
List<Sort> sortList1 = new ArrayList<>();
|
|
|
sortList1.add(new Sort("id_","asc"));
|
|
|
Page<CompanyPosition> page1 = companyPositionService.pageSearch(searchParams1,1,1,false,sortList1);
|