| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959 |
- package com.steerinfo.dil.service.impl;
- import com.alibaba.fastjson.JSONObject;
- import com.steerinfo.dil.feign.DzFeign;
- import com.steerinfo.dil.feign.WmsFeign;
- import com.steerinfo.dil.mapper.*;
- import com.steerinfo.dil.model.*;
- import com.steerinfo.dil.util.DaZongUtil;
- import com.steerinfo.dil.util.DataChange;
- import com.steerinfo.dil.util.EntityDispose;
- import com.steerinfo.framework.controller.RESTfulResult;
- import com.steerinfo.framework.mapper.IBaseMapper;
- import com.steerinfo.framework.service.impl.BaseServiceImpl;
- import org.apache.log4j.Logger;
- import org.checkerframework.checker.units.qual.A;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Required;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import org.springframework.web.bind.annotation.RequestParam;
- import java.text.DateFormat;
- import java.text.SimpleDateFormat;
- import java.util.*;
- import java.math.BigDecimal;
- import java.util.concurrent.*;
- /**
- * TmsWeightResult服务实现:
- * @author generator
- * @version 1.0-SNAPSHORT 2023-10-30 10:06
- * 类描述
- * 修订历史:
- * 日期:2023-10-30
- * 作者:generator
- * 参考:
- * 描述:TmsWeightResult服务实现
- * @see null
- * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
- */
- @Service(value = "tmsWeightResultService")
- public class TmsWeightResultServiceImpl {
- static final Logger log = Logger.getLogger(TmsWeightResultServiceImpl.class);
- @Autowired
- private TmsWeightResultMapper tmsWeightResultMapper;
- @Autowired
- OmsTransOrderServiceImpl omsTransOrderService;
- @Autowired
- private OmsTransOrderMapper omsTransOrderMapper;
- @Autowired
- private RmsOperationPointMapper rmsOperationPointMapper;
- @Autowired
- private AmsTransPlanMapper amsTransPlanMapper;
- @Autowired
- private AmsPlanChildMapper amsPlanChildMapper;
- @Autowired
- private OmsOrderChildMapper omsOrderChildMapper;
- @Autowired
- OmsOrderChildServiceImpl omsOrderChildService;
- @Autowired
- private WmsFeign wmsFeign;
- @Autowired
- EntityDispose entityDispose;
- @Autowired
- DaZongUtil daZongUtil;
- @Autowired
- DzFeign dzFeign;
- DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- @Transactional(rollbackFor = Exception.class)
- public String syncWeightResult(Map<String, Object> map) throws Exception {
- JSONObject jsonObject = new JSONObject(map);
- //查询运输订单
- List<BigDecimal> transOrderIds = omsTransOrderMapper.getTransOrderIdByNumber(map);
- if(transOrderIds.size() != 1){
- omsTransOrderService.reGenerateTransOrder(map);
- throw new Exception("运输订单异常!不能同步!");
- }
- //物资分录
- BigDecimal transOrderChildId = DataChange.dataToBigDecimal(map.get("transOrderChildId").toString());
- //查询运输订单下的计量实绩
- Map<String,Object> searchMap = new HashMap<>();
- searchMap.put("transOrderId",transOrderIds.get(0));
- searchMap.put("deleted",0);
- Map<String, Object> transOrder = omsTransOrderMapper.getTransOrder(searchMap);
- List<TmsWeightResult> list = tmsWeightResultMapper.selectByParametersSt(searchMap);
- log.debug(list.toString());
- String poundNo = map.get("poundNo").toString();
- String weightBz = DataChange.getString(map.get("weightBz"));
- String url = map.get("url") == null ? "" : map.get("url").toString();
- if("新增".equals(map.get("operationType"))){
- // 判断该运单子表是否有净重
- List<BigDecimal> netWeightIds = tmsWeightResultMapper.selectNetWeightId(transOrderChildId);
- if (netWeightIds.size() > 0 && netWeightIds.get(0) != null) {
- return "该运单子实绩已有净重";
- }
- //根据运单获取运单子表的数量
- //if(tmsWeightResultMapper.getTransOrderChildNotWeight(transOrderIds.get(0),transOrderChildId).size() < 1) {
- // //如果实绩ID是运单子表数量的两倍,则说明存在复磅的情况
- // List<BigDecimal> transOrderChildIds = tmsWeightResultMapper.getTransOrderChildId(transOrderIds.get(0));
- // if(transOrderChildIds.size() == 1 && transOrderChildIds.get(0) != null) {
- // }else{
- // throw new Exception("该分录不可用,请检查是否正确。");
- // }
- //}
- if(map.get("tarePointName")!=null && !"".equals(map.get("tarePointName").toString())){
- BigDecimal tarePlaceId = omsTransOrderMapper.getOperationPointId(map.get("tarePointName").toString(),
- "" + map.get("tarePointCode"));
- if(tarePlaceId == null){
- //没有就新增
- tarePlaceId = rmsOperationPointMapper.nextPlaceId();
- RmsOperationPoint rmsOperationPoint = new RmsOperationPoint();
- rmsOperationPoint.setOperationPointId(tarePlaceId);
- rmsOperationPoint.setOperationPointName(map.get("tarePointName").toString());
- rmsOperationPoint.setOperationPointCode(map.get("tarePointCode").toString());
- rmsOperationPoint.setOperationPointType("汽车衡");
- rmsOperationPoint.setOperationPointStatus("正常");
- rmsOperationPoint.setRemark("自动新增");
- rmsOperationPoint.setDeleted(0);
- rmsOperationPointMapper.insertSelective(rmsOperationPoint);
- }
- BigDecimal tareWeight = DataChange.dataToBigDecimal(map.get("tareWeight").toString());
- Date tareWeightTime = DataChange.dataToDate(map.get("tareWeightTime").toString());
- String actualWeight = map.get("actualWeight") == null ? "0" : map.get("actualWeight").toString();
- //皮重
- for(int i =0;i<list.size();i++){
- TmsWeightResult item = list.get(i);
- if(item.getNetWeight() == null){
- item.setTransOrderChildId(transOrderChildId);
- item.setPoundNo(poundNo);
- item.setTarePlaceId(tarePlaceId);
- item.setTareWeight(tareWeight);
- item.setTareWeightTime(tareWeightTime);
- item.setAlternateFields6(url);
- item.setAlternateFields8(weightBz);
- item.setAlternateFields11(actualWeight);
- item.setInsertUpdateRemark(list.get(list.size() - 1).getResultId().toString());
- // item.setUpdateUsername(map.get("userName").toString());
- // item.setUpdateTime(new Date());
- //计算净重
- if(item.getTarePlaceId()!=null && item.getGrossPlaceId()!= null){
- BigDecimal netWeight = DataChange.dataToBigDecimal(map.get("netWeight"));
- BigDecimal bzw = DataChange.dataToBigDecimal(map.get("bzw"));
- if(netWeight != null && netWeight.compareTo(BigDecimal.ZERO) > 0){
- item.setNetWeight(netWeight);
- }else{
- item.setNetWeight(item.getGrossWeight().subtract(item.getTareWeight()));
- }
- item.setAlternateFields13(bzw.toString());
- item.setNetWeightTime(tareWeightTime);
- if("是".equals(transOrder.get("isMultiple"))){
- try {
- //查询运单
- OmsTransOrder omsTransOrder = omsTransOrderMapper.selectByPrimaryKey(transOrderIds.get(0));
- List<OmsOrderChild> omsOrderChildList = omsOrderChildMapper.selectByParameters(searchMap);
- Map<String, Object> objectObjectHashMap = new HashMap<>();
- BigDecimal nineTransOrderId = null;
- if("销售".equals(omsTransOrder.getBusinessScene())) {
- //查询有没有采购状态为9的运单
- objectObjectHashMap.put("scene","采购");
- objectObjectHashMap.put("capacityId",omsTransOrder.getCapacityId());
- objectObjectHashMap.put("driverId",omsTransOrder.getDriverId());
- objectObjectHashMap.put("materialId",omsOrderChildList.get(0).getMaterialId());
- nineTransOrderId = omsTransOrderMapper.getNineTransOrder(objectObjectHashMap);
- }else{
- //查询有没有销售状态为9的运单
- objectObjectHashMap.put("scene","销售");
- objectObjectHashMap.put("capacityId",omsTransOrder.getCapacityId());
- objectObjectHashMap.put("driverId",omsTransOrder.getDriverId());
- objectObjectHashMap.put("materialId",omsOrderChildList.get(0).getMaterialId());
- nineTransOrderId = omsTransOrderMapper.getNineTransOrder(objectObjectHashMap);
- }
- if(nineTransOrderId != null) {
- omsTransOrderMapper.updateNineOrder(nineTransOrderId);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- //判断是否一车多趟
- try{
- omsTransOrderService.reDispatchOrder(transOrderIds.get(0));
- }catch (Exception e){
- e.printStackTrace();
- log.error("一车多趟重复派车失败:"+e.getMessage());
- }
- }
- //迁移库存
- transGridMaterial(transOrderChildId,item.getNetWeight(),""+map.get("userId"),""+map.get("userName"),item.getNetWeightTime());
- }
- if("9".equals(weightBz)){
- //冲减,净重为0
- item.setNetWeight(BigDecimal.ZERO);
- }
- tmsWeightResultMapper.updateByPrimaryKeySelective(item);
- if(item.getNetWeightTime() != null) {
- omsTransOrderService.updateOrderStatus(transOrderIds.get(0),item.getTareSegmentSqe(),"出厂",item.getUpdateUsername(),item.getPoundNo());
- }else{
- omsTransOrderService.updateOrderStatus(transOrderIds.get(0),item.getTareSegmentSqe(),"计皮",item.getUpdateUsername(),item.getPoundNo());
- }
- omsOrderChildService.updateOrderChildInfo(transOrderIds.get(0),item.getTransOrderChildId(),item.getTareWeightTime(),"计皮");
- omsOrderChildService.updateOrderChildInfo(transOrderIds.get(0),item.getTransOrderChildId(),item.getNetWeightTime(),"净重");
- OmsOrderChild omsOrderChild = omsOrderChildMapper.selectByPrimaryKey(transOrderChildId);
- omsOrderChild.setNetWeight(item.getNetWeight());
- omsOrderChild.setActualWeight(DataChange.dataToBigDecimal(item.getAlternateFields11()).compareTo(BigDecimal.ZERO) == 0 ? item.getNetWeight() : DataChange.dataToBigDecimal(item.getAlternateFields11()));
- omsOrderChildMapper.updateByPrimaryKeySelective(omsOrderChild);
- map.put("resultId",item.getResultId());//返回给日志记录
- threadPool.execute(()->{
- try {
- Thread.sleep(500);
- AmsPlanChild amsPlanChild = amsPlanChildMapper.selectByPrimaryKey(omsOrderChild.getPlanChildId());
- omsTransOrderService.sumWeight(amsPlanChild.getRequirementChildId());
- omsTransOrderService.sumWeightPlan(amsPlanChild.getPlanChildId());
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- });
- return "同步成功!";
- }
- }
- }else if(map.get("grossPointName")!=null && !"".equals(map.get("grossPointName").toString())){
- BigDecimal grossPlaceId = omsTransOrderMapper.getOperationPointId(map.get("grossPointName").toString(),
- "" + map.get("grossPointCode"));
- if(grossPlaceId == null){
- //没有就新增
- grossPlaceId = rmsOperationPointMapper.nextPlaceId();
- RmsOperationPoint rmsOperationPoint = new RmsOperationPoint();
- rmsOperationPoint.setOperationPointId(grossPlaceId);
- rmsOperationPoint.setOperationPointName(map.get("grossPointName").toString());
- rmsOperationPoint.setOperationPointCode(map.get("grossPointCode").toString());
- rmsOperationPoint.setOperationPointType("汽车衡");
- rmsOperationPoint.setOperationPointStatus("正常");
- rmsOperationPoint.setRemark("自动新增");
- rmsOperationPoint.setDeleted(0);
- rmsOperationPointMapper.insertSelective(rmsOperationPoint);
- }
- BigDecimal grossWeight = DataChange.dataToBigDecimal(map.get("grossWeight").toString());
- Date grossWeightTime = DataChange.dataToDate(map.get("grossWeightTime").toString());
- String actualWeight = map.get("actualWeight") == null ? "0" : map.get("actualWeight").toString();
- //毛重
- for(int i =0;i<list.size();i++){
- TmsWeightResult item = list.get(i);
- if(item.getNetWeight() == null){
- item.setTransOrderChildId(transOrderChildId);
- item.setPoundNo(poundNo);
- item.setGrossPlaceId(grossPlaceId);
- item.setGrossWeight(grossWeight);
- item.setGrossWeightTime(grossWeightTime);
- item.setResultImage(url);
- item.setAlternateFields8(weightBz);
- item.setAlternateFields11(actualWeight);
- item.setInsertUpdateRemark(list.get(list.size() - 1).getResultId().toString());
- // item.setUpdateUsername(map.get("userName").toString());
- // item.setUpdateTime(new Date());
- //计算净重
- if(item.getTarePlaceId()!=null && item.getGrossPlaceId()!= null){
- BigDecimal netWeight = DataChange.dataToBigDecimal(map.get("netWeight"));
- BigDecimal bzw = DataChange.dataToBigDecimal(map.get("bzw"));
- if(netWeight != null && netWeight.compareTo(BigDecimal.ZERO) > 0){
- item.setNetWeight(netWeight);
- }else{
- item.setNetWeight(item.getGrossWeight().subtract(item.getTareWeight()));
- }
- item.setAlternateFields13(bzw.toString());
- item.setNetWeightTime(grossWeightTime);
- //迁移库存
- transGridMaterial(transOrderChildId,item.getNetWeight(),""+map.get("userId"),""+map.get("userName"),item.getNetWeightTime());
- if("是".equals(transOrder.get("isMultiple"))){
- try {
- //查询运单
- OmsTransOrder omsTransOrder = omsTransOrderMapper.selectByPrimaryKey(transOrderIds.get(0));
- List<OmsOrderChild> omsOrderChildList = omsOrderChildMapper.selectByParameters(searchMap);
- Map<String, Object> objectObjectHashMap = new HashMap<>();
- BigDecimal nineTransOrderId = null;
- if("销售".equals(omsTransOrder.getBusinessScene())) {
- //查询有没有采购状态为9的运单
- objectObjectHashMap.put("scene","采购");
- objectObjectHashMap.put("capacityId",omsTransOrder.getCapacityId());
- objectObjectHashMap.put("driverId",omsTransOrder.getDriverId());
- objectObjectHashMap.put("materialId",omsOrderChildList.get(0).getMaterialId());
- nineTransOrderId = omsTransOrderMapper.getNineTransOrder(objectObjectHashMap);
- }else{
- //查询有没有销售状态为9的运单
- objectObjectHashMap.put("scene","销售");
- objectObjectHashMap.put("capacityId",omsTransOrder.getCapacityId());
- objectObjectHashMap.put("driverId",omsTransOrder.getDriverId());
- objectObjectHashMap.put("materialId",omsOrderChildList.get(0).getMaterialId());
- nineTransOrderId = omsTransOrderMapper.getNineTransOrder(objectObjectHashMap);
- }
- if(nineTransOrderId != null) {
- omsTransOrderMapper.updateNineOrder(nineTransOrderId);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- //判断是否一车多趟
- try{
- omsTransOrderService.reDispatchOrder(transOrderIds.get(0));
- }catch (Exception e){
- e.printStackTrace();
- log.error("一车多趟重复派车失败:"+e.getMessage());
- }
- }
- //判断是否还有下一拼,有则提前设置皮重信息
- // if(i != list.size()-1){
- // list.get(i+1).setTarePlaceId(grossPlaceId);
- // list.get(i+1).setTareWeight(grossWeight);
- // list.get(i+1).setTareWeightTime(grossWeightTime);
- //// list.get(i+1).setUpdateUsername(map.get("userName").toString());
- //// list.get(i+1).setUpdateTime(new Date());
- // tmsWeightResultMapper.updateByPrimaryKeySelective(list.get(i+1));
- // }
- }
- if("9".equals(weightBz)){
- //冲减,净重为0
- item.setNetWeight(BigDecimal.ZERO);
- }
- tmsWeightResultMapper.updateByPrimaryKeySelective(item);
- if(item.getNetWeightTime() != null) {
- omsTransOrderService.updateOrderStatus(transOrderIds.get(0),item.getTareSegmentSqe(),"出厂",item.getUpdateUsername(),item.getPoundNo());
- }else{
- omsTransOrderService.updateOrderStatus(transOrderIds.get(0),item.getTareSegmentSqe(),"计毛",item.getUpdateUsername(),item.getPoundNo());
- }
- omsOrderChildService.updateOrderChildInfo(transOrderIds.get(0),item.getTransOrderChildId(),item.getGrossWeightTime(),"计毛");
- omsOrderChildService.updateOrderChildInfo(transOrderIds.get(0),item.getTransOrderChildId(),item.getNetWeightTime(),"净重");
- OmsOrderChild omsOrderChild = omsOrderChildMapper.selectByPrimaryKey(transOrderChildId);
- omsOrderChild.setNetWeight(item.getNetWeight());
- omsOrderChild.setActualWeight(DataChange.dataToBigDecimal(item.getAlternateFields11()).compareTo(BigDecimal.ZERO) == 0 ? item.getNetWeight() : DataChange.dataToBigDecimal(item.getAlternateFields11()));
- omsOrderChildMapper.updateByPrimaryKeySelective(omsOrderChild);
- map.put("resultId",item.getResultId());//返回给日志记录
- threadPool.execute(()->{
- try {
- Thread.sleep(500);
- AmsPlanChild amsPlanChild = amsPlanChildMapper.selectByPrimaryKey(omsOrderChild.getPlanChildId());
- omsTransOrderService.sumWeight(amsPlanChild.getRequirementChildId());
- omsTransOrderService.sumWeightPlan(amsPlanChild.getPlanChildId());
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- });
- return "同步成功!";
- }
- }
- }else {
- throw new Exception("tarePointName或grossPointName不能为空!");
- }
- }else if ("修改".equals(map.get("operationType"))){
- if(map.get("tarePointName")!=null && !"".equals(map.get("tarePointName").toString())){
- BigDecimal tarePlaceId = omsTransOrderMapper.getOperationPointId(map.get("tarePointName").toString(),
- "" + map.get("tarePointCode"));
- if(tarePlaceId == null){
- //没有就新增
- tarePlaceId = rmsOperationPointMapper.nextPlaceId();
- RmsOperationPoint rmsOperationPoint = new RmsOperationPoint();
- rmsOperationPoint.setOperationPointId(tarePlaceId);
- rmsOperationPoint.setOperationPointName(map.get("tarePointName").toString());
- rmsOperationPoint.setOperationPointCode(map.get("tarePointCode").toString());
- rmsOperationPoint.setOperationPointType("汽车衡");
- rmsOperationPoint.setOperationPointStatus("正常");
- rmsOperationPoint.setRemark("自动新增");
- rmsOperationPoint.setDeleted(0);
- rmsOperationPointMapper.insertSelective(rmsOperationPoint);
- }
- BigDecimal tareWeight = DataChange.dataToBigDecimal(map.get("tareWeight").toString());
- Date tareWeightTime = DataChange.dataToDate(map.get("tareWeightTime").toString());
- String actualWeight = map.get("actualWeight") == null ? "0" : map.get("actualWeight").toString();
- //皮重
- for(int i =0;i<list.size();i++){
- TmsWeightResult item = list.get(i);
- if(transOrderChildId.equals(item.getTransOrderChildId())){
- item.setPoundNo(poundNo);
- item.setTarePlaceId(tarePlaceId);
- item.setTareWeight(tareWeight);
- item.setTareWeightTime(tareWeightTime);
- item.setAlternateFields6(url);
- item.setAlternateFields8(weightBz);
- item.setAlternateFields11(actualWeight);
- //item.setUpdateUsername(map.get("userName").toString());
- item.setUpdateTime(new Date());
- //计算净重
- if(item.getTarePlaceId()!=null && item.getGrossPlaceId()!= null){
- BigDecimal netWeight = DataChange.dataToBigDecimal(map.get("netWeight"));
- BigDecimal bzw = DataChange.dataToBigDecimal(map.get("bzw"));
- if(netWeight != null && netWeight.compareTo(BigDecimal.ZERO) > 0){
- item.setNetWeight(netWeight);
- }else{
- item.setNetWeight(item.getGrossWeight().subtract(item.getTareWeight()));
- }
- item.setAlternateFields13(bzw.toString());
- item.setNetWeightTime(tareWeightTime);
- //迁移库存
- transGridMaterial(transOrderChildId,item.getNetWeight(),""+map.get("userId"),""+map.get("userName"),item.getNetWeightTime());
- }
- if("9".equals(weightBz)){
- //冲减,净重为0
- item.setNetWeight(BigDecimal.ZERO);
- }
- tmsWeightResultMapper.updateByPrimaryKeySelective(item);
- OmsOrderChild omsOrderChild = omsOrderChildMapper.selectByPrimaryKey(transOrderChildId);
- omsOrderChild.setNetWeight(item.getNetWeight());
- omsOrderChild.setActualWeight(DataChange.dataToBigDecimal(item.getAlternateFields11()).compareTo(BigDecimal.ZERO) == 0 ? item.getNetWeight() : DataChange.dataToBigDecimal(item.getAlternateFields11()));
- omsOrderChildMapper.updateByPrimaryKeySelective(omsOrderChild);
- map.put("resultId",item.getResultId());//返回给日志记录
- try{
- if(item.getNetWeightTime() != null) {
- omsTransOrderService.updateOrderStatus(transOrderIds.get(0),item.getTareSegmentSqe(),"出厂",item.getUpdateUsername(),item.getPoundNo());
- }else{
- omsTransOrderService.updateOrderStatus(transOrderIds.get(0),item.getTareSegmentSqe(),"计皮",item.getUpdateUsername(),item.getPoundNo());
- }
- omsOrderChildService.updateOrderChildInfo(transOrderIds.get(0),item.getTransOrderChildId(),item.getTareWeightTime(),"计皮");
- omsOrderChildService.updateOrderChildInfo(transOrderIds.get(0),item.getTransOrderChildId(),item.getNetWeightTime(),"净重");
- }catch (Exception e){}
- threadPool.execute(()->{
- try {
- Thread.sleep(500);
- AmsPlanChild amsPlanChild = amsPlanChildMapper.selectByPrimaryKey(omsOrderChild.getPlanChildId());
- omsTransOrderService.sumWeight(amsPlanChild.getRequirementChildId());
- omsTransOrderService.sumWeightPlan(amsPlanChild.getPlanChildId());
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- });
- return "同步成功!";
- }
- }
- }else if(map.get("grossPointName")!=null && !"".equals(map.get("grossPointName").toString())){
- BigDecimal grossPlaceId = omsTransOrderMapper.getOperationPointId(map.get("grossPointName").toString(),
- "" + map.get("grossPointCode"));
- if(grossPlaceId == null){
- //没有就新增
- grossPlaceId = rmsOperationPointMapper.nextPlaceId();
- RmsOperationPoint rmsOperationPoint = new RmsOperationPoint();
- rmsOperationPoint.setOperationPointId(grossPlaceId);
- rmsOperationPoint.setOperationPointName(map.get("grossPointName").toString());
- rmsOperationPoint.setOperationPointCode(map.get("grossPointCode").toString());
- rmsOperationPoint.setOperationPointType("汽车衡");
- rmsOperationPoint.setOperationPointStatus("正常");
- rmsOperationPoint.setRemark("自动新增");
- rmsOperationPoint.setDeleted(0);
- rmsOperationPointMapper.insertSelective(rmsOperationPoint);
- }
- BigDecimal grossWeight = DataChange.dataToBigDecimal(map.get("grossWeight").toString());
- Date grossWeightTime = DataChange.dataToDate(map.get("grossWeightTime").toString());
- String actualWeight = map.get("actualWeight") == null ? "0" : map.get("actualWeight").toString();
- //毛重
- for(int i =0;i<list.size();i++){
- TmsWeightResult item = list.get(i);
- if(transOrderChildId.equals(item.getTransOrderChildId())){
- item.setPoundNo(poundNo);
- item.setGrossPlaceId(grossPlaceId);
- item.setGrossWeight(grossWeight);
- item.setGrossWeightTime(grossWeightTime);
- item.setResultImage(url);
- item.setAlternateFields8(weightBz);
- item.setAlternateFields11(actualWeight);
- //item.setUpdateUsername(map.get("userName").toString());
- item.setUpdateTime(new Date());
- //计算净重
- if(item.getTarePlaceId()!=null && item.getGrossPlaceId()!= null){
- BigDecimal netWeight = DataChange.dataToBigDecimal(map.get("netWeight"));
- BigDecimal bzw = DataChange.dataToBigDecimal(map.get("bzw"));
- if(netWeight != null && netWeight.compareTo(BigDecimal.ZERO) > 0){
- item.setNetWeight(netWeight);
- }else{
- item.setNetWeight(item.getGrossWeight().subtract(item.getTareWeight()));
- }
- item.setAlternateFields13(bzw.toString());
- item.setNetWeightTime(grossWeightTime);
- //迁移库存
- transGridMaterial(transOrderChildId,item.getNetWeight(),""+map.get("userId"),""+map.get("userName"),item.getNetWeightTime());
- ////判断是否还有下一拼,有则提前设置皮重信息
- //if(i != list.size()-1){
- // list.get(i+1).setTarePlaceId(grossPlaceId);
- // list.get(i+1).setTareWeight(grossWeight);
- // list.get(i+1).setTareWeightTime(grossWeightTime);
- // list.get(i+1).setUpdateUsername(map.get("userId").toString());
- // list.get(i+1).setUpdateTime(new Date());
- // tmsWeightResultMapper.updateByPrimaryKeySelective(list.get(i+1));
- //}
- }
- if("9".equals(weightBz)){
- //冲减,净重为0
- item.setNetWeight(BigDecimal.ZERO);
- }
- tmsWeightResultMapper.updateByPrimaryKeySelective(item);
- OmsOrderChild omsOrderChild = omsOrderChildMapper.selectByPrimaryKey(transOrderChildId);
- omsOrderChild.setNetWeight(item.getNetWeight());
- omsOrderChild.setActualWeight(DataChange.dataToBigDecimal(item.getAlternateFields11()).compareTo(BigDecimal.ZERO) == 0 ? item.getNetWeight() : DataChange.dataToBigDecimal(item.getAlternateFields11()));
- omsOrderChildMapper.updateByPrimaryKeySelective(omsOrderChild);
- map.put("resultId",item.getResultId());//返回给日志记录
- try{
- if(item.getNetWeightTime() != null) {
- omsTransOrderService.updateOrderStatus(transOrderIds.get(0),item.getTareSegmentSqe(),"出厂",item.getUpdateUsername(),item.getPoundNo());
- }else{
- omsTransOrderService.updateOrderStatus(transOrderIds.get(0),item.getTareSegmentSqe(),"计毛",item.getUpdateUsername(),item.getPoundNo());
- }
- omsOrderChildService.updateOrderChildInfo(transOrderIds.get(0),item.getTransOrderChildId(),item.getGrossWeightTime(),"计毛");
- omsOrderChildService.updateOrderChildInfo(transOrderIds.get(0),item.getTransOrderChildId(),item.getNetWeightTime(),"净重");
- }catch (Exception e){}
- threadPool.execute(()->{
- try {
- Thread.sleep(500);
- AmsPlanChild amsPlanChild = amsPlanChildMapper.selectByPrimaryKey(omsOrderChild.getPlanChildId());
- omsTransOrderService.sumWeight(amsPlanChild.getRequirementChildId());
- omsTransOrderService.sumWeightPlan(amsPlanChild.getPlanChildId());
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- });
- return "同步成功!";
- }
- }
- }else{
- throw new Exception("tarePointName或grossPointName不能为空!");
- }
- }else{
- throw new Exception("未知的操作类型:"+map.get("operationType"));
- }
- return "同步成功!实绩已存在!";
- }
- public List<Map<String, Object>> getWeightResultList(Map<String, Object> map) {
- return tmsWeightResultMapper.getTmsWeightResultList(map);
- }
- public List<Map<String, Object>> purchaseTrainWeightList(Map<String, Object> map) {
- return tmsWeightResultMapper.purchaseTrainWeightList(map);
- }
- public String purchaseTrainWeight(Map<String, Object> map) throws Exception {
- List<Map<String, Object>> orderList = (ArrayList) map.get("orderList");
- if(orderList.size() < 1){
- throw new Exception("没有数据!无法计量!");
- }
- DateFormat format = new SimpleDateFormat("yyyyMMdd");
- DateFormat format2 = new SimpleDateFormat("yyyy-MM-dd");
- String userId ="" + map.get("userId");
- String userName ="" + map.get("userName");
- List<TmsWeightResult> insertList = new ArrayList<>();//新增数组
- List<TmsWeightResult> updateList = new ArrayList<>();//更新数组
- List<Map<String,Object>> paramList = new ArrayList<>();//推送大宗数据
- //遍历,有实绩的修改,无实绩的新增
- for(Map<String, Object> item :orderList){
- BigDecimal resultId = DataChange.dataToBigDecimal(item.get("resultId"));
- BigDecimal transOrderId = DataChange.dataToBigDecimal(item.get("transOrderId"));
- BigDecimal transOrderChildId = DataChange.dataToBigDecimal(item.get("transOrderChildId"));
- BigDecimal netWeight = DataChange.dataToBigDecimal(item.get("netWeight"));
- BigDecimal tareWeight = DataChange.dataToBigDecimal(item.get("tareWeight"));
- BigDecimal grossWeight = DataChange.dataToBigDecimal(item.get("grossWeight"));
- Date weightTime = format.parse(item.get("weightTime").toString());
- String requireNumber = item.get("requireNumber").toString();
- String poundNo = item.get("poundNo").toString();
- String trainSeq = item.get("trainSeq").toString();
- String capacityId = item.get("capacityId").toString();
- Date loadTime = format.parse(item.get("loadTime").toString());
- String sendStation = item.get("sendStation").toString();
- String endStation = item.get("endStation").toString();
- String tdls = item.get("tdls").toString();
- String tdfl = item.get("tdfl").toString();
- if(resultId.compareTo(BigDecimal.ZERO) == 0){
- //新增
- TmsWeightResult tmsWeightResult = new TmsWeightResult();
- tmsWeightResult.setResultId(tmsWeightResultMapper.nextId());
- tmsWeightResult.setTransOrderId(transOrderId);
- tmsWeightResult.setTransOrderChildId(transOrderChildId);
- tmsWeightResult.setPoundNo(poundNo);
- tmsWeightResult.setNetWeight(netWeight);
- tmsWeightResult.setTareWeight(tareWeight);
- tmsWeightResult.setGrossWeight(grossWeight);
- tmsWeightResult.setNetWeightTime(weightTime);
- tmsWeightResult.setDeleted(BigDecimal.ZERO);
- tmsWeightResult.setInsertTime(new Date());
- tmsWeightResult.setInsertUsername(userId);
- insertList.add(tmsWeightResult);
- //大宗新增
- Map<String,Object> params =new HashMap<>();
- params.put("ywlx",0);//0 -收货 1-发货
- params.put("czbz",1);//1-新增 2-修改 3-删除
- params.put("djbh",tmsWeightResult.getPoundNo());
- params.put("hccc",trainSeq);
- params.put("clbh",capacityId);
- params.put("cllx","");
- params.put("gbsj",format2.format(weightTime));
- params.put("sfsj",format2.format(loadTime));
- params.put("fhdd",sendStation);
- params.put("shdd",endStation);
- params.put("mz",tmsWeightResult.getGrossWeight());
- params.put("pz",tmsWeightResult.getTareWeight());
- params.put("jz",tmsWeightResult.getNetWeight());
- params.put("tzdh",requireNumber);
- params.put("tdls",tdls);
- params.put("tdfl",tdfl);
- params.put("username",userName);
- params.put("note","");
- paramList.add(params);
- }else{
- //修改
- TmsWeightResult tmsWeightResult = tmsWeightResultMapper.selectByPrimaryKey(resultId);
- tmsWeightResult.setNetWeight(netWeight);
- tmsWeightResult.setTareWeight(tareWeight);
- tmsWeightResult.setGrossWeight(grossWeight);
- tmsWeightResult.setUpdateTime(new Date());
- tmsWeightResult.setUpdateUsername(userId);
- updateList.add(tmsWeightResult);
- //大宗修改
- Map<String,Object> params =new HashMap<>();
- params.put("ywlx",0);//0 -收货 1-发货
- params.put("czbz",2);//1-新增 2-修改 3-删除
- params.put("djbh",tmsWeightResult.getPoundNo());
- params.put("hccc",trainSeq);
- params.put("clbh",capacityId);
- params.put("cllx","");
- params.put("gbsj",format2.format(weightTime));
- params.put("sfsj",format2.format(loadTime));
- params.put("fhdd",sendStation);
- params.put("shdd",endStation);
- params.put("mz",tmsWeightResult.getGrossWeight());
- params.put("pz",tmsWeightResult.getTareWeight());
- params.put("jz",tmsWeightResult.getNetWeight());
- params.put("tzdh",requireNumber);
- params.put("tdls",tdls);
- params.put("tdfl",tdfl);
- params.put("username",userName);
- params.put("note","");
- paramList.add(params);
- }
- }
- //数据更新之前先修改入库(自动更新库存)
- // Map<String,Object> inboundMap = new HashMap<>();
- // inboundMap.put("transPlanId",map.get("transPlanId"));
- // inboundMap.put("inboundNumber",map.get("weight"));
- // inboundMap.put("gridName","原料在途库");
- // inboundMap.put("materialId",map.get("materialId"));
- // inboundMap.put("userId",userId);
- // inboundMap.put("userName",userName);
- // RESTfulResult inbountResult = wmsFeign.updateInbound(inboundMap);
- // if(!"succeed".equals(inbountResult.getStatus())){
- // throw new Exception(inbountResult.getMessage());
- // }
- if(insertList.size() > 0){
- tmsWeightResultMapper.batchInsert(insertList);
- }
- if(updateList.size() > 0){
- tmsWeightResultMapper.batchUpdate(updateList);
- }
- //推送大宗
- // Map<String,Object>[] paramArray = paramList.toArray(new Map[paramList.size()]);
- // daZongUtil.execute("30010000060", paramArray);
- return "上传成功!";
- }
- public String checkWeightResult(Map<String, Object> map) throws Exception {
- //初始化
- List<Map<String,Object>> list = (List) map.get("list");
- List<TmsWeightResult> tmsWeightResults = new ArrayList<>();
- String checkStr = map.get("checkStr").toString();
- List<String> poundNoList = new ArrayList<>();//磅单数组
- //校验并赋值
- for(Map<String ,Object> item : list){
- TmsWeightResult tmsWeightResult = tmsWeightResultMapper.selectByPrimaryKey(DataChange.dataToBigDecimal(item.get("resultId")));
- if(checkStr.contains("已审核")){
- tmsWeightResult.setAlternateFields3("已审核");
- }else{
- tmsWeightResult.setAlternateFields3("已弃审");
- }
- tmsWeightResult.setAlternateFields4(map.get("userName").toString());
- tmsWeightResult.setAlternateFields5(dateFormat.format(new Date()));
- tmsWeightResults.add(tmsWeightResult);
- poundNoList.add(tmsWeightResult.getPoundNo());
- }
- map.put("poundNoList",poundNoList);
- //批量更新
- if(tmsWeightResults.size() > 0){
- tmsWeightResultMapper.batchUpdate(tmsWeightResults);
- //推送大宗
- if(checkStr.contains("已审核")){
- dzFeign.updWeightStatus(map);
- }
- return "操作成功:"+checkStr;
- }else{
- return "没有能审批的数据!";
- }
- }
- //根据运单id返回过磅重量到通知单
- public void netWeightToRequirement(BigDecimal transOrderId, BigDecimal netWeight) {
- //根据运单id获取通知单
- //omsTransOrderMapper.select
- }
- //补单,生成计量实绩与子表实绩
- @Transactional(rollbackFor = Exception.class)
- public List<Map<String,Object>> addOrderWeight(Map<String,Object> map) {
- List<Map<String,Object>> mapList = new ArrayList<>();
- if(!map.containsKey("gross")) {
- mapList.add(map);
- return mapList;
- }
- List<Map<String,Object>> grossList = (List<Map<String, Object>>) map.get("gross");
- if(grossList.size() == 0) {
- mapList.add(map);
- return mapList;
- }
- //根据运单子表Id,查询计划子表ID,需求子表ID
- BigDecimal transOrderChildId = DataChange.dataToBigDecimal(map.get("transOrderChildId"));
- Map<String,Object> mesInfo = tmsWeightResultMapper.selectMesInfo(transOrderChildId);
- BigDecimal transPlanId = DataChange.dataToBigDecimal(mesInfo.get("transPlanId"));
- BigDecimal planChildId = DataChange.dataToBigDecimal(mesInfo.get("planChildId"));
- BigDecimal requirementChildId = DataChange.dataToBigDecimal(mesInfo.get("requirementChildId"));
- Map<String, Object> firstWeightMap = new HashMap<>();
- Map<String, Object> secondTareWeightMap = new HashMap<>();
- Map<String, Object> secondGrossWeightMap = new HashMap<>();
- for (Map<String,Object> stringObjectMap : grossList) {
- Map<String, Object> weightMap = new HashMap<>();
- String tdls = stringObjectMap.get("tdls").toString();
- String tdfl = stringObjectMap.get("tdfl").toString();
- // 防止该通知单数据来自大宗,去查一遍
- BigDecimal stTdfl = tmsWeightResultMapper.selectStTdfl(tdls,tdfl);
- BigDecimal mz = DataChange.dataToBigDecimal(stringObjectMap.get("mz"));
- BigDecimal jz = DataChange.dataToBigDecimal(stringObjectMap.get("netWeight"));
- BigDecimal bzw = DataChange.dataToBigDecimal(stringObjectMap.get("bzw"));
- if (requirementChildId.compareTo(stTdfl) == 0) {
- weightMap.putAll(map);
- weightMap.remove("gross");
- weightMap.put("grossWeight",mz);
- weightMap.put("netWeight",jz);
- weightMap.put("bzw",bzw);
- firstWeightMap.putAll(weightMap);
- //mapList.add(weightMap);
- continue;
- }
- //根据sttdfl去寻找计划子表与计划
- BigDecimal newPlanChildId = amsPlanChildMapper.selectPlanChildId(stTdfl);
- AmsPlanChild amsPlanChild = new AmsPlanChild();
- if (newPlanChildId == null) {
- //需要补录计划表、计划子表、运单子表
- AmsTransPlan amsTransPlan = amsTransPlanMapper.selectByPrimaryKey(transPlanId);
- amsTransPlan.setTransPlanId(amsTransPlanMapper.nextId());
- amsTransPlan.setInsertTime(new Date());
- amsTransPlanMapper.insertSelective(amsTransPlan);
- amsPlanChild = amsPlanChildMapper.selectByPrimaryKey(planChildId);
- amsPlanChild.setPlanChildId(amsPlanChildMapper.nextId());
- amsPlanChild.setTransPlanId(amsTransPlan.getTransPlanId());
- amsPlanChild.setRequirementChildId(stTdfl);
- amsPlanChild.setInsertTime(new Date());
- // 查询通知单数量
- BigDecimal stTdflMaterialWeight = amsPlanChildMapper.selectMaterialWeight(stTdfl);
- amsPlanChild.setMaterialNumber(stTdflMaterialWeight);
- //修改通知单状态
- amsPlanChildMapper.updateRequirementStatus(stTdfl);
- amsPlanChildMapper.insertSelective(amsPlanChild);
- }else {
- amsPlanChild = amsPlanChildMapper.selectByPrimaryKey(newPlanChildId);
- }
- //运单子表
- OmsOrderChild omsOrderChild = omsOrderChildMapper.selectByPrimaryKey(transOrderChildId);
- // 根据运单id去找下面有没有补单的
- BigDecimal newOrderChildId = omsOrderChildMapper.selectNewOrderChildId(omsOrderChild.getTransOrderId());
- if (newOrderChildId == null) {
- omsOrderChild.setOrderChildId(omsOrderChildMapper.nextId());
- omsOrderChild.setPlanChildId(amsPlanChild.getPlanChildId());
- omsOrderChild.setMaterialNumber(new BigDecimal(0));
- omsOrderChild.setInsertUpdateRemark("补单自动生成运单子表");
- omsOrderChild.setAlternateFields7("0");
- entityDispose.disposeOrderChild(omsOrderChild);
- omsOrderChildMapper.insertSelective(omsOrderChild);
- }else{
- omsOrderChild.setOrderChildId(newOrderChildId);
- omsOrderChild.setPlanChildId(amsPlanChild.getPlanChildId());
- omsOrderChild.setMaterialNumber(new BigDecimal(0));
- omsOrderChild.setInsertUpdateRemark("补单自动生成运单子表");
- omsOrderChild.setAlternateFields7("0");
- omsOrderChildMapper.updateByPrimaryKeySelective(omsOrderChild);
- }
- //生成计量实绩皮重报文
- Map<String,Object> tareWeightMap = tmsWeightResultMapper.selectTareWeightMap(omsOrderChild.getTransOrderId());
- if (tareWeightMap != null) {
- tareWeightMap.put("operationType",map.get("operationType"));
- tareWeightMap.put("transOrderNumber",map.get("transOrderNumber"));
- tareWeightMap.put("transOrderChildId",omsOrderChild.getOrderChildId());
- secondTareWeightMap.putAll(tareWeightMap);
- //mapList.add(tareWeightMap);
- }
- //生成计量实绩毛重报文
- weightMap.putAll(map);
- weightMap.remove("gross");
- weightMap.put("grossWeight",mz);
- weightMap.put("netWeight",jz);
- weightMap.put("bzw",bzw);
- weightMap.put("transOrderChildId",omsOrderChild.getOrderChildId());
- secondGrossWeightMap.putAll(weightMap);
- //mapList.add(weightMap);
- }
- mapList.add(firstWeightMap);
- if(secondTareWeightMap.get("transOrderChildId") != null) {
- mapList.add(secondTareWeightMap);
- }
- if(secondGrossWeightMap.get("transOrderChildId") != null) {
- mapList.add(secondGrossWeightMap);
- }
- return mapList;
- }
- /**
- * 迁移库存
- * @param transOrderChildId
- * @param netWeight
- * @param userId
- * @param userName
- */
- public void transGridMaterial(BigDecimal transOrderChildId,BigDecimal netWeight,String userId,String userName,@RequestParam(required = false) Date netWeightTime) {
- return;
- // try{
- // Map<String,Object> boundResult = tmsWeightResultMapper.getBoundResult(transOrderChildId);
- // String businessScene = boundResult.get("businessScene").toString();
- // BigDecimal loadPointId = DataChange.dataToBigDecimal(boundResult.get("loadPointId"));
- // BigDecimal unloadPointId = DataChange.dataToBigDecimal(boundResult.get("unloadPointId"));
- // switch (businessScene){
- // case "采购":
- // //汽车入厂,不入库厂内,出库在途;
- // //boundResult.put("gridId",boundResult.get("unloadPointId"));
- // //boundResult.put("inboundNumber",netWeight);
- // //boundResult.put("inboundType","采购汽运计量入库");
- // //boundResult.put("inboundTime",netWeightTime);
- // //boundResult.put("model","汽运");
- // //boundResult.put("userId",userId);
- // //boundResult.put("userName",userName);
- // //RESTfulResult inbountResult = wmsFeign.inbound(boundResult);
- // //if(!"succeed".equals(inbountResult.getStatus())){
- // // throw new Exception(inbountResult.getMessage());
- // //}
- // boundResult.put("gridId",boundResult.get("loadPointId"));
- // boundResult.put("outboundNumber",netWeight);
- // boundResult.put("outboundType","采购汽运在途出库");
- // boundResult.put("userId",userId);
- // boundResult.put("cgjh","原料在途库");
- // boundResult.put("model","汽运");
- // boundResult.put("userName",userName);
- // boundResult.put("outboundTime",netWeightTime);
- // RESTfulResult outbountResult = wmsFeign.outbound(boundResult);
- // if(!"succeed".equals(outbountResult.getStatus())){
- // throw new Exception(outbountResult.getMessage());
- // }
- // break;
- // case "销售":
- // //boundResult.put("gridId",boundResult.get("loadPointId"));
- // //boundResult.put("outboundNumber",netWeight);
- // //boundResult.put("outboundType","销售汽运计量出库");
- // //boundResult.put("userId",userId);
- // //boundResult.put("model","汽运");
- // //boundResult.put("userName",userName);
- // //boundResult.put("outboundTime",netWeightTime);
- // //RESTfulResult outbountResult = wmsFeign.outbound(boundResult);
- // //if(!"succeed".equals(outbountResult.getStatus())){
- // // throw new Exception(outbountResult.getMessage());
- // //}
- // //break;
- // case "生产":
- //// if(loadPointId.compareTo(unloadPointId) == 0){
- //// //装卸货点相同,则不进行迁移库存
- //// return;
- //// }
- //// //先出库
- //// Map<String,Object> outBoundMap = JSONObject.parseObject(JSONObject.toJSONString(boundResult),Map.class);
- //// outBoundMap.put("gridId",boundResult.get("loadPointId"));
- //// outBoundMap.put("outboundNumber",netWeight);
- //// outBoundMap.put("outboundType","生产汽运计量出库");
- //// outBoundMap.put("userId",userId);
- //// outBoundMap.put("outboundTime",netWeightTime);
- //// outBoundMap.put("userName",userName);
- //// RESTfulResult outbountResult2 = wmsFeign.outbound(outBoundMap);
- ////// if(!"succeed".equals(outbountResult2.getStatus())){
- ////// throw new Exception(outbountResult2.getMessage());
- ////// }
- //// //再入库
- //// Map<String,Object> inBoundMap = JSONObject.parseObject(JSONObject.toJSONString(boundResult),Map.class);
- //// inBoundMap.put("gridId",inBoundMap.get("unloadPointId"));
- //// inBoundMap.put("inboundNumber",netWeight);
- //// inBoundMap.put("inboundType","生产汽运计量入库");
- //// inBoundMap.put("userId",userId);
- //// inBoundMap.put("userName",userName);
- //// inBoundMap.put("inboundTime",netWeightTime);
- //// RESTfulResult inbountResult2 = wmsFeign.inbound(inBoundMap);
- //// if(!"succeed".equals(inbountResult2.getStatus())){
- //// throw new Exception(inbountResult2.getMessage());
- //// }
- // break;
- // default:
- // throw new Exception("未知的业务类型!");
- // }
- // }catch (Exception e){
- // e.printStackTrace();
- // log.error("转移库存失败:"+e.getMessage());
- // }
- }
- @Transactional(rollbackFor = Exception.class)
- public String syncTheoryWeight(Map<String, Object> map) {
- //获取需要同步的订单编码
- List<Map<String, Object>> mapList = tmsWeightResultMapper.syncTheoryWeight(map);
- for (Map<String, Object> objectMap : mapList) {
- //获取大宗理论重量
- Map<String, Object> dzMap = dzFeign.syncTheoryWeight(objectMap);
- TmsWeightResult tmsWeightResult = tmsWeightResultMapper.selectByPrimaryKey(DataChange.dataToBigDecimal(objectMap.get("resultId")));
- tmsWeightResult.setAlternateFields11(dzMap.get("theoryWeight").toString());
- tmsWeightResultMapper.updateByPrimaryKey(tmsWeightResult);
- }
- return "OK";
- }
- public String buluBzwWeight() {
- List<TmsWeightResult> list = tmsWeightResultMapper.selectForBzw();
- while(list.size() > 0){
- Map<String,Object> searchMap = new HashMap<>();
- searchMap.put("list",list);
- List<Map<String,Object>> resultList = dzFeign.getTransOrderBzw(searchMap);
- for(Map<String,Object> item : resultList){
- TmsWeightResult tmsWeightResult = new TmsWeightResult();
- tmsWeightResult.setResultId(DataChange.dataToBigDecimal(item.get("resultId")));
- tmsWeightResult.setGrossWeight(DataChange.dataToBigDecimal(item.get("grossWeight")));
- tmsWeightResult.setTareWeight(DataChange.dataToBigDecimal(item.get("tareWeight")));
- tmsWeightResult.setNetWeight(DataChange.dataToBigDecimal(item.get("netWeight")));
- tmsWeightResult.setAlternateFields13(DataChange.dataToBigDecimal(item.get("bzw")).toString());
- tmsWeightResultMapper.updateByPrimaryKeySelective(tmsWeightResult);
- }
- //继续查询,直到查不到为止
- list = tmsWeightResultMapper.selectForBzw();
- }
- return "操作成功!";
- }
- ExecutorService threadPool = new ThreadPoolExecutor(2,5,
- 1L, TimeUnit.SECONDS,
- new LinkedBlockingQueue<>(3),
- Executors.defaultThreadFactory(),
- new ThreadPoolExecutor.AbortPolicy());
- }
|