Преглед на файлове

导出工单,工单维修金额

lyhzzz преди 1 година
родител
ревизия
d0076a96c2

+ 8 - 0
src/main/java/com/fdkankan/sale/controller/RepairInfoController.java

@@ -2,7 +2,9 @@ package com.fdkankan.sale.controller;
 import java.math.BigDecimal;
 import java.security.interfaces.ECKey;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.stream.Collectors;
 
 import cn.hutool.core.bean.BeanUtil;
 import com.alibaba.excel.EasyExcel;
@@ -14,6 +16,7 @@ import com.fdkankan.sale.entity.PriceList;
 import com.fdkankan.sale.entity.RepairLog;
 import com.fdkankan.sale.entity.SysUser;
 import com.fdkankan.sale.service.IExcelService;
+import com.fdkankan.sale.service.IPriceListService;
 import com.fdkankan.sale.service.IRepairLogService;
 import com.fdkankan.sale.util.StatusUtil;
 import com.fdkankan.sale.vo.request.RepairPayParam;
@@ -51,6 +54,8 @@ public class RepairInfoController extends BaseController{
     IRepairService repairService;
     @Autowired
     IExcelService excelService;
+    @Autowired
+    IPriceListService priceListService;
 
     @GetMapping("/details")
     public ResultData details(@RequestParam(required = false) String repairId){
@@ -115,12 +120,15 @@ public class RepairInfoController extends BaseController{
                     voPage = repairService.pageInfoList(param);
                 }
                 List<RepairerVo> records = voPage.getRecords();
+                HashMap<String,BigDecimal> amountMap = priceListService.getAmountByRepairIds(records);
                 List<RepairInfoExportVo> list = new ArrayList<>();
                 for (RepairerVo record : records) {
                     RepairInfoExportVo vo = new RepairInfoExportVo();
                     BeanUtils.copyProperties(record,vo);
+                    vo.setPayAmount(amountMap.get(vo.getRepairId()) == null ?BigDecimal.ZERO: amountMap.get(vo.getRepairId()));
                     list.add(vo);
                 }
+
                 excelService.commonExport(request,response,"工单详情",list,excelWriter);
             }
 

+ 6 - 0
src/main/java/com/fdkankan/sale/service/IPriceListService.java

@@ -2,6 +2,7 @@ package com.fdkankan.sale.service;
 
 import com.fdkankan.sale.entity.PriceList;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.fdkankan.sale.vo.response.RepairerVo;
 
 import java.math.BigDecimal;
 import java.util.HashMap;
@@ -32,4 +33,9 @@ public interface IPriceListService extends IService<PriceList> {
 
     void delNoCm(String repairId);
 
+    HashMap<String, BigDecimal> getAmountByRepairIds(List<RepairerVo> records);
+
+    List<PriceList> getCheckAmountByRepairIds(List<String> cancelIds);
+
+    List<PriceList> getByRepairIds(List<String> repairIds);
 }

+ 47 - 0
src/main/java/com/fdkankan/sale/service/impl/PriceListServiceImpl.java

@@ -6,12 +6,15 @@ import com.fdkankan.sale.entity.PriceList;
 import com.fdkankan.sale.mapper.IPriceListMapper;
 import com.fdkankan.sale.service.IPriceListService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fdkankan.sale.vo.response.RepairInfoExportVo;
+import com.fdkankan.sale.vo.response.RepairerVo;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -32,6 +35,16 @@ public class PriceListServiceImpl extends ServiceImpl<IPriceListMapper, PriceLis
     }
 
     @Override
+    public List<PriceList> getByRepairIds(List<String> repairIds) {
+        if(repairIds == null || repairIds.size() <=0){
+            return new ArrayList<>();
+        }
+        LambdaQueryWrapper<PriceList> wrapper = new LambdaQueryWrapper<>();
+        wrapper.in(PriceList::getRepairId,repairIds);
+        return list(wrapper);
+    }
+
+    @Override
     public BigDecimal getAmountByRepairId(String repairId) {
         BigDecimal amount = BigDecimal.ZERO;
         List<PriceList> byRepairId = this.getByRepairIdAndStatus(repairId,1);
@@ -91,10 +104,44 @@ public class PriceListServiceImpl extends ServiceImpl<IPriceListMapper, PriceLis
     }
 
     @Override
