123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309 |
- 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.util.DataChange;
- import com.steerinfo.dil.util.NoUtil;
- import com.steerinfo.framework.controller.RESTfulResult;
- import com.steerinfo.dil.service.ITmsshipLoadShipResultService;
- import org.apache.poi.ss.formula.functions.T;
- 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.Date;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- /**
- * TmsshipLoadShipResult服务实现:
- * @author generator
- * @version 1.0-SNAPSHORT 2021-08-19 08:47
- * 类描述
- * 修订历史:
- * 日期:2021-08-19
- * 作者:generator
- * 参考:
- * 描述:TmsshipLoadShipResult服务实现
- * @see null
- * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
- */
- @Service(value = "tmsshipLoadShipResultService")
- public class TmsshipLoadShipResultServiceImpl implements ITmsshipLoadShipResultService {
- @Autowired
- TmsshipLoadShipResultMapper tmsshipLoadShipResultMapper;
- @Autowired
- TmsshipTotalResultServiceImpl tmsshipTotalResultService;
- @Autowired
- TmsshipEntryWharyResultMapper tmsshipEntryWharyResultMapper;
- @Autowired
- TmsshipOutWharyResultMapper tmsshipOutWharyResultMapper;
- @Autowired
- TmsshipShipLocationMapper tmsshipShipLocationMapper;
- @Autowired
- TmsshipWaterQualityResultMapper tmsshipWaterQualityResultMapper;
- @Autowired
- WmshboundFeign wmshboundFeign;
- @Autowired
- NoUtil noUtil;
- /**
- * 新增抵港,离岗,装船实绩
- * @param map
- * @return
- */
- @Override
- @Transactional
- public int insertLoadShip(Map<String,Object> map) throws Exception {
- int i=0;
- Map<String,Object> mapVal = (Map<String, Object>) map.get("mapVal");
- Map<String,Object> rowMap = (Map<String, Object>) map.get("rowMap");
- String userId =(String) mapVal.get("userId");
- TmsshipLoadShipResult tmsshipLoadShipResult = new TmsshipLoadShipResult();
- TmsshipEntryWharyResult tmsshipEntryWharyResult = new TmsshipEntryWharyResult();
- BigDecimal orderId = new BigDecimal((Integer) rowMap.get("orderId"));
- BigDecimal batchInfactoryId= DataChange.dataToBigDecimal(rowMap.get("batchInfactoryId"));
- Map<String,Object> ppMap = tmsshipLoadShipResultMapper.getPortAndPier(batchInfactoryId);
- BigDecimal batchId =DataChange.dataToBigDecimal(rowMap.get("batchId"));
- BigDecimal pierId = (BigDecimal) ppMap.get("pierId");
- Date noticeDeliveryTime = (Date) ppMap.get("noticeDeliveryTime");
- BigDecimal startPortId = DataChange.dataToBigDecimal(ppMap.get("startPortId"));
- String resultMemo = (String) mapVal.get("resultMemo");
- Date resultArrivalTime = new Date((Long)mapVal.get("resultArrivalTime"));
- tmsshipLoadShipResult.setResultArrivalPortTime(resultArrivalTime);
- BigDecimal totalResultId = tmsshipTotalResultService.getResultTotalId(orderId);
- tmsshipEntryWharyResult.setTotalResultId(totalResultId);
- BigDecimal resultEntryId = tmsshipEntryWharyResultMapper.selectEntryId();
- tmsshipEntryWharyResult.setResultId(resultEntryId);
- String resultEntryNumber = noUtil.setResultNo("DG",resultEntryId);
- tmsshipEntryWharyResult.setResultNumber(resultEntryNumber);
- tmsshipEntryWharyResult.setWharyId(pierId);
- //抵港时间
- tmsshipEntryWharyResult.setResultArrivalTime(resultArrivalTime);
- if (resultMemo!=null) {
- tmsshipEntryWharyResult.setResultMemo(resultMemo);
- }
- //离港确认人
- String resultOutWharyName =(String) mapVal.get("resultOutWharyName");
- long resultOutWharyTime = (long) mapVal.get("resultOutWharyTime");
- tmsshipEntryWharyResult.setResultPortDeclarationName(resultOutWharyName);
- // 设置常规字段
- tmsshipEntryWharyResult.setInsertTime(new Date());
- tmsshipEntryWharyResult.setInsertUsername(userId);
- TmsshipOutWharyResult tmsshipOutWharyResult = new TmsshipOutWharyResult();
- tmsshipOutWharyResult.setTotalResultId(totalResultId);
- BigDecimal resultOutId = tmsshipOutWharyResultMapper.selectOutId();
- tmsshipOutWharyResult.setResultId(resultOutId);
- String resultOutNumber = noUtil.setResultNo("LG",resultOutId);
- tmsshipOutWharyResult.setResultNumber(resultOutNumber);
- tmsshipOutWharyResult.setResultOutWharyName(resultOutWharyName);
- tmsshipOutWharyResult.setResultOutWharyTime(new Date(resultOutWharyTime));
- tmsshipOutWharyResult.setWharyId(pierId);
- if (resultMemo!=null) {
- tmsshipOutWharyResult.setResultMemo(resultMemo);
- }
- // 设置常规字段
- tmsshipOutWharyResult.setInsertTime(new Date());
- tmsshipOutWharyResult.setInsertUsername(userId);
- // 装船
- BigDecimal resultId = tmsshipLoadShipResultMapper.selectLoadId();
- //通过总实绩id查找船运起运港口
- //根据港口和批次Id查询实时库存id
- Map<String,Object> idMap=new HashMap<>();
- idMap.put("batchInfactoryId",batchId);
- idMap.put("downSwimPortId",startPortId);
- //查询实时库存
- Map<String,Object> gmMap = tmsshipLoadShipResultMapper.selectGmIdByPortId(idMap);
- if (gmMap==null) {
- return -2;
- }else {
- BigDecimal gmId = DataChange.dataToBigDecimal(gmMap.get("gmId"));
- tmsshipLoadShipResult.setRwarehouseMaterialId(gmId);
- }
- //获得实装数量
- BigDecimal resultActualInstallations = new BigDecimal((String) mapVal.get("resultActualInstallations"));
- //装船时间
- Date resultLoadShipDate = new Date((Long) mapVal.get("resultLoadShipDate"));
- tmsshipLoadShipResult.setResultLoadShipDate(resultLoadShipDate);
- //是否清场
- String resultIsClear = (String) mapVal.get("resultIsClear");
- tmsshipLoadShipResult.setResultIsclear(resultIsClear);
- if (resultIsClear.equals("清场")){
- wmshboundFeign.clearWmshGridMaterial(gmMap);
- }else {
- Map<String,Object> outBoundMap=new HashMap<>();
- //装船入下游港口港存库库存
- outBoundMap.put("portId",rowMap.get("downSwimPortId"));
- outBoundMap.put("batchId",rowMap.get("batchId"));
- outBoundMap.put("resultMaterialNumber",resultActualInstallations);
- wmshboundFeign.addResult(outBoundMap);
- }
- String resultNumber = noUtil.setResultNo("ZC",resultEntryId);
- tmsshipLoadShipResult.setResultId(resultId);
- tmsshipLoadShipResult.setTotalResultId(totalResultId);
- tmsshipLoadShipResult.setBatchId(batchInfactoryId);
- tmsshipLoadShipResult.setResultDeliveryDate(noticeDeliveryTime);
- tmsshipLoadShipResult.setResultOutPortTime(new Date(resultOutWharyTime));
- tmsshipEntryWharyResult.setResultPortDeclarationName((String) map.get("resultOutWharyName"));
- tmsshipLoadShipResult.setResultActualInstallations(resultActualInstallations);
- tmsshipLoadShipResult.setResultNumber(resultNumber);
- tmsshipLoadShipResult.setInsertUpdateRemark(resultMemo);
- // 设置常规字段
- tmsshipLoadShipResult.setInsertTime(new Date());
- tmsshipLoadShipResult.setInsertUsername(userId);
- tmsshipLoadShipResult.setDeleted(new BigDecimal(0));
- i += tmsshipEntryWharyResultMapper.insertSelective(tmsshipEntryWharyResult);
- i += tmsshipOutWharyResultMapper.insertSelective(tmsshipOutWharyResult);
- //获取当前位置
- String instructionsShipPosition =(String)rowMap.get("instructionsShipPosition");
- //新增位置作业,未到闸
- TmsshipShipLocation tmsshipShipLocation=new TmsshipShipLocation();
- BigDecimal locationId = tmsshipShipLocationMapper.selectLocationId();
- tmsshipShipLocation.setLocationId(locationId);
- tmsshipShipLocation.setTotalResultId(totalResultId);
- tmsshipShipLocation.setLocationStatus("未到闸船舶");
- tmsshipShipLocation.setLocationValue(instructionsShipPosition);
- tmsshipShipLocation.setInsertTime(new Date());
- tmsshipShipLocation.setLocationRouteTime(new Date());
- tmsshipShipLocation.setDeleted(new BigDecimal(0));
- i += tmsshipShipLocationMapper.insertSelective(tmsshipShipLocation);
- i += tmsshipLoadShipResultMapper.insertSelective(tmsshipLoadShipResult);
- //新增水分质检
- TmsshipWaterQualityResult tmsshipWaterQualityResult=new TmsshipWaterQualityResult();
- BigDecimal qualityId = tmsshipWaterQualityResultMapper.selectQualityId();
- tmsshipWaterQualityResult.setTotalResultId(totalResultId);
- tmsshipWaterQualityResult.setResultId(qualityId);
- //计划日期
- long resultPlannedDate = (long) mapVal.get("resultPlannedDate");
- tmsshipWaterQualityResult.setResultPlannedDate(new Date(resultPlannedDate));
- //预计放货日期
- long expectNoticeDate = (long) mapVal.get("expectNoticeDate");
- tmsshipWaterQualityResult.setResultEsDeliveryDate(new Date(expectNoticeDate));
- //是否需要拼装
- String isNeedAssemble =(String) mapVal.get("isNeedAssemble");
- tmsshipWaterQualityResult.setIsNeedAssemble(isNeedAssemble);
- //单价
- BigDecimal waterUnitPrice =DataChange.dataToBigDecimal(mapVal.get("waterUnitPrice"));
- tmsshipWaterQualityResult.setWaterUnitPrice(waterUnitPrice);
- //空载
- String resultEmptyHeavyWaterMeter = (String) mapVal.get("resultEmptyHeavyWaterMeter");
- tmsshipWaterQualityResult.setResultEmptyHeavyWaterMeter(resultEmptyHeavyWaterMeter);
- BigDecimal contractMoistureValue = DataChange.dataToBigDecimal(mapVal.get("contractMoistureValue"));
- tmsshipWaterQualityResult.setResultMoistureContent(contractMoistureValue);
- //检测费
- BigDecimal resultInspectionFees = DataChange.dataToBigDecimal(map.get("resultInspectionFees"));
- tmsshipWaterQualityResult.setResultInspectionFees(resultInspectionFees);
- BigDecimal moistureTonnage =DataChange.dataToBigDecimal(mapVal.get("moistureTonnage"));
- tmsshipWaterQualityResult.setResultWaterTonnage(moistureTonnage);
- i+=tmsshipWaterQualityResultMapper.insertSelective(tmsshipWaterQualityResult);
- return i;
- }
- /**
- * 根据主键删除装船
- * @param resultId
- * @return
- */
- @Override
- public int deleteLoadShip(BigDecimal resultId) {
- TmsshipLoadShipResult tmsshipLoadShipResult = selectLoadShip(resultId);
- tmsshipLoadShipResult.setDeleted(new BigDecimal(1));
- return tmsshipLoadShipResultMapper.updateByPrimaryKeySelective(tmsshipLoadShipResult);
- }
- /**
- * 根据主键查询装船
- * @param resultId
- * @return
- */
- @Override
- public TmsshipLoadShipResult selectLoadShip(BigDecimal resultId) {
- return tmsshipLoadShipResultMapper.selectByPrimaryKey(resultId);
- }
- /**
- * 根据主键修改
- * @param
- * @return
- */
- @Override
- public int updateLoadShip(Map<String,Object> map) {
- int i=0;
- TmsshipLoadShipResult tmsshipLoadShipResult=new TmsshipLoadShipResult();
- tmsshipLoadShipResult.setResultId(DataChange.dataToBigDecimal(map.get("resultId")));
- long resultLoadShipDate =(long) map.get("resultLoadShipDate");
- tmsshipLoadShipResult.setResultLoadShipDate(new Date(resultLoadShipDate));
- tmsshipLoadShipResult.setResultActualInstallations(DataChange.dataToBigDecimal(map.get("resultActualInstallations")));
- long resultOutPortTime =(long) map.get("resultOutPortTime");
- tmsshipLoadShipResult.setResultOutPortTime(new Date(resultOutPortTime));
- long resultArrivalPortTime = (long) map.get("resultArrivalPortTime");
- tmsshipLoadShipResult.setResultArrivalPortTime(new Date(resultArrivalPortTime));
- tmsshipLoadShipResult.setUpdateTime(new Date());
- tmsshipLoadShipResult.setUpdateUsername((String) map.get("userId"));
- String resultIsClear = (String) map.get("resultIsClear");
- tmsshipLoadShipResult.setResultIsclear(resultIsClear);
- TmsshipWaterQualityResult tmsshipWaterQualityResult=new TmsshipWaterQualityResult();
- tmsshipWaterQualityResult.setResultId(DataChange.dataToBigDecimal(map.get("waterQualiyResultId")));
- long planDate =(long) map.get("planDate");
- tmsshipWaterQualityResult.setResultPlannedDate(new Date(planDate));
- long planDeliveryDate =(long) map.get("planDeliveryDate");
- tmsshipWaterQualityResult.setResultEsDeliveryDate(new Date(planDeliveryDate));
- String resultHeavyWeight =(String) map.get("resultHeavyWeight");
- tmsshipWaterQualityResult.setResultEmptyHeavyWaterMeter(resultHeavyWeight);
- TmsshipOutWharyResult tmsshipOutWharyResult=new TmsshipOutWharyResult();
- tmsshipOutWharyResult.setResultId(DataChange.dataToBigDecimal(map.get("outWharyResultId")));
- tmsshipOutWharyResult.setResultOutWharyTime(new Date(resultOutPortTime));
- tmsshipOutWharyResult.setResultOutWharyName((String) map.get("resultOutPortName"));
- i += tmsshipOutWharyResultMapper.updateByPrimaryKeySelective(tmsshipOutWharyResult);
- i += tmsshipLoadShipResultMapper.updateByPrimaryKeySelective(tmsshipLoadShipResult);
- i +=tmsshipWaterQualityResultMapper.updateByPrimaryKeySelective(tmsshipWaterQualityResult);
- return i;
- }
- /**
- * 查询所有装船信息
- * @param mapVal
- * @return
- */
- @Override
- public List<Map<String, Object>> selectLoadShipList(Map<String, Object> mapVal) {
- return tmsshipLoadShipResultMapper.selectLoadShipList(mapVal);
- }
- /**
- * 查询一条装船指令下的总重量
- * @param instructionsId
- * @return
- */
- @Override
- public BigDecimal selectAllWeight(BigDecimal instructionsId) {
- return tmsshipLoadShipResultMapper.selectAllWeight(instructionsId);
- }
- /**
- * 查询装船表单
- * @param resultId
- * @return
- */
- @Override
- public List<Map<String, Object>> getLoadShip(BigDecimal resultId) {
- return tmsshipLoadShipResultMapper.selectLoadShip(resultId);
- }
- /**
- * 根据物资名称和外轮船名得到批次
- * @param mapVal
- * @return
- */
- @Override
- public BigDecimal getBatchId(Map<String, Object> mapVal) {
- return tmsshipLoadShipResultMapper.getBatchId(mapVal);
- }
- }
|