Browse Source

合并新疆代码

lyhzzz 10 months ago
parent
commit
b376bb45bb

+ 106 - 0
src/main/java/com/fdkankan/sale/entity/PriceListLog.java

@@ -0,0 +1,106 @@
+package com.fdkankan.sale.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author 
+ * @since 2024-10-10
+ */
+@Getter
+@Setter
+@TableName("t_price_list_log")
+public class PriceListLog implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 报价单
+     */
+    @TableId(value = "price_list_id", type = IdType.AUTO)
+    private Integer priceListId;
+
+    /**
+     * 工单号
+     */
+    @TableField("repair_id")
+    private String repairId;
+
+    /**
+     * 项目名称
+     */
+    @TableField("name")
+    private String name;
+
+    /**
+     * 价格
+     */
+    @TableField("price")
+    @JsonFormat(shape = JsonFormat.Shape.STRING)
+    private BigDecimal price;
+
+    @TableField("count")
+    private Integer count;
+
+    @TableField("rec_status")
+    //@TableLogic(value = "A",delval = "I")
+    private String recStatus;
+
+    @TableField("remark")
+    private String remark;
+
+    @TableField("create_time")
+    private String createTime;
+
+    @TableField("update_time")
+    private String updateTime;
+
+    /**
+     * 1确认过报价,0未确认过报价
+     */
+    @TableField("status")
+    private Integer status;
+    /**
+     * 0备件,1人工
+     */
+    @TableField("type")
+    private Integer type;
+
+    @TableField("labor_id")
+    private Integer laborId;
+
+    @TableField("part_id")
+    private Integer partId;
+
+    /**
+     * 回收状态,0没折扣,1有折扣
+     */
+    @TableField("discount")
+    private Integer discount;
+
+    /**
+     * 价格
+     */
+    @TableField("price_discount")
+    @JsonFormat(shape = JsonFormat.Shape.STRING)
+    private BigDecimal priceDiscount;
+
+    @TableField(exist = false)
+    private String partUnit;
+
+
+}

+ 1 - 1
src/main/java/com/fdkankan/sale/generate/AutoGenerate.java

