123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 |
- package com.steerinfo.dil.service.impl;
- import com.steerinfo.dil.feign.OmsFeign;
- import com.steerinfo.dil.feign.QmsFeign;
- import com.steerinfo.dil.mapper.RulesMapper;
- import com.steerinfo.dil.mapper.TmstruckReceiptResultMapper;
- import com.steerinfo.dil.mapper.TmstruckWeightResultMapper;
- import com.steerinfo.dil.mapper.UtilsMapper;
- import com.steerinfo.dil.model.TmstruckReceiptResult;
- import com.steerinfo.dil.model.TmstruckWeightResult;
- import com.steerinfo.dil.service.ITmstruckWeightResultService;
- 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.DecimalFormat;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- /**
- * TmstruckWeightResult服务实现:
- * @author generator
- * @version 1.0-SNAPSHORT 2021-09-09 02:21
- * 类描述
- * 修订历史:
- * 日期:2021-09-09
- * 作者:generator
- * 参考:
- * 描述:TmstruckWeightResult服务实现
- * @see null
- * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
- */
- @Service(value = "tmstruckWeightResultService")
- public class TmstruckWeightResultServiceImpl implements ITmstruckWeightResultService {
- @Autowired
- private TmstruckWeightResultMapper tmstruckWeightResultMapper;
- @Autowired
- private TmstruckReceiptResultMapper tmstruckReceiptResultMapper;
- @Autowired
- private UtilsServiceImpl utilsService;
- @Autowired
- private UtilsMapper utilsMapper;
- @Autowired
- private QmsFeign qmsFeign;
- @Autowired
- private RulesServiceImpl rulesService;
- @Autowired
- private RulesMapper rulesMapper;
- @Autowired
- OmsFeign omsFeign;
- @Autowired
- private TmstruckLoadResultServiceImpl tmstruckLoadResultService;
- @Autowired
- private TmstruckLeaveFactoryResultServiceImpl tmstruckLeaveFactoryResultService;
- /**
- * 查询所有计毛实绩
- * @param map
- * @return
- */
- @Override
- public List<Map<String, Object>> getAllJiMaoResult(Map<String, Object> map) {
- Integer orderType = (Integer) map.get("orderTypee");
- switch (orderType){
- case 1:
- case 2:
- case 3:
- return tmstruckWeightResultMapper.getXSAllJiMaoResult(map); // apiID:212
- case 4:
- return tmstruckWeightResultMapper.getSteelNzJiMaoResult(map); //apiId:264
- case 5:
- case 6:
- case 7:
- case 8:
- return tmstruckWeightResultMapper.getCGAllJiMaoResult(map); //apiId:102
- case 9:
- return tmstruckWeightResultMapper.getImportedDomesticNzJiMaoResult(map); // apiID:354
- case 10:
- return tmstruckWeightResultMapper.getImportedDomesticNzJiMao2Result(map); // apiID:354
- case 11:
- return tmstruckWeightResultMapper.getInFactoryJiLiangResult(map); //apiId: 358
- case 12:
- return tmstruckWeightResultMapper.getSporadicSuppliesJiMiaoResult(map);//apiId:405
- case 13:
- return tmstruckWeightResultMapper.getFactorySkinSporadicJiMiao(map);//apiId:422
- }
- return null;
- }
- /**
- * 查询所有计皮实绩
- * @param map
- * @return
- */
- @Override
- public List<Map<String, Object>> getAllJiPiResult(Map<String, Object> map) {
- Integer orderType = (Integer) map.get("orderTypee");
- switch (orderType){
- case 1:
- case 2:
- case 3:
- return tmstruckWeightResultMapper.getXSAllJiPiResult(map); //apiId:211
- case 4:
- return tmstruckWeightResultMapper.getSteelNzJiPiResult(map); //apiId:262
- case 5:
- case 6:
- case 7:
- case 8:
- return tmstruckWeightResultMapper.getCGAllJiPiResult(map); // apiId: 104
- case 9:
- return tmstruckWeightResultMapper.getImportedDomesticNzJiPiResult(map);// apiId: 104
- case 10:
- return tmstruckWeightResultMapper.getImportedDomesticNzJiPi2Result(map);// apiId: 104
- case 11:
- break;
- case 12:
- return tmstruckWeightResultMapper.getSporadicSuppliesJiPiResult(map);//apiId:392
- case 13:
- return tmstruckWeightResultMapper.getFactorySkinSporadicJIPi(map); //apiId=401
- }
- return null;
- }
- /**
- * 派单时新增计重实绩
- * 总实绩ID、计皮点、计毛点
- * @return
- */
- @Override
- public int addWeightResult(Map<String, Object> map) {
- TmstruckWeightResult tmstruckWeightResult = new TmstruckWeightResult();
- //生成最大主键ID
- tmstruckWeightResult.setWeightTaskResultId(tmstruckWeightResultMapper.selectMaxId());
- BigDecimal resultTotalId = DataChange.dataToBigDecimal(map.get("resultTotalId"));
- tmstruckWeightResult.setResultTotalId(resultTotalId);
- //通过总实绩ID查询订单类型
- if(map.get("isdeduct") == null){
- //添加是否需要扣水扣杂
- Integer orderType = tmstruckWeightResultMapper.getOrderTypeByTotalId(resultTotalId);
- if("67".contains(orderType.toString()) || orderType == 10){
- tmstruckWeightResult.setIsdeduct(new BigDecimal(1));
- }
- }else {
- tmstruckWeightResult.setIsdeduct(DataChange.dataToBigDecimal(map.get("isdeduct")));
- }
- // 添加物资Id (销售、内转到异地库)
- if(map.get("materialId") != null)
- tmstruckWeightResult.setMaterialId(DataChange.dataToBigDecimal(map.get("materialId")));
- // 添加路段顺序号
- if(map.get("grossSegmentSqe") != null) //毛重路段顺序号
- tmstruckWeightResult.setGrossSegmentSqe(DataChange.dataToBigDecimal(map.get("grossSegmentSqe")));
- if(map.get("tareSegmentSqe") != null) //皮重路段顺序号
- tmstruckWeightResult.setTareSegmentSqe(DataChange.dataToBigDecimal(map.get("tareSegmentSqe")));
- return tmstruckWeightResultMapper.insertSelective(tmstruckWeightResult);
- }
- /**
- * 更新计量实绩 计皮点 计毛点 皮重
- * @param map
- */
- public int updateWeightResult(Map<String, Object> map){
- TmstruckWeightResult tmstruckWeightResult = new TmstruckWeightResult();
- //通过订单Id 查询路段顺序号为最小的 且没有净重的计量实绩ID
- BigDecimal id = tmstruckWeightResultMapper.getWeightIdBySQEAndOrderId(map);
- tmstruckWeightResult.setId(id);
- if(map.get("tarePlaceId") != null){ //如果皮重汽车衡不为空 更新皮重汽车衡
- tmstruckWeightResult.setResultTarePlaceId(DataChange.dataToBigDecimal(map.get("tarePlaceId")));
- }
- if(map.get("grossPlaceId") != null){//如果毛重汽车衡不为空 更新毛重汽车衡
- tmstruckWeightResult.setResultGrossPlaceId(DataChange.dataToBigDecimal(map.get("grossPlaceId")));
- }
- if(map.get("resultTareWeight")!= null){ //如果皮重不为空 更新皮重
- tmstruckWeightResult.setResultTareWeight(DataChange.dataToBigDecimal(map.get("resultTareWeight")));
- }
- return tmstruckWeightResultMapper.updateByPrimaryKeySelective(tmstruckWeightResult);
- }
- /**
- * 自动签收
- * @return
- */
- public int autoReceipt(BigDecimal resultTotalId){
- TmstruckReceiptResult tmstruckReceiptResult = new TmstruckReceiptResult();
- tmstruckReceiptResult.setResultTotalId(resultTotalId);
- tmstruckReceiptResult.setStatus(new BigDecimal(1));
- tmstruckReceiptResult.setInsertUsername("admin");
- tmstruckReceiptResult.setInsertTime(new Date());
- return tmstruckReceiptResultMapper.updateByTotalResultId(tmstruckReceiptResult);
- }
- /**
- * 多拼计算计毛汽车衡
- * @param map
- */
- public int calculateTruckCalculate(Map<String, Object> map, Integer resultTotalId){
- //通过总实绩ID查询订单Id
- Integer orderId = utilsService.getOrderIdByTotalId(resultTotalId);
- //查询未装车的装车实绩
- List<Map<String, Object>> list = rulesService.judgeLastMaterial(new BigDecimal(orderId));
- Map<String, Object> mesMap = new HashMap<>(); //用于查询更新存放数据map
- mesMap.put("orderId", orderId);
- int i = 0;
- if(list.size() == 0){
- //如果是最后一拼则走出厂称 计算出厂称
- mesMap.put("materialId", map.get("materialId"));
- mesMap.put("nature", 1);
- Integer calculate = rulesService.calculateWeighbridge(mesMap);
- //更新汽车衡
- mesMap.put("grossPlaceId", calculate);
- i += updateWeightResult(mesMap);
- }else {
- //如果后面还有物资未装车 则走拼装秤 10号秤 (固定数据)
- mesMap.put("materialId", map.get("materialId"));
- mesMap.put("grossPlaceId", 10);
- i += updateWeightResult(mesMap);
- }
- return i;
- }
- /**
- * 单拼销售计算汽车衡
- * @return
- */
- public int calculateTruckCalculateByOne(Map<String, Object> map, Integer type){
- String orderNumber = (String) map.get("orderNumber");
- //通过运输订单号查找物资ID、订单ID
- Map<String, Object> oIdAndMidMap = tmstruckWeightResultMapper.getOrderIdAndMaterialIdByOrderNum(orderNumber);
- //通过物资ID计算汽车衡
- if(type == 1){
- //1:进厂
- oIdAndMidMap.put("nature", type); //1: 进厂秤
- int calculateId = rulesService.calculateWeighbridge(oIdAndMidMap);
- oIdAndMidMap.put("tarePlaceId", calculateId);
- }else if(type == 2){
- //2:出厂
- oIdAndMidMap.put("nature", type); //2: 出厂称
- int calculateId = rulesService.calculateWeighbridge(oIdAndMidMap);
- oIdAndMidMap.put("grossPlaceId", calculateId);
- }
- return updateWeightResult(oIdAndMidMap);
- }
- }
|