123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692 |
- package com.steerinfo.dil.service.impl;
- import com.steerinfo.dil.feign.WmshBoundFeign;
- import com.steerinfo.dil.mapper.*;
- import com.steerinfo.dil.model.*;
- import com.steerinfo.dil.service.ITmstrainLoadingResultService;
- import com.steerinfo.dil.util.DataChange;
- import com.steerinfo.framework.service.pagehelper.PageHelper;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import java.math.BigDecimal;
- import java.util.*;
- /**
- * TmstrainLoadingResult服务实现:
- * @author generator
- * @version 1.0-SNAPSHORT 2021-08-30 02:23
- * 类描述
- * 修订历史:
- * 日期:2021-08-30
- * 作者:generator
- * 参考:
- * 描述:TmstrainLoadingResult服务实现
- * @see null
- * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
- */
- @Service(value = "tmstrainLoadingResultService")
- public class TmstrainLoadingResultServiceImpl implements ITmstrainLoadingResultService {
- @Autowired
- private TmstrainLoadingResultMapper tmstrainLoadingResultMapper;
- @Autowired
- private TmstrainLoadingTempMapper tmstrainLoadingTempMapper;
- @Autowired
- private WmshBoundFeign wmshBoundFeign;
- @Autowired
- private TmstrainTruckTotalResultMapper tmstrainTruckTotalResultMapper;
- @Autowired
- private TmstrainTotalResultMapper tmstrainTotalResultMapper;
- @Autowired
- private TmstrainMeasureCommissionServiceImpl tmstrainMeasureCommissionService;
- @Autowired
- private TmstrainWeightResultMapper tmstrainWeightResultMapper;
- /**
- * 查看所有装车实绩
- * @param map
- * @return
- */
- @Override
- public List<Map<String, Object>> getTmstrainWagonLoad(Map<String, Object> map) {
- BigDecimal resultType = DataChange.dataToBigDecimal(map.get("resultType"));
- switch (resultType.intValue()){
- case 1:
- case 2:
- case 3:
- List<Map<String, Object>> tmsWagonLoadInfo = tmstrainLoadingResultMapper.getTmsWagonLoadInfo(map);// apiId = 58 - 209
- for (Map<String, Object> obj : tmsWagonLoadInfo) {
- Integer deleted = DataChange.dataToBigDecimal(obj.get("deleted")).intValue();
- if(deleted == 0){
- obj.put("isUnload", "已装车");
- }else {
- obj.put("isUnload", "已卸车");
- }
- }
- return tmsWagonLoadInfo;
- case 4:
- return tmstrainLoadingResultMapper.selectLoadedForConverted(map); //apiId = 203
- case 10:
- //查询国产矿需要补录的装车实绩
- return tmstrainLoadingResultMapper.getNoPurOrderIdLoadResult(map); //apiId = 209
- }
- return null;
- }
- /**
- * 添加火运总实绩
- * @param loadingId
- * @return
- */
- public int addTotalResult(BigDecimal loadingId){
- TmstrainTotalResult tmstrainTotalResult = new TmstrainTotalResult();
- BigDecimal maxId = tmstrainTotalResultMapper.selectMaxId();
- tmstrainTotalResult.setId(maxId); //获取添加火运总实绩主键ID
- //生成火运单号
- tmstrainTotalResult.setTransportNum(DataChange.generateEightDigitsNumber("WTRAN", maxId.intValue()));
- //添加火运装车实绩ID
- tmstrainTotalResult.setLoadingId(loadingId);
- //新增计量实绩
- TmstrainWeightResult tmstrainWeightResult=new TmstrainWeightResult();
- tmstrainWeightResult.setResultId(tmstrainWeightResultMapper.selectMaxId());
- tmstrainWeightResult.setResultTotalId(maxId);
- tmstrainWeightResultMapper.insertSelective(tmstrainWeightResult);
- return tmstrainTotalResultMapper.insertSelective(tmstrainTotalResult);
- }
- /**
- * 进口矿新增装车实绩
- * @param mapValue
- * @return
- */
- @Override
- @Transactional
- public int addTmstrainLoadingResult(Map<String,Object> mapValue) throws Exception{
- List<Map<String, Object>> list= (List<Map<String, Object>>) mapValue.get("list");
- String userId=null;
- if(mapValue.get("userId")!=null)
- userId=mapValue.get("userId").toString();
- else
- throw new Exception("用户id为空,请先登录再操作!");
- //装车实绩list
- List<TmstrainLoadingResult> loadingResults=new ArrayList<>();
- //取分隔符
- List<String> splits=tmstrainLoadingResultMapper.findSplitsForImported();
- int i = 0;
- for(Map<String,Object> map:list){
- TmstrainLoadingResult result=new TmstrainLoadingResult();
- //设置序列号主键
- BigDecimal maxId = tmstrainLoadingResultMapper.selectMaxId();
- result.setResultId(maxId);
- //配单
- List<Map<String,Object>> orderList= tmstrainLoadingResultMapper.getPurchaseOrderListForImported(map);//第一次模糊查询
- if(orderList.size() > 1){
- //根据外轮船名模糊查找不唯一,再根据物资名和外轮船名匹配
- map.put("materialName",map.get("mineral"));
- String productName=map.get("productName").toString();
- for(String split:splits){
- String arr[]=productName.split(split);
- if(arr.length>1){
- //切割成功,退出
- map.put("resultForeignShipName",arr[1]);
- break;
- }
- }
- orderList= tmstrainLoadingResultMapper.getPurchaseOrderListForImported(map);
- }
- if(orderList.size() > 0){
- Map<String,Object> details=orderList.get(0);
- BigDecimal purchaseOrderId=DataChange.dataToBigDecimal(details.get("purchaseOrderId"));
- BigDecimal materialId=DataChange.dataToBigDecimal(details.get("materialId"));
- BigDecimal supplierId=DataChange.dataToBigDecimal(details.get("supplierId"));
- BigDecimal batchId=DataChange.dataToBigDecimal(details.get("batchId"));
- result.setPurchaseOrderRailPlanId(purchaseOrderId);
- result.setMaterialId(materialId);
- result.setSendUnitId(supplierId);
- result.setBatchId(batchId);
- }else{
- throw new Exception("没有对应的进口矿采购订单号:"+map.get("productName").toString());
- }
- //处理实绩表
- result.setSendStationId(DataChange.dataToBigDecimal(mapValue.get("sendStationId")));//发站
- result.setArrivalStationId(DataChange.dataToBigDecimal(mapValue.get("arrivalStationId")));//到站
- result.setResultLoadingDate(new Date((Long)mapValue.get("resultLoadingDate")));//装车日期
- result.setResultType(DataChange.dataToBigDecimal(mapValue.get("resultType")));//装车类型
- // result.setResultIsclear(mapValue.get("resultIsclear").toString());
- // result.setResultClass(mapValue.get("resultClass").toString());
- result.setResultRemarks((String) mapValue.get("resultRemarks"));//备注
- result.setResultWagonNo(map.get("wagonNo").toString());//车皮号
- //添加常规字段
- addRegularField(result,userId);
- //通过车皮号计算车皮标重
- result.setResultBillableTonnage(new BigDecimal(calculateWagonWeight(result.getResultWagonNo())));
- //通过到站ID匹配计量衡 如果是老区轨道衡或者是新区轨道衡 则匹配轨道衡
- //如果到站ID是老区轨道衡
- BigDecimal arrivalStationId = result.getArrivalStationId();
- if(arrivalStationId!=null && arrivalStationId.intValue() == 1){
- result.setTrainCalculateId(new BigDecimal(13)); //设置计量衡为 铁专线(老区)
- result.setSendRequest(new BigDecimal(1));
- }
- loadingResults.add(result);
- i += addTotalResult(maxId);//添加总实绩和计量实绩
- }
- //批量插入
- int count = tmstrainLoadingResultMapper.batchInsert(loadingResults);
- //发送委托
- if(count==loadingResults.size()){
- ArrayList<Map<String,Object>> resultIdList=new ArrayList<>();
- Map<String, Object> map1 = new HashMap<>();
- for(TmstrainLoadingResult tmstrainLoadingResult:loadingResults){
- Map<String, Object> temp = new HashMap<>();
- temp.put("resultId",tmstrainLoadingResult.getResultId());
- resultIdList.add(temp);
- }
- map1.put("resultIdList",resultIdList);
- i = tmstrainMeasureCommissionService.batchSendMeasureCommission(map1);
- if(i==-1){
- throw new Exception("计量委托发送失败!");
- }
- }
- return count;
- }
- /**
- * 国产矿新增导入
- * @param mapValue
- * @return
- */
- public int addDomesticLoadResult(Map<String, Object> mapValue) throws Exception {
- List<Map<String, Object>> list= (List<Map<String, Object>>) mapValue.get("list");
- String userId=null;
- if(mapValue.get("userId")!=null)
- userId=mapValue.get("userId").toString();
- else
- throw new Exception("用户id为空,请先登录再操作!");
- //装车实绩list
- List<TmstrainLoadingResult> loadingResults=new ArrayList<>();
- //获取分隔符
- List<String> splits=tmstrainLoadingResultMapper.findSplitsForDomestic();
- int i = 0;
- for(Map<String,Object> map:list){
- TmstrainLoadingResult result=new TmstrainLoadingResult();
- //设置序列号主键
- BigDecimal maxId = tmstrainLoadingResultMapper.selectMaxId();
- result.setResultId(maxId);
- //配单
- List<Map<String,Object>> orderList= tmstrainLoadingResultMapper.getPurchaseOrderList(map);
- if(orderList.size() <= 0){
- //找不到则对品名拆分,重新查询
- String productName=map.get("productName").toString();
- for(String split:splits){
- String []arr=productName.split(split);
- if(arr.length>1){
- String supplierName=arr[0];
- map.put("supplierName",supplierName);
- break;
- }
- }
- orderList=tmstrainLoadingResultMapper.getPurchaseOrderList(map);
- }
- if(orderList.size() > 0){
- Map<String,Object> details=orderList.get(0);
- BigDecimal purchaseOrderId=DataChange.dataToBigDecimal(details.get("purchaseOrderId"));
- BigDecimal materialId=DataChange.dataToBigDecimal(details.get("materialId"));
- BigDecimal supplierId=DataChange.dataToBigDecimal(details.get("supplierId"));
- BigDecimal batchId=DataChange.dataToBigDecimal(details.get("batchId"));
- result.setPurchaseOrderRailPlanId(purchaseOrderId);
- result.setMaterialId(materialId);
- result.setSendUnitId(supplierId);
- result.setBatchId(batchId);
- }else{
- throw new Exception("没有对应的国产矿采购订单号:"+map.get("productName"));
- }
- //处理实绩表
- result.setArrivalStationId(new BigDecimal(map.get("arrivalStationId").toString()));//到站
- result.setResultLoadingDate(new Date((Long)map.get("resultLoadingDate")));//装车日期
- result.setResultType(new BigDecimal(map.get("resultType").toString()));//装车类型,国产矿应该为3
- result.setResultRemarks((String) map.get("resultRemarks"));//备注
- result.setResultWagonNo(map.get("wagonNo").toString());//车皮号
- //取得发站名,查询是否存在该站台,如果存在则绑定,否则新增该站台再绑定
- String sendStationName=(String) map.get("sendStation");//发站名
- if(sendStationName!=null){
- BigDecimal sendStationId=tmstrainLoadingResultMapper.getSendStationId(sendStationName);
- if(sendStationId==null){
- //如果没有该站,新增
- sendStationId=tmstrainLoadingResultMapper.getMaxSendStationId().add(new BigDecimal(1));
- Map<String,Object> station=new HashMap<>();
- station.put("arrivalId",sendStationId);
- station.put("arrivalName",sendStationName);
- station.put("insertTime",new Date());
- station.put("updateTime",new Date());
- if(tmstrainLoadingResultMapper.addSendStation(station)<=0){
- throw new Exception("添加发站失败");
- }
- }
- result.setSendStationId(sendStationId);
- }
- //添加常规字段
- addRegularField(result,userId);
- //通过车皮号计算车皮标重
- result.setResultBillableTonnage(new BigDecimal(calculateWagonWeight(result.getResultWagonNo())));
- //通过到站ID匹配计量衡 如果是老区轨道衡或者是新区轨道衡 则匹配轨道衡
- //如果到站ID是老区轨道衡
- BigDecimal arrivalStationId = result.getArrivalStationId();
- if(arrivalStationId!=null && arrivalStationId.intValue() == 1){
- result.setTrainCalculateId(new BigDecimal(13)); //设置计量衡为 铁专线(老区)
- result.setSendRequest(new BigDecimal(1));
- }
- loadingResults.add(result);
- i += addTotalResult(maxId);
- }
- //批量插入
- int count = tmstrainLoadingResultMapper.batchInsert(loadingResults);
- //发送委托
- if(count==loadingResults.size()){
- ArrayList<Map<String,Object>> resultIdList=new ArrayList<>();
- Map<String, Object> map1 = new HashMap<>();
- for(TmstrainLoadingResult tmstrainLoadingResult:loadingResults){
- Map<String, Object> temp = new HashMap<>();
- temp.put("resultId",tmstrainLoadingResult.getResultId());
- resultIdList.add(temp);
- }
- map1.put("resultIdList",resultIdList);
- i = tmstrainMeasureCommissionService.batchSendMeasureCommission(map1);
- if(i==-1){
- throw new Exception("计量委托发送失败!");
- }
- }
- return count;
- }
- /**
- * 国产矿新增配单补录
- * @param map
- * @return
- */
- public int updateDomesticLoadResult(Map<String, Object> map) throws Exception {
- //获取要补录的实绩ID 列表
- List<Integer> resultIdList = (List<Integer>) map.get("resultIdList");
- TmstrainLoadingResult tmstrainLoadingResult = new TmstrainLoadingResult();
- BigDecimal purchaseOrderId = DataChange.dataToBigDecimal(map.get("purchaseOrderId"));
- if(purchaseOrderId.intValue() != 0){
- //查询补录信息
- Map<String,Object> record=tmstrainLoadingResultMapper.getRecordByPurOrderId(purchaseOrderId);
- BigDecimal materialId=DataChange.dataToBigDecimal(record.get("materialId"));
- BigDecimal supplierId=DataChange.dataToBigDecimal(record.get("supplierId"));
- BigDecimal batchId =DataChange.dataToBigDecimal(record.get("batchId"));
- //设置补录字段
- tmstrainLoadingResult.setBatchId(batchId);
- tmstrainLoadingResult.setMaterialId(materialId);
- tmstrainLoadingResult.setSendUnitId(supplierId);
- }
- tmstrainLoadingResult.setPurchaseOrderRailPlanId(purchaseOrderId); //采购订单Id
- if(map.get("userId")!=null)
- tmstrainLoadingResult.setUpdateUsername(map.get("userId").toString());
- else
- throw new Exception("用户id为空,请先登录!");
- int count = 0;
- //对每一个实绩id对应的记录修改字段
- for (Integer resultId : resultIdList) {
- tmstrainLoadingResult.setResultId(new BigDecimal(resultId)); //设置要补录的实绩主键
- tmstrainLoadingResult.setUpdateTime(new Date());
- count += tmstrainLoadingResultMapper.updateByPrimaryKeySelective(tmstrainLoadingResult);
- }
- //配单成功,发送计量委托
- if(resultIdList.size()-count==0){
- Map<String, Object> map1 = new HashMap<>();
- List<Map<String,Object>> resultIdList1=new ArrayList<>();
- for(Integer resultId:resultIdList){
- Map<String, Object> temp = new HashMap<>();
- temp.put("resultId",resultId);
- resultIdList1.add(temp);
- }
- map1.put("resultIdList",resultIdList1);
- int i = tmstrainMeasureCommissionService.batchSendMeasureCommission(map1);
- if(i==-1){
- return i;
- }
- }
- return count;
- }
- /**
- * 通过车皮标重计算车皮标重
- * @return
- */
- public int calculateWagonWeight(String wagonNo){
- String number = wagonNo.substring(0,2);
- if (number.equals("14"))
- {
- String No = wagonNo.substring(0,3);
- if (No.equals("143")||No.equals("140")||No.equals("141")||No.equals("142")){
- return 60;
- }
- else if (No.equals("145")){
- return 61;
- }
- }
- else if(number.equals("45")||number.equals("46")){
- return 60;
- }
- else if(number.equals("42")||number.equals("47")||number.equals("48")||number.equals("49")){
- return 61;
- }
- else if(number.equals("15")||number.equals("16")||number.equals("17")||number.equals("18")){
- return 70;
- }
- return 0;
- }
- /**
- * 添加港存库出库实绩
- * @param map2
- * @param batchId
- */
- public int addOutWarehouse(Map<String,Object> map2, BigDecimal batchId){
- Map<String, Object> map = new HashMap<>();
- map.put("isClean",map2.get("isClean"));
- map.put("resultMaterialNumber",map2.get("resultTonnage"));
- map.put("batchId", batchId);
- //通过港口名称查找港口id
- BigDecimal portId = tmstrainLoadingResultMapper.getPortIdByPortName((String) map2.get("portName"));
- map.put("portId", portId);
- //根据港口和批次查找唯一的港存库id
- BigDecimal gridId = tmstrainLoadingResultMapper.getGridIdByPortAndBatch(map);
- map.put("gmId",gridId);
- if (map2.get("isClean").equals("清场")){
- wmshBoundFeign.clearWmshGridMaterial(map);
- }
- else {
- Map<String, Object> stringObjectMap = wmshBoundFeign.addResult(map);
- if (!stringObjectMap.equals("")||stringObjectMap!=null){
- return -1;
- }
- }
- return 1;
- }
- /**
- * 添加常规字段
- * @param tmstrainLoadingResult
- */
- public void addRegularField(TmstrainLoadingResult tmstrainLoadingResult,String userName){
- //常规字段插入
- tmstrainLoadingResult.setInsertUsername(userName);
- tmstrainLoadingResult.setInsertTime(new Date());
- tmstrainLoadingResult.setInsertUpdateRemark("无");
- tmstrainLoadingResult.setDeleted(new BigDecimal(0));
- }
- /**
- * 通过ID获取装车实绩数据
- * @param resultId
- * @return
- */
- @Override
- public List<Map<String, Object>> getTmstrainLoadingResultByResultId(BigDecimal resultId) {
- return tmstrainLoadingResultMapper.selectByResultId(resultId);
- }
- /**
- * 修改进口矿国产矿火运装车实绩
- * @param map
- * @return
- */
- @Transactional(rollbackFor = {Exception.class})
- @Override
- public int updateTmstrainLoadingResult(Map<String,Object> map) throws Exception{
- TmstrainLoadingResult tmstrainLoadingResult=new TmstrainLoadingResult();
- String wagonNo=map.get("resultWagonNo").toString();
- BigDecimal resultId=DataChange.dataToBigDecimal(map.get("resultId"));
- Integer resultType=(Integer) map.get("resultType");
- if(wagonNo==null || wagonNo.length()!=7 || calculateWagonWeight(wagonNo)<=0){
- throw new Exception("车皮号异常");
- }else if(resultId==null){
- throw new Exception("主键为空");
- }else if(resultType==0){
- throw new Exception("类型异常");
- }
- //国产矿未配单仅支持修改部分字段,并且不重新发委托
- List<Map<String,Object>> results=tmstrainLoadingResultMapper.selectByResultId(resultId);
- if(resultType==3 && results!=null && results.get(0)!=null && results.get(0).get("purchaseOrderNo")==null){
- tmstrainLoadingResult.setResultId(resultId);
- tmstrainLoadingResult.setResultWagonNo(wagonNo);
- tmstrainLoadingResult.setSendStationId(DataChange.dataToBigDecimal(map.get("sendStationId")));
- tmstrainLoadingResult.setArrivalStationId(DataChange.dataToBigDecimal(map.get("arrivalStationId")));
- tmstrainLoadingResult.setResultLoadingDate(new Date((Long)map.get("resultLoadingDate")));
- if(map.get("resultRemarks")!=null)
- tmstrainLoadingResult.setResultRemarks(map.get("resultRemarks").toString());
- tmstrainLoadingResultMapper.updateByPrimaryKeySelective(tmstrainLoadingResult);
- return 1;
- }
- //进口矿字段
- if(resultType!=3){
- if(map.get("resultClass")!=null)
- tmstrainLoadingResult.setResultClass(map.get("resultClass").toString());
- if(map.get("resultIsclear")!=null)
- tmstrainLoadingResult.setResultIsclear(map.get("resultIsclear").toString());
- if(map.get("capacityId")!=null)
- tmstrainLoadingResult.setCapacityId(DataChange.dataToBigDecimal(map.get("capacityId")));
- if(map.get("resultBillableTonnage")!=null)
- tmstrainLoadingResult.setResultBillableTonnage(DataChange.dataToBigDecimal(map.get("resultBillableTonnage")));
- }
- //通过采购订单号查询获得采购订单ID、批次ID、物资ID、发货单位ID
- if(map.get("purchaseOrderNo")!=null){
- String purchaseOrderNo = map.get("purchaseOrderNo").toString() ;
- BigDecimal purchaseOrderId = tmstrainLoadingResultMapper.getPurchaseOrderIdByPurOrderNo(purchaseOrderNo);
- BigDecimal batchId = tmstrainLoadingResultMapper.getBatchIdByPurOrderNo(purchaseOrderNo);
- Map<String,Object> record=tmstrainLoadingResultMapper.getRecordByPurOrderId(purchaseOrderId);
- BigDecimal materialId=DataChange.dataToBigDecimal(record.get("materialId"));
- BigDecimal supplierId=DataChange.dataToBigDecimal(record.get("supplierId"));
- if(purchaseOrderId==null || batchId==null ||materialId==null ||supplierId==null){
- throw new Exception("采购订单号异常");
- }
- tmstrainLoadingResult.setBatchId(batchId);
- tmstrainLoadingResult.setPurchaseOrderRailPlanId(purchaseOrderId);
- tmstrainLoadingResult.setMaterialId(materialId);
- tmstrainLoadingResult.setSendUnitId(supplierId);
- }
- //设置其他字段
- tmstrainLoadingResult.setResultId(resultId);
- tmstrainLoadingResult.setResultWagonNo(wagonNo);
- tmstrainLoadingResult.setSendStationId(DataChange.dataToBigDecimal(map.get("sendStationId")));
- tmstrainLoadingResult.setArrivalStationId(DataChange.dataToBigDecimal(map.get("arrivalStationId")));
- tmstrainLoadingResult.setResultLoadingDate(new Date((Long)map.get("resultLoadingDate")));
- if(map.get("resultRemarks")!=null)
- tmstrainLoadingResult.setResultRemarks(map.get("resultRemarks").toString());
- tmstrainLoadingResult.setUpdateTime(new Date());
- if(map.get("userId")!=null){
- tmstrainLoadingResult.setUpdateUsername(map.get("userId").toString());
- }else{
- throw new Exception("没有用户id,请登录再操作!");
- }
- //更新
- int count=tmstrainLoadingResultMapper.updateByPrimaryKeySelective(tmstrainLoadingResult);
- if(count <= 0){
- throw new Exception("修改失败");
- }
- //修改成功,发送计量委托
- List<Map<String, Object>> resultIdList = new ArrayList<>();
- Map<String, Object> map1 = new HashMap<>();
- Map<String, Object> map2 = new HashMap<>();
- map1.put("resultId",resultId);
- resultIdList.add(map1);
- map2.put("resultIdList",resultIdList);
- count = tmstrainMeasureCommissionService.batchSendMeasureCommission(map2);
- if(count<=0)
- throw new Exception("发送计量委托失败");
- return count;
- }
- /**
- * 删除装车作业
- * @param resultId
- * @return
- */
- @Override
- public int deleteTmstrainLoadingResultByResultId(BigDecimal resultId) {
- TmstrainLoadingResult tmstrainLoadingResult = new TmstrainLoadingResult();
- tmstrainLoadingResult.setResultId(resultId);
- tmstrainLoadingResult.setDeleted(new BigDecimal(1));
- return tmstrainLoadingResultMapper.updateByPrimaryKeySelective(tmstrainLoadingResult);
- }
- /**
- * 内转添加装车实绩
- * "railPlanId": 1,
- * "resultClass":"白班",
- * "resultWagonNo":"1609999",
- * "insertUpdateRemark": "这是第二条",
- * "scanCodeText": "HRB400E-12-21706023-9-3077-385-20210909120037-a0691de83a1a1fef-08010103010100014-20"
- * @param map
- * @return
- */
- @Override
- @Transactional
- public int addTrainLoadResultForConverted(Map<String, Object> map) {
- int count = 0;
- TmstrainLoadingResult tmstrainLoadingResult = new TmstrainLoadingResult();
- String resultWagonNo = (String) map.get("resultWagonNo"); //车皮号
- BigDecimal railPlanId = DataChange.dataToBigDecimal(map.get("railPlanId")); //发运计划ID
- Integer loadingId = tmstrainLoadingResultMapper.getLoadingIdByWnoAndRailPlanId(resultWagonNo, railPlanId.intValue());
- //通过火运装车实绩ID查询火运总实绩ID 如果火运装车实绩不为空
- BigDecimal trainTotalId = null;
- if(loadingId != null){
- trainTotalId = tmstrainTotalResultMapper.getTotalIdByLoadingId(loadingId);
- }
- //如果没有这个车皮号和发运计划的装车实绩,则新增一条装车实绩
- if(loadingId == null){
- //获取装车实绩主键ID
- BigDecimal maxId = tmstrainLoadingResultMapper.selectMaxId();
- tmstrainLoadingResult.setId(maxId);
- //获取发运计划ID
- tmstrainLoadingResult.setPurchaseOrderRailPlanId(railPlanId);
- tmstrainLoadingResult.setResultWagonNo(resultWagonNo);
- //通过车皮号计算车皮标重
- tmstrainLoadingResult.setResultBillableTonnage(new BigDecimal(calculateWagonWeight(resultWagonNo)));
- tmstrainLoadingResult.setResultLoadingDate(new Date());
- tmstrainLoadingResult.setResultClass((String) map.get("resultClass")); //班别
- tmstrainLoadingResult.setInsertUpdateRemark((String) map.get("insertUpdateRemark"));
- tmstrainLoadingResult.setInsertTime(new Date());
- tmstrainLoadingResult.setInsertUsername("admin");
- tmstrainLoadingResult.setResultType(new BigDecimal(4)); //内转类型
- tmstrainLoadingResult.setDeleted(new BigDecimal(0)); //逻辑删除0
- //添加车皮装车实绩
- count += tmstrainLoadingResultMapper.insertSelective(tmstrainLoadingResult);
- //添加火运总实绩
- TmstrainTotalResult tmstrainTotalResult = new TmstrainTotalResult();
- trainTotalId = tmstrainTotalResultMapper.selectMaxId();
- tmstrainTotalResult.setId(trainTotalId); //获取添加火运总实绩主键ID
- //添加火运装车实绩ID
- tmstrainTotalResult.setLoadingId(maxId);
- count += tmstrainTotalResultMapper.insertSelective(tmstrainTotalResult);
- }
- //通过物资扫描结果匹配出库主键ID
- Integer outBoundResultId = tmstrainLoadingResultMapper.getOutBoundResultIdByScan((String) map.get("scanCodeText"));
- //通过出库主键查询汽运总实绩ID和物资ID
- Map<String, Object> mesMap = tmstrainLoadingResultMapper.getResultTotalIdByOutBoundResultId(outBoundResultId);
- //通过汽运总实绩ID查询该订单是否已装车(扫一件即可全部扫描上)
- Integer resultId = tmstrainLoadingResultMapper.getTrainTruckIdByTruckTotalId(DataChange.dataToBigDecimal(mesMap.get("resultTotalId")));
- if(resultId != null){
- return 1; //如果已经扫描上了则默认已装车
- }
- //添加火运物资中间表
- TmstrainTruckTotalResult tmstrainTruckTotalResult = new TmstrainTruckTotalResult();
- tmstrainTruckTotalResult.setResultId(tmstrainTruckTotalResultMapper.selectMaxId());//添加火运物资中间表主键ID
- tmstrainTruckTotalResult.setTmstruckTotalResultId(DataChange.dataToBigDecimal(mesMap.get("resultTotalId")));//添加汽运总实绩ID
- tmstrainTruckTotalResult.setMaterialId(DataChange.dataToBigDecimal(mesMap.get("materialId")));//添加物资ID
- tmstrainTruckTotalResult.setTmstrainTotalResultId(trainTotalId);//添加火运总实绩ID
- tmstrainTruckTotalResult.setLoadStatus(new BigDecimal(0)); //已装车
- tmstrainTruckTotalResult.setInsertTime(new Date());
- tmstrainTruckTotalResult.setInsertUsername("admin");
- count += tmstrainTruckTotalResultMapper.insertSelective(tmstrainTruckTotalResult);
- return count;
- }
- @Override
- public List<Map<String, Object>> selectLoadByResultId(BigDecimal resultId) {
- return tmstrainLoadingResultMapper.selectLoadByResultId(resultId);
- }
- @Override
- public List<Map<String, Object>> getSendStationName() {
- return tmstrainLoadingResultMapper.getSendStationName();
- }
- @Override
- public List<Map<String, Object>> getArrivalStationName() {
- return tmstrainLoadingResultMapper.getArrivalStationName();
- }
- @Override
- public List<Map<String, Object>> getBatchId() {
- return tmstrainLoadingResultMapper.getBatchId();
- }
- @Override
- public List<Map<String, Object>> getWagonNo(Map<String, Object> map) {
- return tmstrainLoadingResultMapper.getWagonNo(map);
- }
- /**
- * 内转查询车皮物资信息
- * @param map
- * @return
- */
- @Override
- public List<Map<String, Object>> getMaterialAndCarByLoadingId(Map<String, Object> map) {
- return tmstrainLoadingResultMapper.getMaterialAndCarByLoadingId(map);
- }
- /**
- * 根据物资名和外轮船名查询采购订单号
- * @param map
- * @return
- */
- @Override
- public List<Map<String, Object>> getPurchaseOrderList(Map<String, Object> map) {
- return tmstrainLoadingResultMapper.getPurchaseOrderList(map);
- }
- //万州港出库
- @Override
- @Transactional
- public int addWarehouseOutResult(Map<String, Object> map) {
- //根据车皮号计算标重
- BigDecimal resultType =DataChange.dataToBigDecimal(map.get("resultType"));
- List<Map<String,Object>> wagonList =(List<Map<String, Object>>) map.get("wagonList");
- for (Map<String,Object> wagon:wagonList){
- //根据车皮号计算车皮标重
- String wagonNo =(String) wagon.get("wagonNo");
- //根据采购订单号查找批次
- String purchaseNo =(String) map.get("purchaseNo");
- BigDecimal batchId=null;
- List<Map<String, Object>> batchInfocatoryByNo = tmstrainLoadingResultMapper.getBatchInfocatoryByNo(purchaseNo);
- if (batchInfocatoryByNo.size() >= 1){
- Map<String, Object> map1 = batchInfocatoryByNo.get(0);
- batchId =DataChange.dataToBigDecimal(map1.get("batchId"));
- }
- int wagonWeight = calculateWagonWeight(wagonNo);
- map.put("resultTonnage",wagonWeight);
- //如果订单类型为采购进口矿火运(万州港---达州 || 万州港--老区轨道衡) 添加总车皮标重传输给港存库
- if(resultType.intValue() == 1){
- int i = addOutWarehouse(map, batchId);
- return i;
- }
- }
- return 0;
- }
- }
|