cxd 7 miesięcy temu
rodzic
commit
1ef0aac258

+ 6 - 1
gqy-admin/src/main/java/com/gqy/web/controller/document/ProductController.java

@@ -3,6 +3,8 @@ package com.gqy.web.controller.document;
 import com.gqy.common.core.domain.AjaxResult;
 import com.gqy.common.core.domain.AjaxResult;
 import com.gqy.common.core.domain.AjaxResultCQY;
 import com.gqy.common.core.domain.AjaxResultCQY;
 import com.gqy.document.domain.vo.PageResult;
 import com.gqy.document.domain.vo.PageResult;
+import com.gqy.document.service.IDcProductService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -21,6 +23,9 @@ import java.util.Map;
 @RequestMapping("/product")
 @RequestMapping("/product")
 public class ProductController {
 public class ProductController {
 
 
+    @Autowired
+    IDcProductService iDcProductService;
+
     @PostMapping("/search")
     @PostMapping("/search")
     public AjaxResultCQY search(HttpServletRequest request) {
     public AjaxResultCQY search(HttpServletRequest request) {
         return AjaxResultCQY.success("查询成功", new PageResult());
         return AjaxResultCQY.success("查询成功", new PageResult());
@@ -33,6 +38,6 @@ public class ProductController {
      */
      */
     @PostMapping("/add")
     @PostMapping("/add")
     public AjaxResultCQY add(@RequestBody Map maps) {
     public AjaxResultCQY add(@RequestBody Map maps) {
-        return AjaxResultCQY.success("添加成功");
+        return AjaxResultCQY.success(iDcProductService.add(maps));
     }
     }
 }
 }

+ 2 - 2
gqy-system/src/main/java/com/gqy/document/mapper/DcSystemProductMapper.java

@@ -1,5 +1,6 @@
 package com.gqy.document.mapper;
 package com.gqy.document.mapper;
 
 
+import com.gqy.document.domain.DcSystemProduct;
 import com.gqy.document.domain.DcTemplate;
 import com.gqy.document.domain.DcTemplate;
 
 
 import java.util.List;
 import java.util.List;
@@ -8,8 +9,7 @@ public interface DcSystemProductMapper {
 
 
     /**
     /**
      *  插入
      *  插入
-     * @param dcTemplate
      * @return
      * @return
      */
      */
-    public int insertDcSystemProduct(DcTemplate dcTemplate);
+    public int insertDcSystemProduct(DcSystemProduct dcSystemProduct);
 }
 }

+ 48 - 21
gqy-system/src/main/java/com/gqy/document/service/impl/DcProductServiceImpl.java

@@ -3,8 +3,12 @@ package com.gqy.document.service.impl;
 import com.gqy.common.utils.bean.BeanUtils;
 import com.gqy.common.utils.bean.BeanUtils;
 import com.gqy.document.domain.DcProduct;
 import com.gqy.document.domain.DcProduct;
 import com.gqy.document.domain.DcSpec;
 import com.gqy.document.domain.DcSpec;
+import com.gqy.document.domain.DcSystemProduct;
+import com.gqy.document.domain.DcWorkSystem;
 import com.gqy.document.mapper.DcProductMapper;
 import com.gqy.document.mapper.DcProductMapper;
 import com.gqy.document.mapper.DcSpecMapper;
 import com.gqy.document.mapper.DcSpecMapper;
+import com.gqy.document.mapper.DcSystemProductMapper;
+import com.gqy.document.mapper.DcWorkSystemMapper;
 import com.gqy.document.service.IDcProductService;
 import com.gqy.document.service.IDcProductService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 
 
@@ -19,6 +23,11 @@ public class DcProductServiceImpl implements IDcProductService {
     @Autowired
     @Autowired
     private DcProductMapper dcProductMapper;
     private DcProductMapper dcProductMapper;
 
 
+    @Autowired
+    private DcWorkSystemMapper dcWorkSystemMapper;
+
+    @Autowired
+    private DcSystemProductMapper dcSystemProductMapper;
 
 
     /**
     /**
      *
      *
@@ -27,30 +36,48 @@ public class DcProductServiceImpl implements IDcProductService {
      */
      */
     public int add(Map<String, Object> params) {
     public int add(Map<String, Object> params) {
 
 
-        DcProduct product = new DcProduct();
-        // 拷贝参数
-        BeanUtils.copyProperties(params, product);
-        // 保存
-        dcProductMapper.insertDcProduct(product);
-        // 产品id
-        int dcpId = product.getDcp_id();
-
-        //工程系统表 保存信息 dc_work_system
-        //系统产品表 保存信息  dc_system_product
-
-
-        // 规格管理
-        List<Map> specs = (List<Map>) params.get("specs");
-        for (Map spec : specs) {
-            // 规格
-            DcSpec dcSpec = new DcSpec();
-            //设置 产品id
-            dcSpec.setPs_p_id(dcpId);
+        try {
+            DcProduct product = new DcProduct();
             // 拷贝参数
             // 拷贝参数
-            BeanUtils.copyProperties(spec, dcSpec);
+            BeanUtils.copyProperties(params, product);
+            // 保存
+            dcProductMapper.insertDcProduct(product);
+            // 产品id
+            int dcpId = product.getDcp_id();
+            //系统类别id
+            int  sys_no = Integer.parseInt((String) params.get("sys_no"));
+            //工程id
+            int wr_id = Integer.parseInt((String) params.get("wr_id"));
 
 
-        }
 
 
+            // 工程系统表 保存信息 dc_work_system
+            DcWorkSystem workSystem = new DcWorkSystem();
+            workSystem.setWr_id(wr_id);
+            workSystem.setSys_id(sys_no);
+
+            dcWorkSystemMapper.insertDcWorkSystem(workSystem);
+
+            // 系统产品表 保存信息 dc_system_product
+            DcSystemProduct systemProduct = new DcSystemProduct();
+            systemProduct.setSys_no(sys_no);
+            systemProduct.setP_id(dcpId);
+            dcSystemProductMapper.insertDcSystemProduct(systemProduct);
+
+            // 规格管理
+            List<Map> specs = (List<Map>) params.get("specs");
+            for (Map spec : specs) {
+                // 规格
+                DcSpec dcSpec = new DcSpec();
+                //设置 产品id
+                dcSpec.setPs_p_id(dcpId);
+                // 拷贝参数
+                BeanUtils.copyProperties(spec, dcSpec);
+
+            }
+            return  1;
+        }catch (Exception e){
+            e.printStackTrace();
+        }
         return 0;
         return 0;
     }
     }
 }
 }

+ 4 - 6
gqy-system/src/main/resources/mapper/document/DcSystemProductMapper.xml

@@ -5,11 +5,11 @@
 <mapper namespace="com.gqy.document.mapper.DcSystemProductMapper">
 <mapper namespace="com.gqy.document.mapper.DcSystemProductMapper">
 
 
     <resultMap type="DcSystemProduct" id="DcSystemProductResult">
     <resultMap type="DcSystemProduct" id="DcSystemProductResult">
-        <id     property="sys_id"       column="sys_id"      />
+        <id     property="syp_id"       column="syp_id"      />
         <result property="sys_no"       column="sys_no"      />
         <result property="sys_no"       column="sys_no"      />
         <result property="sys_name"     column="sys_name"    />
         <result property="sys_name"     column="sys_name"    />
         <result property="sys_remark"   column="sys_remark"  />
         <result property="sys_remark"   column="sys_remark"  />
-        <result property="dcp_id"       column="dcp_id"      />
+        <result property="p_id"       column="p_id"      />
         <result property="sys_status"   column="sys_status"  />
         <result property="sys_status"   column="sys_status"  />
     </resultMap>
     </resultMap>
 
 
@@ -19,19 +19,17 @@
     <insert id="insertDcSystemProduct" parameterType="DcSystemProduct">
     <insert id="insertDcSystemProduct" parameterType="DcSystemProduct">
         insert into dc_system_product
         insert into dc_system_product
         <trim prefix="(" suffix=")" suffixOverrides=",">
         <trim prefix="(" suffix=")" suffixOverrides=",">
-            <if test="sys_id != null">sys_id,</if>
             <if test="sys_no != null">sys_no,</if>
             <if test="sys_no != null">sys_no,</if>
             <if test="sys_name != null">sys_name,</if>
             <if test="sys_name != null">sys_name,</if>
             <if test="sys_remark != null">sys_remark,</if>
             <if test="sys_remark != null">sys_remark,</if>
-            <if test="dcp_id != null">dcp_id,</if>
+            <if test="p_id != null">p_id,</if>
             <if test="sys_status != null">sys_status,</if>
             <if test="sys_status != null">sys_status,</if>
         </trim>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
         <trim prefix="values (" suffix=")" suffixOverrides=",">
-            <if test="sys_id != null">#{sys_id},</if>
             <if test="sys_no != null">#{sys_no},</if>
             <if test="sys_no != null">#{sys_no},</if>
             <if test="sys_name != null">#{sys_name},</if>
             <if test="sys_name != null">#{sys_name},</if>
             <if test="sys_remark != null">#{sys_remark},</if>
             <if test="sys_remark != null">#{sys_remark},</if>
-            <if test="dcp_id != null">#{dcp_id},</if>
+            <if test="p_id != null">#{p_id},</if>
             <if test="sys_status != null">#{sys_status},</if>
             <if test="sys_status != null">#{sys_status},</if>
         </trim>
         </trim>
     </insert>
     </insert>