package com.steerinfo.dil.service.impl; import com.alibaba.fastjson.JSONObject; import com.steerinfo.dil.feign.OmsFeign; import com.steerinfo.dil.feign.TmstruckFeign; import com.steerinfo.dil.mapper.*; import com.steerinfo.dil.model.OmstruckOrder; import com.steerinfo.dil.model.TmstruckReceiveResult; import com.steerinfo.dil.model.TmstruckWeightBatch; import com.steerinfo.dil.model.TmstruckWeightResult; import com.steerinfo.dil.service.ITmstruckWeightResultService; import com.steerinfo.dil.util.DataChange; import com.steerinfo.dil.util.SaleLogUtil; import com.steerinfo.dil.util.newFileTool; import org.apache.commons.lang.time.FastDateFormat; import org.apache.ibatis.exceptions.TooManyResultsException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scripting.groovy.GroovyScriptEvaluator; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.io.IOException; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; import java.math.BigDecimal; /** * TmstruckWeightResult服务实现: * @author generator * @version 1.0-SNAPSHORT 2021-10-25 02:28 * 类描述 * 修订历史: * 日期:2021-10-25 * 作者:generator * 参考: * 描述:TmstruckWeightResult服务实现 * @see null * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved. */ @Service(value = "tmstruckWeightResultService") public class TmstruckWeightResultServiceImpl implements ITmstruckWeightResultService { @Autowired KDWebServiceServiceImpl KDWebServiceServiceImpl; @Autowired TmstruckWeightResultMapper tmstruckWeightResultMapper; @Autowired UtilsServiceImpl utilsService; @Autowired UtilsMapper utilsMapper; @Autowired OmsFeign omsFeign; @Autowired TmstruckFeign tmstruckFeign; @Autowired TmstruckReceiveResultMapper tmstruckReceiveResultMapper; @Autowired OmstruckOrderMapper omstruckOrderMapper; @Autowired TmstrainWeightResultServiceImpl tmstrainWeightResultService; @Autowired SaleLogUtil saleLogUtil; @Autowired TmstruckWeightBatchMapper tmstruckWeightBatchMapper; //属于采购订单的订单类型(先计毛后计皮) final private List judgeOrderTypeList = Arrays.asList(5, 6, 7, 8, 9, 12, 15, 17, 18,23,24,19); //老厂区需要给金蝶回传的数据订单类型 final private List judgeToKDTypeList = Arrays.asList(5,6,7,8,17,18,23,20); //纯采购订单类型 final private List apoOrderType = Arrays.asList(5,6,7,17,18); //采购内转订单类型 final private List apoInwardOrderType = Arrays.asList(10,15,16,23,24,20); Logger logger = LoggerFactory.getLogger(getClass()); /** * 接收达钢计量实绩信息 * "orderNumber":"WYSDD2021091000000002", * "resultTareCalculateNumber":"1号汽车衡", * "resultCrossCalculateNumber":"1号汽车衡", * "resultTareWeight":40.00, * "resultCrossWeight":40.00, * "resultNetWeight":0, * "resultTareWeightTime":"2021-09-10 09:05:22", * "resultCrossWeightTime":"2021-09-10 09:05:22", * "resultPoundNo":"Bd123456780", * "materialId":40 * @param mapList * @return */ @Override @Transactional public String receiveTmsTruckWeightResultByDaGang(List> mapList){ //遍历列表 StringBuilder sb = new StringBuilder(); for (Map map : mapList) { sb.append(" "); String resultTareCalculateNumber = (String) map.get("resultTareCalculateNumber"); //如果计量衡名字中含有铁专线 则代表是轨道衡 走轨道衡路线 if(resultTareCalculateNumber.contains("铁专线")){ sb.append(tmstrainWeightResultService.addTrainWeightResult(map)); }else { //走汽车衡 map.put("needCheckToKD", "1"); //老厂区专属变量 用于区分新、老厂区 老厂区部分秤需要给金蝶传输数据 sb.append(addTruckWeightResult(map)); } } return sb.toString(); } /* * 接收达兴计量实绩 * @Author TXF * @Date 2022/2/9 14:57 * @param mapList * @return **/ @Transactional @Override public String receiveTmsTruckWeightResultByDaXing(List> mapList) { StringBuilder sb = new StringBuilder(); //遍历列表 for (Map map : mapList) { sb.append(addTruckWeightResult(map)); } return sb.toString(); } /** * 添加汽车衡计量实绩 * @param map * @return */ public String addTruckWeightResult(Map map) { System.out.println("---------------------------------" + new Date() + "新接收到的计量实绩" + "---------------------------------"); JSONObject jsonObject = new JSONObject(map); logger.info("计量信息:{}", jsonObject.toString()); System.out.println("---------------------------------" + new Date() + "新接收到的计量实绩" + "---------------------------------"); try{ new Thread( new Runnable() { public void run(){ try { newFileTool.newFile(jsonObject.toString(),"计量传输物流实绩"); } catch (IOException e) { e.printStackTrace(); } } }).start(); }catch (Exception e) { e.printStackTrace(); } if(map.get("flag") != null && map.get("flag").equals("GCXS")){ System.out.println("这是钢材销售"); TmstruckWeightResult tmstruckWeightResult = null; try { tmstruckWeightResult = generateSteelWeightResult(map); tmstruckWeightResultMapper.updateByPrimaryKeySelective(tmstruckWeightResult); utilsService.pushMesToWebsocket((String) map.get("carNo"), "计量"); return map.get("carNo") + "传输成功"; } catch (Exception e) { try{ new Thread( new Runnable() { public void run(){ try { newFileTool.newFile(map.get("carNo") + e.getMessage() + "传输失败","计量传输物流实绩"); } catch (IOException e) { e.printStackTrace(); } } }).start(); }catch (Exception e1) { e1.printStackTrace(); } System.out.println(map.get("carNo") + e.getMessage() + "传输失败"); return map.get("carNo") + e.getMessage() + "传输失败"; } } //首先通过运输订单号查询订单类型 Map oneMap = utilsMapper.getOrderTypeByOrderNumber((String) map.get("orderNumber")); //用于判断订单类型 if(oneMap == null){ try{ new Thread( new Runnable() { public void run(){ try { newFileTool.newFile(map.get("orderNumber") + "系统无此订单" + "传输失败","计量传输物流实绩"); } catch (IOException e) { e.printStackTrace(); } } }).start(); }catch (Exception e) { e.printStackTrace(); } return map.get("orderNumber") + "系统无此订单"; } int orderType= DataChange.dataToBigDecimal(oneMap.get("orderType")).intValue(); if(orderType == 11 || orderType == 15 || orderType == 16){ return insertWeightResultBy11(map, oneMap); } //为1的时候计量重新更新单据 if(DataChange.dataToBigDecimal(map.get("WLReUpdateFlag")).intValue() == 1){ return linkUpdateAPO(map, orderType); } //通过运输订单号查询计量实绩Id Map stringObjectMap = tmstruckWeightResultMapper.selectWeightIdByOrderId(map); if(stringObjectMap == null){ //通过传来的运输订单号 与 物资ID查询计重实绩ID stringObjectMap = tmstruckWeightResultMapper.selectTotalIdByOrderNo(map); if(stringObjectMap == null){ try{ new Thread( new Runnable() { public void run(){ try { newFileTool.newFile(map.get("orderNumber") + "没有此订单信息或物资信息(" + map.get("materialId") + ")错误" + "传输失败","计量传输物流实绩"); } catch (IOException e) { e.printStackTrace(); } } }).start(); }catch (Exception e) { e.printStackTrace(); } return map.get("orderNumber") + "没有此订单信息或物资信息(" + map.get("materialId") + ")错误"; } } map.putAll(stringObjectMap); TmstruckWeightResult tmstruckWeightResult = null; try { tmstruckWeightResult = generateWeightResult(map); } catch (Exception e) { return e.getMessage(); } //如果含有这个变量则代表是老区订单需要判断是否回传给金蝶 if(map.get("needCheckToKD") != null){ if(map.get("resultNetWeight") != null){ Object resultCrossWeightTime = map.get("resultCrossWeightTime"); if (judgeToKDTypeList.contains(orderType) && resultCrossWeightTime != null && !"".equals(resultCrossWeightTime)) { String resultNetWeight = String.valueOf(map.get("resultNetWeight")); //如果净重不为空 或者净重不为0 if (!"null".equals(resultNetWeight) && !"".equals(resultNetWeight) && !"0".equals(resultNetWeight)) { //回传数据给金蝶方法 sendMesToKD(map, orderType); } } } } tmstruckWeightResultMapper.updateByPrimaryKeySelective(tmstruckWeightResult); //如果订单类型是零星订单 需要查询一下是否还有未计量物资 if(orderType == 12 || orderType == 13){ dealWithLxOrder(map, stringObjectMap); } //根据线路ID去判断 try { if(oneMap.get("lineId") != null) { Map lastLineMap = tmstruckWeightResultMapper.getLineName(DataChange.dataToBigDecimal(oneMap.get("lineId"))); String lastLineName = lastLineMap.get("lastLineName").toString(); BigDecimal segmentSqe = DataChange.dataToBigDecimal(lastLineMap.get("segmentSqe")); TmstruckWeightResult tmsTruckWeightResult1 = tmstruckWeightResultMapper.selectByPrimaryKey(tmstruckWeightResult.getWeightTaskResultId()); if("计毛".equals(lastLineName) && tmstruckWeightResult != null && tmstruckWeightResult.getResultGrossWeight() != null && tmsTruckWeightResult1.getGrossSegmentSqe().compareTo(segmentSqe) == 0) { omstruckOrderMapper.updateOrderStatus(DataChange.dataToBigDecimal(oneMap.get("orderIds"))); } if("计皮".equals(lastLineName) && tmstruckWeightResult != null && tmstruckWeightResult.getResultTareWeight() != null && tmsTruckWeightResult1.getTareSegmentSqe().compareTo(segmentSqe) == 0) { omstruckOrderMapper.updateOrderStatus(DataChange.dataToBigDecimal(oneMap.get("orderIds"))); } } } catch (Exception e) { e.printStackTrace(); } //推送数据 try { utilsService.pushMesToWebsocket((String) oneMap.get("capacityNumber"), "计量"); } catch (Exception e) { e.printStackTrace(); } return map.get("orderNumber") + "成功"; } private TmstruckWeightResult generateSteelWeightResult(Map map) throws Exception { TmstruckWeightResult tmstruckWeightResult = new TmstruckWeightResult(); //该数据为不走物流扫码的数据 //1.通过车号去寻找正在作业的5的运输订单号 String carNo = (String) map.get("carNo"); //String FLID = (String) map.get("FLID"); Object resultNetWeight = map.get("resultNetWeight"); Object FLID = map.get("FLID"); List> weightMapList = new ArrayList<>(); if(resultNetWeight != null && !"".equals(resultNetWeight) && FLID != null && !"".equals(FLID)) { //物资 Object good = map.get("good"); //物资数量 Object goodNum = map.get("goodNum"); //理重 Object theoryWeight = map.get("theoryWeight"); String[] goodList = good.toString().split("、"); String[] flIdList = FLID.toString().split("&"); String[] goodNumList = goodNum.toString().split("、"); String[] theoryWeightList = theoryWeight.toString().split("、"); for(int i = 0 ; i < flIdList.length ; i ++) { Map codeMap = new HashMap<>(); codeMap.putAll(map); codeMap.put("FLID",flIdList[i]); codeMap.put("good",goodList[i]); codeMap.put("goodNum",goodNumList[i]); codeMap.put("theoryWeight",theoryWeightList[i]); weightMapList.add(codeMap); } if(weightMapList.size() > 1) { weightMapList.get(weightMapList.size() - 1).put("resultNetWeight",0); weightMapList.get(weightMapList.size() - 1).put("resultTareWeight",0); weightMapList.get(weightMapList.size() - 1).put("resultCrossWeight",0); } map.put("weightMapList",weightMapList); addWeightBatchResult(map); }else{ weightMapList.add(map); } for(Map codeMap : weightMapList) { //判断该车有没有净重 BigDecimal saleMaterialId = null; if (resultNetWeight != null && !"".equals(resultNetWeight) && codeMap.get("FLID") != null && !"".equals(codeMap.get("FLID"))) { String flId = codeMap.get("FLID").toString(); codeMap.put("flId",flId); BigDecimal orderIdByFLID = omstruckOrderMapper.selectOrderIdByFLID(codeMap.get("FLID")); if(orderIdByFLID == null) { throw new Exception("该分录没有对应的运输订单"); } saleMaterialId = tmstruckWeightResultMapper.getSaleMaterialId(codeMap); codeMap.put("saleMaterialId",saleMaterialId); //首先判断该分录有没有净重 Map orderMesBySaleMaterialId = tmstruckWeightResultMapper.getOrderMesBySaleMaterialIdHaveWeight(saleMaterialId); if(orderMesBySaleMaterialId == null) { //根据分录id和车号去找 Map orderMesByOrderIdByFLID = tmstruckWeightResultMapper.getOrderMesBySaleMaterialId(orderIdByFLID); if(orderMesByOrderIdByFLID != null) { codeMap.putAll(orderMesByOrderIdByFLID); }else{ throw new Exception("该分录对应的订单没有净重可供填充!"); } }else{ codeMap.putAll(orderMesBySaleMaterialId); } }else{ Map orderMes = tmstruckWeightResultMapper.getOrderMes(carNo); if (orderMes == null) { throw new Exception("该车无分录ID且无正在运行中的订单,系统无法匹配数据"); } codeMap.putAll(orderMes); } tmstruckWeightResult.setId(DataChange.dataToBigDecimal(codeMap.get("weightTaskResultId"))); int orderType = DataChange.dataToBigDecimal(codeMap.get("orderTypee")).intValue(); //磅单号 tmstruckWeightResult.setResultPoundNo((String) codeMap.get("resultPoundNo")); String resultCrossWeightTime = (String) codeMap.get("resultCrossWeightTime"); if(codeMap.get("orderNumber") != null) { tmstruckWeightResult.setInsertUpdateRemark((String)codeMap.get("orderNumber")); } if(resultNetWeight != null && !"".equals(resultNetWeight) && codeMap.get("saleMaterialId") != null) { codeMap.put("good",(codeMap.get("goodspa") + "" + codeMap.get("good")).replaceAll(" ","")); BigDecimal materialId = tmstruckWeightResultMapper.getMaterialId(codeMap); if(materialId == null){ throw new Exception("系统找不到该物资"); } codeMap.put("materialId",materialId); tmstruckWeightResult.setMaterialId(materialId); tmstruckWeightResult.setMaterialNum(DataChange.dataToBigDecimal(codeMap.get("goodNum"))); tmstruckWeightResult.setSaleMaterialId(DataChange.dataToBigDecimal(codeMap.get("saleMaterialId"))); tmstruckWeightResult.setSaleMaterialId(saleMaterialId); } addWeightResult(tmstruckWeightResult, codeMap); //添加计量实绩数据 // 更新订单中路段顺序号,如果毛重时间为空则为计皮:也就是销售第一次计皮,反之有毛重时间则为计毛 if(resultCrossWeightTime == null || resultCrossWeightTime.length() == 0){ codeMap.put("segmentSqe", codeMap.get("tareSegmentSqe")); //皮重路段顺序 }else{ //查询有净重的路段顺序号最大的 BigDecimal orderLineSqe = tmstruckWeightResultMapper.selectOrderLineSqe(DataChange.dataToBigDecimal(codeMap.get("resultTotalId"))); if(orderLineSqe != null && orderLineSqe.compareTo(DataChange.dataToBigDecimal(codeMap.get("grossSegmentSqe"))) > 0){ codeMap.put("segmentSqe",orderLineSqe); }else{ codeMap.put("segmentSqe", codeMap.get("grossSegmentSqe")); //毛重路段顺序 } } if(orderType == 1 || orderType == 4){ //如果是钢材订单,获取下一个还没计量的实绩 将毛重数据作为下一个计量实绩的皮重 //并且是第二次传入重量才执行 List> steelMapList = tmstruckWeightResultMapper.getNoNetWeightResultId(DataChange.dataToBigDecimal(codeMap.get("resultTotalId"))); if(steelMapList.size() >= 2){ //当前更新还未提交所以如果是拼装需要查询两个出来 以第二个为准 Map steelMap = steelMapList.get(1); if(resultNetWeight != null && !"".equals(resultNetWeight)){ updateSteelAssemble(codeMap, steelMap); //更新下一拼实绩 codeMap.put("segmentSqe", steelMap.get("tareSegmentSqe")); // 修改路段顺序号直接到下一皮重路段顺序 } } } utilsService.updateOrderLineSequence(codeMap); } return tmstruckWeightResult; } /** * 生成汽运计量实体类 * @Author TXF * @Date 2022/1/5 16:41 * @param map * @return **/ public TmstruckWeightResult generateWeightResult(Map map) throws Exception { TmstruckWeightResult tmstruckWeightResult = new TmstruckWeightResult(); tmstruckWeightResult.setId(DataChange.dataToBigDecimal(map.get("weightTaskResultId"))); int orderType = DataChange.dataToBigDecimal(map.get("orderTypee")).intValue(); //磅单号 tmstruckWeightResult.setResultPoundNo((String) map.get("resultPoundNo")); String resultCrossWeightTime = (String) map.get("resultCrossWeightTime"); tmstruckWeightResult.setMaterialId(DataChange.dataToBigDecimal(map.get("materialId"))); //如果是采购订单 先计毛再计皮 if(judgeOrderTypeList.contains(orderType)){ //如果毛重数据为空 则是第一次计量为毛重 此时第一次计量时间放皮重时间里面 if(resultCrossWeightTime == null || resultCrossWeightTime.length() == 0){ addMaoWeightResult(tmstruckWeightResult, map); //更新订单中路段顺序号 map.put("segmentSqe", map.get("grossSegmentSqe")); //毛重路段顺序 utilsService.updateOrderLineSequence(map); }else { addWeightResult(tmstruckWeightResult, map); //更新订单中路段顺序号 map.put("segmentSqe", map.get("tareSegmentSqe")); //皮重路段顺序 utilsService.updateOrderLineSequence(map); if (orderType==19){ //获取第二个还未计量的物资将第一个物资的皮重作为第二个物资的毛重。 List> resultMapList = tmstruckWeightResultMapper.getNoNetWeightResultForSaleReturn(DataChange.dataToBigDecimal(map.get("resultTotalId"))); if (resultMapList.size()>=2){//如果为多拼 Map saleReturnMap = resultMapList.get(1); Object resultNetWeight = map.get("resultNetWeight"); if(resultNetWeight != null && !"".equals(resultNetWeight)){ updateSaleReturnAssemble(map, saleReturnMap); //更新下一拼实绩 map.put("segmentSqe", saleReturnMap.get("tareSegmentSqe")); utilsService.updateOrderLineSequence(map);// 修改路段顺序号直接到下一皮重路段顺序 } } }//添加计量实绩数据 String orderNumber = (String) map.get("orderNumber"); //如果是采购订单 计皮后自动完成签收 //查询是此订单是否已签收过 Integer check = utilsMapper.checkoutReceipt(orderNumber); if(check == null){ autoReceipt(orderNumber, map.get("resultTareWeightTime")); } } } else if(orderType == 10 || orderType == 20 || orderType == 14){ //查询还有几条没有净重的实绩 Integer resultNum = tmstruckWeightResultMapper.selectNoNetWeightResult((String) map.get("orderNumber")); if(resultNum == 2){ //如果有两条则是走先计皮后计毛顺序 addWeightResult(tmstruckWeightResult, map); //添加计量实绩数据 (正常添加对应皮毛重方法) if(resultCrossWeightTime == null || resultCrossWeightTime.length() == 0){ map.put("segmentSqe", map.get("tareSegmentSqe")); //皮重路段顺序 }else{ map.put("segmentSqe", map.get("grossSegmentSqe")); //毛重路段顺序 } utilsService.updateOrderLineSequence(map); }else if(resultNum == 1){ //只剩一条数据时则是计毛后计皮顺序 //如果毛重数据为空 则是第一次计量为毛重 此时第一次计量时间放皮重时间里面 if(resultCrossWeightTime == null || resultCrossWeightTime.length() == 0){ addMaoWeightResult(tmstruckWeightResult, map); //更新订单中路段顺序号 map.put("segmentSqe", map.get("grossSegmentSqe")); //毛重路段顺序 utilsService.updateOrderLineSequence(map); }else { //根据总实绩id获取磅单号 String resultPoundNoOld = tmstruckWeightResultMapper.selectTruckWeightResultOld(DataChange.dataToBigDecimal(map.get("resultTotalId"))); if(resultPoundNoOld != null && resultPoundNoOld.equals(map.get("resultPoundNo"))) { return tmstruckWeightResult; } addWeightResult(tmstruckWeightResult, map); //添加计量实绩数据 //更新订单中路段顺序号 map.put("segmentSqe", map.get("tareSegmentSqe")); //皮重路段顺序 utilsService.updateOrderLineSequence(map); String orderNumber = (String) map.get("orderNumber"); //如果是采购订单 计皮后自动完成签收 //查询是此订单是否已签收过 Integer check = utilsMapper.checkoutReceipt(orderNumber); if(check == null){ autoReceipt(orderNumber, map.get("resultTareWeightTime")); } if(orderType == 20){ //此订单类型比较特殊 如果订单类型为20则需要回传金蝶 sendMesToKD(map, orderType); } } } } else{ addWeightResult(tmstruckWeightResult, map); //添加计量实绩数据 // 更新订单中路段顺序号,如果毛重时间为空则为计皮:也就是销售第一次计皮,反之有毛重时间则为计毛 if(resultCrossWeightTime == null || resultCrossWeightTime.length() == 0){ map.put("segmentSqe", map.get("tareSegmentSqe")); //皮重路段顺序 }else{ map.put("segmentSqe", map.get("grossSegmentSqe")); //毛重路段顺序 } if(orderType == 1 || orderType == 4){ //如果是钢材订单,获取下一个还没计量的实绩 将毛重数据作为下一个计量实绩的皮重 //并且是第二次传入重量才执行 List> steelMapList = tmstruckWeightResultMapper.getNoNetWeightResultId(DataChange.dataToBigDecimal(map.get("resultTotalId"))); if(steelMapList.size() >= 2){ //当前更新还未提交所以如果是拼装需要查询两个出来 以第二个为准 Map steelMap = steelMapList.get(1); Object resultNetWeight = map.get("resultNetWeight"); if(resultNetWeight != null && !"".equals(resultNetWeight)){ updateSteelAssemble(map, steelMap); //更新下一拼实绩 map.put("segmentSqe", steelMap.get("tareSegmentSqe")); // 修改路段顺序号直接到下一皮重路段顺序 } } } utilsService.updateOrderLineSequence(map); } return tmstruckWeightResult; } /** * 添加第一次为毛重数据的计量实绩 * @param tmstruckWeightResult * @param map */ public void addMaoWeightResult(TmstruckWeightResult tmstruckWeightResult, Map map) throws Exception{ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //设置毛重时间 String firstTime = (String) map.get("resultTareWeightTime"); tmstruckWeightResult.setResultGrossWeightTime(sdf.parse(firstTime)); //添加毛重汽车衡 Integer tareId = tmstruckWeightResultMapper.selectTruckCalculateId((String) map.get("resultTareCalculateNumber")); if(tareId == null){ throw new Exception("没有此计量衡:" + map.get("resultTareCalculateNumber")); } tmstruckWeightResult.setResultGrossPlaceId(new BigDecimal(tareId)); //设置毛重 BigDecimal resultTareWeight = DataChange.dataToBigDecimal(map.get("resultTareWeight")); tmstruckWeightResult.setResultGrossWeight(resultTareWeight); tmstruckWeightResult.setInsertTime(new Date()); tmstruckWeightResult.setInsertUsername("admin"); } /** * 添加计量实绩添加数据 * @param tmstruckWeightResult * @param map * @return */ public void addWeightResult(TmstruckWeightResult tmstruckWeightResult, Map map) throws Exception{ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //设置皮重汽车衡 String resultTareCalculateNumber = (String) map.get("resultTareCalculateNumber"); if(resultTareCalculateNumber != null){ if(!"".equals(resultTareCalculateNumber)){ Integer tareId = tmstruckWeightResultMapper.selectTruckCalculateId(resultTareCalculateNumber); if(tareId == null){ throw new Exception("没有此皮重汽车衡:" + map.get("resultTareCalculateNumber")); } tmstruckWeightResult.setResultTarePlaceId(new BigDecimal(tareId)); } } //设置毛重汽车衡 String resultCrossCalculateNumber = (String) map.get("resultCrossCalculateNumber"); if(resultCrossCalculateNumber != null){ if(!"".equals(resultCrossCalculateNumber)){ Integer crossId = tmstruckWeightResultMapper.selectTruckCalculateId(resultCrossCalculateNumber); if(crossId == null){ throw new Exception("没有此毛重汽车衡:" + map.get("resultCrossCalculateNumber")); } tmstruckWeightResult.setResultGrossPlaceId(new BigDecimal(crossId)); } } //毛重 if(map.get("resultCrossWeight") != null){ String resultCrossWeight = String.valueOf(map.get("resultCrossWeight")); if(!"".equals(resultCrossWeight)) tmstruckWeightResult.setResultGrossWeight(DataChange.dataToBigDecimal(resultCrossWeight)); } //皮重 if(map.get("resultTareWeight") != null){ String resultTareWeight = String.valueOf(map.get("resultTareWeight")); if(!"".equals(resultTareWeight)) tmstruckWeightResult.setResultTareWeight(DataChange.dataToBigDecimal(resultTareWeight)); } //净重 if(map.get("resultNetWeight") != null){ String resultNetWeight = String.valueOf(map.get("resultNetWeight")); if(!"".equals(resultNetWeight)){ tmstruckWeightResult.setResultNetWeight(DataChange.dataToBigDecimal(resultNetWeight)); } } //设置皮重时间 if(map.get("resultTareWeightTime") != null){ String resultTareWeightTime = (String) map.get("resultTareWeightTime"); if(!"".equals(resultTareWeightTime)){ tmstruckWeightResult.setResultTareWeightTime(sdf.parse(resultTareWeightTime)); } } //设置毛重时间 if(map.get("resultCrossWeightTime") != null){ String resultGrossWeightTime = (String) map.get("resultCrossWeightTime"); if(!"".equals(resultGrossWeightTime)){ tmstruckWeightResult.setResultGrossWeightTime(sdf.parse(resultGrossWeightTime)); } } tmstruckWeightResult.setUpdateTime(new Date()); tmstruckWeightResult.setUpdateUsername("admin"); } /** * 自动签收 * @return */ public void autoReceipt(String orderNumber, Object tareWeightTime){ TmstruckReceiveResult tmstruckReceiveResult = new TmstruckReceiveResult(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //通过运输订单号查询总实绩ID BigDecimal resultTotalId = utilsMapper.getTotalIdByOrderNumber(orderNumber); tmstruckReceiveResult.setResultTotalId(resultTotalId); tmstruckReceiveResult.setStatus(new BigDecimal(1)); tmstruckReceiveResult.setInsertUsername("admin"); Date receiptTime; try { //取皮重时间为收货时间 receiptTime = sdf.parse((String) tareWeightTime); } catch (ParseException e) { receiptTime = new Date(); System.out.println(e.getMessage()); } tmstruckReceiveResult.setInsertTime(receiptTime); tmstruckReceiveResult.setUpdateTime(receiptTime); int i = tmstruckReceiveResultMapper.updateByTotalResultId(tmstruckReceiveResult); if(i == 1) { System.out.println(orderNumber + "收货成功"); }else { System.out.println(orderNumber + "收货失败"); } } /** * 纯内转订单类型 * @Author TXF * @Date 2022/2/18 9:55 * @param map * @return **/ public String insertWeightResultBy11(Map map, Map oneMap){ TmstruckWeightResult tmstruckWeightResult = new TmstruckWeightResult(); tmstruckWeightResult.setResultPoundNo((String) map.get("resultPoundNo")); tmstruckWeightResult.setMaterialId(DataChange.dataToBigDecimal(map.get("materialId"))); int sqe = DataChange.dataToBigDecimal(oneMap.get("Sqe")).intValue(); //获取订单路段顺序号 sqe = sqe + 1; Object resultNetWeight = map.get("resultNetWeight"); if(resultNetWeight != null && !"".equals((String) resultNetWeight)){ //判断是否有卸货实绩已经卸过货 如果有卸货实绩 则结束订单 Integer resultId = utilsMapper.getUnloadResultByTotalId(DataChange.dataToBigDecimal(oneMap.get("totalId"))); if(resultId != null){ int orderIds = DataChange.dataToBigDecimal(oneMap.get("orderIds")).intValue(); try { omsFeign.closeInwardOrder(orderIds, sqe, (String) resultNetWeight); } catch (Exception e) { e.printStackTrace(); } }else { Map threeMap = new HashMap<>(); //用于更新路段顺序号 threeMap.put("orderLineSequence", sqe); threeMap.put("orderNumber", map.get("orderNumber")); utilsMapper.updateLineSeqByOrderIdOrNum2(threeMap); //更新订单路段顺序号 } }else { Map threeMap = new HashMap<>(); //用于更新路段顺序号 threeMap.put("orderLineSequence", sqe); threeMap.put("orderNumber", map.get("orderNumber")); utilsMapper.updateLineSeqByOrderIdOrNum2(threeMap); //更新订单路段顺序号 } //首先查询这个订单号的这个物资ID是否有计量实绩 Map twoMap = tmstruckWeightResultMapper.selectResultIdByOrderNoAndMaterialId(map); //判断这个物资是否已经计量过 Object resultCrossWeightTime = map.get("resultCrossWeightTime"); if(twoMap == null){//如果查出来为空,则进行新增操作 tmstruckWeightResult.setId(tmstruckWeightResultMapper.selectMaxId()); //新增主键 tmstruckWeightResult.setResultTotalId(DataChange.dataToBigDecimal(oneMap.get("totalId"))); //新增总实绩ID if(resultCrossWeightTime == null || "".equals(String.valueOf(resultCrossWeightTime))){//只有一条数据的情况 tmstruckWeightResult.setTareSegmentSqe(new BigDecimal(sqe)); } else { tmstruckWeightResult.setTareSegmentSqe(new BigDecimal(sqe)); tmstruckWeightResult.setGrossSegmentSqe(new BigDecimal(sqe)); } try { addWeightResult(tmstruckWeightResult, map); } catch (Exception e) { return e.getMessage(); } tmstruckWeightResultMapper.insertSelective(tmstruckWeightResult); //新增计量实绩 }else { //如果不为空则证明进行过至少一次计量 tmstruckWeightResult.setId(DataChange.dataToBigDecimal(twoMap.get("weightTaskResultId"))); //取出计量数据与传进来的毛皮数据进行对比 BigDecimal inTareWeight = DataChange.dataToBigDecimal(twoMap.get("resultTareWeight")); if(inTareWeight.compareTo(DataChange.dataToBigDecimal(map.get("resultTareWeight"))) > 0){ //如果取出来的皮重 大于 传进来的皮重 则需要调换路段顺序号 tmstruckWeightResult.setGrossSegmentSqe(DataChange.dataToBigDecimal(twoMap.get("tareSegmentSqe"))); tmstruckWeightResult.setTareSegmentSqe(new BigDecimal(sqe)); }else{ tmstruckWeightResult.setGrossSegmentSqe(new BigDecimal(sqe)); } try { addWeightResult(tmstruckWeightResult, map); } catch (Exception e) { return e.getMessage(); } tmstruckWeightResultMapper.updateByPrimaryKeySelective(tmstruckWeightResult); } //推送数据 utilsService.pushMesToWebsocket((String) oneMap.get("capacityNumber"), "计量"); return map.get("orderNumber") + "成功"; } /** * 处理零星订单多拼方法 * @Author TXF * @Date 2022/3/15 18:37 * @param map * @param stringObjectMap * @return **/ public void dealWithLxOrder(Map map, Map stringObjectMap){ if(map.get("resultNetWeight") != null){ String resultNetWeight = String.valueOf(map.get("resultNetWeight")); if(! ("".equals(resultNetWeight) || "null".equals(resultNetWeight))){ //查询是否还有物资如果为空则为已经计量完成 Integer materialId = utilsMapper.getNextMaterialId(DataChange.dataToBigDecimal(stringObjectMap.get("orderId"))); if(materialId != null){ stringObjectMap.put("materialId", materialId); stringObjectMap.put("asd", 1); Map returnMap = null; try { returnMap = tmstruckFeign.sendMeasureCommission(stringObjectMap); String code = (String) returnMap.get("code"); if(!"200".equals(code)){ System.out.println(returnMap.get("data")); } } catch (Exception e) { System.out.println(e.getMessage()); } } } } } /** * 修改拼装钢材物资 * @param map * @param steelMap */ public void updateSteelAssemble(Map map, Map steelMap) throws Exception{ //更新实绩 TmstruckWeightResult steelWightModel = new TmstruckWeightResult(); steelWightModel.setId(DataChange.dataToBigDecimal(steelMap.get("weightTaskResultId"))); //查询出来的主键 steelMap.put("resultTareCalculateNumber", map.get("resultCrossCalculateNumber")); //皮重汽车衡即为毛重汽车衡 steelMap.put("resultTareWeight", map.get("resultCrossWeight"));//皮重即为毛重 steelMap.put("resultTareWeightTime", map.get("resultCrossWeightTime"));//皮重时间即为毛重时间 addWeightResult(steelWightModel, steelMap); tmstruckWeightResultMapper.updateByPrimaryKeySelective(steelWightModel); } //修改拼装退货物资 /** * 修改拼装钢材物资 * @param map * @param steelMap */ public void updateSaleReturnAssemble(Map map, Map steelMap) throws Exception{ //更新实绩 TmstruckWeightResult SaleReturn = new TmstruckWeightResult(); SaleReturn.setId(DataChange.dataToBigDecimal(steelMap.get("weightTaskResultId"))); //查询出来的主键 steelMap.put("resultCrossCalculateNumber", map.get("resultTareCalculateNumber")); //皮重汽车衡即为毛重汽车衡 steelMap.put("resultCrossWeight", map.get("resultTareWeight"));//毛重即皮重 steelMap.put("resultCrossWeightTime", map.get("resultTareWeightTime"));//毛重时间即皮重时间 addWeightResult(SaleReturn, steelMap); tmstruckWeightResultMapper.updateByPrimaryKeySelective(SaleReturn); } /** * 回传数据给金蝶方法 * @Author TXF * @Date 2022/2/9 15:46 * @param * @return **/ public void sendMesToKD(Map map, Integer orderType){ String resultTareCalculateNumber = String.valueOf(map.get("resultTareCalculateNumber")); if(! resultTareCalculateNumber.contains("精煤")){ //如果不是精煤称的则不回传金蝶 或者没有皮重称 return; } String orderNumber = (String) map.get("orderNumber"); Map mesMap = new HashMap<>(); switch (orderType){ case 6: //查询订单信息 mesMap = tmstruckWeightResultMapper.getPurOrderMesToKD(orderNumber); break; case 20: case 23: mesMap = tmstruckWeightResultMapper.get20PurOrderMesToKD(orderNumber); } //将map数据全放进mesMap中 map.putAll(mesMap); //访问金蝶接口 KDWebServiceServiceImpl.sendMesToKD(map); } /** * 计量联动删除方法 * @param mapList * @return */ public String linkageDeleteTransportOrder(List> mapList) throws Exception{ try{ new Thread( new Runnable() { public void run(){ try { newFileTool.newFile(mapList.toString(),"计量-物流联动删单"); } catch (IOException e) { e.printStackTrace(); } } }).start(); }catch (Exception e) { e.printStackTrace(); } //联动删除 for (Map map : mapList) { String orderNumber = (String) map.get("orderNumber"); //判断该运输订单号是否是钢材的 Map orderMes = tmstruckWeightResultMapper.getOOType(orderNumber); if(orderMes == null) { return "failed"; } //新增日志表 saleLogUtil.logOrder(DataChange.dataToBigDecimal(orderMes.get("orderId")),"计量联动删除","计量系统",SaleLogUtil.DELETE); BigDecimal resultTotalId = DataChange.dataToBigDecimal(orderMes.get("resultTotalId")); BigDecimal orderId = DataChange.dataToBigDecimal(orderMes.get("orderId")); Integer orderType = DataChange.dataToBigDecimal(orderMes.get("orderType")).intValue(); if(orderType == 1 || orderType == 4) { //删皮,此时没有物资名称,只有运输订单号 if(map.get("good") == null || "".equals(map.get("good"))){ //清空皮重信息,且将进厂时间清空,且将路段顺序号置为0 tmstruckWeightResultMapper.updateWeightTare(resultTotalId); tmstruckWeightResultMapper.updateEnfactoryResult(resultTotalId); tmstruckWeightResultMapper.updateOrderLineSqe(orderId); tmstruckWeightResultMapper.updateTotalStatus(resultTotalId); } //如果传输了物资,则判断该物资是第几拼 if(map.get("good") != null && !"".equals(map.get("good"))){ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //查询物资 map.put("good",map.get("goodspa") + "" + map.get("good")); BigDecimal materialId = tmstruckWeightResultMapper.getMaterialId(map); if(materialId == null) { return "没有找到该物资,返回failed"; } //查询该物资id及对应的净重还有毛重时间是哪一拼 String resultGrossWeightTime = (String) map.get("resultCrossWeightTime"); Date resultGrossWeightTime1 = sdf.parse(resultGrossWeightTime); Map weightMap = new HashMap<>(); weightMap.put("resultTotalId",orderMes.get("resultTotalId")); weightMap.put("materialId",materialId); weightMap.put("resultGrossWeightTime",resultGrossWeightTime); weightMap.put("saleMaterialId",map.get("saleMaterialId")); Map map1 = tmstruckWeightResultMapper.selectWeightMes(weightMap); tmstruckWeightResultMapper.updateMakeDate(DataChange.dataToBigDecimal(weightMap.get("saleMaterialId"))); //根据查询信息判断是哪一拼 Integer spellNum = (DataChange.dataToBigDecimal(map1.get("grossSqe")).intValue() + DataChange.dataToBigDecimal(map1.get("tareSqe")).intValue()) / 6; if(spellNum == 1){ //如果是第一拼 tmstruckWeightResultMapper.updateWeightResult(DataChange.dataToBigDecimal(map1.get("weightTaskResultId"))); //删除下二拼的皮重 tmstruckWeightResultMapper.updateWeightTareNoGross(resultTotalId); tmstruckWeightResultMapper.updateEnfactoryResult(resultTotalId); tmstruckWeightResultMapper.updateOrderLineSqe(orderId); tmstruckWeightResultMapper.updateTotalStatus(resultTotalId); }else{ tmstruckWeightResultMapper.updateWeightResult(DataChange.dataToBigDecimal(map1.get("weightTaskResultId"))); tmstruckWeightResultMapper.updateWeightTareNoGross(resultTotalId); //查询有净重的实绩的最大路段顺序号 BigDecimal orderLineSqe = tmstruckWeightResultMapper.selectOrderLineSqe(resultTotalId); if(orderLineSqe != null) { tmstruckWeightResultMapper.updateOrderLineSqeBySqe(orderId,orderLineSqe.intValue()); } } } }else{ tmstruckWeightResultMapper.linkageDeleteTransportOrder(orderNumber); } } return "success"; } /** * 计量联动修改方法(修改关联的采购订单,以及同步修改运输订单物资子表的物资) * @param map * @param orderType * @return */ public String linkUpdateAPO(Map map, Integer orderType){ //如果等于1 则代表是需要变更采购订单号的订单 Map mesMap = tmstruckWeightResultMapper.getAPOMes(String.valueOf(map.get("ArrivalBillNo"))); if (mesMap == null){ return map.get("ArrivalBillNo") + "系统没有此订单号!失败"; } mesMap.put("orderNumber", map.get("orderNumber")); try{ new Thread( new Runnable() { public void run(){ try { Map oldOrderMes = tmstruckWeightResultMapper.getOldOrderMes(mesMap); map.put("oldOrderMes",oldOrderMes); JSONObject jsonObject = new JSONObject(map); newFileTool.newFile(jsonObject.toString(),"计量-物流联动换单"); } catch (IOException e) { e.printStackTrace(); } } }).start(); }catch (Exception e) { e.printStackTrace(); } saleLogUtil.logOrder(map.get("orderNumber")+"","计量联动换采购订单","计量系统",SaleLogUtil.UPDATE); if(orderType == 20 || orderType == 15 || orderType == 16 || orderType == 23 || orderType == 24){ //20订单修改的表不一样呀,找寻该采购订单对应的最新需求id和计划id BigDecimal planId = tmstruckWeightResultMapper.selectNewPlanId(mesMap); mesMap.put("planId",planId); tmstruckWeightResultMapper.updatePurchaseInwordAPOId(mesMap); tmstruckWeightResultMapper.updateOmsTruckMaterialId(mesMap); }else{ //修改订单管理采购订单ID 以及物资子表 物资ID tmstruckWeightResultMapper.updateOmsTruckPlanId(mesMap); tmstruckWeightResultMapper.updateOmsTruckMaterialId(mesMap); } return mesMap.get("orderNumber") + "数据修改成功"; } @Override public Boolean checkOrder(Map map) { //获取三个参数 //try { // if (map != null) { // JSONObject jsonObject = new JSONObject(map); // FastDateFormat format = FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss"); // logger.info("=========" + "计量检查" + format.format(new Date())); // logger.info(jsonObject.toString()); // logger.info("=========" + "计量检查" + format.format(new Date())); // // try{ // new Thread( new Runnable() { // public void run(){ // try { // newFileTool.newFile(jsonObject.toString(),"计量物流金蝶核对"); // } catch (IOException e) { // e.printStackTrace(); // } // } // }).start(); // }catch (Exception e) { // e.printStackTrace(); // } // //判断该车的运输订单号是否是钢材且是否是正在作业中的,如果不是就返回true // int i = tmstruckWeightResultMapper.checkOrderIsSteel(map); // if (i == 0) { // return true; // } // // //判断该分录是不是在物流系统,如果不在返回true // int j = tmstruckWeightResultMapper.checkOrder(map); // BigDecimal saleMaterialId = tmstruckWeightResultMapper.getSaleMaterialId(map); // ////判断该分录在计量实绩表里有没有净重,如果有 // //try { // // Map weightMesBySaleMaterialId = tmstruckWeightResultMapper.getWeightMesBySaleMaterialId(saleMaterialId); // // if(weightMesBySaleMaterialId != null && weightMesBySaleMaterialId.get("poundNo") != null) { // // //系统自动走删皮 // // linkageDeleteTransportOrder2(weightMesBySaleMaterialId); // // } // //} catch (Exception e) { // // e.printStackTrace(); // //} // //根据运输订单号查询计量实绩ID // BigDecimal weightTaskResultId = tmstruckWeightResultMapper.getWeightTaskResultIdNoNet(map); // if(weightTaskResultId != null && saleMaterialId != null) { // //更新计量实绩 // System.out.println("更新计量实绩校验"); // //tmstruckWeightResultMapper.updateWeightTaskBySaleMaterialId(weightTaskResultId,saleMaterialId); // } // if (j == 0) { // //如果是自提,则更换规格 // BigDecimal jlSaleOrderMaterialId = tmstruckWeightResultMapper.getJlSaleOrderMaterialId(map); // BigDecimal wlSaleOrderMaterialId = tmstruckWeightResultMapper.getWlSaleOrderMaterialId(map); // BigDecimal wlOrderId = tmstruckWeightResultMapper.getJlOrderId(wlSaleOrderMaterialId); // if(jlSaleOrderMaterialId != null) { // //如果车序号子表存在,判断拼数是否相同 // BigDecimal jlSpell = tmstruckWeightResultMapper.getJlSpell(jlSaleOrderMaterialId); // BigDecimal wlSpell = tmstruckWeightResultMapper.getWlSpell(map); // //如果拼数相同,则继续更换运单,否则返回 // if (jlSpell.compareTo(wlSpell) == 0) { // //判断正确的车序号主键有没有派车 // BigDecimal jlOrderId = tmstruckWeightResultMapper.getJlOrderId(jlSaleOrderMaterialId); // if(jlOrderId != null) { // //分别更新 // tmstruckWeightResultMapper.updateOrderPlanId(jlOrderId,wlSaleOrderMaterialId); // tmstruckWeightResultMapper.updateOrderPlanId(wlOrderId,jlSaleOrderMaterialId); // //清空运输订单子表的某个数据 // tmstruckWeightResultMapper.updateOrderMaterialId(jlOrderId); // tmstruckWeightResultMapper.updateOrderMaterialId(wlOrderId); // }else{ // tmstruckWeightResultMapper.updateOrderPlanId(wlOrderId,jlSaleOrderMaterialId); // tmstruckWeightResultMapper.updateOrderMaterialId(wlOrderId); // } // } // }else { // //如果对不上,那么就将运输订单里面的状态变一下 // tmstruckWeightResultMapper.updateOmsRedQrCode(map); // } // //根据分录ID查询车序号 // utilsService.pushMesToWebsocket((String) map.get("carNo"), "计量"); // return false; // }else{ // return true; // } // } //} catch (Exception e) { // return true; //} return true; } /** * 计量联动删除方法 * @param map * @return */ public String linkageDeleteTransportOrder2(Map map) throws Exception{ try{ new Thread( new Runnable() { public void run(){ try { JSONObject jsonObject = new JSONObject(map); newFileTool.newFile(jsonObject.toString(),"计量-物流联动删单"); } catch (IOException e) { e.printStackTrace(); } } }).start(); }catch (Exception e) { e.printStackTrace(); } //联动删除 String poundNo = (String) map.get("poundNo"); //判断该运输订单号是否是钢材的 Map orderMes = null; try { orderMes = tmstruckWeightResultMapper.getOOPoundMes(poundNo); } catch (Exception e) { return "error:信息错误,该磅单号对应多条实绩."; } if(orderMes == null) { return "error:没有找到对应的单据信息,请核实后再发送"; } BigDecimal resultTotalId = DataChange.dataToBigDecimal(orderMes.get("resultTotalId")); BigDecimal orderId = DataChange.dataToBigDecimal(orderMes.get("orderId")); Integer orderType = DataChange.dataToBigDecimal(orderMes.get("orderType")).intValue(); if(orderType == 1 || orderType == 4) { //删皮,此时没有物资名称,只有运输订单号 if(orderMes.get("netWeight") == null || "".equals(orderMes.get("netWeight"))){ //清空皮重信息,且将进厂时间清空,且将路段顺序号置为0 tmstruckWeightResultMapper.updateWeightTare(resultTotalId); tmstruckWeightResultMapper.updateEnfactoryResult(resultTotalId); tmstruckWeightResultMapper.updateOrderLineSqe(orderId); tmstruckWeightResultMapper.updateTotalStatus(resultTotalId); try { Map enFactoryMap = new HashMap<>(); enFactoryMap.put("orderNumber",orderMes.get("orderNumber") + " "); tmstruckFeign.enFactoryResultByPDA(enFactoryMap); } catch (Exception e) { e.printStackTrace(); } return "删除皮重信息,同时将进厂信息删除,请提醒司机重新扫进厂,否则不能过磅!"; } //如果传输了物资,则判断该物资是第几拼 if(orderMes.get("netWeight") != null){ //查询该物资id及对应的净重还有毛重时间是哪一拼 //判断该总实绩下净重的条数 int netWeightCount = tmstruckWeightResultMapper.getNetWeightCount(resultTotalId); //去除制单日期 tmstruckWeightResultMapper.updateMakeDate(DataChange.dataToBigDecimal(orderMes.get("saleMaterialId"))); //根据查询信息判断是哪一拼 Integer spellNum = (DataChange.dataToBigDecimal(orderMes.get("grossSqe")).intValue() + DataChange.dataToBigDecimal(orderMes.get("tareSqe")).intValue()) / 6; if(spellNum == 1){ //如果是第一拼 tmstruckWeightResultMapper.updateWeightResult(DataChange.dataToBigDecimal(orderMes.get("weightTaskResultId"))); }else{ tmstruckWeightResultMapper.updateWeightResult(DataChange.dataToBigDecimal(orderMes.get("weightTaskResultId"))); tmstruckWeightResultMapper.updateWeightTareNoGross(resultTotalId); //查询有净重的实绩的最大路段顺序号 BigDecimal orderLineSqe = tmstruckWeightResultMapper.selectOrderLineSqe(resultTotalId); if(orderLineSqe != null) { tmstruckWeightResultMapper.updateOrderLineSqeBySqe(orderId,orderLineSqe.intValue()); } } if(netWeightCount == 1) { //删除下面拼装的皮重 tmstruckWeightResultMapper.updateWeightTareNoGross(resultTotalId); tmstruckWeightResultMapper.updateEnfactoryResult(resultTotalId); tmstruckWeightResultMapper.updateOrderLineSqe(orderId); tmstruckWeightResultMapper.updateTotalStatus(resultTotalId); //try { // Map enFactoryMap = new HashMap<>(); // enFactoryMap.put("orderNumber",orderMes.get("orderNumber") + " "); // tmstruckFeign.enFactoryResultByPDA(enFactoryMap); //} catch (Exception e) { // e.printStackTrace(); //} return "该车整条计量数据1条,删除整条数据1条,同时将进厂信息删除,请提醒司机重新扫进厂,否则不能过磅!"; } return "磅单号:" + poundNo + "删除成功" ; } }else{ return "error:非出厂钢材订单,不能通过该操作删除"; } return "success"; } @Transactional(rollbackFor = Exception.class) public String changeOrderNumber(Map map) throws Exception{ //校验 if(map==null || map.get("capacityNumber")==null){ throw new Exception("缺乏车牌号:capacityNumber"); } //查询车辆对应订单信息 Map details = null; try{ details = omstruckOrderMapper.findOrderDetailByCapacityNumber(map); }catch (TooManyResultsException e){ e.printStackTrace(); throw new Exception("查询到多个实绩"); } if(details==null || details.get("orderId")==null){ throw new Exception("没有查询到正在执行的运单!"); } //生成新的运输订单号 BigDecimal orderId=omstruckOrderMapper.selectMaxId(); String result=DataChange.generateEightDigitsNumber("WYSDD", orderId.intValue()); //更新 OmstruckOrder omstruckOrder=new OmstruckOrder(); omstruckOrder.setOrderId(DataChange.dataToBigDecimal(details.get("orderId"))); omstruckOrder.setOrderNumber(result); omstruckOrderMapper.updateByPrimaryKeySelective(omstruckOrder); return result; } @Override public List> queryApoByOrderNo(List orderNos) { List> mapList = new ArrayList<>(); for (String orderNo :orderNos) { Integer orderType = tmstruckWeightResultMapper.queryOrderType(orderNo); String apo = null; Map map = null; if(apoOrderType.contains(orderType)) { map = tmstruckWeightResultMapper.queryApoByOrderNo(orderNo); } if (apoInwardOrderType.contains(orderType)) { map = tmstruckWeightResultMapper.queryApoInwardByOrderNo(orderNo); } if(map != null) { mapList.add(map); } } return mapList; } public void addWeightBatchResult(Map map) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); TmstruckWeightBatch tmstruckWeightBatch = new TmstruckWeightBatch(); BigDecimal weightBatchId = tmstruckWeightBatchMapper.weightBatchID(); tmstruckWeightBatch.setId(weightBatchId); //皮重 if(map.get("resultTareWeight") != null && !"".equals(map.get("resultTareWeight"))) { tmstruckWeightBatch.setBatchTareWeight(DataChange.dataToBigDecimal(map.get("resultTareWeight"))); } //毛重 if(map.get("resultCrossWeight") != null && !"".equals(map.get("resultCrossWeight"))) { tmstruckWeightBatch.setBatchGrossWeight(DataChange.dataToBigDecimal(map.get("resultCrossWeight"))); } //净重 if(map.get("resultNetWeight") != null && !"".equals(map.get("resultNetWeight"))) { tmstruckWeightBatch.setBatchNetWeight(DataChange.dataToBigDecimal(map.get("resultNetWeight"))); } //毛重时间 if(map.get("resultCrossWeightTime") != null && !"".equals(map.get("resultCrossWeightTime"))) { try { tmstruckWeightBatch.setBatchGrossWeightTime(sdf.parse(map.get("resultCrossWeightTime").toString())); } catch (ParseException e) { e.printStackTrace(); } } //皮重时间 if(map.get("resultTareWeightTime") != null && !"".equals(map.get("resultTareWeightTime"))) { try { tmstruckWeightBatch.setBatchTareWeightTime(sdf.parse(map.get("resultTareWeightTime").toString())); } catch (ParseException e) { e.printStackTrace(); } } //绑定批次表与分录id的关系 List> weightMapList = (List>) map.get("weightMapList"); //改分录表 for (Map weightMap : weightMapList) { weightMap.put("weightBatchId",weightBatchId); tmstruckWeightBatchMapper.updateFluMes(weightMap); } for (Map weightMap : weightMapList) { weightMap.put("weightBatchId",weightBatchId); tmstruckWeightBatchMapper.updateOmMes(weightMap); } tmstruckWeightBatchMapper.insertSelective(tmstruckWeightBatch); } }