Browse Source

凯和配船,单航次配船,箱分布统计

lazhaoqian 4 years ago
parent
commit
34d20b1e7d
23 changed files with 1413 additions and 42 deletions
  1. 23 5
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/shipping/controller/KHUpdateOrderMessage.java
  2. 50 0
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/shipping/controller/TCntrnoController.java
  3. 77 1
      ruoyi-shipping/src/main/java/com/ruoyi/shipping/domain/TCntrno.java
  4. 1 1
      ruoyi-shipping/src/main/java/com/ruoyi/shipping/domain/TCntrtracking.java
  5. 154 0
      ruoyi-shipping/src/main/java/com/ruoyi/shipping/excel/AirForceStationExcel.java
  6. 51 0
      ruoyi-shipping/src/main/java/com/ruoyi/shipping/excel/BoxAddressMessage.java
  7. 53 0
      ruoyi-shipping/src/main/java/com/ruoyi/shipping/excel/BoxDistributionStatistics.java
  8. 205 0
      ruoyi-shipping/src/main/java/com/ruoyi/shipping/excel/BoxMessage.java
  9. 1 1
      ruoyi-shipping/src/main/java/com/ruoyi/shipping/excel/DeriveInventoryExcel.java
  10. 34 1
      ruoyi-shipping/src/main/java/com/ruoyi/shipping/excel/SingleVoyageByShipExcel.java
  11. 34 0
      ruoyi-shipping/src/main/java/com/ruoyi/shipping/mapper/TCntrnoMapper.java
  12. 7 0
      ruoyi-shipping/src/main/java/com/ruoyi/shipping/mapper/TWarehousebillsCntritemsMapper.java
  13. 21 0
      ruoyi-shipping/src/main/java/com/ruoyi/shipping/service/ITCntrnoService.java
  14. 293 2
      ruoyi-shipping/src/main/java/com/ruoyi/shipping/service/impl/TCntrnoServiceImpl.java
  15. 135 1
      ruoyi-shipping/src/main/resources/mapper/shipping/TCntrnoMapper.xml
  16. 1 1
      ruoyi-shipping/src/main/resources/mapper/shipping/TCntrtrackingMapper.xml
  17. 18 3
      ruoyi-shipping/src/main/resources/mapper/shipping/TVoyageMapper.xml
  18. 4 0
      ruoyi-shipping/src/main/resources/mapper/shipping/TWarehousebillsCntritemsMapper.xml
  19. 12 0
      ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/domain/TWarehouseBills.java
  20. 4 5
      ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/mapper/TWarehouseBillsMapper.java
  21. 9 3
      ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/ITWarehouseBillsService.java
  22. 195 8
      ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/impl/TWarehouseBillsServiceImpl.java
  23. 31 10
      ruoyi-warehouse/src/main/resources/mapper/warehouseBusiness/TWarehousebillsMapper.xml

+ 23 - 5
ruoyi-admin/src/main/java/com/ruoyi/web/controller/shipping/controller/KHUpdateOrderMessage.java

@@ -14,11 +14,10 @@ import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.common.enums.BusinessType;
 import com.ruoyi.common.utils.ServletUtils;
 import com.ruoyi.common.utils.StringUtils;
-import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.common.utils.spring.SpringUtils;
 import com.ruoyi.framework.web.service.TokenService;
-import com.ruoyi.shipping.domain.TAddress;
-import com.ruoyi.shipping.excel.singleVoyageByShipExcel;
+import com.ruoyi.shipping.domain.TCntrno;
+import com.ruoyi.shipping.excel.SingleVoyageByShipExcel;
 import com.ruoyi.warehouseBusiness.domain.TWarehouseBills;
 import com.ruoyi.warehouseBusiness.service.ITWarehouseBillsService;
 import lombok.extern.slf4j.Slf4j;
@@ -106,8 +105,27 @@ public class KHUpdateOrderMessage extends BaseController {
     @GetMapping("/singleVoyageByShip")
     public TableDataInfo singleVoyageByShip (TWarehouseBills tWarehouseBills){
         startPage();
-        List<singleVoyageByShipExcel> singleVoyageByShipExcels = tWarehousebillsService.singleVoyageByShip(tWarehouseBills);
-        return getDataTable(singleVoyageByShipExcels);
+        List<SingleVoyageByShipExcel> SingleVoyageByShipExcels = tWarehousebillsService.singleVoyageByShip(tWarehouseBills);
+        return getDataTable(SingleVoyageByShipExcels);
+    }
+    /**
+     * 单航次配船 离港出运 1 到港卸船 2
+     * @param tCntrno
+     * @return
+     */
+    @PostMapping("/updateAirForceStation")
+    public AjaxResult updateBoxMessage(@RequestBody TCntrno tCntrno){
+        if (tCntrno.getUpdateStatus() == null){
+            return AjaxResult.error("请选择离港出运或到港卸船");
+        }
+        if (StringUtils.isEmpty(tCntrno.getfVsl()) ||StringUtils.isEmpty(tCntrno.getfVoy())){
+            return AjaxResult.error("请选择船名航次");
+        }
+        if (tCntrno.getfUpdatetime() == null){
+            return AjaxResult.error("请选择离港出运或到港卸船时间");
+        }
+        LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
+        return tWarehousebillsService.updateBoxMessage(tCntrno,loginUser);
     }
 
 }

+ 50 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/shipping/controller/TCntrnoController.java

@@ -10,6 +10,8 @@ import com.ruoyi.common.utils.ServletUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.spring.SpringUtils;
 import com.ruoyi.framework.web.service.TokenService;
+import com.ruoyi.shipping.excel.AirForceStationExcel;
+import com.ruoyi.shipping.excel.BoxDistributionStatistics;
 import com.ruoyi.shipping.excel.TCntrnoExcel;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -251,7 +253,55 @@ public class TCntrnoController extends BaseController
         List<Map<String, Object>> list = tCntrnoService.getTcntrnoFno(tCntrno);
         return getDataTable(list);
     }
+    /**
+     * 下载场站箱动态模板
+     */
+    @GetMapping("/importTCnTrNoAirForce")
+    public AjaxResult importTCnTrNoAirForce()
+    {
+        ExcelUtil<AirForceStationExcel> util = new ExcelUtil<AirForceStationExcel>(AirForceStationExcel.class);
+        return util.importTemplateExcel("场站箱动态模板");
+    }
+    /**
+     * 凯和导入场站箱动态
+     * @param file
+     * @return
+     * @throws Exception
+     */
+    @PostMapping(value = "/importAirForceStation")
+    public AjaxResult importAirForceStation(@RequestParam("file") MultipartFile file)
+    {
+        try {
+            return tCntrnoService.importAirForceStation(file);
+        } catch (Exception e) {
+            return AjaxResult.error("导入箱站动态失败");
+        }
+    }
+    /**
+     * 保存场站动态信息
+     */
+    //@PreAuthorize("@ss.hasPermi('shipping:cntrno:updateTCntrno')")
+    //@Log(title = "集装箱号", businessType = BusinessType.UPDATE)
+    @PostMapping("/updateAirForceStation")
+    public AjaxResult updateAirForceStation(@RequestBody TCntrno tCntrno)
+    {
+        if (CollectionUtils.isEmpty(tCntrno.gettCntrno())){
+            return AjaxResult.error("请选择后再提交");
+        }
+        return tCntrnoService.updateAirForceStation(tCntrno.gettCntrno());
+    }
 
+    /**
+     * 箱分布统计
+     * @param
+     * @return
+     */
+    @GetMapping("/boxDistributedStatistics")
+    public TableDataInfo boxDistributedStatistics(){
+        startPage();
+        List<BoxDistributionStatistics> list = tCntrnoService.boxDistributedStatistics();
+        return getDataTable(list);
+    }
 
 
 

+ 77 - 1
ruoyi-shipping/src/main/java/com/ruoyi/shipping/domain/TCntrno.java

@@ -1,5 +1,6 @@
 package com.ruoyi.shipping.domain;
 
+import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
 
@@ -94,7 +95,7 @@ public class TCntrno extends BaseEntity
     private String fRent;
 
     /** 最新时间 */
-    @JsonFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm")
     //@Excel(name = "最新时间", width = 30, dateFormat = "yyyy-MM-dd")
     private Date fUpdatetime;
     /** 造箱时间 */
@@ -129,6 +130,7 @@ public class TCntrno extends BaseEntity
     private String fStatus;
     /**数据字典 调箱动作*/
     private String fOpctnstatus;
+    //铅封号
     private String fSealno;
     //提单号
     private String fMblno;
@@ -142,6 +144,10 @@ public class TCntrno extends BaseEntity
     private String fVsl;
     //航次
     private String fVoy;
+    //船ID
+    private Long fVslid;
+    //航次ID
+    private Long fVoyid;
     //调入地点
     private String foldSite;
     //调入空重
@@ -156,6 +162,74 @@ public class TCntrno extends BaseEntity
     private List<TConditionAccessory> accessoryList;
     //调箱动作中文名
     private String opctnstatusName;
