Commit c86e5ad0de470e1867cc8c1814cc0ffc6c851eba

Authored by wangqian
1 parent 80efeb18

模板上传获取总公司名称

urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/costfee/CostFeeServiceImpl.java
... ... @@ -206,6 +206,8 @@ public class CostFeeServiceImpl implements CostFeeService {
206 206 log.info("数据列表为空,跳过插入操作");
207 207 return;
208 208 }
  209 + //总公司
  210 + DeptRespDTO deptRespDTO = deptApi.getDept(getCompanyId());
209 211 //单位集合
210 212 List<DeptRespDTO> companyList = deptApi.getSubDeptList();
211 213 // 1. 预加载部门映射(循环外加载,避免重复查询)
... ... @@ -220,7 +222,7 @@ public class CostFeeServiceImpl implements CostFeeService {
220 222 ));
221 223  
222 224  
223   - // 模板类型校验
  225 + // 模板类型校验
224 226 Class<?> importClass = template.getImportClass(); // 从枚举获取导入类,避免switch
225 227 // 根据不同模板类型执行不同的处理逻辑
226 228 if (WaterFeeImport.class.isAssignableFrom(importClass)) {
... ... @@ -239,8 +241,8 @@ public class CostFeeServiceImpl implements CostFeeService {
239 241 WaterFeeDO fee = new WaterFeeDO();
240 242 BeanUtils.copyProperties(importObj, fee);
241 243 fee.setCompanyId(String.valueOf(getCompanyId()));
242   - if (getCompanyId() == 100) {
243   - fee.setCompanyName("蓟城山水");
  244 + if (deptRespDTO.getParentId() == 0) {
  245 + fee.setCompanyName(Objects.toString(deptRespDTO.getName(), ""));
244 246 } else {
245 247 // 设置单位id
246 248 fee.setCompanyName(String.valueOf(companyIdToNamedMap.get(getCompanyId())));
... ... @@ -612,7 +614,7 @@ public class CostFeeServiceImpl implements CostFeeService {
612 614 Set<ConstraintViolation<WaterFeeImport>> violations = validator.validate(importBean);
613 615 if (!violations.isEmpty()) {
614 616 // 收集所有校验错误信息(比如“用水量不能为空”“格式应为两位小数”)
615   - // StringBuilder errorMsg = new StringBuilder();
  617 + // StringBuilder errorMsg = new StringBuilder();
616 618 for (ConstraintViolation<WaterFeeImport> violation : violations) {
617 619 //errorMsg.append(violation.getMessage()).append(";");
618 620 throw exception0(BAD_REQUEST.getCode() ,String.format(
... ... @@ -644,13 +646,13 @@ public class CostFeeServiceImpl implements CostFeeService {
644 646 // 收集所有校验错误信息(比如“用水量不能为空”“格式应为两位小数”)
645 647 //StringBuilder errorMsg = new StringBuilder();
646 648 for (ConstraintViolation<PersonalCostImport> violation : violations) {
647   - // errorMsg.append(violation.getMessage()).append(";");
  649 + // errorMsg.append(violation.getMessage()).append(";");
648 650 throw exception0(BAD_REQUEST.getCode() ,String.format(
649 651 "第[{}]条数据:"+ violation.getMessage()
650 652 ), rowNum);
651 653 }
652 654 // 抛出包含行号和所有错误的异常
653   - // throw exception0(BAD_REQUEST.getCode(), errorMsg.toString().trim(), violations);
  655 + // throw exception0(BAD_REQUEST.getCode(), errorMsg.toString().trim(), violations);
654 656 }
655 657 Long companyId = nameToCompanyIdMap.get(importBean.getCompanyName());
656 658 //单位校验
... ... @@ -766,9 +768,9 @@ public class CostFeeServiceImpl implements CostFeeService {
766 768 Set<ConstraintViolation<RentalMechanicalCostImport>> violations = validator.validate(importBean);
767 769 if (!violations.isEmpty()) {
768 770 // 收集所有校验错误信息(比如“用水量不能为空”“格式应为两位小数”)
769   - // StringBuilder errorMsg = new StringBuilder();
  771 + // StringBuilder errorMsg = new StringBuilder();
770 772 for (ConstraintViolation<RentalMechanicalCostImport> violation : violations) {
771   - // errorMsg.append(violation.getMessage()).append(";");
  773 + // errorMsg.append(violation.getMessage()).append(";");
772 774 throw exception0(BAD_REQUEST.getCode() ,String.format(
773 775 "第[{}]条数据:"+violation.getMessage()
774 776 ), rowNum);
... ...