123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- package com.steerinfo.dil.service.impl;
- import com.steerinfo.dil.feign.BmsShipFeign;
- import com.steerinfo.dil.feign.BmsTruckFeign;
- import com.steerinfo.dil.feign.OmsFeign;
- import com.steerinfo.dil.mapper.TmstruckEnfactoryResultMapper;
- import com.steerinfo.dil.mapper.TmstruckLeaveFactoryResultMapper;
- import com.steerinfo.dil.model.TmstruckLeaveFactoryResult;
- import com.steerinfo.dil.service.ITmstruckLeaveFactoryResultService;
- import com.steerinfo.dil.service.IUtilsService;
- import com.steerinfo.dil.util.DataChange;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import java.math.BigDecimal;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- /**
- * TmstruckLeaveFactoryResult服务实现:
- * @author generator
- * @version 1.0-SNAPSHORT 2021-09-11 10:32
- * 类描述
- * 修订历史:
- * 日期:2021-09-11
- * 作者:generator
- * 参考:
- * 描述:TmstruckLeaveFactoryResult服务实现
- * @see null
- * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
- */
- @Service(value = "tmstruckLeaveFactoryResultService")
- public class TmstruckLeaveFactoryResultServiceImpl implements ITmstruckLeaveFactoryResultService {
- @Autowired
- private TmstruckLeaveFactoryResultMapper tmstruckLeaveFactoryResultMapper;
- @Autowired
- private TmstruckEnfactoryResultMapper tmstruckEnfactoryResultMapper;
- @Autowired
- private IUtilsService utilsService;
- @Autowired
- private BmsShipFeign bmsShipFeign;
- @Autowired
- private BmsTruckFeign bmsTruckFeign;
- @Autowired
- OmsFeign omsFeign;
- /**
- * 查看运输线路是否为出厂
- * @param orderNumber
- * @return
- */
- @Override
- public Integer selectTransportRoute(String orderNumber) {
- return tmstruckLeaveFactoryResultMapper.selectTransportRoute(orderNumber);
- }
- /**
- * 派单后新增出厂实绩
- * 总实绩ID、线路终点
- * @param map
- * @return
- */
- @Override
- public int addLeaveFactory(Map<String, Object> map) {
- TmstruckLeaveFactoryResult tmstruckLeaveFactoryResult = new TmstruckLeaveFactoryResult();
- //添加主键
- tmstruckLeaveFactoryResult.setId(tmstruckLeaveFactoryResultMapper.selectMaxId());
- //添加总实绩ID
- tmstruckLeaveFactoryResult.setResultTotalId(DataChange.dataToBigDecimal(map.get("resultTotalId")));
- //添加路段顺序号
- tmstruckLeaveFactoryResult.setSegmentSqe(DataChange.dataToBigDecimal(map.get("segmentSqe")));
- //添加门岗ID 出厂门岗为线路的终点
- // tmstruckLeaveFactoryResult.setGatepostId(DataChange.dataToBigDecimal(map.get("lineEndNodeId")));
- return tmstruckLeaveFactoryResultMapper.insertSelective(tmstruckLeaveFactoryResult);
- }
- @Override
- public Map<String, Object> getTruckFactoryResult(String nu) {
- return tmstruckLeaveFactoryResultMapper.getTruckFactoryResult(nu);
- }
- /**
- * APP查询出厂信息
- * @param orderNumber
- * @return
- */
- @Override
- public List<Map<String, Object>> getLeaveFactoryList(String orderNumber) {
- return tmstruckLeaveFactoryResultMapper.getLeaveFactoryList(orderNumber);
- }
- /**
- * 查询所有的出厂实绩
- * 1:销售订单;2:焦炭发运计划;3:水渣发运计划;4:内转到异地库;5:采购辅料订单;6:采购老区燃料订单;
- * 7:采购新区燃料订单;8:采购进口矿(万州-厂内);9:采购内转(达州-厂内);10:采购内转(老区-厂内); 11:厂内内转
- * @param map
- * @return
- */
- @Override
- public List<Map<String, Object>> getLeaveFactoryResult(Map<String, Object> map) {
- Integer orderType = (Integer) map.get("orderTypee");
- switch (orderType){
- case 1:
- case 2:
- case 3:
- return tmstruckLeaveFactoryResultMapper.selectAllLeaveFacatoryForSale(map);
- case 4:
- return tmstruckLeaveFactoryResultMapper.selectSteelNzLeaveFactory(map);
- case 5:
- case 6:
- case 7:
- case 8:
- return tmstruckLeaveFactoryResultMapper.getCGLeaveFactoryResult(map); //apiId:110
- case 9:
- return tmstruckLeaveFactoryResultMapper.getImportedDomesticNzEnFactoryResult(map); //apiId:110
- case 10:
- break;
- case 11:
- return tmstruckLeaveFactoryResultMapper.getInFactoryOutFactoryResult(map); //apiId:361
- }
- return null;
- }
- /**
- * 通过 PDA 出厂
- * 1:销售订单;2:焦炭发运计划;3:水渣发运计划;4:内转到异地库;5:采购辅料订单;6:采购老区燃料订单;
- * 7:采购新区燃料订单;8:采购进口矿(万州-厂内);9:采购内转(达州-厂内);10:采购内转(老区-厂内); 11:厂内内转
- * @param map
- * @return
- */
- public int leaveFactoryByPDA(Map<String, Object> map){
- int i = 0;
- String orderNumber = (String) map.get("orderNumber");
- String substring = orderNumber.substring(0, orderNumber.length() - 1);
- map.putAll(tmstruckLeaveFactoryResultMapper.selectResultId(substring));
- BigDecimal orderType = DataChange.dataToBigDecimal(map.get("orderTypee"));
- i += updateLeaveResultByPDA(map); //更新出厂实绩
- switch (orderType.intValue()){
- case 1:
- break;
- case 2:
- break;
- case 3:
- break;
- case 4:
- break;
- case 5:
- case 6:
- case 7:
- case 8:
- case 9:
- i += utilsService.updateOrderStatus(map, 2); // 修改运输订单状态 2:已结束
- // i += utilsService.updateCapacityStatus(map, 0); //修改运力状态 0:空闲中
- //采购出厂 通过feign调用新增详单
- // try {
- // bmsShipFeign.addDetailsOrder(DataChange.dataToBigDecimal(map.get("resultId"))); // 出厂实绩Id
- // bmsTruckFeign.addDetailsOrder(DataChange.dataToBigDecimal(map.get("orderId"))); // 运单ID
- // } catch (Exception e) {
- // e.printStackTrace();
- // }
- break;
- case 10:
- break;
- case 11:
- }
- //路段顺序号 + 1
- i += utilsService.updateOrderLineSequence(map, 1);
- omsFeign.pushMesToWebsocket(map);
- return i;
- }
- /**
- * 更新出厂实绩
- * @param mapValue {运输订单号:orderNumber 门岗名称:gatepostName}
- * @return
- */
- public int updateLeaveResultByPDA(Map<String, Object> mapValue){
- TmstruckLeaveFactoryResult tmstruckLeaveFactoryResult = new TmstruckLeaveFactoryResult();
- tmstruckLeaveFactoryResult.setResultId(DataChange.dataToBigDecimal(mapValue.get("resultId")));
- //通过门岗名称获取门岗ID
- Integer gatepostId = tmstruckEnfactoryResultMapper.selectGatepostIdByGatepostName((String) mapValue.get("gatepostName"));
- if(gatepostId != null){
- tmstruckLeaveFactoryResult.setGatepostId(new BigDecimal(gatepostId));
- }
- //设置常规字段 添加 出厂时间 和 出厂方式
- tmstruckLeaveFactoryResult.setResultOutGateTime(new Date());
- tmstruckLeaveFactoryResult.setResultOutMode("手动抬杠");
- tmstruckLeaveFactoryResult.setInsertUsername("admin");
- tmstruckLeaveFactoryResult.setInsertTime(new Date());
- return tmstruckLeaveFactoryResultMapper.updateByPrimaryKeySelective(tmstruckLeaveFactoryResult);
- }
- /**
- * 通过总实绩Id修改出厂实绩出厂门岗
- * @param resultTotalId
- * @param gatepostId
- * @return
- */
- public int updateLeaveFactoryGatepostId(Integer resultTotalId, Integer gatepostId){
- TmstruckLeaveFactoryResult tmstruckLeaveFactoryResult = new TmstruckLeaveFactoryResult();
- //通过总实绩ID查询出产实绩
- BigDecimal resultId = tmstruckLeaveFactoryResultMapper.getResultIdByTotalId(resultTotalId);
- tmstruckLeaveFactoryResult.setResultId(resultId);
- tmstruckLeaveFactoryResult.setGatepostId(new BigDecimal(gatepostId));
- return tmstruckLeaveFactoryResultMapper.updateByPrimaryKeySelective(tmstruckLeaveFactoryResult);
- }
- }
|