shixr 1 год назад
Родитель
Сommit
e455b7d820

+ 39 - 2
src/main/java/com/kexun/controller/CooperatorProductController.java

@@ -1,7 +1,10 @@
 package com.kexun.controller;
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.kexun.common.utils.Result;
+import com.kexun.entity.CooperatorField;
+import com.kexun.entity.CooperatorInfo;
 import com.kexun.entity.CooperatorProduct;
 import com.kexun.service.CooperatorProductService;
 import lombok.extern.java.Log;
@@ -10,10 +13,12 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
 import java.util.List;
 
 @RestController
-@RequestMapping("/admin/cooperator")
+@RequestMapping("/admin/cooperator_product")
 @Log
 public class CooperatorProductController {
 
@@ -23,7 +28,6 @@ public class CooperatorProductController {
     // 获取合作产品信息
     @GetMapping("cooperatorProductList")
     public Result cooperatorProductList() {
-        System.out.println("aaaa");
         JSONObject resJson=new JSONObject();
         List<CooperatorProduct> list=CooperatorProductService.productList();
         resJson.put("cooperator_Product_List",list);
@@ -32,4 +36,37 @@ public class CooperatorProductController {
         return Result.success("ok",resJson);
     }
 
+    // 获取合作产品字段
+    @GetMapping("findCooperatorProductFieldByNum")
+    public Result findCooperatorProductFieldByNum(String productNum) {
+
+        JSONObject result = new JSONObject();
+        List<CooperatorField> list = CooperatorProductService.findCooperatorProductFieldByNum();
+        result.put("cooperator_product_field",list);
+        System.out.println(list);
+
+        return Result.success("ok", result);
+    }
+
+    // 申请合作产品
+    @PostMapping("apply")
+    public Result cooperatorProductApply(@RequestBody String json)
+    {
+        JSONObject req = JSON.parseObject(json);
+        String cooperatorNo = req.getString("cooperator_no");
+        String cooperatorName = req.getString("cooperator_name");
+        String productNo = req.getString("product_num");
+        String productName = req.getString("product_name");
+        String modelId = req.getString("model_id");
+        Calendar calendar= Calendar.getInstance();
+        SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd :hh:mm:ss");
+        String createTime = dateFormat.format(calendar.getTime());
+
+        CooperatorProductService.Apply(cooperatorNo, cooperatorName, productNo, productName, modelId, createTime);
+
+
+        return Result.success();
+
+    }
+
 }

+ 47 - 0
src/main/java/com/kexun/controller/ModelDefineController.java

@@ -0,0 +1,47 @@
+package com.kexun.controller;
+
+//import ch.qos.logback.core.rolling.helper.FileStoreUtil;
+//import ch.qos.logback.core.util.FileUtil;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.kexun.common.utils.Result;
+import com.kexun.entity.CooperatorField;
+import com.kexun.entity.CooperatorInfo;
+import com.kexun.entity.CooperatorProduct;
+import com.kexun.entity.ModelDefine;
+import com.kexun.service.ModelDefineService;
+import lombok.extern.java.Log;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
+
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.List;
+
+
+@RestController
+@RequestMapping("/admin/model_define")
+@Log
+public class ModelDefineController {
+
+    @Autowired
+    private ModelDefineService ModelDefineService;
+
+    // 获取模型信息
+    @GetMapping("modelDefineList")
+    public Result modelDefineList() {
+        JSONObject resJson=new JSONObject();
+        List<ModelDefine> list= ModelDefineService.list();
+        resJson.put("model_define_list",list);
+        System.out.println(list);
+
+        return Result.success("ok",resJson);
+    }
+
+
+
+}

+ 29 - 0
src/main/java/com/kexun/entity/ModelDefine.java

@@ -0,0 +1,29 @@
+package com.kexun.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@TableName(value = "model")
+@Data
+public class ModelDefine implements Serializable {
+
+
+    @TableId(value = "id")
+    private Long id;
+
+    @TableField(value = "model_no")
+    private String modelNo;
+
+    @TableField(value = "model_name")
+    private String modelName;
+
+    @TableField(value = "create_time")
+    private String createTime;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+}

+ 2 - 0
src/main/java/com/kexun/mapper/CooperatorProductMapper.java

@@ -12,4 +12,6 @@ import java.util.List;
 public interface CooperatorProductMapper extends BaseMapper<CooperatorProduct> {
 
     List<CooperatorProduct> Query();
+    List<CooperatorField> fieldQuery();
+    void Apply(String cooperatorNo, String cooperatorName, String productNo, String productName, String modelId, String createTime);
 }

+ 20 - 0
src/main/java/com/kexun/mapper/ModelDefineMapper.java

@@ -0,0 +1,20 @@
+package com.kexun.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.kexun.entity.CooperatorField;
+import com.kexun.entity.CooperatorInfo;
+import com.kexun.entity.CooperatorProduct;
+import com.kexun.entity.ModelDefine;
+
+import java.util.List;
+
+/**
+ * @Entity com.kexun.entity.PartnerInfo
+ */
+public interface ModelDefineMapper extends BaseMapper<ModelDefine> {
+
+}
+
+
+
+

+ 2 - 0
src/main/java/com/kexun/service/CooperatorProductService.java

@@ -12,4 +12,6 @@ import java.util.List;
  */
 public interface CooperatorProductService extends IService<CooperatorProduct> {
     List<CooperatorProduct> productList();
+    List<CooperatorField> findCooperatorProductFieldByNum();
+    void Apply(String cooperatorNo, String cooperatorName, String productNo, String productName, String modelId, String createTime);
 }

+ 15 - 0
src/main/java/com/kexun/service/ModelDefineService.java

@@ -0,0 +1,15 @@
+package com.kexun.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.kexun.entity.CooperatorField;
+import com.kexun.entity.CooperatorProduct;
+import com.kexun.entity.ModelDefine;
+
+import java.util.List;
+
+/**
+ *
+ */
+public interface ModelDefineService extends IService<ModelDefine> {
+
+}

+ 11 - 0
src/main/java/com/kexun/service/impl/CooperatorProductServiceImpl.java

@@ -25,4 +25,15 @@ public class CooperatorProductServiceImpl extends ServiceImpl<CooperatorProductM
         List<CooperatorProduct> l = cooperatorProductMapper.Query();
         return l;
     }
+
+    @Override
+    public List<CooperatorField> findCooperatorProductFieldByNum() {
+        List<CooperatorField> l = cooperatorProductMapper.fieldQuery();
+        return l;
+    }
+
+    @Override
+    public void Apply(String cooperatorNo, String cooperatorName, String productNo, String productName, String modelId, String createTime) {
+        cooperatorProductMapper.Apply(cooperatorNo,cooperatorName, productNo, productName,  modelId,  createTime);
+    }
 }

