Explorar el Código

aps-匹配技术要求

sucheng hace 5 meses
padre
commit
5129e2965b

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

@@ -64,7 +64,7 @@ public interface ApsProductDetailDao extends BaseMapper<ApsProductDetailDo> {
 
     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);
+    GetOldTechnicalRequirementRes selectMyList(@Param("technicalRequirementId") String technicalRequirementId, @Param("id") String id, @Param("alloy") String alloy, @Param("alloystatus") String alloystatus, @Param("orderProductTypeId") String orderProductTypeId);
 
     List<GetOldTechnicalRequirementRes> selectMyList1(@Param("technicalRequirementId") String technicalRequirementId, @Param("id") String id, @Param("customId") String customId, @Param("alloy") String alloy);
 

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

@@ -630,48 +630,48 @@ public class ApsProductDetailServiceImpl extends ServiceImpl<ApsProductDetailDao
         String alloy = orderDetail.getAlloy();
         String alloystatus = orderDetail.getAlloystatus();
 
-//        List<GetOldTechnicalRequirementRes> apsProductDetailDoList = this.baseMapper.selectMyList(technicalRequirementId, orderDetail.getId(), alloy, alloystatus, orderProductTypeId);
-        List<GetOldTechnicalRequirementRes> list1 = this.baseMapper.selectMyList1(technicalRequirementId, orderDetail.getId(), customId, alloy);
-        List<GetOldTechnicalRequirementRes> list2 = this.baseMapper.selectMyList2(technicalRequirementId, orderDetail.getId(), customId, alloystatus);
-        List<GetOldTechnicalRequirementRes> list3 = this.baseMapper.selectMyList3(technicalRequirementId, orderDetail.getId(), customId, orderProductTypeId);
-
-        //合并三个list
-        List<GetOldTechnicalRequirementRes> apsProductDetailDoList = new LinkedList<>();
-        apsProductDetailDoList.addAll(list1);
-        apsProductDetailDoList.addAll(list2);
-        apsProductDetailDoList.addAll(list3);
-        apsProductDetailDoList = apsProductDetailDoList.stream().distinct().collect(Collectors.toList());
-
-        List<GetOldTechnicalRequirementRes> list = new LinkedList<>();
-        for (GetOldTechnicalRequirementRes vo : apsProductDetailDoList) {
-            int score = 0;
-            if (ObjectUtil.isNotEmpty(vo.getAlloy()) && vo.getAlloy().equals(alloy)) {
-                score += 10;
-            }
-            if (ObjectUtil.isNotEmpty(vo.getAlloystatus()) && vo.getAlloystatus().equals(alloystatus)) {
-                score += 1;
-            }
-            if (ObjectUtil.isNotEmpty(vo.getOrderproducttypeid()) && 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);
+        GetOldTechnicalRequirementRes apsProductDetailDo = this.baseMapper.selectMyList(technicalRequirementId, orderDetail.getId(), alloy, alloystatus, orderProductTypeId);
+//        List<GetOldTechnicalRequirementRes> list1 = this.baseMapper.selectMyList1(technicalRequirementId, orderDetail.getId(), customId, alloy);
+//        List<GetOldTechnicalRequirementRes> list2 = this.baseMapper.selectMyList2(technicalRequirementId, orderDetail.getId(), customId, alloystatus);
+//        List<GetOldTechnicalRequirementRes> list3 = this.baseMapper.selectMyList3(technicalRequirementId, orderDetail.getId(), customId, orderProductTypeId);
+//
+//        //合并三个list
+//        List<GetOldTechnicalRequirementRes> apsProductDetailDoList = new LinkedList<>();
+//        apsProductDetailDoList.addAll(list1);
+//        apsProductDetailDoList.addAll(list2);
+//        apsProductDetailDoList.addAll(list3);
+//        apsProductDetailDoList = apsProductDetailDoList.stream().distinct().collect(Collectors.toList());
+//
+//        List<GetOldTechnicalRequirementRes> list = new LinkedList<>();
+//        for (GetOldTechnicalRequirementRes vo : apsProductDetailDoList) {
+//            int score = 0;
+//            if (ObjectUtil.isNotEmpty(vo.getAlloy()) && vo.getAlloy().equals(alloy)) {
+//                score += 10;
+//            }
+//            if (ObjectUtil.isNotEmpty(vo.getAlloystatus()) && vo.getAlloystatus().equals(alloystatus)) {
+//                score += 1;
+//            }
+//            if (ObjectUtil.isNotEmpty(vo.getOrderproducttypeid()) && 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(apsProductDetailDo);
     }
 
 

+ 13 - 8
cx-aps/cx-aps-common/src/main/resources/mybatis/ApsProductDetailDao.xml

@@ -143,20 +143,25 @@
             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)
+            aptr.*,
+            IF(apd.ALLOY = #{alloy},10,0)+IF(apd.ALLOYSTATUS = #{alloystatus},1,0)+IF(apd.PRODUCTTYPEID = #{orderProductTypeId},100,0) AS 'core'
+        from
+            aps_production_order apo
+                LEFT JOIN aps_product_detail apd ON apo.ID = apd.MAINID
+                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 apo.CUSTOMID = #{customId}
           AND (
-              apd.ALLOY = #{alloy}
-                  OR apd.ALLOYSTATUS = #{alloystatus}
-                  OR aptr.ORDERPRODUCTTYPEID = #{orderProductTypeId}
-              )
+            apd.ALLOY = #{alloy}
+                OR apd.ALLOYSTATUS = #{alloystatus}
+                OR aptr.ORDERPRODUCTTYPEID = #{orderProductTypeId}
+            )
+        ORDER BY core desc,aptr.CREATEDATE desc
+        limit 1
     </select>
     <select id="selectMyList1" resultType="com.rongwei.bsentity.vo.GetOldTechnicalRequirementRes">
         select