+    //箱重量
+    private BigDecimal fBoxWeight;
+    //单航次配船修改状态 1 离港出运 2 到港卸船
+    private Long updateStatus;
+    //港口名称中文名
+    private String portName;
+    //港口名称
+    private String port;
+    /**
+     * 是否按日志分组
+     */
+    private Integer whether = 0;
+
+    public Integer getWhether() {
+        return whether;
+    }
+
+    public void setWhether(Integer whether) {
+        this.whether = whether;
+    }
+
+    public String getPort() {
+        return port;
+    }
+
+    public void setPort(String port) {
+        this.port = port;
+    }
+
+    public String getPortName() {
+        return portName;
+    }
+
+    public void setPortName(String portName) {
+        this.portName = portName;
+    }
+
+    public Long getfVslid() {
+        return fVslid;
+    }
+
+    public void setfVslid(Long fVslid) {
+        this.fVslid = fVslid;
+    }
+
+    public Long getfVoyid() {
+        return fVoyid;
+    }
+
+    public void setfVoyid(Long fVoyid) {
+        this.fVoyid = fVoyid;
+    }
+
+    public Long getUpdateStatus() {
+        return updateStatus;
+    }
+
+    public void setUpdateStatus(Long updateStatus) {
+        this.updateStatus = updateStatus;
+    }
+
+    public BigDecimal getfBoxWeight() {
+        return fBoxWeight;
+    }
+
+    public void setfBoxWeight(BigDecimal fBoxWeight) {
+        this.fBoxWeight = fBoxWeight;
+    }
 
     public String getfBoxLord() {
         return fBoxLord;
@@ -496,6 +570,8 @@ public class TCntrno extends BaseEntity
             .append("fBuildBoxTime", getfBuildBoxTime())
             .append("fBoxTurtleYear", getfBoxTurtleYear())
             .append("fBoxTurtleMonth", getfBoxTurtleMonth())
+            .append("fMblno", getfMblno())
+            .append("fBoxWeight", getfBoxWeight())
             .toString();
     }
 }

+ 1 - 1
ruoyi-shipping/src/main/java/com/ruoyi/shipping/domain/TCntrtracking.java

@@ -47,7 +47,7 @@ public class TCntrtracking extends BaseEntity
     private String fVoy;
 
     /** 最新时间 */
-    @JsonFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm")
     @Excel(name = "最新时间", width = 30, dateFormat = "yyyy-MM-dd")
     private Date fUpdatetime;
 

+ 154 - 0
ruoyi-shipping/src/main/java/com/ruoyi/shipping/excel/AirForceStationExcel.java

