lyhzzz hace 11 meses
padre
commit
50d23d16b7

+ 4 - 0
src/main/java/com/fdkankan/sale/service/IPartLogService.java

@@ -6,6 +6,8 @@ import com.fdkankan.sale.entity.Part;
 import com.fdkankan.sale.entity.PartLog;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.HashMap;
+
 /**
  * <p>
  *  服务类
@@ -19,4 +21,6 @@ public interface IPartLogService extends IService<PartLog> {
     void saveLog(Integer partId,Integer count, Long userId,Integer status,String repairId);
 
     PageInfo pageList(RequestBase param);
+
+    HashMap<Integer,PartLog> getByRepairId(String repairId, Integer status);
 }

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

@@ -38,4 +38,6 @@ public interface IPriceListService extends IService<PriceList> {
     List<PriceList> getCheckAmountByRepairIds(List<String> cancelIds);
 
     List<PriceList> getByRepairIds(List<String> repairIds);
+
+    Boolean checkPartOut(List<PriceList> collect, String repairId);
 }

+ 21 - 0
src/main/java/com/fdkankan/sale/service/impl/PartLogServiceImpl.java

@@ -16,6 +16,9 @@ import com.fdkankan.sale.vo.response.PartLogVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.HashMap;
+import java.util.List;
+
 /**
  * <p>
  *  服务实现类
@@ -51,4 +54,22 @@ public class PartLogServiceImpl extends ServiceImpl<IPartLogMapper, PartLog> imp
         Page<PartLogVo> page = this.getBaseMapper().pageList(new Page<>(param.getPageNum(), param.getPageSize()),0);
         return PageInfo.PageInfo(page);
     }
+
+    @Override
+    public HashMap<Integer,PartLog> getByRepairId(String repairId, Integer status) {
+        LambdaQueryWrapper<PartLog> wrapper2 = new LambdaQueryWrapper<>();
+        wrapper2.eq(PartLog::getRepairId,repairId);
+        wrapper2.eq(PartLog::getStatus,status);
+        List<PartLog> partLogs = this.list(wrapper2);
+        HashMap<Integer,PartLog> outMap = new HashMap<>();
+        for (PartLog partLog : partLogs) {
+            if(outMap.get(partLog.getPartId()) != null){
+                PartLog partLog1 = outMap.get(partLog.getPartId());
+                partLog1.setCount(partLog1.getCount() + partLog.getCount());
+            }else {
+                outMap.put(partLog.getPartId(),partLog);
+            }
+        }
+        return outMap;
+    }
 }

+ 23 - 1
src/main/java/com/fdkankan/sale/service/impl/PriceListServiceImpl.java

@@ -2,12 +2,15 @@ package com.fdkankan.sale.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.fdkankan.sale.entity.PartLog;
 import com.fdkankan.sale.entity.PriceList;
 import com.fdkankan.sale.mapper.IPriceListMapper;
+import com.fdkankan.sale.service.IPartLogService;
 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.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
@@ -27,6 +30,8 @@ import java.util.stream.Collectors;
 @Service
 public class PriceListServiceImpl extends ServiceImpl<IPriceListMapper, PriceList> implements IPriceListService {
 
+    @Autowired
+    IPartLogService partLogService;
     @Override
     public List<PriceList> getByRepairId(String repairId) {
         LambdaQueryWrapper<PriceList> wrapper = new LambdaQueryWrapper<>();
@@ -135,7 +140,23 @@ public class PriceListServiceImpl extends ServiceImpl<IPriceListMapper, PriceLis
 
         return map;
     }
-    private void setMapAmount( HashMap<String,BigDecimal> map,List<PriceList> priceLists){
+
+    @Override
+    public Boolean checkPartOut(List<PriceList> collect, String repairId) {
+        Boolean flag = true;
+        HashMap<Integer, PartLog> outMap = partLogService.getByRepairId(repairId, 1);
+        if(!outMap.isEmpty()){
+            for (PriceList priceList : collect) {
+                PartLog partLog = outMap.get(priceList.getPartId());
+                if(partLog == null || !partLog.getCount().equals(priceList.getCount())){
+                    return false;
+                }
+            }
+        }
+        return flag;
+    }
+
+    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());
@@ -144,4 +165,5 @@ public class PriceListServiceImpl extends ServiceImpl<IPriceListMapper, PriceLis
             map.put(priceList.getRepairId(),payAmount);
         }
     }
+
 }

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

@@ -41,6 +41,8 @@ public class RepairCustomerService {
     IPriceListService priceListService;
     @Autowired
     RepairSupplyService repairSupplyService;
+    @Autowired
+    IPartLogService partLogService;
 
     public Object getRepairByOpenId(String openId) {
         List<Customer> list = customerService.getByOpenId(openId);
@@ -97,6 +99,10 @@ public class RepairCustomerService {
             if(collect.size() <=0){
                 repairLogService.saveBySysUser(param.getUserId(),repair.getRepairId(),RepairStatusEnum.TO_BE_REPAIRED.status(),repair.getStatus(),"维修确认");
             }else {
+                Boolean flag = priceListService.checkPartOut( collect ,repair.getRepairId());
+                if(!flag){
+                    repairLogService.saveBySysUser(param.getUserId(),repair.getRepairId(),RepairStatusEnum.TO_BE_REPAIRED.status(),repair.getStatus(),"维修确认");
+                }
                 repairLogService.saveBySysUser(param.getUserId(),repair.getRepairId(),RepairStatusEnum.TO_BE_U8SEND.status(),repair.getStatus(),"维修确认");
             }
         }

+ 2 - 20
src/main/java/com/fdkankan/sale/service/impl/RepairSupplyService.java

@@ -72,7 +72,7 @@ public class RepairSupplyService {
 
     public List<RepairRegisterPartVo> partInfo(String repairId,Integer type) {
 
-        HashMap<Integer,PartLog> outMap = getPartLogMap(repairId,1);
+        HashMap<Integer, PartLog> outMap = partLogService.getByRepairId(repairId, 1);
 
         if(type == 0){  //获取备件出库单
             HashMap<Integer,PriceList> priceMap = new HashMap<>();
@@ -113,8 +113,7 @@ public class RepairSupplyService {
             return  parts;
         }
 
-
-        HashMap<Integer,PartLog> reMap = getPartLogMap(repairId,2);
+        HashMap<Integer, PartLog> reMap = partLogService.getByRepairId(repairId, 2);
 
         List<RepairRegisterPartVo> parts = new ArrayList<>();
 
@@ -142,23 +141,6 @@ public class RepairSupplyService {
 
     }
 
-    private HashMap<Integer,PartLog> getPartLogMap (String repairId,Integer status){
-        LambdaQueryWrapper<PartLog> wrapper2 = new LambdaQueryWrapper<>();
-        wrapper2.eq(PartLog::getRepairId,repairId);
-        wrapper2.eq(PartLog::getStatus,status);
-        List<PartLog> partLogs = partLogService.list(wrapper2);
-        HashMap<Integer,PartLog> outMap = new HashMap<>();
-        for (PartLog partLog : partLogs) {
-            if(outMap.get(partLog.getPartId()) != null){
-                PartLog partLog1 = outMap.get(partLog.getPartId());
-                partLog1.setCount(partLog1.getCount() + partLog.getCount());
-            }else {
-                outMap.put(partLog.getPartId(),partLog);
-            }
-        }
-        return outMap;
-    }
-
 
     public void partOut(Repair param, Long userId) {
         if(StringUtils.isBlank(param.getRepairId())){