@@ -18,7 +18,7 @@ public class AutoGenerate {
         String path =System.getProperty("user.dir");
 
         generate(path,"sale", getTables(new String[]{
-                "t_repair_check_account",
+                "t_price_list_log",
         }));
 
 //        generate(path,"goods", getTables(new String[]{

+ 18 - 0
src/main/java/com/fdkankan/sale/mapper/IPriceListLogMapper.java

@@ -0,0 +1,18 @@
+package com.fdkankan.sale.mapper;
+
+import com.fdkankan.sale.entity.PriceListLog;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author 
+ * @since 2024-10-10
+ */
+@Mapper
+public interface IPriceListLogMapper extends BaseMapper<PriceListLog> {
+
+}

+ 23 - 0
src/main/java/com/fdkankan/sale/service/IPriceListLogService.java

@@ -0,0 +1,23 @@
+package com.fdkankan.sale.service;
+
+import com.fdkankan.sale.entity.PriceListLog;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.List;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author 
+ * @since 2024-10-10
+ */
+public interface IPriceListLogService extends IService<PriceListLog> {
+
+    void updateByRepairId(String repairId);
+
+    List<PriceListLog> getRepairId(String repairId);
+
+    void removeByRepairId(String repairId);
+}

+ 0 - 3
src/main/java/com/fdkankan/sale/service/IRepairRegisterService.java

@@ -28,7 +28,4 @@ public interface IRepairRegisterService extends IService<RepairRegister> {
 
     RepairRegisterVo getVoByRegisterLogId(Integer registerLogId);
 
-    void delByRepairId(String repairId);
-
-    PriceListVo getPriceList(String repairId);
 }

+ 59 - 0
src/main/java/com/fdkankan/sale/service/impl/PriceListLogServiceImpl.java

@@ -0,0 +1,59 @@
+package com.fdkankan.sale.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.fdkankan.sale.entity.PriceList;
+import com.fdkankan.sale.entity.PriceListLog;
+import com.fdkankan.sale.mapper.IPriceListLogMapper;
+import com.fdkankan.sale.service.IPriceListLogService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fdkankan.sale.service.IPriceListService;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author 
+ * @since 2024-10-10
+ */
+@Service
+public class PriceListLogServiceImpl extends ServiceImpl<IPriceListLogMapper, PriceListLog> implements IPriceListLogService {
+
+    @Autowired
+    IPriceListService priceListService;
+    @Override
+    public void updateByRepairId(String repairId) {
+        List<PriceListLog> priceListLogs = this.getRepairId(repairId);
+        List<Integer> ids = priceListLogs.stream().map(PriceListLog::getPriceListId).collect(Collectors.toList());
+        if(!ids.isEmpty()){
+            this.removeByIds(ids);
+        }
+        List<PriceList> priceListList = priceListService.getByRepairId(repairId);
+        for (PriceList priceList : priceListList) {
+            PriceListLog priceListLog = new PriceListLog();
+            BeanUtils.copyProperties(priceList,priceListLog);
+            this.save(priceListLog);
+        }
+    }
+
+    @Override
+    public List<PriceListLog> getRepairId(String repairId) {
+        LambdaQueryWrapper<PriceListLog> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(PriceListLog::getRepairId,repairId);
+        return this.list(wrapper);
+    }
+
+    @Override
+    public void removeByRepairId(String repairId) {
+        LambdaQueryWrapper<PriceListLog> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(PriceListLog::getRepairId,repairId);
+        this.remove(wrapper);
+    }
+}

+ 5 - 0
src/main/java/com/fdkankan/sale/service/impl/RepairPersonnelService.java

@@ -56,6 +56,8 @@ public class RepairPersonnelService {
     @Autowired
     IPriceListService priceListService;
     @Autowired
+    IPriceListLogService priceListLogService;
+    @Autowired
     IPartService partService;
     @Autowired
     IRepairRegisterLogService repairRegisterLogService;
@@ -193,6 +195,9 @@ public class RepairPersonnelService {
             }
             priceListService.save(priceList);
 
+            PriceListLog priceListLog = new PriceListLog();
+            BeanUtils.copyProperties(priceList,priceListLog);
+            priceListLogService.save(priceListLog);
         }
     }
 

+ 0 - 65
src/main/java/com/fdkankan/sale/service/impl/RepairRegisterServiceImpl.java

@@ -116,69 +116,4 @@ public class RepairRegisterServiceImpl extends ServiceImpl<IRepairRegisterMapper
         vo.setPartNamesStr(partNamesList.toString());
     }
 