@@ -0,0 +1,154 @@
+package com.ruoyi.shipping.excel;
+
+import com.ruoyi.common.annotation.Excel;
+
+import java.util.Date;
+
+/**
+ * 导出场站箱动态模板
+ */
+public class AirForceStationExcel {
+    private static final long serialVersionUID = 1L;
+
+    //箱动态
+    @Excel(name = "箱动态")
+    private String fOpctnstatus;
+    //箱号
+    @Excel(name = "箱号")
+    private String fNo;
+    //动态日期
+    @Excel(name = "动态日期")
+    private Date updateTime;
+    //船名
+    @Excel(name = "船名")
+    private String fVsl;
+    //航次
+    @Excel(name = "航次")
+    private String fVoy;
+    //重量
+    @Excel(name = "重量")
+    private String fBoxWeight;
+    //港口名称
+    @Excel(name = "港口名称")
+    private String portName;
+    //堆放地点
+    @Excel(name = "堆放地点")
+    private String fUpdateaddress;
+    //提单号
+    @Excel(name = "提单号")
+    private String fMblno;
+    //铅封号
+    @Excel(name = "铅封号")
+    private String fSealno;
+    //是否箱损
+    @Excel(name = "是否箱损")
+    private String fCntrstatus;
+    //箱损描述
+    @Excel(name = "箱损描述(备注)")
+    private String remark;
+
+    public String getfOpctnstatus() {
+        return fOpctnstatus;
+    }
+
+    public void setfOpctnstatus(String fOpctnstatus) {
+        this.fOpctnstatus = fOpctnstatus;
+    }
+
+    public String getfNo() {
+        return fNo;
+    }
+
+    public void setfNo(String fNo) {
+        this.fNo = fNo;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public String getfVsl() {
+        return fVsl;
+    }
+
+    public void setfVsl(String fVsl) {
+        this.fVsl = fVsl;
+    }
+
+    public String getfVoy() {
+        return fVoy;
+    }
+
+    public void setfVoy(String fVoy) {
+        this.fVoy = fVoy;
+    }
+
+    public String getfBoxWeight() {
+        return fBoxWeight;
+    }
+
+    public void setfBoxWeight(String fBoxWeight) {
+        this.fBoxWeight = fBoxWeight;
+    }
+
+    public String getfUpdateaddress() {
+        return fUpdateaddress;
+    }
+
+    public void setfUpdateaddress(String fUpdateaddress) {
+        this.fUpdateaddress = fUpdateaddress;
+    }
+
+    public String getfMblno() {
+        return fMblno;
+    }
+
+    public void setfMblno(String fMblno) {
+        this.fMblno = fMblno;
+    }
+
+    public String getfSealno() {
+        return fSealno;
+    }
+
+    public void setfSealno(String fSealno) {
+        this.fSealno = fSealno;
+    }
+
+    public String getfCntrstatus() {
+        return fCntrstatus;
+    }
+
+    public void setfCntrstatus(String fCntrstatus) {
+        this.fCntrstatus = fCntrstatus;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    @Override
+    public String toString() {
+        return "AirForceStationExcel{" +
+                "fOpctnstatus='" + fOpctnstatus + '\'' +
+                ", fNo='" + fNo + '\'' +
+                ", updateTime=" + updateTime +
+                ", fVsl='" + fVsl + '\'' +
+                ", fVoy='" + fVoy + '\'' +
+                ", fBoxWeight='" + fBoxWeight + '\'' +
+                ", fUpdateaddress='" + fUpdateaddress + '\'' +
+                ", fMblno='" + fMblno + '\'' +
+                ", fSealno='" + fSealno + '\'' +
+                ", fCntrstatus='" + fCntrstatus + '\'' +
+                ", remark='" + remark + '\'' +
+                '}';
+    }
+}

+ 51 - 0
ruoyi-shipping/src/main/java/com/ruoyi/shipping/excel/BoxAddressMessage.java

@@ -0,0 +1,51 @@
+package com.ruoyi.shipping.excel;
+
+import java.util.List;
+
+public class BoxAddressMessage {
+    private static final long serialVersionUID = 1L;
+    /**
+     * 地点
+     */
+    private String address;
+    /**
+     * 箱分布信息
+     */
+    private List<BoxMessage> boxMessages;
+    /**
+     * 调箱动态个数
+     */
+    private Integer numberSize;
+
+    public Integer getNumberSize() {
+        return numberSize;
+    }
+
+    public void setNumberSize(Integer numberSize) {
+        this.numberSize = numberSize;
+    }
+
+    public String getAddress() {
+        return address;
+    }
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+    public List<BoxMessage> getBoxMessages() {
+        return boxMessages;
+    }
+
+    public void setBoxMessages(List<BoxMessage> boxMessages) {
+        this.boxMessages = boxMessages;
+    }
+
+    @Override
+    public String toString() {
+        return "BoxAddressMessage{" +
+                "address='" + address + '\'' +
+                ", boxMessages=" + boxMessages +
+                '}';
+    }
+}

+ 53 - 0
ruoyi-shipping/src/main/java/com/ruoyi/shipping/excel/BoxDistributionStatistics.java

@@ -0,0 +1,53 @@
+package com.ruoyi.shipping.excel;
+
+import java.util.List;
+
+public class BoxDistributionStatistics {
+    private static final long serialVersionUID = 1L;
+    /**
+     * 港口
+     */
+    private String haven;
+    /**
+     * 地点信息
+     */
+    private List<BoxAddressMessage> boxAddressMessages;
+
+    /**
+     * 合并单元格大小
+     * @return
+     */
+    private Integer number;
+
+    public Integer getNumber() {
+        return number;
+    }
+
+    public void setNumber(Integer number) {
+        this.number = number;
+    }
+
+    public String getHaven() {
+        return haven;
+    }
+
+    public void setHaven(String haven) {
+        this.haven = haven;
+    }
+
+    public List<BoxAddressMessage> getBoxAddressMessages() {
+        return boxAddressMessages;
+    }
+
+    public void setBoxAddressMessages(List<BoxAddressMessage> boxAddressMessages) {
+        this.boxAddressMessages = boxAddressMessages;
+    }
+
+    @Override
+    public String toString() {
+        return "BoxDistributionStatistics{" +
+                "haven='" + haven + '\'' +
+                ", boxAddressMessages=" + boxAddressMessages +
+                '}';
+    }
+}

+ 205 - 0
ruoyi-shipping/src/main/java/com/ruoyi/shipping/excel/BoxMessage.java

@@ -0,0 +1,205 @@
+package com.ruoyi.shipping.excel;
+
+public class BoxMessage {
+    private static final long serialVersionUID = 1L;
+    /**
+     * 调箱状态
+     */
+    private String OpcTnStatus;
+    /**
+     * 备注
+     */
+    private String remark;
+    /**
+     * 20GP
+     */
+    private Long TWENTYGP = 0L;
+    /**
+     * 20RF
+     */
+    private Long TWENTYRF = 0L;
+    /**
+     * 20OT
+     */
+    private Long TWENTYOT = 0L;
+    /**
+     * 20FR
+     */
+    private Long TWENTYFR = 0L;
+    /**
+     * 20TK
+     */
+    private Long TWENTYTK = 0L;
+    /**
+     * 40GP
+     */
+    private Long FORTYGP = 0L;
+    /**
+     * 40HC
+     */
+    private Long FORTYHC = 0L;
+    /**
+     * 40HR
+     */
+    private Long FORTYHR = 0L;
+    /**
+     * 40FR
+     */
+    private Long FORTYFR = 0L;
+    /**
+     * 40TK
+     */
+    private Long FORTYTK = 0L;
+    /**
+     * 40OT
+     */
+    private Long FORTYOT = 0L;
+    /**
+     * unit
+     */
+    private Long UNIT = 0L;
+    /**
+     * teu
+     */
+    private Long TEU  = 0L;
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    public String getOpcTnStatus() {
+        return OpcTnStatus;
+    }
+
+    public void setOpcTnStatus(String opcTnStatus) {
+        OpcTnStatus = opcTnStatus;
+    }
+
+    public Long getTWENTYGP() {
+        return TWENTYGP;
+    }
+
+    public void setTWENTYGP(Long TWENTYGP) {
+        this.TWENTYGP = TWENTYGP;
+    }
+
+    public Long getTWENTYRF() {
+        return TWENTYRF;
+    }
+
+    public void setTWENTYRF(Long TWENTYRF) {
+        this.TWENTYRF = TWENTYRF;
+    }
+
+    public Long getTWENTYOT() {
+        return TWENTYOT;
+    }
+
+    public void setTWENTYOT(Long TWENTYOT) {
+        this.TWENTYOT = TWENTYOT;
+    }
+
+    public Long getTWENTYFR() {
+        return TWENTYFR;
+    }
+
+    public void setTWENTYFR(Long TWENTYFR) {
+        this.TWENTYFR = TWENTYFR;
+    }
+
+    public Long getTWENTYTK() {
+        return TWENTYTK;
+    }
+
+    public void setTWENTYTK(Long TWENTYTK) {
+        this.TWENTYTK = TWENTYTK;
+    }
+
+    public Long getFORTYGP() {
+        return FORTYGP;
+    }
+
+    public void setFORTYGP(Long FORTYGP) {
+        this.FORTYGP = FORTYGP;
+    }
+
+    public Long getFORTYHC() {
+        return FORTYHC;
+    }
+
+    public void setFORTYHC(Long FORTYHC) {
+        this.FORTYHC = FORTYHC;
+    }
+
+    public Long getFORTYHR() {
+        return FORTYHR;
+    }
+
+    public void setFORTYHR(Long FORTYHR) {
+        this.FORTYHR = FORTYHR;
+    }
+
+    public Long getFORTYFR() {
+        return FORTYFR;
+    }
+
+    public void setFORTYFR(Long FORTYFR) {
+        this.FORTYFR = FORTYFR;
+    }
+
+    public Long getFORTYTK() {
+        return FORTYTK;
+    }
+
+    public void setFORTYTK(Long FORTYTK) {
+        this.FORTYTK = FORTYTK;
+    }
+
+    public Long getFORTYOT() {
+        return FORTYOT;
+    }
+
+    public void setFORTYOT(Long FORTYOT) {
+        this.FORTYOT = FORTYOT;
+    }
+
+    public Long getUNIT() {
+        return UNIT;
+    }
+
+    public void setUNIT(Long UNIT) {
+        this.UNIT = UNIT;
+    }
+
+    public Long getTEU() {
+        return TEU;
+    }
+
+    public void setTEU(Long TEU) {
+        this.TEU = TEU;
+    }
+
+    @Override
+    public String toString() {
+        return "BoxMessage{" +
+                "OpcTnStatus='" + OpcTnStatus + '\'' +
+                ", TWENTYGP=" + TWENTYGP +
+                ", TWENTYRF=" + TWENTYRF +
+                ", TWENTYOT=" + TWENTYOT +
+                ", TWENTYFR=" + TWENTYFR +
+                ", TWENTYTK=" + TWENTYTK +
+                ", FORTYGP=" + FORTYGP +
+                ", FORTYHC=" + FORTYHC +
+                ", FORTYHR=" + FORTYHR +
+                ", FORTYFR=" + FORTYFR +
+                ", FORTYTK=" + FORTYTK +
+                ", FORTYOT=" + FORTYOT +
+                ", UNIT=" + UNIT +
+                ", TEU=" + TEU +
+                '}';
+    }
+}

+ 1 - 1
ruoyi-shipping/src/main/java/com/ruoyi/shipping/excel/deriveInventoryExcel.java → ruoyi-shipping/src/main/java/com/ruoyi/shipping/excel/DeriveInventoryExcel.java

@@ -11,7 +11,7 @@ import java.math.BigDecimal;
 /**
  * 凯和导出清单Excel
  */
-public class deriveInventoryExcel {
+public class DeriveInventoryExcel {
     private static final long serialVersionUID = 1L;
     /**
      * 序号

+ 34 - 1
ruoyi-shipping/src/main/java/com/ruoyi/shipping/excel/singleVoyageByShipExcel.java → ruoyi-shipping/src/main/java/com/ruoyi/shipping/excel/SingleVoyageByShipExcel.java

@@ -1,5 +1,6 @@
 package com.ruoyi.shipping.excel;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.ruoyi.common.annotation.Excel;
 
 import java.util.Date;
@@ -7,7 +8,7 @@ import java.util.Date;
 /**
  * 凯和单航次配船
  */
-public class singleVoyageByShipExcel {
+public class SingleVoyageByShipExcel {
 
     private static final long serialVersionUID = 1L;
     @Excel(name = "船名")
@@ -15,8 +16,10 @@ public class singleVoyageByShipExcel {
     @Excel(name = "航次")
     private String voyNo;
     @Excel(name = "开船日期")
+    @JsonFormat(pattern = "yyyy-MM-dd")
     private Date fAtd;
     @Excel(name = "到港日期")
+    @JsonFormat(pattern = "yyyy-MM-dd")
     private Date fAta;
     @Excel(name = "航线")
     private String fName;
@@ -24,6 +27,36 @@ public class singleVoyageByShipExcel {
     private String loadportName;
     @Excel(name = "卸港")
     private String destportName;
+    //船ID
+    private Long fVslid;
+    //航次ID
+    private Long fVoyid;
+    /** 到港状态 0 未离港 1离港 2 到港 */
+    private Integer fArrivalStatus;
+
+    public Integer getfArrivalStatus() {
+        return fArrivalStatus;
+    }
+
+    public void setfArrivalStatus(Integer fArrivalStatus) {
+        this.fArrivalStatus = fArrivalStatus;
+    }
+
+    public Long getfVslid() {
+        return fVslid;
+    }
+
+    public void setfVslid(Long fVslid) {
+        this.fVslid = fVslid;
+    }
+
+    public Long getfVoyid() {
+        return fVoyid;
+    }
+
+    public void setfVoyid(Long fVoyid) {
+        this.fVoyid = fVoyid;
+    }
 
     public String getVslName() {
         return vslName;

+ 34 - 0
ruoyi-shipping/src/main/java/com/ruoyi/shipping/mapper/TCntrnoMapper.java

@@ -4,6 +4,7 @@ import java.util.List;
 import java.util.Map;
 
 import com.ruoyi.shipping.domain.TCntrno;
+import com.ruoyi.shipping.excel.BoxMessage;
 import org.apache.ibatis.annotations.Param;
 
 /**
@@ -66,6 +67,13 @@ public interface TCntrnoMapper
      * @return 结果
      */
     public int updateTCntrno(TCntrno tCntrno);
+    /**
+     * 根据箱号修改数据
+     *
+     * @param tCntrno 集装箱号
+     * @return 结果
+     */
+    public int updateTCntrnoByfNo(TCntrno tCntrno);
 
     /**
      * 删除集装箱号
@@ -119,4 +127,30 @@ public interface TCntrnoMapper
      * @return
      */
     public List<Map<String, Object>> getTcntrnoFno(TCntrno tCntrno);
+
+    /**
+     * 获取箱分布情况
+     * @param tCntrno
+     * @return
+     */
+    public BoxMessage boxDistributionStatistics(TCntrno tCntrno);
+
+    /**
+     * 获取箱信息中地点为港口的地址  fUpdateaddress 地点ID   addressName 地点中文名
+     * @return
+     */
+    public List<TCntrno> getBoxPortMessage();
+    /**
+     * 获取箱信息中地点不为港口的地址  fUpdateaddress 地点ID   addressName 地点中文名 portName 港口名称
+     * @return
+     */
+    public List<TCntrno> getBoxAddressMessage();
+
+    /**
+     * 查询在船的集装箱备注
+     * @param fUpdateaddress
+     * @return
+     */
+    public List<TCntrno> getBoxRemark(@Param("fUpdateaddress") String fUpdateaddress);
+
 }

+ 7 - 0
ruoyi-shipping/src/main/java/com/ruoyi/shipping/mapper/TWarehousebillsCntritemsMapper.java

@@ -18,6 +18,13 @@ public interface TWarehousebillsCntritemsMapper
      * @return 凯和箱明细
      */
     public TWarehousebillsCntritems selectTWarehousebillsCntritemsById(Long fId);
+    /**
+     * 查询凯和箱明细
+     *
+     * @param fId 凯和箱明细ID
+     * @return 凯和箱明细
+     */
+    public List<TWarehousebillsCntritems> selectTWarehousebillsCntritemsByPId(Long fId);
 
     /**
      * 查询凯和箱明细列表

+ 21 - 0
ruoyi-shipping/src/main/java/com/ruoyi/shipping/service/ITCntrnoService.java

@@ -7,6 +7,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.core.domain.model.LoginUser;
 import com.ruoyi.shipping.domain.TCntrno;
+import com.ruoyi.shipping.excel.BoxDistributionStatistics;
 import org.springframework.web.multipart.MultipartFile;
 
 /**
@@ -49,6 +50,13 @@ public interface ITCntrnoService
      */
     public int updateTCntrno(List<TCntrno> tCntrno);
     /**
+     * 保存场站动态信息
+     *
+     * @param tCntrno 集装箱号
+     * @return 结果
+     */
+    public AjaxResult updateAirForceStation(List<TCntrno> tCntrno);
+    /**
      * 修改集装箱号
      *
      * @param tCntrno 集装箱号
@@ -143,4 +151,17 @@ public interface ITCntrnoService
      * @return
      */
     public List<Map<String, Object>> getTcntrnoFno(TCntrno tCntrno);
+    /**
+     *  导入场站动态
+     * @param file  excel
+     * @return  结果
+     */
+    public AjaxResult importAirForceStation(MultipartFile file)throws Exception;
+
+    /**
+     * 箱分布统计
+     * @param
+     * @return
+     */
+    public List<BoxDistributionStatistics> boxDistributedStatistics();
 }

+ 293 - 2
ruoyi-shipping/src/main/java/com/ruoyi/shipping/service/impl/TCntrnoServiceImpl.java

@@ -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字段
      *

+ 135 - 1
ruoyi-shipping/src/main/resources/mapper/shipping/TCntrnoMapper.xml

@@ -28,11 +28,13 @@
         <result property="fBoxTurtleMonth"    column="f_box_turtle_month"    />
         <result property="fBoxLord"    column="f_box_lord"    />
         <result property="fPactDealHorn"    column="f_pact_deal_horn"    />
+        <result property="fMblno"    column="f_mblno"    />
+        <result property="fBoxWeight"    column="f_box_weight"    />
     </resultMap>
 
     <sql id="selectTCntrnoVo">
         select f_id, f_no, f_typeid, f_owner, f_source, f_rent, f_updatetime, f_updateaddress, f_updateEF, f_cntrstatus, case when f_status = 'T' then '正常' else '停用' end as f_status,f_opctnstatus,f_sealno,create_by, create_time, update_by, update_time, remark,
-               f_build_box_time,f_box_turtle_year,f_box_turtle_month,f_box_lord,f_pact_deal_horn from t_cntrno
+               f_build_box_time,f_box_turtle_year,f_box_turtle_month,f_box_lord,f_pact_deal_horn,f_mblno,f_box_weight from t_cntrno
     </sql>
 
     <select id="selectTCntrnoList" parameterType="TCntrno" resultMap="TCntrnoResult">
@@ -61,6 +63,8 @@
             <if test="fBoxTurtleMonth != null  and fBoxTurtleMonth != ''"> and f_box_turtle_month = #{fBoxTurtleMonth}</if>
             <if test="fBoxLord != null  and fBoxLord != ''"> and f_box_lord = #{fBoxLord}</if>
             <if test="fPactDealHorn != null  and fPactDealHorn != ''"> and f_pact_deal_horn = #{fPactDealHorn}</if>
+            <if test="fMblno != null  and fMblno != ''"> and f_mblno = #{fMblno}</if>
+            <if test="fBoxWeight != null "> and f_box_weight = #{fBoxWeight}</if>
         </where>
     </select>
     <select id="selectTcntrnoMessage" parameterType="TCntrno" resultMap="TCntrnoResult">
@@ -144,6 +148,8 @@
             <if test="tc.fBoxTurtleMonth != null  and tc.fBoxTurtleMonth != ''"> and tc.f_box_turtle_month = #{fBoxTurtleMonth}</if>
             <if test="tc.fBoxLord != null  and tc.fBoxLord != ''"> and tc.f_box_lord = #{tc.fBoxLord}</if>
             <if test="tc.fPactDealHorn != null  and tc.fPactDealHorn != ''"> and tc.f_pact_deal_horn = #{tc.fPactDealHorn}</if>
+            <if test="tc.fMblno != null  and tc.fMblno != ''"> and tc.f_mblno = #{tc.fMblno}</if>
+            <if test="tc.fBoxWeight != null "> and tc.f_box_weight = #{tc.fBoxWeight}</if>
         </where>
         ORDER BY tc.f_no,CONVERT(tc.f_updateaddress USING gbk),CONVERT(t.f_no USING gbk),
         tc.f_updateEF,tc.f_cntrstatus,tc.f_owner
@@ -336,6 +342,34 @@
         </trim>
         where f_id = #{fId}
     </update>
+    <update id="updateTCntrnoByfNo" parameterType="TCntrno">
+        update t_cntrno
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="fNo != null and fNo != ''">f_no = #{fNo},</if>
+            <if test="fTypeid != null">f_typeid = #{fTypeid},</if>
+            <if test="fOwner != null and fOwner != ''">f_owner = #{fOwner},</if>
+            <if test="fSource != null">f_source = #{fSource},</if>
+            <if test="fRent != null">f_rent = #{fRent},</if>
+            <if test="fUpdatetime != null">f_updatetime = #{fUpdatetime},</if>
+            <if test="fUpdateaddress != null and fUpdateaddress != ''">f_updateaddress = #{fUpdateaddress},</if>
+            <if test="fUpdateef != null and fUpdateef != ''">f_updateEF = #{fUpdateef},</if>
+            <if test="fCntrstatus != null and fCntrstatus != ''">f_cntrstatus = #{fCntrstatus},</if>
+            <if test="fStatus != null">f_status = #{fStatus},</if>
+            <if test="fOpctnstatus != null  and fOpctnstatus != ''">f_opctnstatus = #{fOpctnstatus},</if>
+            <if test="fSealno != null  and fSealno != ''">f_sealno = #{fSealno},</if>
+            <if test="createBy != null">create_by = #{createBy},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="remark != null">remark = #{remark},</if>
+            <if test="fBuildBoxTime != null">f_build_box_time = #{fBuildBoxTime},</if>
+            <if test="fBoxTurtleYear != null">f_box_turtle_year = #{fBoxTurtleYear},</if>
+            <if test="fBoxTurtleMonth != null">f_box_turtle_month = #{fBoxTurtleMonth},</if>
+            <if test="fBoxLord != null">f_box_lord = #{fBoxLord},</if>
+            <if test="fPactDealHorn != null">f_pact_deal_horn = #{fPactDealHorn},</if>
+        </trim>
+        where f_no = #{fNo}
+    </update>
 
     <delete id="deleteTCntrnoById" parameterType="Long">
         delete from t_cntrno where f_id = #{fId}
@@ -540,6 +574,106 @@
         </where>
         ORDER BY tc.f_no
     </select>
+    <!--获取箱分布情况-->
+    <select id="boxDistributionStatistics" parameterType="TCntrno" resultType="com.ruoyi.shipping.excel.BoxMessage">
+        SELECT
+        MAX(case when tc.fNo = '20GP' then tc.boxNumber ELSE 0 end) AS 'TWENTYGP',
+        MAX(case when tc.fNo = '20RF' then tc.boxNumber ELSE 0 end) AS 'TWENTYRF',
+        MAX(case when tc.fNo = '20OT' then tc.boxNumber ELSE 0 end) AS 'TWENTYOT',
+        MAX(case when tc.fNo = '20FR' then tc.boxNumber ELSE 0 end) AS 'TWENTYFR',
+        MAX(case when tc.fNo = '20TK' then tc.boxNumber ELSE 0 end) AS 'TWENTYTK',
+        MAX(case when tc.fNo = '40GP' then tc.boxNumber ELSE 0 end) AS 'FORTYGP',
+        MAX(case when tc.fNo = '40HC' then tc.boxNumber ELSE 0 end) AS 'FORTYHC',
+        MAX(case when tc.fNo = '40HR' then tc.boxNumber ELSE 0 end) AS 'FORTYHR',
+        MAX(case when tc.fNo = '40FR' then tc.boxNumber ELSE 0 end) AS 'FORTYFR',
+        MAX(case when tc.fNo = '40TK' then tc.boxNumber ELSE 0 end) AS 'FORTYTK',
+        MAX(case when tc.fNo = '40OT' then tc.boxNumber ELSE 0 end) AS 'FORTYOT'
+        FROM
+        (
+        SELECT
+        IFNULL( COUNT( 1 ), 0 ) boxNumber,
+        tr.f_no fNo,
+        sd.dict_label opCTnStatusName
+        FROM
+        t_cntrno tc
+        LEFT JOIN t_cntr tr ON tc.f_typeid = tr.f_id
+        LEFT JOIN t_address ta ON tc.f_updateaddress = ta.f_id
+        LEFT JOIN sys_dict_data sd ON tc.f_opctnstatus = sd.dict_value
+        AND sd.dict_type = 'f_opctnstatus'
+        <where>
+            tc.f_status = 'T'
+            <if test="fUpdateaddress != null  and fUpdateaddress != ''">and tc.f_updateaddress = #{fUpdateaddress}</if>
+            <if test="fOpctnstatus != null  and fOpctnstatus != ''">and tc.f_opctnstatus = #{fOpctnstatus}</if>
+            <if test="remark != null">and tc.remark = #{remark}</if>
+        </where>
+        GROUP BY
+        LEFT ( tr.f_no, 2 ),
+        RIGHT ( tr.f_no, 2 )
+        )tc
+    </select>
+    <!--获取箱地点为港口信息情况-->
+    <select id="getBoxPortMessage" parameterType="TCntrno" resultMap="TCntrnoResult">
+    SELECT
+DISTINCT
+	IFNULL(ta.f_portid, 0) fUpdateaddress,
+	IFNULL(tr.f_name,'无') addressName
+FROM
+	t_cntrno tc
+	LEFT JOIN
+	t_address ta ON ta.f_id = tc.f_updateaddress
+	LEFT JOIN t_address tr ON ta.f_portid = tr.f_id
+	LEFT JOIN sys_dict_data sd ON ta.f_types = sd.dict_value AND sd.dict_type = 'f_types'
+	WHERE sd.dict_label != '港口'
+	UNION
+	    SELECT
+DISTINCT
+	IFNULL(tc.f_updateaddress,0) fUpdateaddress,
+	IFNULL(ta.f_name ,'无') addressName
+FROM
+	t_cntrno tc
+	LEFT JOIN
+	t_address ta ON ta.f_id = tc.f_updateaddress
+	LEFT JOIN sys_dict_data sd ON ta.f_types = sd.dict_value AND sd.dict_type = 'f_types'
+	WHERE sd.dict_label = '港口'
+    </select>
+    <!--获取箱地点不为港口信息情况-->
+    <select id="getBoxAddressMessage" parameterType="TCntrno" resultMap="TCntrnoResult">
+        SELECT
+DISTINCT
+	tc.f_updateaddress,
+	ta.f_name addressName,
+	ta.f_name portName
+FROM
+	t_cntrno tc
+	LEFT JOIN
+	t_address ta ON ta.f_id = tc.f_updateaddress
+	LEFT JOIN sys_dict_data sd ON ta.f_types = sd.dict_value AND sd.dict_type = 'f_types'
+	WHERE sd.dict_label = '港口'
+	UNION
+	SELECT
+DISTINCT
+	tc.f_updateaddress,
+	ta.f_name addressName,
+	IFNULL(tr.f_name,'无')portName
+FROM
+	t_cntrno tc
+	LEFT JOIN
+	t_address ta ON ta.f_id = tc.f_updateaddress
+	LEFT JOIN t_address tr ON ta.f_portid = tr.f_id
+	LEFT JOIN sys_dict_data sd ON ta.f_types = sd.dict_value AND sd.dict_type = 'f_types'
+	WHERE sd.dict_label != '港口'
+    </select>
+    <!--获取地点为在船的备注-->
+    <select id="getBoxRemark" parameterType="TCntrno" resultMap="TCntrnoResult">
+    SELECT
+DISTINCT
+	remark
+FROM
+	t_cntrno
+	WHERE
+	f_updateaddress = #{fUpdateaddress}
+	AND remark IS NOT NULL
+    </select>
 
 
 </mapper>

+ 1 - 1
ruoyi-shipping/src/main/resources/mapper/shipping/TCntrtrackingMapper.xml

@@ -94,7 +94,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 and tc.f_updatetime &lt;= #{cLoadDate[1]}
             </if>
         </where>
-        ORDER BY tc.f_updatetime desc,tc.f_no
+        ORDER BY tc.f_id desc,tc.f_updatetime desc,tc.f_no
     </select>
     
     <select id="selectTCntrtrackingById" parameterType="Long" resultMap="TCntrtrackingResult">

+ 18 - 3
ruoyi-shipping/src/main/resources/mapper/shipping/TVoyageMapper.xml

@@ -452,9 +452,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	        t_voyage
         WHERE
 	        f_status = 'T'
-        <if test="fNo != null and fNo != ''">
-            and f_no like concat('%', #{fNo}, '%')
-        </if>
+        <if test="fPid != null "> and f_pid = #{fPid}</if>
+        <if test="fNo != null  and fNo != ''"> and f_no = #{fNo}</if>
+        <if test="fPortofloadid != null "> and f_portofloadid = #{fPortofloadid}</if>
+        <if test="fPortofdischargeid != null "> and f_portofdischargeid = #{fPortofdischargeid}</if>
+        <if test="fDistinationid != null "> and f_distinationid = #{fDistinationid}</if>
+        <if test="fPortoftransshipment != null "> and f_portoftransshipment = #{fPortoftransshipment}</if>
+        <if test="fEtd != null "> and f_ETD = #{fEtd}</if>
+        <if test="fAtd != null "> and f_ATD = #{fAtd}</if>
+        <if test="fEta != null "> and f_ETA = #{fEta}</if>
+        <if test="fAta != null "> and f_ATA = #{fAta}</if>
+        <if test="fDays != null "> and f_days = #{fDays}</if>
+        <if test="fDucomentrayoffdate != null "> and f_ducomentrayoffdate = #{fDucomentrayoffdate}</if>
+        <if test="fCutoffdate != null "> and f_cutoffdate = #{fCutoffdate}</if>
+        <if test="fTeu != null  and fTeu != ''"> and f_teu = #{fTeu}</if>
+        <if test="fManageid != null "> and f_manageid = #{fManageid}</if>
+        <if test="fTel != null  and fTel != ''"> and f_tel = #{fTel}</if>
+        <if test="fStatus != null  and fStatus != ''"> and f_status = #{fStatus}</if>
+        <if test="fLaneid != null "> and f_laneid = #{fLaneid}</if>
     </select>
 
 </mapper>

+ 4 - 0
ruoyi-shipping/src/main/resources/mapper/shipping/TWarehousebillsCntritemsMapper.xml

@@ -95,6 +95,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <include refid="selectTWarehousebillsCntritemsVo"/>
         where f_id = #{fId}
     </select>
+    <select id="selectTWarehousebillsCntritemsByPId" parameterType="Long" resultMap="TWarehousebillsCntritemsResult">
+        <include refid="selectTWarehousebillsCntritemsVo"/>
+        where f_pid = #{fId}
+    </select>
         
     <insert id="insertTWarehousebillsCntritems" parameterType="TWarehousebillsCntritems" useGeneratedKeys="true" keyProperty="fId">
         insert into t_warehousebills_cntritems

+ 12 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/domain/TWarehouseBills.java

@@ -561,6 +561,9 @@ public class TWarehouseBills extends BaseEntity {
     /** 是否配船(0 是 1 否) */
     @Excel(name = "是否配船(0 是 1 否)")
     private Long fCargoPlanning;
+    /** 到港状态 0 未离港 1离港 2 到港 */
+    @Excel(name = "到港状态 0 未离港 1离港 2 到港")
+    private Integer fArrivalStatus;
 
     /** 仓储费计费类型 */
     @Excel(name = "仓储费计费类型")
@@ -617,6 +620,14 @@ public class TWarehouseBills extends BaseEntity {
     //航线中文名
     private String laneidName;
 
+    public Integer getfArrivalStatus() {
+        return fArrivalStatus;
+    }
+
+    public void setfArrivalStatus(Integer fArrivalStatus) {
+        this.fArrivalStatus = fArrivalStatus;
+    }
+
     public Long getfUpdeteStatus() {
         return fUpdeteStatus;
     }
@@ -1893,6 +1904,7 @@ public class TWarehouseBills extends BaseEntity {
                 ", fDeleteStatus=" + fDeleteStatus +
                 ", fRemarksFees=" + fRemarksFees +
                 ", fCargoPlanning=" + fCargoPlanning +
+                ", fArrivalStatus=" + fArrivalStatus +
                 '}';
     }
 }

+ 4 - 5
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/mapper/TWarehouseBillsMapper.java

@@ -3,13 +3,12 @@ package com.ruoyi.warehouseBusiness.mapper;
 
 import com.baomidou.mybatisplus.mapper.BaseMapper;
 import com.ruoyi.approvalFlow.domain.AuditItems;
-import com.ruoyi.common.core.domain.entity.TWarehouse;
 import com.ruoyi.reportManagement.domain.SingleAnalysisExcel;
 import com.ruoyi.reportManagement.domain.SingleAnalysisFeesExcel;
 import com.ruoyi.reportManagement.domain.TWareHouseItemsExcel;
 import com.ruoyi.reportManagement.dto.TWarehousebill;
-import com.ruoyi.shipping.excel.deriveInventoryExcel;
-import com.ruoyi.shipping.excel.singleVoyageByShipExcel;
+import com.ruoyi.shipping.excel.DeriveInventoryExcel;
+import com.ruoyi.shipping.excel.SingleVoyageByShipExcel;
 import com.ruoyi.warehouseBusiness.domain.TWareHouseExcelItems;
 import com.ruoyi.warehouseBusiness.domain.TWarehouseBills;
 import org.apache.ibatis.annotations.Param;
@@ -202,7 +201,7 @@ public interface TWarehouseBillsMapper extends BaseMapper<TWarehouseBills> {
      * @param tWarehouseBills
      * @return
      */
-    public List<deriveInventoryExcel> deriveInventory(TWarehouseBills tWarehouseBills);
+    public List<DeriveInventoryExcel> deriveInventory(TWarehouseBills tWarehouseBills);
 
     /**
      * 批量查询凯和订单的船名航次信息
@@ -229,5 +228,5 @@ public interface TWarehouseBillsMapper extends BaseMapper<TWarehouseBills> {
      * @param tWarehouseBills 主表
      * @return
      */
-    public List<singleVoyageByShipExcel> singleVoyageByShip(TWarehouseBills tWarehouseBills);
+    public List<SingleVoyageByShipExcel> singleVoyageByShip(TWarehouseBills tWarehouseBills);
 }

+ 9 - 3
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/ITWarehouseBillsService.java

@@ -3,8 +3,8 @@ package com.ruoyi.warehouseBusiness.service;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.model.LoginUser;
 import com.ruoyi.reportManagement.domain.TWareHouseItemsExcel;
-import com.ruoyi.reportManagement.dto.TWarehousebill;
-import com.ruoyi.shipping.excel.singleVoyageByShipExcel;
+import com.ruoyi.shipping.domain.TCntrno;
+import com.ruoyi.shipping.excel.SingleVoyageByShipExcel;
 import com.ruoyi.system.domain.SysCheckCode;
 import com.ruoyi.warehouseBusiness.domain.StorageChargeInsert;
 import com.ruoyi.warehouseBusiness.domain.TWareHouseExcelItems;
@@ -550,5 +550,11 @@ public interface ITWarehouseBillsService {
      * @param tWarehouseBills 主表
      * @return
      */
-    public List<singleVoyageByShipExcel> singleVoyageByShip(TWarehouseBills tWarehouseBills);
+    public List<SingleVoyageByShipExcel> singleVoyageByShip(TWarehouseBills tWarehouseBills);
+    /**
+     * 单航次配船修改箱动态信息
+     * @param tCntrno
+     * @return
+     */
+    public AjaxResult updateBoxMessage(TCntrno tCntrno,LoginUser loginUser);
 }

+ 195 - 8
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/impl/TWarehouseBillsServiceImpl.java

@@ -30,8 +30,8 @@ import com.ruoyi.reportManagement.domain.TWhgenleg;
 import com.ruoyi.reportManagement.mapper.TWhgenlegMapper;
 import com.ruoyi.shipping.domain.*;
 import com.ruoyi.shipping.excel.TWarehousebillsCntritemsExcel;
-import com.ruoyi.shipping.excel.deriveInventoryExcel;
-import com.ruoyi.shipping.excel.singleVoyageByShipExcel;
+import com.ruoyi.shipping.excel.DeriveInventoryExcel;
+import com.ruoyi.shipping.excel.SingleVoyageByShipExcel;
 import com.ruoyi.shipping.mapper.*;
 import com.ruoyi.system.domain.SysCheckCode;
 import com.ruoyi.system.domain.SysConfig;
@@ -40,7 +40,6 @@ import com.ruoyi.warehouseBusiness.domain.*;
 import com.ruoyi.warehouseBusiness.excel.*;
 import com.ruoyi.warehouseBusiness.mapper.*;
 import com.ruoyi.warehouseBusiness.service.ITWarehouseBillsService;
-import jdk.jfr.events.ExceptionThrownEvent;
 import org.apache.poi.hssf.usermodel.*;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.util.CellRangeAddress;
@@ -48,15 +47,13 @@ import org.apache.poi.ss.util.CellReference;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.omg.CORBA.OBJ_ADAPTER;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
 import org.springframework.web.multipart.MultipartFile;
 
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpServletResponseWrapper;
 import java.io.*;
 import java.math.BigDecimal;
 import java.text.ParseException;
@@ -173,6 +170,11 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
     private TVesselMapper tVesselMapper;
     @Autowired
     private TCntrnoMapper tCntrnoMapper;
+    @Autowired
+    private TAddressMapper tAddressMapper;
+    @Autowired
+    private TCntrtrackingMapper tCntrtrackingMapper;
+
     private static final Logger log = LoggerFactory.getLogger(AddressUtils.class);
 
 
@@ -5174,7 +5176,7 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
         }
 
         //根据船名航次查询清单
-        List<deriveInventoryExcel> list = tWarehouseBillsMapper.deriveInventory(tWarehouseBills);
+        List<DeriveInventoryExcel> list = tWarehouseBillsMapper.deriveInventory(tWarehouseBills);
 
         for(int i = 0;i<list.size();i++){
             HSSFRow tempRow = sheet.createRow(rowNum++);
@@ -5282,10 +5284,64 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
         //先查要改的多个订单的船名航次是否一直
         if (fVessel != null && fVoyage != null){
             List<TWarehouseBills> tWarehouseBills = tWarehouseBillsMapper.selectTWarehousebillsByIds(fIds);
+            //循环判断是否存在已经离港出运或者到港卸货的船名航次
+            if (CollectionUtils.isNotEmpty(tWarehouseBills) && fCargoPlanning.longValue() == 0){
+                List<String> list = new ArrayList<>();
+                List<String> boxMessage = new ArrayList<>();
+                for (TWarehouseBills tWarehouseBill : tWarehouseBills) {
+                    if (tWarehouseBill.getfCargoPlanning().longValue() == 0){
+                        list.add(tWarehouseBill.getfBillno());
+                    }
+                    //查询货物信息中的箱量
+                    TWarehousebillsCntr warehousebillsCntr = tWarehousebillsCntrMapper.selectTWarehousebillsCntrByPId(tWarehouseBill.getfId());
+                    //查询箱信息数量
+                    List<TWarehousebillsCntritems> tWarehousebillsCntritems = tWarehousebillsCntritemsMapper.selectTWarehousebillsCntritemsByPId(tWarehouseBill.getfId());
+                    if (CollectionUtils.isEmpty(tWarehousebillsCntritems) || tWarehousebillsCntritems.size() != warehousebillsCntr.getfCntrcount()){
+                        boxMessage.add(tWarehouseBill.getfBillno());
+                    }
+
+                }
+                if (CollectionUtils.isNotEmpty(list) || CollectionUtils.isNotEmpty(boxMessage)){
+                    String message = null;
+                    if (CollectionUtils.isNotEmpty(boxMessage) && CollectionUtils.isNotEmpty(list)){
+                        StringBuffer stringBuffer = new StringBuffer("订单缺少箱信息或者箱量不足,订单号为:");
+                        stringBuffer.append(org.apache.commons.lang.StringUtils.join(boxMessage.toArray(), ","));
+                        StringBuffer buffer = new StringBuffer("订单已配船请勿重复配船,订单号为:");
+                        buffer.append(org.apache.commons.lang.StringUtils.join(list.toArray(), ","));
+                        message = message+stringBuffer.toString()+","+buffer.toString();
+                    }else if (CollectionUtils.isNotEmpty(boxMessage) && CollectionUtils.isEmpty(list)){
+                        StringBuffer stringBuffer = new StringBuffer("订单缺少箱信息或者箱量不足,订单号为:");
+                        stringBuffer.append(org.apache.commons.lang.StringUtils.join(boxMessage.toArray(), ","));
+                        message = message+stringBuffer.toString();
+                    }else if (CollectionUtils.isEmpty(boxMessage) && CollectionUtils.isNotEmpty(list)){
+                        StringBuffer buffer = new StringBuffer("订单已配船请勿重复配船,订单号为:");
+                        buffer.append(org.apache.commons.lang.StringUtils.join(list.toArray(), ","));
+                        message= message+buffer.toString();
+                    }
+                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                    return AjaxResult.error(message);
+                }
+            }
             ArrayList<TWarehouseBills> collect = tWarehouseBills.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(TWarehouseBills -> TWarehouseBills.getfVslid() + ";"+ TWarehouseBills.getfVoyid()))), ArrayList::new));
             if (collect.size()>1){
                 return AjaxResult.error("请选择相同的船名航次");
             }
+        }else {
+            List<TWarehouseBills> tWarehouseBills = tWarehouseBillsMapper.selectTWarehousebillsByIds(fIds);
+            if (CollectionUtils.isNotEmpty(tWarehouseBills) && fCargoPlanning.longValue() == 1){
+                List<String> list = new ArrayList<>();
+                for (TWarehouseBills tWarehouseBill : tWarehouseBills) {
+                    if (tWarehouseBill.getfArrivalStatus().longValue() != 0){
+                        list.add(tWarehouseBill.getfBillno());
+                    }
+                }
+                if (CollectionUtils.isNotEmpty(list)){
+                    StringBuffer stringBuffer = new StringBuffer("订单已离港出运或到港卸货,订单号为:");
+                    stringBuffer.append(org.apache.commons.lang.StringUtils.join(list.toArray(), ","));
+                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                    return AjaxResult.error(stringBuffer.toString());
+                }
+            }
         }
         //一致批量更改船名航次
         int i = tWarehouseBillsMapper.updateTWarehousebillsByIds(fIds, fVessel, fVoyage,fCargoPlanning);
@@ -5302,7 +5358,7 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
     }
 
     @Override
-    public List<singleVoyageByShipExcel> singleVoyageByShip(TWarehouseBills tWarehouseBills) {
+    public List<SingleVoyageByShipExcel> singleVoyageByShip(TWarehouseBills tWarehouseBills) {
         return tWarehouseBillsMapper.singleVoyageByShip(tWarehouseBills);
     }
 
@@ -5864,5 +5920,136 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
         }
         return AjaxResult.success();
     }
+    @Override
+    @Transactional
+    public AjaxResult updateBoxMessage(TCntrno tCntrno,LoginUser loginUser) {
+        String remark = tCntrno.getfVsl()+tCntrno.getfVoy();
+        Date date = tCntrno.getfUpdatetime();
+        //查询船名航次对应的信息
+        TWarehouseBills tWarehouseBills = new TWarehouseBills();
+        tWarehouseBills.setfVslid(tCntrno.getfVslid());
+        tWarehouseBills.setfVoyid(tCntrno.getfVoyid());
+        tWarehouseBills.setfCargoPlanning(0L);
+        if (tCntrno.getUpdateStatus().longValue() == 1){
+            tWarehouseBills.setfArrivalStatus(0);
+            List<TWarehouseBills> tWarehouseBillsList = tWarehouseBillsMapper.webVersionOrderList(tWarehouseBills);
+            if (CollectionUtils.isEmpty(tWarehouseBillsList)){
+                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                return AjaxResult.error("该船名航次未配船或已离港出运或到港卸船");
+            }
+            //获取地点ID
+            Long aLong = tAddressMapper.selectTAddressByfName("在船");
+            if (aLong == null){
+                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                return AjaxResult.error("系统中缺少在船地点请维护");
+            }
+            //获取调箱动态ID
+            String fOpCTnsTaTus = sysDictDataMapper.selectDictValue("f_opctnstatus", "装船");
+            if (StringUtils.isEmpty(fOpCTnsTaTus)){
+                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                return AjaxResult.error("系统缺少箱动态装船请维护");
+            }
+            for (TWarehouseBills bills : tWarehouseBillsList) {
+                //查询货物信息
+                TWarehousebillsCntr warehousebillsCntr = tWarehousebillsCntrMapper.selectTWarehousebillsCntrByPId(bills.getfId());
+                //查询订单箱信息
+                TWarehousebillsCntritems tWarehousebillsCntritems = new TWarehousebillsCntritems();
+                tWarehousebillsCntritems.setfPid(bills.getfId());
+                List<TWarehousebillsCntritems> warehousebillsCntritems = tWarehousebillsCntritemsMapper.selectTWarehousebillsCntritemsList(tWarehousebillsCntritems);
+                if (CollectionUtils.isNotEmpty(warehousebillsCntritems)){
+                    for (TWarehousebillsCntritems warehousebillsCntritem : warehousebillsCntritems) {
+                        TCntrno cntrno = new TCntrno();
+                        cntrno.setfNo(warehousebillsCntritem.getfCntrno());
+                        cntrno.setUpdateTime(date);
+                        cntrno.setUpdateBy(loginUser.getUser().getUserName());
+                        cntrno.setfUpdatetime(date);
+                        cntrno.setRemark(remark);
+                        cntrno.setfUpdateaddress(aLong.toString());
+                        cntrno.setfOpctnstatus(fOpCTnsTaTus);
+                        cntrno.setfCntrstatus(warehousebillsCntr.getfCntrstatus());
+                        tCntrnoMapper.updateTCntrnoByfNo(cntrno);
+                        //保存历史信息
+                        TCntrno cntrnoById = tCntrnoMapper.selectTCnTrNoByfNo(warehousebillsCntritem.getfCntrno());
+                        if (cntrnoById == null){
+                            continue;
+                        }
+                        if (cntrnoById.getfStatus().equals("T") || cntrnoById.getfStatus().equals("正常")) {
+                            cntrnoById.setfStatus("T");
+                        } else {
+                            cntrnoById.setfStatus("F");
+                        }
+                        TCntrtracking tCntrtracking = new TCntrtracking();
+                        BeanUtils.copyProperties(cntrnoById, tCntrtracking);
+                        tCntrtracking.setfId(null);
+                        tCntrtracking.setfVoy(tCntrno.getfVoy());//航次
+                        tCntrtracking.setfVsl(tCntrno.getfVsl());//船名
+                        tCntrtrackingMapper.insertTCntrtracking(tCntrtracking);
+                    }
+                }
+                //修改主表状态为离港出运
+                TWarehouseBills warehouseBills = new TWarehouseBills();
+                warehouseBills.setfId(bills.getfId());
+                warehouseBills.setfArrivalStatus(1);
+                tWarehouseBillsMapper.updateKaHeOrder(warehouseBills);
+            }
+
+        }else if (tCntrno.getUpdateStatus().longValue() == 2){
+            tWarehouseBills.setfArrivalStatus(1);
+            List<TWarehouseBills> tWarehouseBillsList = tWarehouseBillsMapper.webVersionOrderList(tWarehouseBills);
+            if (CollectionUtils.isEmpty(tWarehouseBillsList)){
+                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                return AjaxResult.error("该船名航次未离港出运");
+            }
+            //获取调箱动态ID
+            String fOpCTnsTaTus = sysDictDataMapper.selectDictValue("f_opctnstatus", "卸船");
+            if (StringUtils.isEmpty(fOpCTnsTaTus)){
+                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                return AjaxResult.error("系统缺少箱动态卸船请维护");
+            }
+            for (TWarehouseBills bills : tWarehouseBillsList) {
+                //查询货物信息
+                TWarehousebillsCntr warehousebillsCntr = tWarehousebillsCntrMapper.selectTWarehousebillsCntrByPId(bills.getfId());
+                //查询订单箱信息
+                TWarehousebillsCntritems tWarehousebillsCntritems = new TWarehousebillsCntritems();
+                tWarehousebillsCntritems.setfPid(bills.getfId());
+                List<TWarehousebillsCntritems> warehousebillsCntritems = tWarehousebillsCntritemsMapper.selectTWarehousebillsCntritemsList(tWarehousebillsCntritems);
+                if (CollectionUtils.isNotEmpty(warehousebillsCntritems)){
+                    for (TWarehousebillsCntritems warehousebillsCntritem : warehousebillsCntritems) {
+                        TCntrno cntrno = new TCntrno();
+                        cntrno.setfNo(warehousebillsCntritem.getfCntrno());
+                        cntrno.setUpdateTime(date);
+                        cntrno.setUpdateBy(loginUser.getUser().getUserName());
+                        cntrno.setfUpdatetime(date);
+                        cntrno.setRemark(remark);
+                        cntrno.setfUpdateaddress(bills.getfDestportid().toString());
+                        cntrno.setfOpctnstatus(fOpCTnsTaTus);
+                        cntrno.setfCntrstatus(warehousebillsCntr.getfCntrstatus());
+                        tCntrnoMapper.updateTCntrnoByfNo(cntrno);
+                        //保存历史信息
+                        TCntrno cntrnoById = tCntrnoMapper.selectTCnTrNoByfNo(warehousebillsCntritem.getfCntrno());
+                        if (cntrnoById.getfStatus().equals("T") || cntrnoById.getfStatus().equals("正常")) {
+                            cntrnoById.setfStatus("T");
+                        } else {
+                            cntrnoById.setfStatus("F");
+                        }
+                        TCntrtracking tCntrtracking = new TCntrtracking();
+                        BeanUtils.copyProperties(cntrnoById, tCntrtracking);
+                        tCntrtracking.setfId(null);
+                        tCntrtracking.setfVoy(tCntrno.getfVoy());//航次
+                        tCntrtracking.setfVsl(tCntrno.getfVsl());//船名
+                        tCntrtrackingMapper.insertTCntrtracking(tCntrtracking);
+                    }
+                }
+                //修改主表状态为已到港卸货
+                TWarehouseBills warehouseBills = new TWarehouseBills();
+                warehouseBills.setfId(bills.getfId());
+                warehouseBills.setfArrivalStatus(2);
+                tWarehouseBillsMapper.updateKaHeOrder(warehouseBills);
+            }
+        }else {
+            return AjaxResult.error("请选择离岗出运或到港卸船");
+        }
+        return AjaxResult.success();
+    }
 
 }

+ 31 - 10
ruoyi-warehouse/src/main/resources/mapper/warehouseBusiness/TWarehousebillsMapper.xml

@@ -116,6 +116,7 @@
         <result property="fDeleteStatus"    column="f_delete_status"/>
         <result property="fRemarksFees"    column="f_remarks_fees"    />
         <result property="fCargoPlanning"    column="f_cargo_planning"    />
+        <result property="fArrivalStatus"    column="f_arrival_status"    />
     </resultMap>
 
     <sql id="selectTWarehousebillsVo">
@@ -128,7 +129,7 @@
         f_consigneeattn, f_consigneetel, f_insurance, f_insuranceamt, f_closedate, f_docmentdate, f_vslid, f_voyid, f_typeid, f_paymode, f_laneid, f_cntval,
         free_container_date, f_business_attribution, f_supervision_unit, f_declaration_elements, f_part_number, f_ifinspection, f_value, f_weighing_date,
         f_ifsampling, send_sample_date, f_ifweight_recovery, weight_recovery_date, warehouse_status, f_times ,f_date_changed, f_chargetype,f_weigh_weight,
-               f_predict_branch,f_grade,f_delivery_details,f_salesman_id,f_itemstatus,f_updete_status, f_submit_update, f_delete_status,f_remarks_fees,f_cargo_planning from t_warehousebills
+               f_predict_branch,f_grade,f_delivery_details,f_salesman_id,f_itemstatus,f_updete_status, f_submit_update, f_delete_status,f_remarks_fees,f_cargo_planning,f_arrival_status from t_warehousebills
     </sql>
 
     <select id="selectTWarehousebillsList" parameterType="TWarehousebills" resultMap="TWarehousebillsResult">
@@ -893,6 +894,7 @@
             <if test="fDeleteStatus != null">f_delete_status,</if>
             <if test="fRemarksFees != null">f_remarks_fees,</if>
             <if test="fCargoPlanning != null">f_cargo_planning,</if>
+            <if test="fArrivalStatus != null">f_arrival_status,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="fBillno != null">#{fBillno},</if>
@@ -1005,6 +1007,7 @@
             <if test="fDeleteStatus != null">#{fDeleteStatus},</if>
             <if test="fRemarksFees != null">#{fRemarksFees},</if>
             <if test="fCargoPlanning != null">#{fCargoPlanning},</if>
+            <if test="fArrivalStatus != null">#{fArrivalStatus},</if>
         </trim>
     </insert>
 
@@ -1121,6 +1124,7 @@
             <if test="fDeleteStatus != null">f_delete_status = #{fDeleteStatus},</if>
             <if test="fRemarksFees != null">f_remarks_fees = #{fRemarksFees},</if>
             <if test="fCargoPlanning != null">f_cargo_planning = #{fCargoPlanning},</if>
+            <if test="fArrivalStatus != null">f_arrival_status = #{fArrivalStatus},</if>
         </trim>
         where f_id = #{fId}
     </update>
@@ -1239,6 +1243,7 @@
             <if test="fDeleteStatus != null">f_delete_status = #{fDeleteStatus},</if>
             <if test="fRemarksFees != null">f_remarks_fees = #{fRemarksFees},</if>
             <if test="fCargoPlanning != null">f_cargo_planning = #{fCargoPlanning},</if>
+            <if test="fArrivalStatus != null">f_arrival_status = #{fArrivalStatus},</if>
         </trim>
         where f_id = #{fId}
     </update>
@@ -1508,7 +1513,8 @@
             tw.f_updete_status,
             tw.f_submit_update,
             tw.f_delete_status,
-            tw.f_cargo_planning
+            tw.f_cargo_planning,
+            tw.f_arrival_status
         FROM t_warehousebills tw
             LEFT JOIN t_address address ON address.f_id = tw.f_loadportid
             LEFT JOIN t_address ta ON ta.f_id = tw.f_loadportid
@@ -1622,6 +1628,8 @@
             <if test='timeInterval != null and timeInterval[1] != null and timeInterval[1]!= ""'>
                 and tw.create_time &lt;= #{timeInterval[1]}
             </if>
+            <if test="fCargoPlanning != null "> and tw.f_cargo_planning = #{fCargoPlanning}</if>
+            <if test="fArrivalStatus != null "> and tw.f_arrival_status = #{fArrivalStatus}</if>
         </where>
         ORDER BY tw.create_time DESC, tw.f_id DESC
     </select>
@@ -1716,7 +1724,10 @@
         tw.f_updete_status fUpdeteStatus,
         tw.f_submit_update fSubmitUpdate,
         tw.f_delete_status fDeleteStatus,
-        tw.f_cargo_planning fCargoPlanning
+        tw.f_cargo_planning fCargoPlanning,
+        tw.f_arrival_status fArrivalStatus,
+        tw.f_vslid fVslid,
+        tw.f_voyid fVoyid
         FROM
         t_warehousebills tw
         LEFT JOIN t_address ta ON ta.f_id = tw.f_laneid
@@ -1871,6 +1882,8 @@
             <if test='cLoadDate != null and cLoadDate[1] != null and cLoadDate[1]!= ""'>
                 and tw.f_bsdate &lt;= #{cLoadDate[1]}
             </if>
+            <if test="fCargoPlanning != null "> and tw.f_cargo_planning = #{fCargoPlanning}</if>
+            <if test="fArrivalStatus != null "> and tw.f_arrival_status = #{fArrivalStatus}</if>
         </where>
         ORDER BY tw.create_time DESC, tw.f_id DESC
     </select>
@@ -1966,7 +1979,8 @@
         tw.f_submit_update fSubmitUpdate,
         tw.f_delete_status fDeleteStatus,
         ROUND(IFNULL(tf.fAmount,0),2) fAmount,
-        tw.f_cargo_planning fCargoPlanning
+        tw.f_cargo_planning fCargoPlanning,
+        tw.f_arrival_status
         FROM
         t_warehousebills tw
         LEFT JOIN t_address ta ON ta.f_id = tw.f_laneid
@@ -2121,6 +2135,8 @@
             <if test='cLoadDate != null and cLoadDate[1] != null and cLoadDate[1]!= ""'>
                 and tw.f_bsdate &lt;= #{cLoadDate[1]}
             </if>
+            <if test="fCargoPlanning != null "> and tw.f_cargo_planning = #{fCargoPlanning}</if>
+            <if test="fArrivalStatus != null "> and tw.f_arrival_status = #{fArrivalStatus}</if>
         </where>
         ORDER BY tw.create_time DESC, tw.f_id DESC
     </select>
@@ -2224,7 +2240,8 @@
                tw.f_updete_status,
                tw.f_submit_update,
                tw.f_delete_status,
-               tw.f_cargo_planning
+               tw.f_cargo_planning,
+               tw.f_arrival_status
         FROM t_warehousebills tw
                  LEFT JOIN t_address address ON address.f_id = tw.f_loadportid
                  LEFT JOIN t_address ta ON ta.f_id = tw.f_loadportid
@@ -2472,7 +2489,7 @@
         order by f.create_time asc
     </select>
     <!--凯和导出清单根据船名航次-->
-    <select id="deriveInventory" parameterType="TWarehousebills" resultType="com.ruoyi.shipping.excel.deriveInventoryExcel">
+    <select id="deriveInventory" parameterType="TWarehousebills" resultType="com.ruoyi.shipping.excel.DeriveInventoryExcel">
         SELECT
             @rank:=@rank + 1 AS rankNo,
             a.*
@@ -2529,13 +2546,15 @@
                     <if test='cLoadDate != null and cLoadDate[1] != null and cLoadDate[1]!= ""'>
                         and tw.f_bsdate &lt;= #{cLoadDate[1]}
                     </if>
+                    <if test="fCargoPlanning != null "> and tw.f_cargo_planning = #{fCargoPlanning}</if>
+                    <if test="fArrivalStatus != null "> and tw.f_arrival_status = #{fArrivalStatus}</if>
                 </where>
                 ORDER BY tw.f_mblno,twc.f_cntrno
             )a,
             (SELECT @rank:= 0) b
     </select>
     <select id="selectTWarehousebillsByIds" parameterType="String" resultMap="TWarehousebillsResult">
-        select f_id,f_vslid, f_voyid from t_warehousebills
+        select f_id,f_vslid, f_voyid,f_arrival_status,f_billno,f_cargo_planning from t_warehousebills
         where f_id in
         <foreach item="fId" collection="array" open="(" separator="," close=")">
             #{fId}
@@ -2555,7 +2574,7 @@
         </foreach>
     </update>
     <!--凯和单航次配船-->
-    <select id="singleVoyageByShip" parameterType="TWarehousebills" resultType="com.ruoyi.shipping.excel.singleVoyageByShipExcel">
+    <select id="singleVoyageByShip" parameterType="TWarehousebills" resultType="com.ruoyi.shipping.excel.SingleVoyageByShipExcel">
        SELECT
         tv.f_name vslName,
         ty.f_no voyNo,
@@ -2563,8 +2582,10 @@
 				ty.f_ATA fAta,
 				ta.f_name fName,
         tre.f_name loadportName,
-        ts.f_name  destportName
-
+        ts.f_name  destportName,
+        tw.f_vslid fVslid,
+        tw.f_voyid fVoyid,
+        tw.f_arrival_status fArrivalStatus
         FROM
         t_warehousebills tw
         LEFT JOIN t_address ta ON ta.f_id = tw.f_laneid