|
@@ -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;
|
|
|
+ }
|
|
|
}
|