Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/mode-min-unit' into mode-min-unit

fangpy 9 mēneši atpakaļ
vecāks
revīzija
e262515a0b

+ 3 - 0
cx-aps/cx-aps-common/src/main/java/com/rongwei/bscommon/sys/dao/ApsProductDetailDao.java

@@ -4,6 +4,7 @@ package com.rongwei.bscommon.sys.dao;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.rongwei.bsentity.domain.*;
 import com.rongwei.bsentity.vo.ApsProcessOutputProductAndBlankStatusVo;
+import com.rongwei.bsentity.vo.GetOldTechnicalRequirementRes;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 
@@ -62,4 +63,6 @@ public interface ApsProductDetailDao extends BaseMapper<ApsProductDetailDo> {
     List<ApsProductDetailDo> getProductDetailByMainId(@Param("mainId") String mainId);
 
     void publishCancel(@Param("productionOrderIds") List<String> productionOrderIds);
+
+    List<GetOldTechnicalRequirementRes> selectMyList(@Param("technicalRequirementId") String technicalRequirementId, @Param("id") String id, @Param("alloy") String alloy, @Param("alloystatus") String alloystatus, @Param("orderProductTypeId") String orderProductTypeId);
 }

+ 3 - 0
cx-aps/cx-aps-common/src/main/java/com/rongwei/bscommon/sys/service/ApsProductDetailService.java

@@ -2,6 +2,7 @@ package com.rongwei.bscommon.sys.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.rongwei.bsentity.domain.ApsProductDetailDo;
+import com.rongwei.bsentity.vo.GetOldTechnicalRequirementReq;
 import com.rongwei.bsentity.vo.UpdateProductDetailsAndBlankOutputReq;
 import com.rongwei.rwcommon.base.R;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -28,4 +29,6 @@ public interface ApsProductDetailService extends IService<ApsProductDetailDo> {
     R updateOrSaveProductDetails(List<ApsProductDetailDo> req);
 
     R updateProductDetailsAndBlankOutput(UpdateProductDetailsAndBlankOutputReq req);
+
+    R getOldTechnicalRequirement(GetOldTechnicalRequirementReq req);
 }

+ 55 - 0
cx-aps/cx-aps-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ApsProductDetailServiceImpl.java

@@ -8,6 +8,8 @@ import com.rongwei.bscommon.sys.dao.ApsProductDetailDao;
 import com.rongwei.bscommon.sys.service.*;
 import com.rongwei.bsentity.domain.*;
 import com.rongwei.bsentity.vo.ApsProcessOutputProductAndBlankStatusVo;
+import com.rongwei.bsentity.vo.GetOldTechnicalRequirementReq;
+import com.rongwei.bsentity.vo.GetOldTechnicalRequirementRes;
 import com.rongwei.bsentity.vo.UpdateProductDetailsAndBlankOutputReq;
 import com.rongwei.rwadmincommon.system.vo.SysUserVo;
 import com.rongwei.rwcommon.base.R;
@@ -605,4 +607,57 @@ public class ApsProductDetailServiceImpl extends ServiceImpl<ApsProductDetailDao
 
         return R.ok();
     }
+
+    @Override
+    public R getOldTechnicalRequirement(GetOldTechnicalRequirementReq req) {
+        String technicalRequirementId = req.getTechnicalRequirementId();
+        if (ObjectUtil.isEmpty(technicalRequirementId)) {
+            return R.error("当前技术要求ID不能为空");
+        }
+        String orderProductTypeId = req.getOrderProductTypeId();
+        if (ObjectUtil.isEmpty(orderProductTypeId)) {
+            return R.error("当前技术要求的订单产品类型ID不能为空");
+        }
+        ApsProductDetailDo orderDetail = req.getOrderDetail();
+        if (ObjectUtil.isEmpty(orderDetail)) {
+            return R.error("产品明细不能为空");
+        }
+        String alloy = orderDetail.getAlloy();
+        String alloystatus = orderDetail.getAlloystatus();
+
+        List<GetOldTechnicalRequirementRes> apsProductDetailDoList = this.baseMapper.selectMyList(technicalRequirementId, orderDetail.getId(), alloy, alloystatus, orderProductTypeId);
+
+        List<GetOldTechnicalRequirementRes> list = new LinkedList<>();
+        for (GetOldTechnicalRequirementRes vo : apsProductDetailDoList) {
+            int score = 0;
+            if (vo.getAlloy().equals(alloy)) {
+                score += 10;
+            }
+            if (vo.getAlloystatus().equals(alloystatus)) {
+                score += 1;
+            }
+            if (vo.getOrderproducttypeid().equals(orderProductTypeId)) {
+                score += 100;
+            }
+            vo.setScore(score);
+            list.add(vo);
+        }
+
+        list.sort((a, b) -> {
+            if (a.getScore() > b.getScore()) {
+                return -1;
+            } else if (a.getScore() < b.getScore()) {
+                return 1;
+            } else {//分数相同时,按照创建时间倒序
+                return b.getCreatedate().compareTo(a.getCreatedate());
+            }
+        });
+        GetOldTechnicalRequirementRes res = null;
+        if (ObjectUtil.isNotEmpty(list)) {
+            res = list.get(0);
+        }
+        return R.ok(res);
+    }
+
+
 }

