Sfoglia il codice sorgente

凯和管理导入箱明细

lazhaoqian 4 anni fa
parent
commit
a390dda922

+ 1 - 1
pom.xml

@@ -130,7 +130,7 @@
                 <artifactId>poi-ooxml</artifactId>
                 <version>${poi.version}</version>
             </dependency>
-			
+
             <!--velocity代码生成使用模板 -->
             <dependency>
                 <groupId>org.apache.velocity</groupId>

+ 31 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/shipping/controller/TCntrnoController.java

@@ -5,7 +5,12 @@ import java.util.Map;
 
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.ruoyi.common.constant.UserConstants;
+import com.ruoyi.common.core.domain.model.LoginUser;
+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.TCntrnoExcel;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -205,9 +210,34 @@ public class TCntrnoController extends BaseController
     @GetMapping("/importTCntrnoTemplate")
     public AjaxResult importTCntrnoTemplate()
     {
-        ExcelUtil<TCntrno> util = new ExcelUtil<TCntrno>(TCntrno.class);
+        ExcelUtil<TCntrnoExcel> util = new ExcelUtil<TCntrnoExcel>(TCntrnoExcel.class);
         return util.importTemplateExcel("箱信息数据模板");
     }
+    /**
+     * 导入【箱信息】Excel
+     */
+    @PreAuthorize("@ss.hasPermi('shipping:cntrno:import')")
+    @Log(title = "导入集装箱动态", businessType = BusinessType.IMPORT)
+    @PostMapping(value = "/importCreate")
+    public AjaxResult importCreateCompanyMsg(@RequestParam("file") MultipartFile file)throws Exception
+    {
+        return tCntrnoService.importCreateCompanyMsg(file);
+    }
+    /**
+     * 批量导入箱数据
+     */
+    @PreAuthorize("@ss.hasPermi('shipping:cntrno:add')")
+    @Log(title = "集装箱号", businessType = BusinessType.INSERT)
+    @PostMapping("/batch")
+    public AjaxResult batch(@RequestParam("tCntrno") String tCntrno)
+    {
+        if (StringUtils.isEmpty(tCntrno)){
+            return AjaxResult.error("导入数据不能为空");
+        }else {
+            LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
+            return tCntrnoService.batch(tCntrno,loginUser);
+        }
+    }
 
 
 

+ 165 - 0
ruoyi-shipping/src/main/java/com/ruoyi/shipping/excel/TCntrnoExcel.java

