Pārlūkot izejas kodu

添加erp节点字段

hongxudong 1 gadu atpakaļ
vecāks
revīzija
dcad4e8859

+ 15 - 0
src/main/java/com/dk/mdm/controller/common/CommonController.java

@@ -1407,6 +1407,21 @@ public class CommonController extends BaseController<Map<String, Object>> {
     public ResponseResultVO<PageList<Map<String, Object>>> getMotherMoldByPage(@RequestBody Map<String, Object> param) {
         return commonService.getMotherMoldByPage(param);
     }
+
+
+    /**
+     * @desc   : 查询ERP节点
+     * @author : 洪旭东
+     * @date   : 2024-04-28 16:07
+     */
+    @ApiOperation(
+            value = "查询ERP节点",
+            notes = "查询ERP节点"
+    )
+    @PostMapping("get_erp_node_by_page")
+    public ResponseResultVO<List<Map<String, Object>>> getErpNodeByPage(@RequestBody Map<String, Object> param) {
+        return commonService.getErpNodeByPage(param);
+    }
 }
 
 

+ 14 - 0
src/main/java/com/dk/mdm/mapper/common/CommonMapper.java

@@ -968,4 +968,18 @@ public interface CommonMapper extends BaseMapper<Map<String, Object>> {
      * @date   : 2024-04-09 14:52
      */
     Long countMotherMoldByPage(Map param);
+
+    /**
+     * @desc   : 查询ERP节点
+     * @author : 洪旭东
+     * @date   : 2024-04-28 16:06
+     */
+    List<Map<String, Object>> getErpNodeByPage(Map param);
+
+    /**
+     * @desc   : 查询ERP节点个数
+     * @author : 洪旭东
+     * @date   : 2024-04-28 16:06
+     */
+    Long countErpNodeByPage(Map param);
 }

+ 32 - 0
src/main/java/com/dk/mdm/mapper/common/CommonMapper.xml

