123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364 |
- package com.steerinfo.dil.service.impl;
- import com.steerinfo.dil.feign.WmshboundFeign;
- import com.steerinfo.dil.mapper.AmsshipCargoTransferResultMapper;
- import com.steerinfo.dil.mapper.DilBatchMapper;
- import com.steerinfo.dil.model.AmsshipCargoTransferResult;
- import com.steerinfo.dil.model.DilBatch;
- import com.steerinfo.dil.model.OmsshipShipmentInstructions;
- import com.steerinfo.dil.util.DataChange;
- import com.steerinfo.framework.mapper.IBaseMapper;
- import com.steerinfo.framework.service.impl.BaseServiceImpl;
- import com.steerinfo.dil.model.AmsshipDeliveryNotice;
- import com.steerinfo.dil.mapper.AmsshipDeliveryNoticeMapper;
- import com.steerinfo.dil.service.IAmsshipDeliveryNoticeService;
- import com.steerinfo.framework.utils.misc.IdGenerator;
- import com.steerinfo.framework.utils.upload.UploadUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import org.springframework.web.multipart.MultipartFile;
- import java.io.File;
- import java.math.BigDecimal;
- import java.text.SimpleDateFormat;
- import java.util.*;
- /**
- * AmsshipDeliveryNotice服务实现:
- * @author generator
- * @version 1.0-SNAPSHORT 2021-08-18 03:54
- * 类描述
- * 修订历史:
- * 日期:2021-08-18
- * 作者:generator
- * 参考:
- * 描述:AmsshipDeliveryNotice服务实现
- * @see null
- * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
- */
- @Service(value = "amsshipDeliveryNoticeService")
- public class AmsshipDeliveryNoticeServiceImpl implements IAmsshipDeliveryNoticeService {
- @Autowired
- private AmsshipDeliveryNoticeMapper amsshipDeliveryNoticeMapper;
- @Autowired
- private AmsshipCargoTransferResultMapper cargoTransferResultMapper;
- @Autowired
- private DilBatchServiceImpl dilBatchService;
- @Autowired
- private DilBatchMapper dilBatchMapper;
- @Autowired
- private WmshboundFeign wmshboundFeign;
- //查询所有数据
- @Override
- public List<Map<String, Object>> selectShipDeliveryNotice(Map<String, Object> mapVal) {
- return amsshipDeliveryNoticeMapper.selectShipDeliveryNotice(mapVal);
- }
- //新增发货通知
- @Override
- @Transactional(rollbackFor = {Exception.class})
- public int insert(Map<String,Object> map) throws Exception{
- int i=0;
- String inFactoryShipName=null;
- AmsshipDeliveryNotice amsshipDeliveryNotice=new AmsshipDeliveryNotice();
- String userId =(String) map.get("userId");
- String userName=null;
- if (userId!=null){
- userName = cargoTransferResultMapper.getUserNameByUserId(userId);
- }
- BigDecimal noticeId = amsshipDeliveryNoticeMapper.selectNoticeId();
- amsshipDeliveryNotice.setNoticeId(noticeId);
- amsshipDeliveryNotice.setNoticeCommerceMethod((String) map.get("noticeCommerceMethod"));
- amsshipDeliveryNotice.setNoticeHandoverMethod((String) map.get("noticeHandoverMethod"));
- if (map.get("portId")!=null) {
- amsshipDeliveryNotice.setPortId(DataChange.dataToBigDecimal(map.get("portId")));
- }
- if (map.get("noticePortConstructionFee")!=null) {
- amsshipDeliveryNotice.setNoticePortConstructionFee(DataChange.dataToBigDecimal(map.get("noticePortConstructionFee")));
- }
- long noticeDeliveryTime =(long) map.get("noticeDeliveryTime");
- amsshipDeliveryNotice.setNoticeDeliveryTime(new Date(noticeDeliveryTime));
- amsshipDeliveryNotice.setNoticePileFreeDays(DataChange.dataToBigDecimal(map.get("noticePileFreeDays")));
- amsshipDeliveryNotice.setNoticeDistributionStatus(new BigDecimal(0));
- if (map.get("purchaseContractUnitPrice")!=null) {
- amsshipDeliveryNotice.setPurchaseContractUnitPrice(DataChange.dataToBigDecimal(map.get("purchaseContractUnitPrice")));
- }
- if (map.get("isNeedBonded")!=null){
- amsshipDeliveryNotice.setIsNeedBonded((String) map.get("isNeedBonded"));
- }else {
- throw new Exception("请选择是否需要宁波报税");
- }
- if (map.get("purchaseContractMoisture")!=null) {
- amsshipDeliveryNotice.setPurchaseContractMoisture((String) map.get("purchaseContractMoisture"));
- }
- if (map.get("purchaseContractQualityindex")!=null) {
- amsshipDeliveryNotice.setPurchaseContractUnitPrice(DataChange.dataToBigDecimal(map.get("purchaseContractQualityindex")));
- }
- if (map.get("tfeContent")!=null) {
- amsshipDeliveryNotice.setTfeContent((String) map.get("tfeContent"));
- }
- if (map.get("silicaContent")!=null){
- amsshipDeliveryNotice.setSilicaContent((String)map.get("silicaContent"));
- }
- if (map.get("aluminaContent")!=null){
- amsshipDeliveryNotice.setAluminaContent((String)map.get("aluminaContent"));
- }
- if (map.get("phosphorusContent")!=null){
- amsshipDeliveryNotice.setPhosphorusContent((String)map.get("phosphorusContent"));
- }
- if (map.get("manganeseContent")!=null){
- amsshipDeliveryNotice.setManganeseContent((String)map.get("manganeseContent"));
- }
- //设置S含量
- if(map.get("sulfurcontent")!=null){
- amsshipDeliveryNotice.setSulfurContent((String) map.get("sulfurcontent"));
- }
- amsshipDeliveryNotice.setInsertTime(new Date());
- amsshipDeliveryNotice.setInsertUsername(userId);
- amsshipDeliveryNotice.setDeleted(new BigDecimal(0));
- //联系人
- amsshipDeliveryNotice.setResultContactPerson((String) map.get("resultContactPerson"));
- amsshipDeliveryNotice.setResultTelephoneFax((String) map.get("resultTelephoneFax"));
- //货代信息
- amsshipDeliveryNotice.setResultFreightForwardingInfo((String) map.get("resultFreightForwardingInfo"));
- //备注
- amsshipDeliveryNotice.setResultMemo((String) map.get("resultMemo"));
- //放货数量
- amsshipDeliveryNotice.setResultNumberOfLoans(DataChange.dataToBigDecimal(map.get("resultNumberOfLoans")));
- //货权转移送达单位
- amsshipDeliveryNotice.setCargoId(DataChange.dataToBigDecimal(map.get("cargoId")));
- //收货人单位
- amsshipDeliveryNotice.setGroupId(DataChange.dataToBigDecimal(map.get("groupId")));
- amsshipDeliveryNotice.setMaterialTypeId(DataChange.dataToBigDecimal(map.get("materialTypeId")));
- amsshipDeliveryNotice.setIsNeedPortFee((String) map.get("isNeedPortFee"));
- amsshipDeliveryNotice.setIsNeedPortCharge((String) map.get("isNeedPortDisCharge"));
- amsshipDeliveryNotice.setCargoImageUrl((String) map.get("cargoPictureUrl"));
- BigDecimal portId= DataChange.dataToBigDecimal(map.get("portId"));
- //生成批次
- //根据portId查找portName
- String portName = dilBatchMapper.getPortName(DataChange.dataToBigDecimal(map.get("portId")));
- if (portName==null||portName.equals("")){
- throw new Exception("港口不存在");
- }
- SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Date time =new Date(noticeDeliveryTime);
- inFactoryShipName = portName + sdf.format(time);
- map.put("inFactoryShipName",inFactoryShipName);
- //新增批次
- Map<String, Object> map1 = dilBatchService.insertBatchId(map);
- BigDecimal batchIdInfacotryId =DataChange.dataToBigDecimal(map1.get("batchIdInfacotryId"));
- amsshipDeliveryNotice.setBatchId(batchIdInfacotryId);
- //调用港口入库
- // Map<String,Object> mapValue = new HashMap<>();
- // mapValue.put("batchId",map1.get("batchIds"));
- // mapValue.put("portId",portId);
- // mapValue.put("resultMaterialNumber",DataChange.dataToBigDecimal(map.get("resultNumberOfLoans")));
- // if(mapValue.get("batchId") ==null || DataChange.dataToBigDecimal(mapValue.get("batchId")).compareTo(new BigDecimal(0))==0){
- // //如果是录入批次,则传新增批次的批次id
- // mapValue.put("batchId",map1.get("batchId"));
- // }
- // wmshboundFeign.addWarehousingResult(mapValue);
- i += amsshipDeliveryNoticeMapper.insertSelective(amsshipDeliveryNotice);
- return i ;
- }
- @Override
- public int sendDeliveryNotice(Map<String, Object> map) {
- BigDecimal noticeId =DataChange.dataToBigDecimal(map.get("noticeId"));
- AmsshipDeliveryNotice amsshipDeliveryNotice=new AmsshipDeliveryNotice();
- amsshipDeliveryNotice.setNoticeId(noticeId);
- amsshipDeliveryNotice.setNoticeDistributionStatus(new BigDecimal(1));
- return amsshipDeliveryNoticeMapper.updateByPrimaryKeySelective(amsshipDeliveryNotice);
- }
- @Override
- public int deleteByPrimaryKey(BigDecimal noticeId) {
- return amsshipDeliveryNoticeMapper.deleteByPrimaryKey(noticeId);
- }
- @Override
- public int updateByPrimaryKey(BigDecimal noticeId) {
- return amsshipDeliveryNoticeMapper.updateByPrimaryKey(noticeId);
- }
- @Override
- public AmsshipDeliveryNotice selectByPrimaryKey(BigDecimal noticeId) {
- return amsshipDeliveryNoticeMapper.selectByPrimaryKey(noticeId);
- }
- @Override
- public List<Map<String, Object>> getResultNumber() {
- return amsshipDeliveryNoticeMapper.getResultNumber();
- }
- //货权转移下拉框
- @Override
- public List<Map<String, Object>> getcarrier() {
- return amsshipDeliveryNoticeMapper.getcarrier();
- }
- ////采购订单号下拉框
- // @Override
- // public List<Map<String, Object>> getOrderNo() {
- // return amsshipDeliveryNoticeMapper.getOrderNo();
- // }
- @Override
- public List<Map<String, Object>> getShipper() {
- return amsshipDeliveryNoticeMapper.getShipper();
- }
- @Override
- public int deleteDeliveryNotice(Map<String, Object> map) {
- AmsshipDeliveryNotice amsshipDeliveryNotice=new AmsshipDeliveryNotice();
- amsshipDeliveryNotice.setNoticeId(DataChange.dataToBigDecimal(map.get("noticeId")));
- amsshipDeliveryNotice.setDeleted(new BigDecimal(1));
- return amsshipDeliveryNoticeMapper.updateByPrimaryKeySelective(amsshipDeliveryNotice);
- }
- @Override
- public List<Map<String, Object>> selectByNoticeId(Integer noticeId) {
- return amsshipDeliveryNoticeMapper.selectByNoticeId(noticeId);
- }
- //更新发货通知
- @Override
- @Transactional(rollbackFor = {Exception.class})
- public int updateAmsDeliveryNotice(Map<String, Object> map) throws Exception {
- int i=0;
- BigDecimal noticeId = DataChange.dataToBigDecimal(map.get("noticeId"));
- AmsshipDeliveryNotice amsshipDeliveryNotice=new AmsshipDeliveryNotice();
- if (map.get("noticeId")!=null) {
- amsshipDeliveryNotice.setNoticeId(noticeId);
- }
- //贸易方式
- if (map.get("noticeCommerceMethod")!=null) {
- amsshipDeliveryNotice.setNoticeHandoverMethod((String) map.get("noticeCommerceMethod"));
- }
- //交接方式
- if (map.get("noticeHandoverMethod")!=null) {
- amsshipDeliveryNotice.setNoticeCommerceMethod((String) map.get("noticeHandoverMethod"));
- }
- //港口id
- if (map.get("portId")!=null) {
- amsshipDeliveryNotice.setPortId(DataChange.dataToBigDecimal(map.get("portId")));
- }
- //港建费金额
- if (map.get("noticePortConstructionFee")!=null) {
- amsshipDeliveryNotice.setNoticePortConstructionFee(DataChange.dataToBigDecimal(map.get("noticePortConstructionFee")));
- }
- //放货时间
- if (map.get("noticeDeliveryTime")!=null) {
- long noticeDeliveryTime = (long) map.get("noticeDeliveryTime");
- amsshipDeliveryNotice.setNoticeDeliveryTime(new Date(noticeDeliveryTime));
- }
- //免堆天数
- if (map.get("noticePileFreeDays")!=null){
- amsshipDeliveryNotice.setNoticePileFreeDays(DataChange.dataToBigDecimal(map.get("noticePileFreeDays")));
- }
- if (map.get("isNeedBonded")!=null){
- amsshipDeliveryNotice.setIsNeedBonded((String) map.get("isNeedBonded"));
- }else {
- throw new Exception("请选择是否需要宁波报税");
- }
- //单价
- if (map.get("purchaseContractUnitPrice")!=null){
- amsshipDeliveryNotice.setPurchaseContractUnitPrice(DataChange.dataToBigDecimal(map.get("purchaseContractUnitPrice")));
- }
- //合同水分
- if (map.get("purchaseContractMoisture")!=null){
- amsshipDeliveryNotice.setPurchaseContractMoisture((String) map.get("purchaseContractMoisture"));
- }
- //微元素含量
- if (map.get("tfeContent")!=null){
- amsshipDeliveryNotice.setTfeContent((String) map.get("tfeContent"));
- }
- if (map.get("silicaContent")!=null){
- amsshipDeliveryNotice.setSilicaContent((String) map.get("silicaContent"));
- }
- if (map.get("aluminaContent")!=null){
- amsshipDeliveryNotice.setAluminaContent((String) map.get("aluminaContent"));
- }
- if (map.get("phosphorusContent")!=null){
- amsshipDeliveryNotice.setPhosphorusContent((String) map.get("phosphorusContent"));
- }
- if (map.get("manganeseContent")!=null){
- amsshipDeliveryNotice.setManganeseContent((String) map.get("manganeseContent"));
- }
- //联系人
- if (map.get("resultContactPerson")!=null){
- amsshipDeliveryNotice.setResultContactPerson((String) map.get("resultContactPerson"));
- }
- if (map.get("resultTelephoneFax")!=null){
- amsshipDeliveryNotice.setResultTelephoneFax((String) map.get("resultTelephoneFax"));
- }
- if (map.get("resultFreightForwardingInfo")!=null){
- amsshipDeliveryNotice.setResultFreightForwardingInfo((String) map.get("resultFreightForwardingInfo"));
- }
- if (map.get("resultMemo")!=null){
- amsshipDeliveryNotice.setResultMemo((String) map.get("resultMemo"));
- }
- if (map.get("resultNumberOfLoans")!=null){
- amsshipDeliveryNotice.setResultNumberOfLoans(DataChange.dataToBigDecimal(map.get("resultNumberOfLoans")));
- }
- if (map.get("cargoId")!=null){
- amsshipDeliveryNotice.setCargoId(DataChange.dataToBigDecimal(map.get("cargoId")));
- }
- if (map.get("groupId")!=null){
- amsshipDeliveryNotice.setGroupId(DataChange.dataToBigDecimal(map.get("groupId")));
- }
- if (map.get("inFactoryShipName")!=null||map.get("materialId")!=null||map.get("foreignShipName")!=null){
- //判断如果外轮船名或物资id或进厂船名不为空
- //根据物资和外轮船名判断批次是否存在
- BigDecimal batchFacotryId = dilBatchMapper.selectBatchIdByName(map);
- //如果存在则取批次id
- if (batchFacotryId != null && batchFacotryId.intValue() != 0){
- amsshipDeliveryNotice.setBatchId(batchFacotryId);
- }else {
- Map<String, Object> map1 = dilBatchService.insertBatchId(map);
- if (map1 != null) {
- System.out.println("新增批次成功");
- BigDecimal batchIdInfacotryId = DataChange.dataToBigDecimal(map1.get("batchIdInfacotryId"));
- amsshipDeliveryNotice.setBatchId(batchIdInfacotryId);
- } else {
- System.out.println("新增批次失败");
- }
- }
- }
- if (map.get("materialTypeId")!=null){
- amsshipDeliveryNotice.setMaterialTypeId(DataChange.dataToBigDecimal(map.get("materialTypeId")));
- }
- if (map.get("isNeedPortDisCharge")!=null){
- amsshipDeliveryNotice.setIsNeedPortCharge((String) map.get("isNeedPortDisCharge"));
- }
- if (map.get("isNeedPortFee")!=null){
- amsshipDeliveryNotice.setIsNeedPortFee((String) map.get("isNeedPortFee"));
- }
- if (map.get("cargoPictureUrl")!=null){
- amsshipDeliveryNotice.setCargoImageUrl((String) map.get("cargoPictureUrl"));
- }
- if (map.get("userId")!=null){
- amsshipDeliveryNotice.setUpdateUsername((String) map.get("userId"));
- }
- amsshipDeliveryNotice.setUpdateTime(new Date());
- i += amsshipDeliveryNoticeMapper.updateByPrimaryKeySelective(amsshipDeliveryNotice);
- return i;
- }
- @Override
- public String getLoadDeliveryNotice(Integer noticeId) {
- return amsshipDeliveryNoticeMapper.getLoadDeliveryNotice(noticeId);
- }
- }
|