-    @Override
-    public void delByRepairId(String repairId) {
-        LambdaQueryWrapper<RepairRegister> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(RepairRegister::getRepairId,repairId);
-        this.remove(wrapper);
-    }
-
-    @Override
-    public PriceListVo getPriceList(String repairId) {
-        RepairRegisterVo vo = this.getBaseMapper().getVoByRepairId(repairId);
-        if(vo == null){
-            return null;
-        }
-        List<RepairRegisterPart> partList = repairRegisterPartService.getByRepairId(vo.getRepairId());
-        PriceListVo priceListVo = new PriceListVo();
-        priceListVo.setCount(1);
-
-        HashMap<Integer,Part> partHashMap = new HashMap<>();
-        List<Integer> collect = partList.stream().map(RepairRegisterPart::getPartId).collect(Collectors.toList());
-        if(collect.size() >0){
-            List<Part> parts = partService.listByIds(collect);
-            parts.forEach(entity -> partHashMap.put(entity.getPartId(),entity));
-        }
-        List<PriceList> priceListList = priceListService.getByRepairId(repairId);
-        List<PriceList> priceLists = priceListList.stream().filter(e -> e.getStatus() == 2).collect(Collectors.toList());
-        HashMap<Integer,Integer> partCountMap = new HashMap<>();
-        for (PriceList priceList : priceLists) {
-            partCountMap.merge(priceList.getPartId(), priceList.getCount(), Integer::sum);
-            Part part = partHashMap.get(priceList.getPartId());
-            if(part == null){
-                continue;
-            }
-            priceList.setPartUnit(part.getPartUnit());
-        }
-        for (RepairRegisterPart repairRegisterPart : partList) {
-            Part part = partHashMap.get(repairRegisterPart.getPartId());
-            if(part == null){
-                continue;
-            }
-            Integer count = partCountMap.get(part.getPartId());
-            Integer partCount = repairRegisterPart.getPartCount();
-            if(count != null){
-                partCount =  count -  repairRegisterPart.getPartCount() ;
-            }
-            if(partCount == 0){
-                continue;
-            }
-            partCountMap.put(part.getPartId(),partCount);
-
-            PriceList priceList = new PriceList();
-            priceList.setPriceListId(repairRegisterPart.getId());
-            priceList.setRepairId(repairId);
-            priceList.setName(part.getPartName());
-            priceList.setPrice(part.getPartPrice());
-            priceList.setCount(partCount);
-            priceList.setPartId(part.getPartId());
-            priceList.setPriceDiscount(part.getPartPriceDiscount());
-            priceList.setPartUnit(part.getPartUnit());
-            priceList.setType(0);
-            priceList.setStatus(0);
-            priceLists.add(priceList);
-        }
-        priceListVo.setPriceLists(priceLists);
-        return priceListVo;
-    }
 }

+ 11 - 2
src/main/java/com/fdkankan/sale/service/impl/RepairSaleService.java

@@ -51,6 +51,8 @@ public class RepairSaleService {
     @Autowired
     IPriceListService priceListService;
     @Autowired
+    IPriceListLogService priceListLogService;
+    @Autowired
     IRepairPayService repairPayService;
     @Autowired
     IPartService partService;
@@ -258,10 +260,17 @@ public class RepairSaleService {
             throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
         }
         //重置报价单
+        List<PriceList> priceLists = new ArrayList<>();
         if(isRest == 1){
-            return repairRegisterService.getPriceList(repairId);
+            List<PriceListLog> priceListLogs = priceListLogService.getRepairId(repairId);
+            for (PriceListLog priceListLog : priceListLogs) {
+                PriceList priceList = new PriceList();
+                BeanUtils.copyProperties(priceListLog,priceList);
+                priceLists.add(priceList);
+            }
+        }else {
+            priceLists = priceListService.getByRepairId(repairId);
         }
-        List<PriceList> priceLists = priceListService.getByRepairId(repairId);
         Set<Integer> collect = priceLists.stream().map(PriceList::getPartId).collect(Collectors.toSet());
         HashMap<Integer,Part> partHashMap = new HashMap<>();
         if(collect.size() >0){

+ 3 - 0
src/main/java/com/fdkankan/sale/service/impl/RepairSupplyService.java

@@ -54,6 +54,8 @@ public class RepairSupplyService {
     @Autowired
     IPriceListService priceListService;
     @Autowired
+    IPriceListLogService priceListLogService;
+    @Autowired
     IPartLogService partLogService;
 
     /**
@@ -162,6 +164,7 @@ public class RepairSupplyService {
             partService.outStock(partVo.getPartId(),partVo.getPartCount(),userId,repair.getRepairId());
         }
         priceListService.updateStatusByRepairId(repair.getRepairId(),2);
+        priceListLogService.updateByRepairId(repair.getRepairId());
 
         repairLogService.saveBySysUser(userId,param.getRepairId(),RepairStatusEnum.TO_BE_REPAIRED.status(),repair.getStatus(),"备件出库");
     }

+ 5 - 0
src/main/resources/mapper/sale/PriceListLogMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fdkankan.sale.mapper.IPriceListLogMapper">
+
+</mapper>