ソースを参照

成本报表 添加

liuchaohui 2 年 前
コミット
4ddb0615fe

+ 12 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/controller/SyCostAllocationController.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.cost.controller;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -28,6 +29,7 @@ import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartHttpServletRequest;
 import org.springframework.web.servlet.ModelAndView;
+import springfox.documentation.spring.web.json.Json;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -183,12 +185,20 @@ public class SyCostAllocationController {
     /**
      * 添加
      *
-     * @param syCostAllocationPage
+     * @param
      * @return
      */
     @AutoLog(value = "成本分配-添加")
     @PostMapping(value = "/add")
-    public Result<?> add(@RequestBody SyCostAllocationPage syCostAllocationPage) {
+    public Result<?> add(@RequestParam(name = "plannum", required = true) String plannum,
+                         @RequestParam(name = "json", required = true) JSONObject json) {
+        syCostAllocationService.saveMain(plannum, json);
+        return Result.OK("添加成功!");
+    }
+
+    @AutoLog(value = "成本分配-添加")
+    @PostMapping(value = "/addd")
+    public Result<?> addd(@RequestBody SyCostAllocationPage syCostAllocationPage) {
         SyCostAllocation syCostAllocation = new SyCostAllocation();
         BeanUtils.copyProperties(syCostAllocationPage, syCostAllocation);
         syCostAllocationService.saveMain(syCostAllocation, syCostAllocationPage.getSyCostAllocationAccidentList(), syCostAllocationPage.getSyCostAllocationCostpayList(), syCostAllocationPage.getSyCostAllocationFabricList(), syCostAllocationPage.getSyCostAllocationIngredientList(), syCostAllocationPage.getSyCostAllocationShipdetailList());

+ 31 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/entity/SyCostJson.java

@@ -0,0 +1,31 @@
+package org.jeecg.modules.cost.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.jeewx.api.wxuser.Test;
+import springfox.documentation.spring.web.json.Json;
+import java.io.Serializable;
+
+/**
+ * @Description: 成本分配存储json
+ * @Author: jeecg-boot
+ * @Date:   2022-06-21
+ * @Version: V1.0
+ */
+@Data
+@TableName("sy_cost_json")
+@ApiModel(value="sy_cost_json对象", description="成本分配存储json")
+public class SyCostJson implements Serializable {
+
+    /**计划单号*/
+    @ApiModelProperty(value = "计划单号")
+    private String planNum;
+
+    @ApiModelProperty(value = "内容")
+    private String costInfo;
+
+}

+ 14 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/mapper/SyCostJsonMapper.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.cost.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.cost.entity.SyCostJson;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public interface SyCostJsonMapper extends BaseMapper<SyCostJson> {
+    /*int batchInsertData(@Param("tableName") String tableName,
+                        @Param("cols") Set<String> cols, @Param("data") List<Map<String, Object>> data);*/
+}

+ 29 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/mapper/xml/SyCostJsonMapper.xml

@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.cost.mapper.SyCostJsonMapper">
+<!--    <insert id="batchInsertData">
+        insert into ${tableName}
+        <foreach collection="cols" item="col" open="(" close=")" separator=",">
+            ${col}
+        </foreach>
+        values
+        <foreach collection="data" item="map" separator=",">
+            (
+            <foreach collection="map.entrySet()" item="value" index="key" separator=",">
+                #{value}
+            </foreach>
+            )
+        </foreach>
+    </insert>
+
+    <insert id="insertDynamic" parameterType="org.jeecg.modules.dxp.entity.VO.InsertMap" >
+        insert ignore into ${tableName}
+        <foreach collection="params.keys" item="key" open="(" close=")" separator="," >
+            ${key}
+        </foreach>
+        values
+        <foreach collection="params.keys"  item="key" open="(" close=")" separator=",">
+            #{params.${key}}
+        </foreach>
+    </insert>-->
+</mapper>

+ 2 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/service/ISyCostAllocationService.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.cost.service;
 
+import com.alibaba.fastjson.JSONObject;
 import org.jeecg.modules.cost.entity.SyCostAllocationAccident;
 import org.jeecg.modules.cost.entity.SyCostAllocationCostpay;
 import org.jeecg.modules.cost.entity.SyCostAllocationFabric;
@@ -24,7 +25,7 @@ public interface ISyCostAllocationService extends IService<SyCostAllocation> {
      *
      */
     public void saveMain(SyCostAllocation syCostAllocation, List<SyCostAllocationAccident> syCostAllocationAccidentList, List<SyCostAllocationCostpay> syCostAllocationCostpayList, List<SyCostAllocationFabric> syCostAllocationFabricList, List<SyCostAllocationIngredient> syCostAllocationIngredientList, List<SyCostAllocationShipdetail> syCostAllocationShipdetailList) ;
-
+    public void saveMain(String plannum, JSONObject json);
     /**
      * 修改一对多
      *

+ 23 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/service/impl/SyCostAllocationServiceImpl.java

@@ -3,6 +3,7 @@ package org.jeecg.modules.cost.service.impl;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.google.gson.JsonObject;
 import org.jeecg.common.exception.JeecgBootException;
 import org.jeecg.modules.cost.entity.*;
 import org.jeecg.modules.cost.mapper.*;
@@ -14,8 +15,10 @@ import org.springframework.beans.BeansException;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import springfox.documentation.spring.web.json.Json;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
@@ -37,6 +40,8 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
     @Autowired
     private SyCostAllocationMapper syCostAllocationMapper;
     @Autowired
+    private SyCostJsonMapper syCostJsonMapper;
+    @Autowired
     private SyCostAllocationAccidentMapper syCostAllocationAccidentMapper;
     @Autowired
     private SyCostAllocationCostpayMapper syCostAllocationCostpayMapper;
@@ -92,6 +97,24 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
             syCostAllocationShipdetailMapper.insert(entity);
         }
     }
+    //@Scheduled(cron = "0 43 16 * * ?")
+    public void saveMain(String plannum, JSONObject json) {
+        //方法1:后台使用string接受数据,数据库用json接受数据,但是这个添加字符串也会添加成功
+/*        String string = "{\"accidentUsdamount\": null,\"accidentcnyAmount\": null,\"actualShipquantity\": 25990,\"billstatus\": null,\"createBy\": null,\"createTime\": null,\"customerShortame\": \"PMK\",\"delFlag\": null,\"department\": \"业务四部\",\"excipiencostIncludestax\": 6654511.49,\"excipiencostNotincludestax\": 0,\"exportSales\": \"兰春梅\",\"fabriccostIncludestax\": null,\"fabriccostNotincludestax\": null,\"fabricshortcost\": null,\"garmentContractno\": \"AW22-PRIMARK-24583a\",\"id\": null,\"outdata\": \"2022-02-25 00:00:00\",\"pkOrg\": null,\"planNum\": \"\",\"planQuantity\": 25990,\"poStyleNum\": \"秋冬男童2B拼块网眼布polo衫\",\"preparedBy\": \"兰春梅\",\"processUnit\": \"FASHIONTEX APPAREL CO LTD\",\"processUnitList\": [1,2,3],\"remarks\": null,\"remarksTwo\": null,\"rmbExpense\": 1607.79,\"rmbExportamount\": 406950.35,\"rmbProcesscost\": 0,\"salesordersLocaltotal\": 387513.66,\"salesrrdersOriginaltotal\": 61045,\"shortseveral\": 0,\"shortvalue\": null,\"syCostAllocationAccidentList\": null,\"syCostAllocationCostpayList\": [{\"id\": null, \"syCostAllocationId\": null, \"createBy\": null, \"createTime\": null, \"updateBy\": null}],\"taxrate\": null,\"updateBy\": null,\"updateTime\": null,\"usdExpense\": 10754.34,\"usdProcesscost\": null,\"usdTotalexportprice\": 61045,\"success\": true,\"timestamp\": 1665641607070}";
+        JSONObject object = JSONObject
+                .parseObject(string);
+        String json = object.toJSONString();
+        SyCostJson cost = new SyCostJson();
+        cost.setPlanNum("测试");
+        cost.setCostInfo(json);
+        syCostJsonMapper.insert(cost);*/
+
+        String info = json.toJSONString();
+        SyCostJson cost = new SyCostJson();
+        cost.setPlanNum(plannum);
+        cost.setCostInfo(info);
+        syCostJsonMapper.insert(cost);
+    }
 
     @Override
     @Transactional