+ 23 - 0
src/main/java/com/kexun/service/impl/ModelDefineServiceImpl.java

@@ -0,0 +1,23 @@
+package com.kexun.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.kexun.entity.CooperatorField;
+import com.kexun.entity.CooperatorProduct;
+import com.kexun.entity.ModelDefine;
+import com.kexun.mapper.CooperatorProductMapper;
+import com.kexun.mapper.ModelDefineMapper;
+import com.kexun.service.CooperatorProductService;
+import com.kexun.service.ModelDefineService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ *
+ */
+@Service
+public class ModelDefineServiceImpl extends ServiceImpl<ModelDefineMapper, ModelDefine>
+        implements ModelDefineService {
+
+}

+ 17 - 0
src/main/resources/mapper/CooperatorProductMapper.xml

@@ -34,5 +34,22 @@
                LEFT JOIN model ON model.model_no = prd_product.model_id
     </select>
 
+    <select id="fieldQuery" resultType="com.kexun.entity.CooperatorField">
+        SELECT DISTINCT
+            field_define.field_no,
+            field_define.`name`,
+            field_define.name_zh,
+            field_define.type
+        FROM
+            field_define
+                LEFT JOIN product_field_ref ON product_field_ref.field_no = field_define.field_no
+        WHERE product_field_ref.product_num = 'CPXX100'
+    </select>
+
+    <insert id="Apply">
+        insert into prd_product(cooperator_num,cooperator_name,product_num,product_name,model_id,create_time)
+        values(#{cooperatorNo},#{cooperatorName},#{productNo},#{productName},#{modelId},#{createTime})
+    </insert>
+
 
 </mapper>