@@ -0,0 +1,165 @@
+package com.ruoyi.shipping.excel;
+
+import com.ruoyi.common.annotation.Excel;
+
+/**
+ * @Author ZhaoQian La
+ * @Date 2021/5/21 10:04
+ * @Version 1.0
+ */
+public class TCntrnoExcel {
+    private static final long serialVersionUID = 1L;
+    /** 箱号 */
+    @Excel(name = "箱号")
+    private String fNo;
+    //箱类型
+    private Long fTypeid;
+    //箱主
+    private String fOwner;
+    //地点
+    private String fUpdateaddress;
+    //空重
+    private String fUpdateef;
+    //箱状态
+    private String fCntrstatus;
+    //箱主中文
+    @Excel(name = "箱主",readConverterExp = "如凯和")
+    private String ownerName;
+    //箱类型中文
+    @Excel(name = "箱类型",readConverterExp = "如20GP")
+    private String typeidName;
+    //空重中文
+    @Excel(name = "空重",readConverterExp = "如空")
+    private String updateEFName;
+    //地点中文名称
+    @Excel(name = "最新地点")
+    private String addressName;
+    @Excel(name = "地点类型")
+    private String addressType;
+
+    private String addressTypeId;
+    //箱状态中文
+    @Excel(name = "箱状态",readConverterExp = "如好或者坏")
+    private String cntrstatusName;
+
+    public String getAddressTypeId() {
+        return addressTypeId;
+    }
+
+    public void setAddressTypeId(String addressTypeId) {
+        this.addressTypeId = addressTypeId;
+    }
+
+    public String getAddressType() {
+        return addressType;
+    }
+
+    public void setAddressType(String addressType) {
+        this.addressType = addressType;
+    }
+
+    public String getfNo() {
+        return fNo;
+    }
+    public void setfNo(String fNo) {
+        this.fNo = fNo;
+    }
+
+    public Long getfTypeid() {
+        return fTypeid;
+    }
+
+    public void setfTypeid(Long fTypeid) {
+        this.fTypeid = fTypeid;
+    }
+
+    public String getfOwner() {
+        return fOwner;
+    }
+
+    public void setfOwner(String fOwner) {
+        this.fOwner = fOwner;
+    }
+
+    public String getfUpdateaddress() {
+        return fUpdateaddress;
+    }
+
+    public void setfUpdateaddress(String fUpdateaddress) {
+        this.fUpdateaddress = fUpdateaddress;
+    }
+
+    public String getfUpdateef() {
+        return fUpdateef;
+    }
+
+    public void setfUpdateef(String fUpdateef) {
+        this.fUpdateef = fUpdateef;
+    }
+
+    public String getfCntrstatus() {
+        return fCntrstatus;
+    }
+
+    public void setfCntrstatus(String fCntrstatus) {
+        this.fCntrstatus = fCntrstatus;
+    }
+
+    public String getOwnerName() {
+        return ownerName;
+    }
+
+    public void setOwnerName(String ownerName) {
+        this.ownerName = ownerName;
+    }
+
+    public String getTypeidName() {
+        return typeidName;
+    }
+
+    public void setTypeidName(String typeidName) {
+        this.typeidName = typeidName;
+    }
+
+    public String getUpdateEFName() {
+        return updateEFName;
+    }
+
+    public void setUpdateEFName(String updateEFName) {
+        this.updateEFName = updateEFName;
+    }
+
+    public String getAddressName() {
+        return addressName;
+    }
+
+    public void setAddressName(String addressName) {
+        this.addressName = addressName;
+    }
+
+    public String getCntrstatusName() {
+        return cntrstatusName;
+    }
+
+    public void setCntrstatusName(String cntrstatusName) {
+        this.cntrstatusName = cntrstatusName;
+    }
+
+    @Override
+    public String toString() {
+        return "TCntrnoExcel{" +
+                "fNo='" + fNo + '\'' +
+                ", fTypeid=" + fTypeid +
+                ", fOwner='" + fOwner + '\'' +
+                ", fUpdateaddress='" + fUpdateaddress + '\'' +
+                ", fUpdateef='" + fUpdateef + '\'' +
+                ", fCntrstatus='" + fCntrstatus + '\'' +
+                ", ownerName='" + ownerName + '\'' +
+                ", typeidName='" + typeidName + '\'' +
+                ", updateEFName='" + updateEFName + '\'' +
+                ", addressName='" + addressName + '\'' +
+                ", cntrstatusName='" + cntrstatusName + '\'' +
+                ", addressType='" + addressType + '\'' +
+                '}';
+    }
+}

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

@@ -98,4 +98,11 @@ public interface TCntrnoMapper
      * @return
      */
     public TCntrno selectTCntrnoFNo(TCntrno tCntrno);
+    /**
+     * 批量新增集装箱号
+     *
+     * @param tCntrno 集装箱号
+     * @return 结果
+     */
+    public int insertTCntrnoList(List<TCntrno> tCntrno);
 }

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

@@ -5,6 +5,7 @@ import java.util.Map;
 
 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 org.springframework.web.multipart.MultipartFile;
 
@@ -122,4 +123,17 @@ public interface ITCntrnoService
      * @return 结果
      */
     public AjaxResult importTcntrnoDataExcel(MultipartFile fileName);
+    /**
+     *  导入Excel生成箱信息
+     * @param file  excel
+     * @return  结果
+     */
+    public AjaxResult importCreateCompanyMsg(MultipartFile file) throws Exception;
+
+    /**
+     * 批量新增箱信息
+     * @param tCntrno
+     * @return
+     */
+    public AjaxResult batch(String tCntrno, LoginUser loginUser);
 }

+ 255 - 55
ruoyi-shipping/src/main/java/com/ruoyi/shipping/service/impl/TCntrnoServiceImpl.java

