|  | @@ -1,9 +1,13 @@
 | 
											
												
													
														|  |  package org.jeecg.modules.cost.service.impl;
 |  |  package org.jeecg.modules.cost.service.impl;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +import com.alibaba.fastjson.JSON;
 | 
											
												
													
														|  |  import com.alibaba.fastjson.JSONObject;
 |  |  import com.alibaba.fastjson.JSONObject;
 | 
											
												
													
														|  | 
 |  | +import com.baomidou.mybatisplus.core.conditions.Wrapper;
 | 
											
												
													
														|  |  import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 |  |  import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 | 
											
												
													
														|  |  import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 |  |  import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 | 
											
												
													
														|  |  import com.google.gson.JsonObject;
 |  |  import com.google.gson.JsonObject;
 | 
											
												
													
														|  | 
 |  | +import org.apache.poi.ss.formula.functions.T;
 | 
											
												
													
														|  | 
 |  | +import org.jeecg.common.api.vo.Result;
 | 
											
												
													
														|  |  import org.jeecg.common.exception.JeecgBootException;
 |  |  import org.jeecg.common.exception.JeecgBootException;
 | 
											
												
													
														|  |  import org.jeecg.modules.cost.entity.*;
 |  |  import org.jeecg.modules.cost.entity.*;
 | 
											
												
													
														|  |  import org.jeecg.modules.cost.mapper.*;
 |  |  import org.jeecg.modules.cost.mapper.*;
 | 
											
										
											
												
													
														|  | @@ -22,10 +26,7 @@ import springfox.documentation.spring.web.json.Json;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  import java.io.Serializable;
 |  |  import java.io.Serializable;
 | 
											
												
													
														|  |  import java.math.BigDecimal;
 |  |  import java.math.BigDecimal;
 | 
											
												
													
														|  | -import java.util.ArrayList;
 |  | 
 | 
											
												
													
														|  | -import java.util.Collection;
 |  | 
 | 
											
												
													
														|  | -import java.util.List;
 |  | 
 | 
											
												
													
														|  | -import java.util.Map;
 |  | 
 | 
											
												
													
														|  | 
 |  | +import java.util.*;
 | 
											
												
													
														|  |  import java.util.stream.Collectors;
 |  |  import java.util.stream.Collectors;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  /**
 |  |  /**
 | 
											
										
											
												
													
														|  | @@ -67,53 +68,28 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
 | 
											
												
													
														|  |      private static ISenYuDataSourceOne senYuDataSourceOne;
 |  |      private static ISenYuDataSourceOne senYuDataSourceOne;
 | 
											
												
													
														|  |      @Autowired
 |  |      @Autowired
 | 
											
												
													
														|  |      private static ISenYuDataSourceThree senYuDataSourceThree;
 |  |      private static ISenYuDataSourceThree senYuDataSourceThree;
 | 
											
												
													
														|  | -//    @Override
 |  | 
 | 
											
												
													
														|  | -//    @Transactional
 |  | 
 | 
											
												
													
														|  | -//    public void saveMain(SyCostAllocation syCostAllocation, List<SyCostAllocationAccident> syCostAllocationAccidentList,List<SyCostAllocationCostpay> syCostAllocationCostpayList,List<SyCostAllocationFabric> syCostAllocationFabricList,List<SyCostAllocationIngredient> syCostAllocationIngredientList,List<SyCostAllocationShipdetail> syCostAllocationShipdetailList) {
 |  | 
 | 
											
												
													
														|  | -//        syCostAllocationMapper.insert(syCostAllocation);
 |  | 
 | 
											
												
													
														|  | -//        for(SyCostAllocationAccident entity:syCostAllocationAccidentList) {
 |  | 
 | 
											
												
													
														|  | -//            //外键设置
 |  | 
 | 
											
												
													
														|  | -//            entity.setSyCostAllocationId(syCostAllocation.getId());
 |  | 
 | 
											
												
													
														|  | -//            syCostAllocationAccidentMapper.insert(entity);
 |  | 
 | 
											
												
													
														|  | -//        }
 |  | 
 | 
											
												
													
														|  | -//        for(SyCostAllocationCostpay entity:syCostAllocationCostpayList) {
 |  | 
 | 
											
												
													
														|  | -//            //外键设置
 |  | 
 | 
											
												
													
														|  | -//            entity.setSyCostAllocationId(syCostAllocation.getId());
 |  | 
 | 
											
												
													
														|  | -//            syCostAllocationCostpayMapper.insert(entity);
 |  | 
 | 
											
												
													
														|  | -//        }
 |  | 
 | 
											
												
													
														|  | -//        for(SyCostAllocationFabric entity:syCostAllocationFabricList) {
 |  | 
 | 
											
												
													
														|  | -//            //外键设置
 |  | 
 | 
											
												
													
														|  | -//            entity.setSyCostAllocationId(syCostAllocation.getId());
 |  | 
 | 
											
												
													
														|  | -//            syCostAllocationFabricMapper.insert(entity);
 |  | 
 | 
											
												
													
														|  | -//        }
 |  | 
 | 
											
												
													
														|  | -//        for(SyCostAllocationIngredient entity:syCostAllocationIngredientList) {
 |  | 
 | 
											
												
													
														|  | -//            //外键设置
 |  | 
 | 
											
												
													
														|  | -//            entity.setSyCostAllocationId(syCostAllocation.getId());
 |  | 
 | 
											
												
													
														|  | -//            syCostAllocationIngredientMapper.insert(entity);
 |  | 
 | 
											
												
													
														|  | -//        }
 |  | 
 | 
											
												
													
														|  | -//        for(SyCostAllocationShipdetail entity:syCostAllocationShipdetailList) {
 |  | 
 | 
											
												
													
														|  | -//            //外键设置
 |  | 
 | 
											
												
													
														|  | -//            entity.setSyCostAllocationId(syCostAllocation.getId());
 |  | 
 | 
											
												
													
														|  | -//            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();
 |  | 
 | 
											
												
													
														|  | 
 |  | +    public Result<T> saveMain(String plannum, SyCostAllocation json) {
 | 
											
												
													
														|  | 
 |  | +        Result<T> result = new Result<>();
 | 
											
												
													
														|  | 
 |  | +        //查询保存表中有没有当前单据 如果有 更新操作:删除旧单据并重新添加新单据
 | 
											
												
													
														|  | 
 |  | +        Map<String,Object> queryMap = new HashMap();
 | 
											
												
													
														|  | 
 |  | +        queryMap.put("plan_num",plannum);
 | 
											
												
													
														|  | 
 |  | +        List<SyCostJson> list = syCostJsonMapper.selectByMap(queryMap);
 | 
											
												
													
														|  | 
 |  | +        if(list.size()>0){
 | 
											
												
													
														|  | 
 |  | +            syCostJsonMapper.deleteByMap(queryMap);
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        JSONObject costJson = JSONObject.parseObject(JSON.toJSONString(json));
 | 
											
												
													
														|  |          SyCostJson cost = new SyCostJson();
 |  |          SyCostJson cost = new SyCostJson();
 | 
											
												
													
														|  |          cost.setPlanNum(plannum);
 |  |          cost.setPlanNum(plannum);
 | 
											
												
													
														|  | -        cost.setCostInfo(info);
 |  | 
 | 
											
												
													
														|  | -        syCostJsonMapper.insert(cost);
 |  | 
 | 
											
												
													
														|  | 
 |  | +        cost.setCostInfo(costJson);
 | 
											
												
													
														|  | 
 |  | +        int i = syCostJsonMapper.insert(cost);
 | 
											
												
													
														|  | 
 |  | +        if(i==1){
 | 
											
												
													
														|  | 
 |  | +            result.setMessage("保存成功!!!");
 | 
											
												
													
														|  | 
 |  | +        }else{
 | 
											
												
													
														|  | 
 |  | +            result.setMessage("保存失败!!!");
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +        return result;
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      @Override
 |  |      @Override
 |