+    public List<PriceList> getCheckAmountByRepairIds(List<String> cancelIds) {
+        if(cancelIds != null && cancelIds.size() >0){
+            LambdaQueryWrapper<PriceList> wrapper = new LambdaQueryWrapper<>();
+            wrapper.in(PriceList::getRepairId,cancelIds);
+            wrapper.eq(PriceList::getLaborId,1);
+            return list(wrapper);
+        }
+        return new ArrayList<>();
+    }
+
+    @Override
     public void delNoCm(String repairId) {
         LambdaQueryWrapper<PriceList> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(PriceList::getRepairId,repairId);
         this.remove(wrapper);
     }
 
+    @Override
+    public HashMap<String, BigDecimal> getAmountByRepairIds(List<RepairerVo> list) {
+        HashMap<String,BigDecimal> map = new HashMap<>();
+        List<String> cancelIds = list.stream().filter(e ->e.getCancelStatus() == 1).map(RepairerVo::getRepairId).collect(Collectors.toList());
+        List<String> repairIds = list.stream().filter(e ->e.getCancelStatus() == 0).map(RepairerVo::getRepairId).collect(Collectors.toList());
+
+        List<PriceList> cancelPriceList =  this.getCheckAmountByRepairIds(cancelIds);
+        List<PriceList> priceLists =  this.getByRepairIds(repairIds);
+        
+        setMapAmount(map,cancelPriceList);
+        setMapAmount(map,priceLists);
+
+        return map;
+    }
+    private void setMapAmount( HashMap<String,BigDecimal> map,List<PriceList> priceLists){
+        for (PriceList priceList : priceLists) {
+            map.putIfAbsent(priceList.getRepairId(), BigDecimal.ZERO);
+            BigDecimal payAmount = map.get(priceList.getRepairId());
+            BigDecimal price = priceList.getDiscount() == 1 ? priceList.getPriceDiscount() : priceList.getPrice();
+            payAmount = payAmount.add(price.multiply(new BigDecimal(priceList.getCount())));
+            map.put(priceList.getRepairId(),payAmount);
+        }
+    }
 }

+ 16 - 17
src/main/java/com/fdkankan/sale/vo/response/RepairInfoExportVo.java

@@ -13,10 +13,16 @@ import java.math.BigDecimal;
 @Data
 public class RepairInfoExportVo {
 
+    @ExcelProperty("维修单号")
+    private String repairId;
+
+    @ExcelProperty("接单日期")
+    private String orderReceivingTime;
+
     @ExcelProperty("报修时间")
     private String createTime;
 
-    @ExcelProperty("客户名称")
+    @ExcelProperty("客户名称(全称)")
     private String companyName;
 
     @ExcelIgnore
@@ -37,28 +43,21 @@ public class RepairInfoExportVo {
     @ExcelProperty("保修类型")
     private String warrantyTypeStr;
 
-    @ExcelProperty("售后工程师")
-    private String saleName;
-
-    @ExcelProperty("接单日期")
-    private String orderReceivingTime;
-
-    @ExcelProperty("故障分析")
-    private String checkResult;
+    @ExcelIgnore
+    private Integer status;
+    @ExcelProperty("状态")
+    private String statusStr;
 
-    @ExcelProperty("维修工程师")
-    private String repairManName;
+    @ExcelProperty("维修金额")
+    @JsonFormat(shape = JsonFormat.Shape.STRING)
+    private BigDecimal payAmount;
 
     @ExcelProperty("维修完成日期")
     private String repairOverTime;
 
-    @ExcelIgnore
-    private Integer status;
-    @ExcelProperty("状态")
-    private String statusStr;
 
-    @ExcelProperty("维修单号")
-    private String repairId;
+
+
 
     public String getCameraTypeStr() {
         if(cameraType == null){