@@ -1,25 +1,41 @@
 package com.ruoyi.shipping.service.impl;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigDecimal;
 import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.Function;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
 
+import com.alibaba.fastjson.JSONArray;
+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.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.TCntrtracking;
-import com.ruoyi.shipping.domain.TConditionAccessory;
+import com.ruoyi.shipping.domain.*;
+import com.ruoyi.shipping.excel.TCntrnoExcel;
+import com.ruoyi.shipping.excel.TWarehousebillsCntritemsExcel;
 import com.ruoyi.shipping.mapper.*;
 import com.ruoyi.system.mapper.SysDictDataMapper;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.util.CellReference;
+import org.apache.poi.xssf.streaming.SXSSFWorkbook;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import com.ruoyi.shipping.domain.TCntrno;
 import com.ruoyi.shipping.service.ITCntrnoService;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
 
+import static com.ruoyi.common.utils.poi.Excel.filter;
+
 /**
  * 集装箱号Service业务层处理
  *
@@ -27,8 +43,7 @@ import org.springframework.web.multipart.MultipartFile;
  * @date 2021-03-22
  */
 @Service
-public class TCntrnoServiceImpl implements ITCntrnoService
-{
+public class TCntrnoServiceImpl implements ITCntrnoService {
     @Autowired
     private TCntrnoMapper tCntrnoMapper;
     @Autowired
@@ -49,8 +64,7 @@ public class TCntrnoServiceImpl implements ITCntrnoService
      * @return 集装箱号
      */
     @Override
-    public TCntrno selectTCntrnoById(Long fId)
-    {
+    public TCntrno selectTCntrnoById(Long fId) {
         return tCntrnoMapper.selectTCntrnoById(fId);
     }
 
@@ -61,8 +75,7 @@ public class TCntrnoServiceImpl implements ITCntrnoService
      * @return 集装箱号
      */
     @Override
-    public List<TCntrno> selectTCntrnoList(TCntrno tCntrno)
-    {
+    public List<TCntrno> selectTCntrnoList(TCntrno tCntrno) {
         return tCntrnoMapper.selectTCntrnoList(tCntrno);
     }
 
@@ -73,8 +86,7 @@ public class TCntrnoServiceImpl implements ITCntrnoService
      * @return 结果
      */
     @Override
-    public int insertTCntrno(TCntrno tCntrno)
-    {
+    public int insertTCntrno(TCntrno tCntrno) {
         tCntrno.setCreateTime(DateUtils.getNowDate());
         tCntrno.setCreateBy(SecurityUtils.getUsername());
         tCntrno.setfUpdatetime(DateUtils.getNowDate());
@@ -90,59 +102,58 @@ public class TCntrnoServiceImpl implements ITCntrnoService
      */
     @Override
     @Transactional
-    public int updateTCntrno(List<TCntrno> tCntrno)
-    {
+    public int updateTCntrno(List<TCntrno> tCntrno) {
         int update = 0;
-        if (CollectionUtils.isNotEmpty(tCntrno)){
+        if (CollectionUtils.isNotEmpty(tCntrno)) {
             for (TCntrno cntrno : tCntrno) {
                 String remark = cntrno.getRemark();
                 cntrno.setUpdateTime(DateUtils.getNowDate());
                 cntrno.setUpdateBy(SecurityUtils.getUsername());
                 //最新时间
-                if (cntrno.getFoldtime() == null){
+                if (cntrno.getFoldtime() == null) {
                     cntrno.setfUpdatetime(DateUtils.getNowDate());
-                }else {
+                } else {
                     cntrno.setfUpdatetime(cntrno.getFoldtime());
                 }
                 //调入地点
-                if (StringUtils.isNotEmpty(cntrno.getFoldSite())){
+                if (StringUtils.isNotEmpty(cntrno.getFoldSite())) {
                     cntrno.setfUpdateaddress(cntrno.getFoldSite());
                 }
                 //调入空重
-                if (StringUtils.isNotEmpty(cntrno.getFoldFUpdateef())){
+                if (StringUtils.isNotEmpty(cntrno.getFoldFUpdateef())) {
                     cntrno.setfUpdateef(cntrno.getFoldFUpdateef());
                 }
                 //调入状态
-                if (StringUtils.isNotEmpty(cntrno.getFoldFCntrstatus())){
+                if (StringUtils.isNotEmpty(cntrno.getFoldFCntrstatus())) {
                     cntrno.setfCntrstatus(cntrno.getFoldFCntrstatus());
                 }
-                if (StringUtils.isNotEmpty(remark)){
+                if (StringUtils.isNotEmpty(remark)) {
                     cntrno.setRemark(null);
                 }
                 //更改t_cntro表信息
                 update = tCntrnoMapper.updateTCntrno((cntrno));
                 //保存信息
                 TCntrno cntrnoById = tCntrnoMapper.selectTCntrnoById(cntrno.getfId());
-                if (cntrnoById.getfStatus().equals("T") ||cntrnoById.getfStatus().equals("正常")){
+                if (cntrnoById.getfStatus().equals("T") || cntrnoById.getfStatus().equals("正常")) {
                     cntrnoById.setfStatus("T");
-                }else {
+                } else {
                     cntrnoById.setfStatus("F");
                 }
-                if (StringUtils.isNotEmpty(cntrno.getfMblno())){//提单号
+                if (StringUtils.isNotEmpty(cntrno.getfMblno())) {//提单号
                     cntrnoById.setfMblno(cntrno.getfMblno());
                 }
-                if (StringUtils.isNotEmpty(cntrno.getfVoy())){//航次
+                if (StringUtils.isNotEmpty(cntrno.getfVoy())) {//航次
                     cntrnoById.setfVoy(cntrno.getfVoy());
                 }
-                if (StringUtils.isNotEmpty(cntrno.getfVsl())){//船名
+                if (StringUtils.isNotEmpty(cntrno.getfVsl())) {//船名
                     cntrnoById.setfVsl(cntrno.getfVsl());
                 }
-                if (StringUtils.isNotEmpty(remark)){
+                if (StringUtils.isNotEmpty(remark)) {
                     cntrnoById.setRemark(remark);
                 }
                 TCntrtracking setfield = setfield(cntrnoById);
                 tCntrtrackingMapper.insertTCntrtracking(setfield);
-                if (CollectionUtils.isNotEmpty(cntrno.getAccessoryList())){
+                if (CollectionUtils.isNotEmpty(cntrno.getAccessoryList())) {
                     for (TConditionAccessory tConditionAccessory : cntrno.getAccessoryList()) {
                         tConditionAccessory.setfPid(setfield.getfId());
                         tConditionAccessory.setCreateBy(SecurityUtils.getUsername());
@@ -161,9 +172,9 @@ public class TCntrnoServiceImpl implements ITCntrnoService
         tCntrno.setUpdateTime(DateUtils.getNowDate());
         tCntrno.setUpdateBy(SecurityUtils.getUsername());
         tCntrno.setfUpdatetime(DateUtils.getNowDate());
-        if (tCntrno.getfStatus().equals("T") ||tCntrno.getfStatus().equals("正常")){
+        if (tCntrno.getfStatus().equals("T") || tCntrno.getfStatus().equals("正常")) {
             tCntrno.setfStatus("T");
-        }else {
+        } else {
             tCntrno.setfStatus("F");
         }
         TCntrtracking setfield = setfield(tCntrno);
@@ -180,8 +191,7 @@ public class TCntrnoServiceImpl implements ITCntrnoService
      * @return 结果
      */
     @Override
-    public int deleteTCntrnoByIds(Long[] fIds)
-    {
+    public int deleteTCntrnoByIds(Long[] fIds) {
         return tCntrnoMapper.deleteTCntrnoByIds(fIds);
     }
 
@@ -192,13 +202,13 @@ public class TCntrnoServiceImpl implements ITCntrnoService
      * @return 结果
      */
     @Override
-    public int deleteTCntrnoById(Long fId)
-    {
+    public int deleteTCntrnoById(Long fId) {
         return tCntrnoMapper.deleteTCntrnoById(fId);
     }
 
     /**
      * 批量更新数据状态将正常状态改为停用
+     *
      * @param fIds
      * @return
      */
@@ -209,7 +219,7 @@ public class TCntrnoServiceImpl implements ITCntrnoService
 
     @Override
     public List<TCntrno> selectTcntrnoMessage(TCntrno tCntrno) {
-        return tCntrnoMapper.selectTcntrnoMessage(tCntrno,null,null,null,null,null);
+        return tCntrnoMapper.selectTcntrnoMessage(tCntrno, null, null, null, null, null);
     }
 
     @Override
@@ -217,14 +227,14 @@ public class TCntrnoServiceImpl implements ITCntrnoService
         StringBuffer stringBuffer = new StringBuffer();
         List<String> list = tCntrMapper.selectTCntrFNo();
         String sql = null;
-        if (CollectionUtils.isNotEmpty(list)){
+        if (CollectionUtils.isNotEmpty(list)) {
             for (String s : list) {
-                stringBuffer.append("MAX( CASE WHEN tt.f_no = '"+s);
-                stringBuffer.append("' THEN tt.typeidCount ELSE 0 END ) AS '" +s +"',");
+                stringBuffer.append("MAX( CASE WHEN tt.f_no = '" + s);
+                stringBuffer.append("' THEN tt.typeidCount ELSE 0 END ) AS '" + s + "',");
             }
-            sql = stringBuffer.subSequence(0,stringBuffer.length() -1).toString();
+            sql = stringBuffer.subSequence(0, stringBuffer.length() - 1).toString();
         }
-        return tCntrnoMapper.getTCntrnoMessage(sql,tCntrno);
+        return tCntrnoMapper.getTCntrnoMessage(sql, tCntrno);
     }
 
     @Override
@@ -234,21 +244,21 @@ public class TCntrnoServiceImpl implements ITCntrnoService
         String typeidName = null;//箱类型
         String cntrstatusName = null;//箱状态
         String updateEFName = null;//空重
-        if (StringUtils.isNotEmpty(tCntrno.getAddressName())){
+        if (StringUtils.isNotEmpty(tCntrno.getAddressName())) {
             address = tCntrno.getAddressName();
         }
-        if (StringUtils.isNotEmpty(tCntrno.getTypeidName())){
+        if (StringUtils.isNotEmpty(tCntrno.getTypeidName())) {
             typeidName = tCntrno.getTypeidName();
         }
         //箱状态不为空查箱状态
-        if (StringUtils.isNotEmpty(tCntrno.getCntrstatusName())){
+        if (StringUtils.isNotEmpty(tCntrno.getCntrstatusName())) {
             cntrstatusName = tCntrno.getCntrstatusName();
         }
         //箱空重部位空查空重
-        if (StringUtils.isNotEmpty(tCntrno.getUpdateEFName())){
+        if (StringUtils.isNotEmpty(tCntrno.getUpdateEFName())) {
             updateEFName = tCntrno.getUpdateEFName();
         }
-        return tCntrnoMapper.selectTcntrnoMessage(tCntrno,address,typeidName,cntrstatusName,updateEFName,tCntrno.getCntrsize());
+        return tCntrnoMapper.selectTcntrnoMessage(tCntrno, address, typeidName, cntrstatusName, updateEFName, tCntrno.getCntrsize());
     }
 
     @Override
@@ -274,8 +284,9 @@ public class TCntrnoServiceImpl implements ITCntrnoService
     }
 
     /**
-     *  后续维护
-     * @param fileName        更新箱信息数据列表
+     * 后续维护
+     *
+     * @param fileName 更新箱信息数据列表
      * @return
      */
     @Override
@@ -284,8 +295,9 @@ public class TCntrnoServiceImpl implements ITCntrnoService
     }
 
     /**
-     *  后续维护
-     * @param fileName        更新箱信息数据列表
+     * 后续维护
+     *
+     * @param fileName 更新箱信息数据列表
      * @return
      */
     @Override
@@ -293,23 +305,207 @@ public class TCntrnoServiceImpl implements ITCntrnoService
         return null;
     }
 
+    @Override
+    public AjaxResult importCreateCompanyMsg(MultipartFile file) throws Exception {
+        List<TCntrnoExcel> fleetCompanyMsgs = new ArrayList<>();
+
+        InputStream inputStream = null;
+        try {
+            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;
+                }
+                TCntrnoExcel companyMsg = new TCntrnoExcel();
+                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);
+                            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 + "箱类型");
+                            }
+                            companyMsg.setTypeidName(cell.getStringCellValue());
+                            if (StringUtils.isNotEmpty(cell.getStringCellValue())) {
+                                Long fId = tCntrMapper.selectRcntrFId(companyMsg.getTypeidName());
+                                companyMsg.setfTypeid(fId);
+                            }
+                            break;
+                        case "最新地点":
+                            //设置单元格类型
+                            cell.setCellType(CellType.STRING);
+                            if (StringUtils.isEmpty(cell.getStringCellValue())) {
+                                return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少最新地点");
+                            }
+                            companyMsg.setAddressName((cell.getStringCellValue()));
+                            break;
+                        case "箱主":
+                            //设置单元格类型
+                            cell.setCellType(CellType.STRING);
+                            if (StringUtils.isEmpty(cell.getStringCellValue())) {
+                                return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少货名");
+                            }
+                            companyMsg.setOwnerName(cell.getStringCellValue());
+                            if (StringUtils.isNotEmpty(cell.getStringCellValue())) {
+                                String fPackageid = sysDictDataMapper.selectDictValue("f_owner", cell.getStringCellValue());
+                                if (StringUtils.isNotEmpty(fPackageid)) {
+                                    companyMsg.setfOwner(fPackageid);
+                                }
+                            }
+                            break;
+                        case "箱状态":
+                            //设置单元格类型
+                            cell.setCellType(CellType.STRING);
+                            if (StringUtils.isEmpty(cell.getStringCellValue())) {
+                                return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少箱状态");
+                            }
+                            companyMsg.setCntrstatusName(cell.getStringCellValue());
+                            if (StringUtils.isNotEmpty(cell.getStringCellValue())) {
+                                String setCntrstatusid = sysDictDataMapper.selectDictValue("f_cntrstatus", cell.getStringCellValue());
+                                if (StringUtils.isNotEmpty(setCntrstatusid)) {
+                                    companyMsg.setfCntrstatus(setCntrstatusid);
+                                }
+                            }
+                            break;
+                        case "空重":
+                            //设置单元格类型
+                            cell.setCellType(CellType.STRING);
+                            if (StringUtils.isEmpty(cell.getStringCellValue())) {
+                                return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少箱型");
+                            }
+                            companyMsg.setUpdateEFName(cell.getStringCellValue());
+                            if (StringUtils.isNotEmpty(cell.getStringCellValue())) {
+                                String setUpdateEFid = sysDictDataMapper.selectDictValue("f_updateEF", cell.getStringCellValue());
+                                if (StringUtils.isNotEmpty(setUpdateEFid)) {
+                                    companyMsg.setfUpdateef(setUpdateEFid);
+                                }
+                            }
+                            break;
+                        case "地点类型":
+                            //设置单元格类型
+                            cell.setCellType(CellType.STRING);
+                            if (StringUtils.isEmpty(cell.getStringCellValue())) {
+                                return AjaxResult.error("Excel箱信息数据第" + line + "行数据缺少地点类型");
+                            }
+                            companyMsg.setAddressType(cell.getStringCellValue());
+                            if (StringUtils.isNotEmpty(cell.getStringCellValue())) {
+                                String fPackageid = sysDictDataMapper.selectDictValue("f_types", cell.getStringCellValue());
+                                if (StringUtils.isNotEmpty(fPackageid)) {
+                                    companyMsg.setAddressTypeId(fPackageid);
+                                }
+                            }
+                            break;
+                        /*case "箱来源":
+                            //设置单元格类型
+                            cell.setCellType(CellType.STRING);
+                            companyMsg.setSourceName(cell.getStringCellValue());
+                            if (StringUtils.isNotEmpty(cell.getStringCellValue())) {
+                                String setSourceid = sysDictDataMapper.selectDictValue("f_source", cell.getStringCellValue());
+                                if (StringUtils.isNotEmpty(setSourceid)) {
+                                    companyMsg.setfSource(setSourceid);
+                                }
+                            }
+                            break;
+                        case "租赁方式":
+                            //设置单元格类型
+                            cell.setCellType(CellType.STRING);
+                            companyMsg.setRentName(cell.getStringCellValue());
+                            if (StringUtils.isNotEmpty(cell.getStringCellValue())) {
+                                String setRentid = sysDictDataMapper.selectDictValue("f_rent", cell.getStringCellValue());
+                                if (StringUtils.isNotEmpty(setRentid)) {
+                                    companyMsg.setfRent(setRentid);
+                                }
+                            }
+                            break;
+                        case "备注":
+                            //设置单元格类型
+                            cell.setCellType(CellType.STRING);
+                            companyMsg.setRemark(cell.getStringCellValue());
+                            break;*/
+                    }
+                    if (StringUtils.isNotEmpty(companyMsg.getAddressName()) && StringUtils.isNotEmpty(companyMsg.getAddressTypeId())) {
+                        TAddress tAddress = new TAddress();
+                        tAddress.setfName(companyMsg.getAddressName());
+                        tAddress.setfTypes(companyMsg.getAddressTypeId());
+                        TAddress address = tAddressMapper.selectAddressFName(tAddress);
+                        if (address != null){
+                            companyMsg.setfUpdateaddress(address.getfId().toString());
+                        }
+                    }
+                }
+                fleetCompanyMsgs.add(companyMsg);
+            }
+            fleetCompanyMsgs = fleetCompanyMsgs.stream().filter(distinctByKey(TCntrnoExcel::getfNo)).collect(Collectors.toList());
+        } catch (IOException e) {
+            return AjaxResult.error("上传文件失败,请检查文件是否损坏");
+        }
+        return AjaxResult.success("success", fleetCompanyMsgs);
+    }
+
+    @Override
+    @Transactional
+    public AjaxResult batch(String tCntrno, LoginUser loginUser) {
+        JSONArray jsonCrArray = JSONArray.parseArray(tCntrno);
+        List<TCntrno> tCntrnoList = JSONObject.parseArray(jsonCrArray.toJSONString(), TCntrno.class);
+        StringBuffer stringBuffer = new StringBuffer();
+        if (CollectionUtils.isNotEmpty(tCntrnoList)) {
+            for (TCntrno cntrno : tCntrnoList) {
+                if (UserConstants.NOT_UNIQUE.equals(this.selectTCntrnoFNo(cntrno))) {
+                    stringBuffer.append(cntrno.getfNo() + "编号已存在,");
+                    continue;
+                } else {
+                    cntrno.setCreateTime(DateUtils.getNowDate());
+                    cntrno.setCreateBy(SecurityUtils.getUsername());
+                    cntrno.setfUpdatetime(DateUtils.getNowDate());
+                    cntrno.setfStatus("T");
+                    tCntrnoMapper.insertTCntrno(cntrno);
+                }
+            }
+        }
+        if (StringUtils.isNotEmpty(stringBuffer)){
+            return AjaxResult.success("success",stringBuffer.toString());
+        }else {
+            return AjaxResult.success();
+        }
+    }
+
     /**
      * set字段
+     *
      * @param tCntrno
      * @return
      */
-    public TCntrtracking  setfield(TCntrno tCntrno){
+    public TCntrtracking setfield(TCntrno tCntrno) {
         TCntrtracking tCntrtracking = new TCntrtracking();
-        BeanUtils.copyProperties(tCntrno,tCntrtracking);
+        BeanUtils.copyProperties(tCntrno, tCntrtracking);
         tCntrtracking.setfId(null);
         return tCntrtracking;
     }
-    public List<String> GetMapKey(List<Map<String, Object>> listResult)
-    {
-        if ((listResult != null) && (!listResult.isEmpty()))
-        {
+
+    public List<String> GetMapKey(List<Map<String, Object>> listResult) {
+        if ((listResult != null) && (!listResult.isEmpty())) {
             List listKey = new ArrayList();
-            Map mapResult = (Map)listResult.get(0);
+            Map mapResult = (Map) listResult.get(0);
             Set mapKeySet = mapResult.keySet();
             String listHead = "";
             Iterator iteratorKey = mapKeySet.iterator();
@@ -321,4 +517,8 @@ public class TCntrnoServiceImpl implements ITCntrnoService
         }
         return null;
     }
+    private static <T> Predicate<T> distinctByKey(Function<? super T, Object> keyExtractor) {
+        Map<Object, Boolean> seen = new ConcurrentHashMap<>();
+        return t -> seen.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null;
+    }
 }

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

@@ -100,7 +100,7 @@
         LEFT JOIN t_address address ON address.f_id = tc.f_updateaddress
         <where>
             tc.f_status = 'T'
-            <if test="tc.fNo != null  and tc.fNo != ''">and tc.f_no = #{tc.fNo}</if>
+            <if test="tc.fNo != null  and tc.fNo != ''">and tc.f_no like concat('%', #{tc.fNo}, '%') </if>
             <if test="tc.fTypeid != null ">and tc.f_typeid = #{tc.fTypeid}</if>
             <if test="tc.fOwner != null  and tc.fOwner != ''">and tc.f_owner = #{tc.fOwner}</if>
             <if test="tc.fSource != null  and tc.fSource != ''">and tc.f_source = #{tc.fSource}</if>
@@ -384,6 +384,51 @@
         WHERE
         f_no = #{fNo}
     </select>
+    <insert id="insertTCntrnoList" parameterType="list">
+        insert into t_cntrno
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="fId != null">f_id,</if>
+            <if test="fNo != null and fNo != ''">f_no,</if>
+            <if test="fTypeid != null">f_typeid,</if>
+            <if test="fOwner != null and fOwner != ''">f_owner,</if>
+            <if test="fSource != null">f_source,</if>
+            <if test="fRent != null">f_rent,</if>
+            <if test="fUpdatetime != null">f_updatetime,</if>
+            <if test="fUpdateaddress != null and fUpdateaddress != ''">f_updateaddress,</if>
+            <if test="fUpdateef != null and fUpdateef != ''">f_updateEF,</if>
+            <if test="fCntrstatus != null and fCntrstatus != ''">f_cntrstatus,</if>
+            <if test="fStatus != null">f_status,</if>
+            <if test="fOpctnstatus != null  and fOpctnstatus != ''">f_opctnstatus,</if>
+            <if test="fSealno != null  and fSealno != ''">f_sealno,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateBy != null">update_by,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="remark != null">remark,</if>
+        </trim>
+        <foreach collection="list" item="item" separator=",">
+            <trim prefix="values (" suffix=")" suffixOverrides=",">
+                <if test="fId != null">#{fId},</if>
+                <if test="fNo != null and fNo != ''">#{fNo},</if>
+                <if test="fTypeid != null">#{fTypeid},</if>
+                <if test="fOwner != null and fOwner != ''">#{fOwner},</if>
+                <if test="fSource != null">#{fSource},</if>
+                <if test="fRent != null">#{fRent},</if>
+                <if test="fUpdatetime != null">#{fUpdatetime},</if>
+                <if test="fUpdateaddress != null and fUpdateaddress != ''">#{fUpdateaddress},</if>
+                <if test="fUpdateef != null and fUpdateef != ''">#{fUpdateef},</if>
+                <if test="fCntrstatus != null and fCntrstatus != ''">#{fCntrstatus},</if>
+                <if test="fStatus != null">#{fStatus},</if>
+                <if test="fOpctnstatus != null  and fOpctnstatus != ''">#{fOpctnstatus},</if>
+                <if test="fSealno != null  and fSealno != ''">#{fSealno},</if>
+                <if test="createBy != null">#{createBy},</if>
+                <if test="createTime != null">#{createTime},</if>
+                <if test="updateBy != null">#{updateBy},</if>
+                <if test="updateTime != null">#{updateTime},</if>
+                <if test="remark != null">#{remark},</if>
+            </trim>
+        </foreach>
+    </insert>
 
 
 </mapper>