@@ -3009,4 +3009,36 @@
             and position(#{uniqueCode} in unique_code) > 0
         </if>
     </select>
+
+    <select id="getErpNodeByPage" resultType="Map">
+        select
+        node_id   as "nodeId",
+        sys.f_code_name(node_code,node_name) AS "nodeCodeName"
+        from mst.t_erp_node
+        where fty_id = #{ftyId}
+        and flg_valid
+        <if test="nodeCode != null and nodeCode != ''">
+            and position(#{nodeCode} in node_code) > 0
+        </if>
+        <if test="nodeName != null and nodeName != ''">
+            and position(#{nodeName} in node_name) > 0
+        </if>
+        order by display_no
+        <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
+            limit #{end} offset #{start}
+        </if>
+    </select>
+
+    <select id="countErpNodeByPage" resultType="Long">
+        select count(1)
+        from mst.t_erp_node
+        where fty_id = #{ftyId}
+        and flg_valid
+        <if test="nodeCode != null and nodeCode != ''">
+            and position(#{nodeCode} in node_code) > 0
+        </if>
+        <if test="nodeName != null and nodeName != ''">
+            and position(#{nodeName} in node_name) > 0
+        </if>
+    </select>
 </mapper>

+ 3 - 0
src/main/java/com/dk/mdm/mapper/mst/ErpNodeMapper.xml

@@ -34,6 +34,9 @@
             <if test="nodeType != null and nodeType != ''">
                 AND ten.node_type = #{nodeType}
             </if>
+            <if test="flgValid != null">
+                AND ten.flg_valid = #{flgValid}
+            </if>
             <if test="flgValidList != null and flgValidList.size()>0">
                 AND ten.flg_valid = any(#{flgValidList, typeHandler= BooleanListTypeHandler})
             </if>

+ 6 - 0
src/main/java/com/dk/mdm/mapper/mst/ModelPdtErpMapper.xml

@@ -142,11 +142,15 @@
         pdtErp.pdt_model_id as "pdtModelId",
         pdtErp.erp_model_code as "erpModelCode",
         pdtErp.remarks as "remarks",
+        pdtLogo.logo_id as "logoId",
         pdtLogo.logo_name as "logoName",
+        pdtColour.colour_id as "colourId",
         pdtColour.colour_name as "colourName",
         pdtErp.flg_default as "flgDefault",
         pdtErp.erp_sku_id                                           as "erpSkuId",
         tmm.model_code                                                   as "erpSkuCode",
+        ten.node_id                                                     as "erpNodeId",
+        sys.f_code_name(ten.node_code, ten.node_name)                             AS "erpNodeCodeName",
         (
             select json_agg(jsonb_build_object('labelCode', label_code, 'labelKind', label_kind))
             from mst.t_model_pdt_label
@@ -164,6 +168,7 @@
         left join mst.t_product_colour pdtColour
         on pdtErp.colour_id =  pdtColour.colour_id
         left join mst.t_model_material tmm on tmm.model_id = pdtErp.erp_sku_id
+        left join mst.t_erp_node ten on ten.node_id = pdtErp.erp_node_id
         where pdtErp.flg_valid
             and   pdtErp.fty_id = #{ftyId}
         <if test="pdtModelId != null and pdtModelId != ''">
@@ -186,6 +191,7 @@
          and modelpdterp.logo_id = #{logoId}
         and modelpdterp.colour_id = #{colourId}
         and modelpdterp.pdt_model_id = #{pdtModelId}
+        and modelpdterp.erp_node_id = #{erpNodeId}
         <if test="itemId != null and itemId != ''">
             AND modelpdterp.item_id != #{itemId}
         </if>

+ 3 - 0
src/main/java/com/dk/mdm/mapper/mst/ModelProductMapper.xml

@@ -170,6 +170,8 @@
                logo.logo_name                                                   as "logoId_Name",
                modelPdtErp.colour_id                                            as "colourId",
                colour.colour_name                                               as "colourId_Name",
+               modelPdtErp.erp_node_id                                          as "erpNodeId",
+               sys.f_code_name(ten.node_code, ten.node_name)                             AS "erpNodeId_Name",
                modelPdtErp.erp_model_code                                       as "erpModelCode",
                modelPdtErp.remarks                                              as "remarks",
                modelPdtErp.erp_sku_id                                           as "erpSkuId",
@@ -193,6 +195,7 @@
         left join mst.t_product_colour as colour
         on modelPdtErp.colour_id = colour.colour_id
         left join mst.t_model_material tmm on tmm.model_id = modelPdtErp.erp_sku_id
+        left join mst.t_erp_node ten on ten.node_id = modelPdtErp.erp_node_id
         where modelPdtErp.pdt_model_id = #{modelId}
     </select>
 

+ 4 - 2
src/main/java/com/dk/mdm/mapper/pdm/ProcessNodeMapper.xml

@@ -435,7 +435,7 @@
             cnt_quy_defect,
             cnt_job_defect,
             node_desc, node_types, tech_type, work_shop,kiln_ids,car_kind,
-            wh_id, place_id
+            wh_id, place_id, erp_node_id
         </trim>
         )
         values
@@ -519,6 +519,7 @@
                 #{item.carKind},
                 #{item.whId},
                 #{item.placeId},
+                #{item.erpNodeId},
             </trim>
             )
         </foreach>
@@ -567,7 +568,8 @@
         kiln_ids = excluded."kiln_ids",
         car_kind = excluded."car_kind",
         wh_id = excluded."wh_id",
-        place_id = excluded."place_id"
+        place_id = excluded."place_id",
+        erp_node_id = excluded."erp_node_id"
     </insert>
 
     <select id="selectByMap" resultMap="ResResultMap">

+ 3 - 0
src/main/java/com/dk/mdm/model/pojo/mst/ModelPdtErp.java

@@ -168,6 +168,9 @@ public class ModelPdtErp extends PageInfo<ModelPdtErp> implements Serializable {
     @ApiModelProperty(value = "默认标识")
     private Boolean flgDefault;
 
+    @ApiModelProperty(value = "ERP节点ID")
+    private Integer erpNodeId;
+
     /*
      * 相关属性
      * @TableField(exist = false)

+ 3 - 0
src/main/java/com/dk/mdm/model/pojo/pdm/ProcessNode.java

@@ -399,6 +399,9 @@ public class ProcessNode extends PageInfo<ProcessNode> implements Serializable {
     @ApiModelProperty(value = "仓位ID")
     private Integer placeId;
 
+    @ApiModelProperty(value = "ERP节点ID")
+    private Integer erpNodeId;
+
     /*
      * 相关属性
      * @TableField(exist = false)

+ 2 - 1
src/main/java/com/dk/mdm/model/pojo/pdm/Production.java

@@ -534,7 +534,7 @@ public class Production implements Serializable {
      */
     public Production(Long productionId, Long productId, String opnBatch,
                       Integer currentUserId, String allFlowProdLevel, Integer ftyId,
-                      MoldingItem moldingItem, ProcessNode processNode, ProductGradeResponse productGrade, Integer pdtModelId) {
+                      MoldingItem moldingItem, ProcessNode processNode, ProductGradeResponse productGrade, Integer pdtModelId, Integer erpNodeId) {
         this.setProdId(productionId)
                 .setPdtUniqueId(productId)
                 .setFlowNodeId(moldingItem.getFlowNodeId()).setStationId(moldingItem.getStationId())
@@ -560,6 +560,7 @@ public class Production implements Serializable {
                 }})
                 .setAllFlowProdLevel(allFlowProdLevel + "#")
                 .setFtyId(ftyId)
+                .setErpNodeId(erpNodeId)
         ;
     }
 

+ 1 - 5
src/main/java/com/dk/mdm/model/pojo/pdm/ProductionRds.java

@@ -381,11 +381,7 @@ public class ProductionRds extends PageInfo<ProductionRds> implements Serializab
         this.whpRdsType = whpRdsType;
         this.rdsDirection = rdsDirection;
         this.rdsProdId = production.getProdId();
-        if (rdsDirection.equals(Constant.RdsDirection.IN.getCode())) {
-            this.perProdId = this.rdsProdId;
-        } else {
-            this.perProdId = production.getPerProdId();
-        }
+        this.perProdId = production.getPerProdId();
         this.setPdtUniqueId(production.getPdtUniqueId())
                 .setFlowNodeId(production.getFlowNodeId())
                 .setStationId(production.getStationId())

+ 5 - 0
src/main/java/com/dk/mdm/model/query/mst/ErpNodeQuery.java

@@ -54,6 +54,8 @@ public class ErpNodeQuery extends PageInfo<ErpNodeQuery> implements Serializable
     @ApiModelProperty(value = "节点名称")
     private String nodeName;
 
+    @ApiModelProperty(value = "节点类别 (【系统字典】产阶类型-成型、半成、产成)")
+    private String nodeType;
 
     /**
      * 工厂ID
@@ -62,6 +64,9 @@ public class ErpNodeQuery extends PageInfo<ErpNodeQuery> implements Serializable
     @ApiModelProperty(value = "工厂ID")
     private Integer ftyId;
 
+    @ApiModelProperty(value = "有效标识 (1:正常 0:停用)")
+    private Boolean flgValid;
+
     /*
      * 相关属性
      * @TableField(exist = false)

+ 2 - 0
src/main/java/com/dk/mdm/model/vo/mst/ModelPdtErpVO.java

@@ -116,6 +116,8 @@ public class ModelPdtErpVO extends PageInfo<ModelPdtErpVO> implements Serializab
     private Boolean flgDefault;
 
 
+    @ApiModelProperty(value = "ERP节点ID")
+    private Integer erpNodeId;
 
     /*
      * 相关属性

+ 11 - 0
src/main/java/com/dk/mdm/service/common/CommonService.java

@@ -1319,4 +1319,15 @@ public class CommonService extends BaseService<Map<String, Object>> {
         return super.mergeListWithCount(param, commonMapper.getMotherMoldByPage(param),
                 commonMapper.countMotherMoldByPage(param));
     }
+
+
+    /**
+     * @desc   : 查询ERP节点
+     * @author : 洪旭东
+     * @date   : 2024-04-28 16:07
+     */
+    public ResponseResultVO<List<Map<String, Object>>> getErpNodeByPage(Map<String, Object> param) {
+//        this.getLimit(param);
+        return ResponseResultUtil.success(commonMapper.getErpNodeByPage(param));
+    }
 }

+ 31 - 4
src/main/java/com/dk/mdm/service/pdm/ProductService.java

@@ -1,5 +1,6 @@
 package com.dk.mdm.service.pdm;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.dk.common.exception.BaseBusinessException;
 import com.dk.common.infrastructure.annotaiton.Pagination;
@@ -14,11 +15,15 @@ import com.dk.common.service.BaseService;
 import com.dk.mdm.infrastructure.convert.pdm.ProductConvert;
 import com.dk.mdm.infrastructure.strategy.production.ProductionContext;
 import com.dk.mdm.infrastructure.util.AuthUtils;
+import com.dk.mdm.mapper.common.CommonMapper;
+import com.dk.mdm.mapper.mst.ErpNodeMapper;
 import com.dk.mdm.mapper.mst.ModelProductMapper;
 import com.dk.mdm.mapper.mst.ProductGradeMapper;
 import com.dk.mdm.mapper.pdm.*;
 import com.dk.mdm.model.pojo.pdm.*;
+import com.dk.mdm.model.query.mst.ErpNodeQuery;
 import com.dk.mdm.model.query.pdm.ProductQuery;
+import com.dk.mdm.model.response.mst.ErpNodeResponse;
 import com.dk.mdm.model.response.mst.ProductGradeResponse;
 import com.dk.mdm.model.response.pdm.ProductResponse;
 import com.dk.mdm.model.vo.pdm.ProductVO;
@@ -27,9 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
+import java.util.*;
 
 @Service
 public class ProductService extends BaseService<Product> {
@@ -78,6 +81,12 @@ public class ProductService extends BaseService<Product> {
 	@Autowired
 	private ProductionContext productionContext;
 
+	@Autowired
+	private CommonMapper commonMapper;
+
+	@Autowired
+	private ErpNodeMapper erpNodeMapper;
+
 	/**
 	 * @desc   : 重写主键
 	 * @author : 常皓宁
@@ -131,6 +140,24 @@ public class ProductService extends BaseService<Product> {
 		// 当前工序
 		ProcessNode processNode = null;
 
+		Integer ftyId = authUtils.getUser().getFtyId();
+		//erp节点
+		Integer erpNodeId = null;
+		Map<String, Object> map = new HashMap<>();
+		map.put("code", Constant.StringConstant.SYS_PDM_005.getName());
+		map.put("ftyId", ftyId);
+		String value = commonMapper.getSettingValue(map);
+		if (value!=null) {
+			JSONArray jsonArray = JSONArray.parseArray(value);
+			if (jsonArray.contains("3")) {
+				List<ErpNodeResponse> erpNodes = erpNodeMapper.selectByCond(new ErpNodeQuery().setFtyId(ftyId).setFlgValid(true).setNodeType("产阶类型-成型"));
+				if (erpNodes!=null && erpNodes.size()>0) {
+					erpNodeId = erpNodes.get(0).getNodeId();
+				}
+			}
+		}
+
+
 		for (Product it : productList) {
 			if (it.getUniqueId() != null) {
 				productMapper.updateById(productMapper.selectById(it.getUniqueId()).setRemarks(it.getRemarks()));
@@ -188,7 +215,7 @@ public class ProductService extends BaseService<Product> {
 						productionMapper.getLevelById(productionId),
 						it.getFtyId(),
 						moldingItem, processNode, productGrade,
-						it.getModelId()
+						it.getModelId(), erpNodeId
 				);
 				productionMapper.insert(production);