瀏覽代碼

单据列表返回设备归属人,工程名称

yusm 2 月之前
父節點
當前提交
c7e82cb4c9

+ 10 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/ExpenseSheet.java

@@ -155,7 +155,16 @@ public class ExpenseSheet extends Model<ExpenseSheet> {
     private String payWayName;
 
     @TableField("equipment_owner_id")
-    private String equipmentOwnerId;
+    private Integer equipmentOwnerId;
+
+    @TableField(exist = false)
+    private String equipmentOwnerName;
+
+    /**
+     * 工程名称
+     */
+    @TableField(exist = false)
+    private String engineeringName;
 
 
     @Override

+ 3 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/EquipmentOwnerServiceImpl.java

@@ -53,6 +53,7 @@ public class EquipmentOwnerServiceImpl extends ServiceImpl<EquipmentOwnerMapper,
             if (count>0){
                 msg.setError("归属人名称:"+equipmentOwner.getEquipmentOwner()+",已存在");
             }else {
+                equipmentOwner.setCompanyId(user.getCompanyId());
                 int insert = equipmentOwnerMapper.insert(equipmentOwner);
                 if (insert>0){
                     return msg;
@@ -90,7 +91,8 @@ public class EquipmentOwnerServiceImpl extends ServiceImpl<EquipmentOwnerMapper,
         if (user.getCompanyId()!=Constant.ZHE_ZHONG_COMPANY_ID){
             msg.setData(new ArrayList<EquipmentOwner>());
         }else {
-            List<EquipmentOwner> selectedList = equipmentOwnerMapper.selectList(new QueryWrapper<EquipmentOwner>().eq("company_id", user.getCompanyId()));
+            List<EquipmentOwner> selectedList = equipmentOwnerMapper.selectList(new QueryWrapper<EquipmentOwner>()
+                    .eq("company_id", user.getCompanyId()).orderByDesc("id"));
             msg.setData(selectedList);
         }
         return msg;

+ 42 - 10
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ExpenseSheetServiceImpl.java

@@ -101,6 +101,9 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
     @Resource
     private CompanyDingdingService companyDingdingService;
 
+    @Resource
+    private EquipmentOwnerMapper equipmentOwnerMapper;
+
 
     @Override
     public HttpRespMsg add(ExpenseSheet sheet, String items, String userId) {
@@ -145,7 +148,8 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
                 msg.setError(MessageUtils.message("other.billNoExist"));
                 return msg;
             }
-        } else {
+        }
+        else {
             if(user.getCompanyId()==Constant.ZHE_ZHONG_COMPANY_ID&&user.getId().equals(sheet.getOwnerId())&&expenseMainType!=null&&sheet.getType().equals(expenseMainType.getId())){
                 //柘中公司
                 if (sheet.getTotalAmount() > 0) {
@@ -328,7 +332,7 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
             expenseItemService.saveBatch(itemList);
         }
 
-        if (isNew && auditSetting != null && auditSetting.getAuditType() == 1) {
+        if (isNew && auditSetting != null && auditSetting.getAuditType() == 1&&sheet.getFirstCheckerId()!=null) {
             //发送给项目经理审核
             List<Integer> collect = itemList.stream().map(ExpenseItem::getProjectId).collect(Collectors.toList());
             if (collect.size() > 0) {
@@ -383,7 +387,8 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
                     informationService.saveBatch(informationList);
                 }
             }
-        }else if (isNew && auditSetting != null && auditSetting.getAuditType() == 2) {
+        }
+        else if (isNew && auditSetting != null && auditSetting.getAuditType() == 2&&sheet.getFirstCheckerId()!=null) {
             //发送给第一审核人审核
             List<User> targetUserList = new ArrayList<>();
             User firstChecker = userMapper.selectById(sheet.getFirstCheckerId());
@@ -453,7 +458,8 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         queryWrapper.eq("company_id", sheet.getCompanyId()).orderByDesc("id");
         ExpenseAuditSetting expenseAuditSetting = expenseAuditSettingMapper.selectById(sheet.getCompanyId());
-
+        List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", user.getCompanyId()));
+        List<EquipmentOwner> equipmentOwnerList = equipmentOwnerMapper.selectList(new QueryWrapper<EquipmentOwner>().eq("company_id", user.getCompanyId()));
         if (!StringUtils.isEmpty(sheet.getCode())) {
             queryWrapper.eq("code", sheet.getCode());
         }
@@ -540,13 +546,16 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
                 IPage<ExpenseSheet> listIPager = expenseSheetMapper.selectPage(new Page<>(pageIndex, pageSize),
                         queryWrapper);
                 List<ExpenseSheet> records = listIPager.getRecords();
-
+                List<Integer> expenseSheetIds = records.stream().map(ExpenseSheet::getId).collect(Collectors.toList());
+                List<ExpenseItem> expenseItemList = expenseItemMapper.selectList(new QueryWrapper<ExpenseItem>().in("expense_id",expenseSheetIds));
                 List<ExpenseMainType> expenseMainTypes = expenseMainTypeService.list(new QueryWrapper<ExpenseMainType>().eq("company_id", sheet.getCompanyId()).or().eq("is_system",1));
                 records.forEach(re->{
                     Optional<ExpenseMainType> first = expenseMainTypes.stream().filter(et -> et.getId().equals(re.getType())).findFirst();
                     if(first.isPresent()){
                         re.setExpenseMainTypeName(first.get().getName());
                     }
+                    Optional<EquipmentOwner> equipmentOwnerOptional = equipmentOwnerList.stream().filter(eo -> re.getEquipmentOwnerId() != null && eo.getId().equals(re.getEquipmentOwnerId())).findFirst();
+                    equipmentOwnerOptional.ifPresent(equipmentOwner -> re.setEquipmentOwnerName(equipmentOwner.getEquipmentOwner()));
                 });
                 if (records.size()>0){
                     records.forEach(r->{
@@ -554,8 +563,17 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
                                 .filter(e -> e.getExpenseId().equals(r.getId())&&e.getProjectId().equals(projectId)).collect(Collectors.toList());
                         double amount = items.stream().mapToDouble(item -> Optional.ofNullable(item.getAmount()).orElse(0.0)).sum();
                         r.setTotalAmount(amount);
+
+                        List<Integer> projectIds = expenseItemList.stream().filter(e -> e.getExpenseId().equals(r.getId())).map(ExpenseItem::getProjectId).distinct().collect(Collectors.toList());
+                        StringJoiner stringJoiner = new StringJoiner(",");
+                        for (Integer id : projectIds) {
+                            Optional<Project> optional = projectList.stream().filter(p -> p.getId().equals(id)).findFirst();
+                            optional.ifPresent(p->stringJoiner.add(p.getProjectName()));
+                        }
+                        r.setEngineeringName(stringJoiner.toString());
                     });
                 }
+
                 Long total = listIPager.getTotal();
                 Map<String, Object> map = new HashMap<>();
                 map.put("records", records);
@@ -570,13 +588,25 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
             IPage<ExpenseSheet> listIPager = expenseSheetMapper.selectPage(new Page<>(pageIndex, pageSize),
                     queryWrapper);
             List<ExpenseSheet> records = listIPager.getRecords();
-
+            List<Integer> expenseSheetIds = records.stream().map(ExpenseSheet::getId).collect(Collectors.toList());
+            List<ExpenseItem> expenseItemList = expenseItemMapper.selectList(new QueryWrapper<ExpenseItem>().in("expense_id",expenseSheetIds));
             List<ExpenseMainType> expenseMainTypes = expenseMainTypeService.list(new QueryWrapper<ExpenseMainType>().eq("company_id", sheet.getCompanyId()).or().eq("is_system",1));
             records.forEach(re->{
                 Optional<ExpenseMainType> first = expenseMainTypes.stream().filter(et -> et.getId().equals(re.getType())).findFirst();
                 if(first.isPresent()){
                     re.setExpenseMainTypeName(first.get().getName());
                 }
+                Optional<EquipmentOwner> equipmentOwnerOptional = equipmentOwnerList.stream().filter(eo -> re.getEquipmentOwnerId() != null && eo.getId().equals(re.getEquipmentOwnerId())).findFirst();
+                equipmentOwnerOptional.ifPresent(equipmentOwner -> re.setEquipmentOwnerName(equipmentOwner.getEquipmentOwner()));
+
+
+                List<Integer> projectIds = expenseItemList.stream().filter(e -> e.getExpenseId().equals(re.getId())).map(ExpenseItem::getProjectId).distinct().collect(Collectors.toList());
+                StringJoiner stringJoiner = new StringJoiner(",");
+                for (Integer id : projectIds) {
+                    Optional<Project> optional = projectList.stream().filter(p -> p.getId().equals(id)).findFirst();
+                    optional.ifPresent(p->stringJoiner.add(p.getProjectName()));
+                }
+                re.setEngineeringName(stringJoiner.toString());
             });
             Long total = listIPager.getTotal();
             Map<String, Object> map = new HashMap<>();
@@ -612,7 +642,9 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
     @Override
     public HttpRespMsg getDetail(Integer id,Integer projectId) {
         String token = request.getHeader("TOKEN");
+        User selectUser = userMapper.selectById(token);
         ExpenseSheet expenseSheet = expenseSheetMapper.selectById(id);
+        List<EquipmentOwner> equipmentOwnerList = equipmentOwnerMapper.selectList(new QueryWrapper<EquipmentOwner>().eq("company_id", selectUser.getCompanyId()));
         if(!StringUtils.isEmpty(expenseSheet.getFirstCheckerId())){
             User user = userMapper.selectById(expenseSheet.getFirstCheckerId());
             expenseSheet.setFirstCheckerName(user.getName());
@@ -656,6 +688,8 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
         double amount = list.stream().mapToDouble(item -> Optional.ofNullable(item.getAmount()).orElse(0.0)).sum();
         expenseSheet.setTotalAmount(amount);
         HttpRespMsg msg = new HttpRespMsg();
+        Optional<EquipmentOwner> equipmentOwnerOptional = equipmentOwnerList.stream().filter(eo -> expenseSheet.getEquipmentOwnerId() != null && eo.getId().equals(expenseSheet.getEquipmentOwnerId())).findFirst();
+        equipmentOwnerOptional.ifPresent(equipmentOwner -> expenseSheet.setEquipmentOwnerName(equipmentOwner.getEquipmentOwner()));
         msg.data = expenseSheet;
         return msg;
     }
@@ -719,10 +753,8 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
                     informationList.add(information);
                 }
                 informationService.saveBatch(informationList);
-            }else if(sheet.getReviewProcess()!=null&&sheet.getReviewProcess()==1){
-                sheet.setReviewProcess(2);
-                sheet.setStatus(0);
-            }else if(sheet.getReviewProcess()!=null&&sheet.getReviewProcess()==0&&user.getCompanyId()==Constant.ZHE_ZHONG_COMPANY_ID){
+            }
+            else if(sheet.getReviewProcess()!=null&&sheet.getReviewProcess()==1){
                 sheet.setReviewProcess(2);
                 sheet.setStatus(0);
             }