123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- package com.steerinfo.dil.service.impl;
- import com.steerinfo.dil.feign.TmsFeign;
- import com.steerinfo.dil.mapper.TmstruckReceiptResultMapper;
- import com.steerinfo.dil.mapper.UtilsMapper;
- import com.steerinfo.dil.model.TmstruckReceiptResult;
- import com.steerinfo.dil.model.TmstruckWeightResult;
- import com.steerinfo.dil.mapper.TmstruckWeightResultMapper;
- import com.steerinfo.dil.service.ITmstruckWeightResultService;
- import com.steerinfo.dil.util.DataChange;
- import io.swagger.annotations.ApiModel;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.math.BigDecimal;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- /**
- * 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
- TmstruckWeightResultMapper tmstruckWeightResultMapper;
- @Autowired
- TmsFeign tmsFeign;
- @Autowired
- UtilsServiceImpl utilsService;
- @Autowired
- UtilsMapper utilsMapper;
- @Autowired
- TmstruckReceiptResultMapper tmstruckReceiptResultMapper;
- /**
- * 接收计量实绩信息
- * "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",
- * "resultNetWeightTime":"2021-09-10 09:05:22",
- * "resultPoundNo":"Bd123456780",
- * "materialId":40
- * @param mapList
- * @return
- */
- @Override
- public int receiveTmsTruckWeightResult(List<Map<String, Object>> mapList) throws Exception {
- //遍历列表
- int count = 0;
- for (Map<String, Object> map : mapList) {
- //通过传来的运输订单号 与 物资ID查询计重实绩ID
- Map<String, Object> stringObjectMap = tmstruckWeightResultMapper.selectTotalIdByOrderNo(map);
- if(stringObjectMap == null){
- throw new Exception(map.get("orderNumber") + "没有此订单信息或物资信息(" + map.get("materialId") + ")错误");
- }
- map.putAll(stringObjectMap);
- TmstruckWeightResult tmstruckWeightResult = generateWeightResult(map);
- count += tmstruckWeightResultMapper.updateByPrimaryKeySelective(tmstruckWeightResult);
- BigDecimal orderType = DataChange.dataToBigDecimal(map.get("orderTypee"));
- if("5678".contains(orderType.toString())){
- if(map.get("resultTareWeightTime") != null ){
- //如果是采购订单 计皮后自动完成签收
- autoReceipt((String) map.get("orderNumber"));
- }
- }
- //路段顺序号+1
- utilsService.updateOrderLineSequence(map);
- //推送数据
- utilsService.pushMesToWebsocket((String) stringObjectMap.get("capacityNumber"), "计量");
- }
- return count;
- }
- /**
- * 生成计量实体类
- * @param map
- * @return
- */
- public TmstruckWeightResult generateWeightResult(Map<String, Object> map) throws Exception {
- TmstruckWeightResult tmstruckWeightResult = new TmstruckWeightResult();
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
- tmstruckWeightResult.setId(DataChange.dataToBigDecimal(map.get("weightTaskResultId")));
- BigDecimal orderType = DataChange.dataToBigDecimal(map.get("orderTypee"));
- //磅单号
- tmstruckWeightResult.setResultPoundNo((String) map.get("resultPoundNo"));
- //如果是采购订单 先计毛再计皮
- if("5678".contains(orderType.toString())){
- String resultCrossWeightTime = (String) map.get("resultCrossWeightTime");
- //如果毛重数据为空 则是第一次计量为毛重 此时第一次计量时间放皮重时间里面
- if(resultCrossWeightTime == null || resultCrossWeightTime.length() == 0){
- //设置毛重时间
- 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.setResultTarePlaceId(new BigDecimal(tareId));
- //设置毛重
- BigDecimal resultTareWeight = DataChange.dataToBigDecimal(map.get("resultTareWeight"));
- tmstruckWeightResult.setResultGrossWeight(resultTareWeight);
- tmstruckWeightResult.setInsertTime(new Date());
- tmstruckWeightResult.setInsertUsername("admin");
- }else {
- //设置皮重汽车衡
- Integer tareId = tmstruckWeightResultMapper.selectTruckCalculateId((String) map.get("resultTareCalculateNumber"));
- if(tareId == null){
- throw new Exception("没有此皮重汽车衡:" + map.get("resultTareCalculateNumber"));
- }
- tmstruckWeightResult.setResultTarePlaceId(new BigDecimal(tareId));
- //设置毛重汽车衡
- Integer crossId = tmstruckWeightResultMapper.selectTruckCalculateId((String) map.get("resultCrossCalculateNumber"));
- if(crossId == null){
- throw new Exception("没有此毛重汽车衡:" + map.get("resultCrossCalculateNumber"));
- }
- tmstruckWeightResult.setResultGrossPlaceId(new BigDecimal(crossId));
- //毛重
- BigDecimal resultCrossWeight = DataChange.dataToBigDecimal(map.get("resultCrossWeight"));
- tmstruckWeightResult.setResultGrossWeight(resultCrossWeight);
- //皮重
- BigDecimal resultTareWeight = DataChange.dataToBigDecimal(map.get("resultTareWeight"));
- tmstruckWeightResult.setResultTareWeight(resultTareWeight);
- //净重
- tmstruckWeightResult.setResultNetWeight(DataChange.dataToBigDecimal(map.get("resultNetWeight")));
- //设置皮重时间
- String resultTareWeightTime = (String) map.get("resultTareWeightTime");
- tmstruckWeightResult.setResultTareWeightTime(sdf.parse(resultTareWeightTime));
- //设置毛重时间
- String resultGrossWeightTime = (String) map.get("resultCrossWeightTime");
- tmstruckWeightResult.setResultGrossWeightTime(sdf.parse(resultGrossWeightTime));
- tmstruckWeightResult.setUpdateTime(new Date());
- tmstruckWeightResult.setUpdateUsername("admin");
- }
- }
- return tmstruckWeightResult;
- }
- /**
- * 自动签收
- * @return
- */
- public void autoReceipt(String orderNumber){
- TmstruckReceiptResult tmstruckReceiptResult = new TmstruckReceiptResult();
- //通过运输订单号查询总实绩ID
- BigDecimal resultTotalId = utilsMapper.getTotalIdByOrderNumber(orderNumber);
- tmstruckReceiptResult.setResultTotalId(resultTotalId);
- tmstruckReceiptResult.setStatus(new BigDecimal(1));
- tmstruckReceiptResult.setInsertUsername("admin");
- tmstruckReceiptResult.setInsertTime(new Date());
- tmstruckReceiptResultMapper.updateByTotalResultId(tmstruckReceiptResult);
- System.out.println(orderNumber + "收货成功");
- }
- }
|