+ 22 - 0
cx-aps/cx-aps-common/src/main/resources/mybatis/ApsProductDetailDao.xml

@@ -136,4 +136,26 @@
             </foreach>
         </if>
     </select>
+    <select id="selectMyList" resultType="com.rongwei.bsentity.vo.GetOldTechnicalRequirementRes">
+        select
+            apd.ID AS 'orderDetailId',
+            apd.ALLOY AS 'alloy',
+            apd.ALLOYSTATUS AS 'alloystatus',
+            apd.PRODUCTTYPEID AS 'producttypeid',
+            apd.PRODUCTTYPE AS 'producttype',
+            aptr.*
+        from aps_product_detail apd
+            LEFT JOIN aps_production_technical_requirement aptr
+                ON  FIND_IN_SET(apd.ID,aptr.ORDERDETAILIDS)
+        where apd.DELETED = 0
+          AND aptr.DELETED = 0
+          AND apd.ID != #{id}
+          AND aptr.ID != #{technicalRequirementId}
+          AND aptr.ID is not null
+          AND (
+              apd.ALLOY = #{alloy}
+                  OR apd.ALLOYSTATUS = #{alloystatus}
+                  OR aptr.ORDERPRODUCTTYPEID = #{orderProductTypeId}
+              )
+    </select>
 </mapper>

+ 20 - 0
cx-aps/cx-aps-entity/src/main/java/com/rongwei/bsentity/vo/GetOldTechnicalRequirementReq.java

@@ -0,0 +1,20 @@
+package com.rongwei.bsentity.vo;
+
+import com.rongwei.bsentity.domain.ApsProductDetailDo;
+import lombok.Data;
+
+/**
+ * @author :sc
+ * @since :2024/10/31
+ */
+@Data
+public class GetOldTechnicalRequirementReq {
+    //技术要求ID
+    private String technicalRequirementId;
+
+    //技术要求选择的产品类型
+    private String orderProductTypeId;
+
+    //产品明细详情
+    private ApsProductDetailDo orderDetail;
+}

+ 41 - 0
cx-aps/cx-aps-entity/src/main/java/com/rongwei/bsentity/vo/GetOldTechnicalRequirementRes.java

@@ -0,0 +1,41 @@
+package com.rongwei.bsentity.vo;
+
+import com.rongwei.bsentity.domain.ApsProductDetailDo;
+import com.rongwei.bsentity.domain.ApsProductionTechnicalRequirementHistoryDo;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @author :sc
+ * @since :2024/10/31
+ */
+@Data
+public class GetOldTechnicalRequirementRes extends ApsProductionTechnicalRequirementHistoryDo {
+    //评分
+    private Integer score = 0;
+
+    //产品明细ID
+    private String orderDetailId;
+
+    /**
+     * 产品类型
+     */
+    private String producttype;
+
+    /**
+     * 合金
+     */
+    private String alloy;
+
+    /**
+     * 合金状态
+     */
+    private String alloystatus;
+
+
+    /**
+     * 产品类型ID
+     */
+    private String producttypeid;
+}

+ 19 - 0
cx-aps/cx-aps-server/src/main/java/com/rongwei/bsserver/controller/ApsProductDetailController.java

@@ -3,6 +3,7 @@ package com.rongwei.bsserver.controller;
 
 import com.rongwei.bscommon.sys.service.ApsProductDetailService;
 import com.rongwei.bsentity.domain.ApsProductDetailDo;
+import com.rongwei.bsentity.vo.GetOldTechnicalRequirementReq;
 import com.rongwei.bsentity.vo.UpdateProductDetailsAndBlankOutputReq;
 import com.rongwei.rwcommon.base.R;
 import lombok.extern.slf4j.Slf4j;
@@ -101,5 +102,23 @@ public class ApsProductDetailController {
             return R.error("更新或保存产品明细及其对应的输出成品失败,请联系管理员");
         }
     }
+
+    /**
+     * 新增或更改技术要求的订单产品后,记录技术要求的合金=技术要求所选第一个产品明细的合金;合金状态=技术要求所选第一个产品明细的合金状态;
+     * 选择订单产品类型后,查找该客户生产状态=待开工或加工中或已完工的历史订单匹配度大等于1并且最高,并且最新的技术要求,匹配度计算逻辑:
+     * 如果合金状态相同,则匹配度加1
+     * 如果合金相同,则匹配度加10
+     * 如果产品类型相同,则匹配度加100
+     */
+    @PostMapping("/getOldTechnicalRequirement")
+    public R getOldTechnicalRequirement(@RequestBody GetOldTechnicalRequirementReq req) {
+        try {
+            log.info("匹配技术要求;参数为:{}", req);
+            return apsProductDetailService.getOldTechnicalRequirement(req);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return R.error("匹配技术要求失败,请联系管理员");
+        }
+    }
 }