|
@@ -3,6 +3,8 @@ package com.ruoyi.shipping.service.impl;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
import java.util.function.Function;
|
|
@@ -14,13 +16,13 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.ruoyi.common.constant.UserConstants;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
+import com.ruoyi.common.core.domain.entity.SysDictData;
|
|
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.shipping.domain.*;
|
|
|
-import com.ruoyi.shipping.excel.TCntrnoExcel;
|
|
|
-import com.ruoyi.shipping.excel.TWarehousebillsCntritemsExcel;
|
|
|
+import com.ruoyi.shipping.excel.*;
|
|
|
import com.ruoyi.shipping.mapper.*;
|
|
|
import com.ruoyi.system.mapper.SysDictDataMapper;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
@@ -32,6 +34,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.ruoyi.shipping.service.ITCntrnoService;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import static com.ruoyi.common.utils.poi.Excel.filter;
|
|
@@ -169,6 +172,54 @@ public class TCntrnoServiceImpl implements ITCntrnoService {
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
+ public AjaxResult updateAirForceStation(List<TCntrno> tCntrno) {
|
|
|
+ int update = 0;
|
|
|
+ if (CollectionUtils.isNotEmpty(tCntrno)) {
|
|
|
+ for (TCntrno cntrno : tCntrno) {
|
|
|
+ String remark = cntrno.getRemark();
|
|
|
+ cntrno.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ cntrno.setUpdateBy(SecurityUtils.getUsername());
|
|
|
+ TCntrno cnTrNoByfNo = tCntrnoMapper.selectTCnTrNoByfNo(cntrno.getfNo());
|
|
|
+ if (cnTrNoByfNo == null){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return AjaxResult.error("箱号:"+cntrno.getfNo()+"系统中不存在请维护");
|
|
|
+ }else {
|
|
|
+ cntrno.setfId(cnTrNoByfNo.getfId());
|
|
|
+ //更改t_cntro表信息
|
|
|
+ update = tCntrnoMapper.updateTCntrno((cntrno));
|
|
|
+ }
|
|
|
+ //保存历史信息
|
|
|
+ TCntrno cntrnoById = tCntrnoMapper.selectTCntrnoById(cntrno.getfId());
|
|
|
+ if (cntrnoById.getfStatus().equals("T") || cntrnoById.getfStatus().equals("正常")) {
|
|
|
+ cntrnoById.setfStatus("T");
|
|
|
+ } else {
|
|
|
+ cntrnoById.setfStatus("F");
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(cntrno.getfMblno())) {//提单号
|
|
|
+ cntrnoById.setfMblno(cntrno.getfMblno());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(cntrno.getfVoy())) {//航次
|
|
|
+ cntrnoById.setfVoy(cntrno.getfVoy());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(cntrno.getfVsl())) {//船名
|
|
|
+ cntrnoById.setfVsl(cntrno.getfVsl());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(remark)) {
|
|
|
+ cntrnoById.setRemark(remark);
|
|
|
+ }
|
|
|
+ TCntrtracking setfield = setfield(cntrnoById);
|
|
|
+ update = tCntrtrackingMapper.insertTCntrtracking(setfield);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (update <= 0 ){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return AjaxResult.error("保存场站信息失败");
|
|
|
+ }
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
public int updateTCntrnoMessage(TCntrno tCntrno) {
|
|
|
tCntrno.setUpdateTime(DateUtils.getNowDate());
|
|
|
tCntrno.setUpdateBy(SecurityUtils.getUsername());
|
|
@@ -505,6 +556,246 @@ public class TCntrnoServiceImpl implements ITCntrnoService {
|
|
|
return tCntrnoMapper.getTcntrnoFno(tCntrno);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public AjaxResult importAirForceStation(MultipartFile file) throws Exception{
|
|
|
+ List<TCntrno> tCntrno = new ArrayList<>();
|
|
|
+ InputStream inputStream = null;
|
|
|
+ inputStream = file.getInputStream();
|
|
|
+ String originalFilename = file.getOriginalFilename();
|
|
|
+ Workbook workbook = null;
|
|
|
+ if (originalFilename.endsWith("xls")){
|
|
|
+ workbook = WorkbookFactory.create(inputStream);
|
|
|
+ }else if (originalFilename.endsWith("xlsx")){
|
|
|
+ workbook = new XSSFWorkbook(inputStream);
|
|
|
+ }
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+ int line = 0;
|
|
|
+ for (Row rows : sheet) {
|
|
|
+ line++;
|
|
|
+ if (rows.getRowNum() == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ TCntrno companyMsg = new TCntrno();
|
|
|
+ for (int a = 0; a < rows.getPhysicalNumberOfCells(); a++) {
|
|
|
+ Cell cell = rows.getCell(a);
|
|
|
+ String value = filter(sheet.getRow(0), CellReference.convertNumToColString(cell.getColumnIndex()));
|
|
|
+ switch (value) {
|
|
|
+ case "箱动态":
|
|
|
+ //设置单元格类型
|
|
|
+ cell.setCellType(CellType.STRING);
|
|
|
+ companyMsg.setOpctnstatusName(cell.getStringCellValue());
|
|
|
+ if (StringUtils.isEmpty(cell.getStringCellValue())) {
|
|
|
+ return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少箱动态");
|
|
|
+ }
|
|
|
+ String fOpCTnsTaTus = sysDictDataMapper.selectDictValue("f_opctnstatus", cell.getStringCellValue());
|
|
|
+ if (StringUtils.isEmpty(fOpCTnsTaTus)){
|
|
|
+ return AjaxResult.error("系统缺少箱动态"+cell.getStringCellValue()+"请维护");
|
|
|
+ }
|
|
|
+ companyMsg.setfOpctnstatus(fOpCTnsTaTus);
|
|
|
+ break;
|
|
|
+ case "箱号":
|
|
|
+ //设置单元格类型
|
|
|
+ cell.setCellType(CellType.STRING);
|
|
|
+ if (StringUtils.isEmpty(cell.getStringCellValue())) {
|
|
|
+ return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少箱号");
|
|
|
+ }
|
|
|
+ companyMsg.setfNo(cell.getStringCellValue());
|
|
|
+ break;
|
|
|
+ case "动态日期":
|
|
|
+ //设置单元格类型
|
|
|
+ cell.setCellType(CellType.STRING);
|
|
|
+ if (StringUtils.isEmpty(cell.getStringCellValue())) {
|
|
|
+ return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少动态日期");
|
|
|
+ }
|
|
|
+ Date tDate = new Date();
|
|
|
+ long localOffset = tDate.getTimezoneOffset() * 60000; //系统时区偏移 1900/1/1 到 1970/1/1 的 25569 天
|
|
|
+ tDate.setTime((long) ((Double.valueOf(cell.getStringCellValue()) - 25569) * 24 * 3600 * 1000 + localOffset));
|
|
|
+ companyMsg.setUpdateTime(tDate);
|
|
|
+ break;
|
|
|
+ case "船名":
|
|
|
+ //设置单元格类型
|
|
|
+ cell.setCellType(CellType.STRING);
|
|
|
+ /*if (StringUtils.isEmpty(cell.getStringCellValue())) {
|
|
|
+ return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少船名");
|
|
|
+ }*/
|
|
|
+ companyMsg.setfVsl(cell.getStringCellValue());
|
|
|
+ break;
|
|
|
+ case "航次":
|
|
|
+ //设置单元格类型
|
|
|
+ cell.setCellType(CellType.STRING);
|
|
|
+ /*if (StringUtils.isEmpty(cell.getStringCellValue())) {
|
|
|
+ return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少航次");
|
|
|
+ }*/
|
|
|
+ companyMsg.setfVoy(cell.getStringCellValue());
|
|
|
+ break;
|
|
|
+ case "重量":
|
|
|
+ //设置单元格类型
|
|
|
+ cell.setCellType(CellType.STRING);
|
|
|
+ /*if (StringUtils.isEmpty(cell.getStringCellValue())) {
|
|
|
+ return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少重量");
|
|
|
+ }*/
|
|
|
+ BigDecimal bigDecimal = new BigDecimal(cell.getStringCellValue());
|
|
|
+ companyMsg.setfBoxWeight(bigDecimal);
|
|
|
+ break;
|
|
|
+ case "港口名称":
|
|
|
+ //设置单元格类型
|
|
|
+ cell.setCellType(CellType.STRING);
|
|
|
+ if (StringUtils.isEmpty(cell.getStringCellValue())) {
|
|
|
+ return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少港口名称");
|
|
|
+ }
|
|
|
+ String fTypes = sysDictDataMapper.selectDictValue("f_types", cell.getStringCellValue());
|
|
|
+ if (StringUtils.isEmpty(fTypes)){
|
|
|
+ return AjaxResult.error("系统缺少地点类型"+cell.getStringCellValue()+"请维护");
|
|
|
+ }
|
|
|
+ companyMsg.setPort(fTypes);
|
|
|
+ companyMsg.setPortName(cell.getStringCellValue());
|
|
|
+ break;
|
|
|
+ case "堆放地点":
|
|
|
+ //设置单元格类型
|
|
|
+ cell.setCellType(CellType.STRING);
|
|
|
+ if (StringUtils.isEmpty(cell.getStringCellValue())) {
|
|
|
+ return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少堆放地点");
|
|
|
+ }
|
|
|
+ companyMsg.setAddressName(cell.getStringCellValue());
|
|
|
+ TAddress address = new TAddress();
|
|
|
+ address.setfName(cell.getStringCellValue());
|
|
|
+ if (StringUtils.isEmpty(companyMsg.getPort())){
|
|
|
+ return AjaxResult.error("缺少地点类型"+companyMsg.getPortName());
|
|
|
+ }
|
|
|
+ address.setfTypes(companyMsg.getPort());
|
|
|
+ List<TAddress> tAddresses = tAddressMapper.selectTAddressBasicList(address);
|
|
|
+ if (CollectionUtils.isEmpty(tAddresses)){
|
|
|
+ return AjaxResult.error("系统缺少类型为"+companyMsg.getPortName()+"的地点"+cell.getStringCellValue()+"请维护");
|
|
|
+ }
|
|
|
+ companyMsg.setfUpdateaddress(tAddresses.get(0).getfId().toString());
|
|
|
+ break;
|
|
|
+ case "提单号":
|
|
|
+ //设置单元格类型
|
|
|
+ cell.setCellType(CellType.STRING);
|
|
|
+ /*if (StringUtils.isEmpty(cell.getStringCellValue())) {
|
|
|
+ return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少提单号");
|
|
|
+ }*/
|
|
|
+ companyMsg.setfMblno(cell.getStringCellValue());
|
|
|
+ break;
|
|
|
+ case "铅封号":
|
|
|
+ //设置单元格类型
|
|
|
+ cell.setCellType(CellType.STRING);
|
|
|
+ /*if (StringUtils.isEmpty(cell.getStringCellValue())) {
|
|
|
+ return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少铅封号");
|
|
|
+ }*/
|
|
|
+ companyMsg.setfSealno(cell.getStringCellValue());
|
|
|
+ break;
|
|
|
+ case "是否箱损":
|
|
|
+ //设置单元格类型
|
|
|
+ cell.setCellType(CellType.STRING);
|
|
|
+ companyMsg.setCntrstatusName(cell.getStringCellValue());
|
|
|
+ if (StringUtils.isEmpty(cell.getStringCellValue())) {
|
|
|
+ return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少箱损状态");
|
|
|
+ }
|
|
|
+ String fCnTrsTaTus = sysDictDataMapper.selectDictValue("f_cntrstatus", cell.getStringCellValue());
|
|
|
+ if (StringUtils.isEmpty(fCnTrsTaTus)){
|
|
|
+ return AjaxResult.error("系统缺少箱状态"+cell.getStringCellValue()+"请维护");
|
|
|
+ }
|
|
|
+ companyMsg.setfCntrstatus(fCnTrsTaTus);
|
|
|
+ break;
|
|
|
+ case "箱损描述(备注)":
|
|
|
+ //设置单元格类型
|
|
|
+ cell.setCellType(CellType.STRING);
|
|
|
+ companyMsg.setRemark(cell.getStringCellValue());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tCntrno.add(companyMsg);
|
|
|
+ }
|
|
|
+ return AjaxResult.success("success", tCntrno);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<BoxDistributionStatistics> boxDistributedStatistics() {
|
|
|
+ List<BoxDistributionStatistics> list = new ArrayList<>();
|
|
|
+ //先获取箱地址为港口信息
|
|
|
+ List<TCntrno> boxPortMessage = tCntrnoMapper.getBoxPortMessage();
|
|
|
+ //获取箱信息地址不为港口的信息
|
|
|
+ List<TCntrno> addressMessageList = tCntrnoMapper.getBoxAddressMessage();
|
|
|
+ //获取箱动态信息
|
|
|
+ List<SysDictData> fOpcTnsTaTus = sysDictDataMapper.selectDictDataByType("f_opctnstatus");
|
|
|
+ //在获取港口下的堆场对应的箱信息
|
|
|
+ if (CollectionUtils.isNotEmpty(boxPortMessage) && CollectionUtils.isNotEmpty(fOpcTnsTaTus)){
|
|
|
+ for (TCntrno cntrno : boxPortMessage) {
|
|
|
+ BoxDistributionStatistics boxDistributionStatistics = new BoxDistributionStatistics();
|
|
|
+ boxDistributionStatistics.setHaven(cntrno.getAddressName());
|
|
|
+ List<BoxAddressMessage> boxAddressMessageList = new ArrayList<>();
|
|
|
+ if (CollectionUtils.isNotEmpty(addressMessageList)){
|
|
|
+ for (TCntrno trno : addressMessageList) {
|
|
|
+ if (cntrno.getAddressName().equals(trno.getPortName()) && !trno.getAddressName().equals("在船")){
|
|
|
+ BoxAddressMessage boxAddressMessage = new BoxAddressMessage();
|
|
|
+ boxAddressMessage.setAddress(trno.getAddressName());
|
|
|
+ boxAddressMessage.setNumberSize(fOpcTnsTaTus.size());
|
|
|
+ List<BoxMessage> boxMessageList = new ArrayList<>();
|
|
|
+ for (SysDictData opcTnsTaTus : fOpcTnsTaTus) {
|
|
|
+ TCntrno tro = new TCntrno();
|
|
|
+ BoxMessage boxMessage = new BoxMessage();
|
|
|
+ tro.setfUpdateaddress(trno.getfUpdateaddress());
|
|
|
+ tro.setfOpctnstatus(opcTnsTaTus.getDictValue());
|
|
|
+ BoxMessage message = tCntrnoMapper.boxDistributionStatistics(tro);
|
|
|
+ if (message != null){
|
|
|
+ boxMessage = message;
|
|
|
+ }
|
|
|
+ boxMessage.setOpcTnStatus(opcTnsTaTus.getDictLabel());
|
|
|
+ boxMessage.setUNIT(boxMessage.getTWENTYFR() +boxMessage.getTWENTYGP() + boxMessage.getTWENTYOT()
|
|
|
+ +boxMessage.getTWENTYRF()+boxMessage.getTWENTYTK() +boxMessage.getFORTYFR()+boxMessage.getFORTYGP()
|
|
|
+ +boxMessage.getFORTYHC()+boxMessage.getFORTYHR()+boxMessage.getFORTYOT()+boxMessage.getFORTYTK());
|
|
|
+ boxMessage.setTEU(boxMessage.getTWENTYFR() +boxMessage.getTWENTYGP() + boxMessage.getTWENTYOT()
|
|
|
+ +boxMessage.getTWENTYRF()+boxMessage.getTWENTYTK() +boxMessage.getFORTYFR()*2+boxMessage.getFORTYGP()*2
|
|
|
+ +boxMessage.getFORTYHC()*2+boxMessage.getFORTYHR()*2+boxMessage.getFORTYOT()*2+boxMessage.getFORTYTK()*2);
|
|
|
+ boxMessageList.add(boxMessage);
|
|
|
+ }
|
|
|
+ boxAddressMessage.setBoxMessages(boxMessageList);
|
|
|
+ boxAddressMessageList.add(boxAddressMessage);
|
|
|
+ }else if (cntrno.getAddressName().equals(trno.getPortName()) && trno.getAddressName().equals("在船")){
|
|
|
+ //获取在船的备注
|
|
|
+ List<TCntrno> boxRemark = tCntrnoMapper.getBoxRemark(trno.getfUpdateaddress());
|
|
|
+ if (CollectionUtils.isNotEmpty(boxRemark)){
|
|
|
+ for (TCntrno tCntrno : boxRemark) {
|
|
|
+ BoxAddressMessage boxAddressMessage = new BoxAddressMessage();
|
|
|
+ boxAddressMessage.setAddress(trno.getAddressName()+tCntrno.getRemark());
|
|
|
+ boxAddressMessage.setNumberSize(fOpcTnsTaTus.size());
|
|
|
+ List<BoxMessage> boxMessageList = new ArrayList<>();
|
|
|
+ for (SysDictData opcTnsTaTus : fOpcTnsTaTus) {
|
|
|
+ TCntrno tro = new TCntrno();
|
|
|
+ BoxMessage boxMessage = new BoxMessage();
|
|
|
+ tro.setfUpdateaddress(trno.getfUpdateaddress());
|
|
|
+ tro.setfOpctnstatus(opcTnsTaTus.getDictValue());
|
|
|
+ tro.setRemark(tCntrno.getRemark());
|
|
|
+ BoxMessage message = tCntrnoMapper.boxDistributionStatistics(tro);
|
|
|
+ if (message != null){
|
|
|
+ boxMessage = message;
|
|
|
+ }
|
|
|
+ boxMessage.setOpcTnStatus(opcTnsTaTus.getDictLabel());
|
|
|
+ boxMessage.setUNIT(boxMessage.getTWENTYFR() +boxMessage.getTWENTYGP() + boxMessage.getTWENTYOT()
|
|
|
+ +boxMessage.getTWENTYRF()+boxMessage.getTWENTYTK() +boxMessage.getFORTYFR()+boxMessage.getFORTYGP()
|
|
|
+ +boxMessage.getFORTYHC()+boxMessage.getFORTYHR()+boxMessage.getFORTYOT()+boxMessage.getFORTYTK());
|
|
|
+ boxMessage.setTEU(boxMessage.getTWENTYFR() +boxMessage.getTWENTYGP() + boxMessage.getTWENTYOT()
|
|
|
+ +boxMessage.getTWENTYRF()+boxMessage.getTWENTYTK() +boxMessage.getFORTYFR()*2+boxMessage.getFORTYGP()*2
|
|
|
+ +boxMessage.getFORTYHC()*2+boxMessage.getFORTYHR()*2+boxMessage.getFORTYOT()*2+boxMessage.getFORTYTK()*2);
|
|
|
+ boxMessageList.add(boxMessage);
|
|
|
+ }
|
|
|
+ boxAddressMessage.setBoxMessages(boxMessageList);
|
|
|
+ boxAddressMessageList.add(boxAddressMessage);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ boxDistributionStatistics.setBoxAddressMessages(boxAddressMessageList);
|
|
|
+ boxDistributionStatistics.setNumber(fOpcTnsTaTus.size()*boxAddressMessageList.size());
|
|
|
+ list.add(boxDistributionStatistics);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* set字段
|
|
|
*
|