package com.steerinfo.dil.service.impl; import com.steerinfo.dil.mapper.AmsshipCargoTransferResultMapper; import com.steerinfo.dil.model.TmsshipShipLocation; import com.steerinfo.dil.util.DataChange; import com.steerinfo.framework.mapper.IBaseMapper; import com.steerinfo.framework.service.impl.BaseServiceImpl; import com.steerinfo.dil.model.OmsshipShipmentInstructions; import com.steerinfo.dil.mapper.OmsshipShipmentInstructionsMapper; import com.steerinfo.dil.service.IOmsshipShipmentInstructionsService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; /** * OmsshipShipmentInstructions服务实现: * @author generator * @version 1.0-SNAPSHORT 2021-08-20 03:05 * 类描述 * 修订历史: * 日期:2021-08-20 * 作者:generator * 参考: * 描述:OmsshipShipmentInstructions服务实现 * @see null * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved. */ @Service(value = "omsshipShipmentInstructionsService") public class OmsshipShipmentInstructionsServiceImpl implements IOmsshipShipmentInstructionsService { @Autowired private OmsshipShipmentInstructionsMapper omsshipShipmentInstructionsMapper; @Autowired private AmsshipCargoTransferResultMapper amsshipCargoTransferResultMapper; /** * 通过主键查询 * @param shipmentInstructionsId * @return */ @Override public OmsshipShipmentInstructions selectByKey(BigDecimal shipmentInstructionsId) { return omsshipShipmentInstructionsMapper.selectByPrimaryKey(shipmentInstructionsId); } /** * 展示所有装船指令 * @param mapVal * @return */ @Override public List> selectAll(Map mapVal) { List> mapList = omsshipShipmentInstructionsMapper.selectAll(mapVal); if (mapList.size()!=0){ for (Map map:mapList){ map.put("shipperName","四川省达州钢铁集团有限公司"); } } return mapList; } /** * 逻辑删除 * @param shipmentInstructionsId * @return */ @Override public int deleteByPrimaryKey(BigDecimal shipmentInstructionsId) { OmsshipShipmentInstructions omsshipShipmentInstructions = selectByKey(shipmentInstructionsId); omsshipShipmentInstructions.setDeleted(new BigDecimal(1)); return omsshipShipmentInstructionsMapper.updateByPrimaryKeySelective(omsshipShipmentInstructions); } /** * 新增装船指令 * @param map * @return */ @Override public int insert(Map map) { OmsshipShipmentInstructions omsshipShipmentInstructions=new OmsshipShipmentInstructions(); String userId = (String) map.get("userId"); if (userId!=null){ String userName = amsshipCargoTransferResultMapper.getUserNameByUserId(userId); //设置新增用户名 omsshipShipmentInstructions.setInsertUsername(userName); } BigDecimal shipmentInstructionsId = omsshipShipmentInstructionsMapper.selectInstructionId(); omsshipShipmentInstructions.setShipmentInstructionsId(shipmentInstructionsId); BigDecimal batchId = DataChange.dataToBigDecimal(map.get("batchId")); Map map1 = omsshipShipmentInstructionsMapper.getPortAndPier(batchId); BigDecimal pierId = (BigDecimal) map1.get("pierId"); BigDecimal portId = (BigDecimal) map1.get("portId"); omsshipShipmentInstructions.setRecipientCarrierId(pierId); omsshipShipmentInstructions.setPortCarrierId(portId); omsshipShipmentInstructions.setBatchId(batchId); //新增合计吨位 omsshipShipmentInstructions.setInstructionsTotalTonnage(DataChange.dataToBigDecimal(map.get("instructionsTotalTonnage"))); //新增装船日期 long instructionTime =(long) map.get("instructionTime"); omsshipShipmentInstructions.setInstructionTime(new Date(instructionTime)); // 设置常规字段 omsshipShipmentInstructions.setInsertTime(new Date()); omsshipShipmentInstructions.setInsertUpdateRemark("无"); omsshipShipmentInstructions.setDeleted(new BigDecimal(0)); omsshipShipmentInstructions.setInstructionIssueStatus("未下发"); return omsshipShipmentInstructionsMapper.insertSelective(omsshipShipmentInstructions); } /** * 通过主键修改 * @param omsshipShipmentInstructions * @return */ @Override public int updateByPrimaryKey(Map omsshipShipmentInstructions) { BigDecimal instructionsId = DataChange.dataToBigDecimal(omsshipShipmentInstructions.get("shipmentInstructionsId")); BigDecimal instructionsTotalTonnage = DataChange.dataToBigDecimal(omsshipShipmentInstructions.get("instructionsTotalTonnage")); long instructionTime = (long)omsshipShipmentInstructions.get("instructionTime"); OmsshipShipmentInstructions omsshipShipmentInstructions1=new OmsshipShipmentInstructions(); omsshipShipmentInstructions1.setShipmentInstructionsId(instructionsId); omsshipShipmentInstructions1.setInstructionsTotalTonnage(instructionsTotalTonnage); omsshipShipmentInstructions1.setInstructionTime(new Date(instructionTime)); return omsshipShipmentInstructionsMapper.updateByPrimaryKeySelective(omsshipShipmentInstructions1); } // @Override // public BigDecimal selectMaxId() { // return omsshipShipmentInstructionsMapper.selectMaxId(); // } /** * 查询装船指令表单 * @param shipmentInstructionsId * @return */ @Override public List> selectShipmentInstructions(BigDecimal shipmentInstructionsId) { return omsshipShipmentInstructionsMapper.selectShipmentInstructions(shipmentInstructionsId); } /** * 修改下发状态 * @param shipmentInstructionsId * @return */ @Override public int updateIssueStatus(BigDecimal shipmentInstructionsId) { OmsshipShipmentInstructions omsshipShipmentInstructions = selectByKey(shipmentInstructionsId); omsshipShipmentInstructions.setInstructionIssueStatus("已下发"); return omsshipShipmentInstructionsMapper.updateByPrimaryKeySelective(omsshipShipmentInstructions); } /** * 获得批次下拉框 * @return */ @Override public List> getBatchId() { return omsshipShipmentInstructionsMapper.getBatchId(); } @Override public List> getPortList(Map map) { return omsshipShipmentInstructionsMapper.getPortList(map); } //修改状态 @Override public int updateByPrimaryKeySelective(OmsshipShipmentInstructions omsshipShipmentInstructions) { return omsshipShipmentInstructionsMapper.updateByPrimaryKeySelective(omsshipShipmentInstructions); } }