Browse Source

备件台账以及库位导入修复

master
songguoqiang 6 months ago
parent
commit
3500a68dfd
  1. 2
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemaccounts/ItemAccountsController.java
  2. 3
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemaccounts/vo/ItemAccountsErrorVO.java
  3. 2
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/location/vo/LocationImportExcelVo.java
  4. 2
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemaccounts/ItemAccountsService.java
  5. 23
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemaccounts/ItemAccountsServiceImpl.java

2
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemaccounts/ItemAccountsController.java

@ -181,7 +181,7 @@ public class ItemAccountsController {
@RequestParam(value = "updatePart", required = false, defaultValue = "false") Boolean updatePart) throws Exception { @RequestParam(value = "updatePart", required = false, defaultValue = "false") Boolean updatePart) throws Exception {
List<ItemAccountsImportExcelVO> list = ExcelUtils.read(file, ItemAccountsImportExcelVO.class); List<ItemAccountsImportExcelVO> list = ExcelUtils.read(file, ItemAccountsImportExcelVO.class);
List<ItemAccountsImportExcelVO> errorList = itemAccountsService.importItemAccountsList(list, mode, updatePart); List<ItemAccountsErrorVO> errorList = itemAccountsService.importItemAccountsList(list, mode, updatePart);
Map<String, Object> returnMap = new HashMap<>(); Map<String, Object> returnMap = new HashMap<>();
returnMap.put("errorCount", errorList.size()); returnMap.put("errorCount", errorList.size());

3
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/itemaccounts/vo/ItemAccountsErrorVO.java

@ -14,4 +14,7 @@ public class ItemAccountsErrorVO extends ItemAccountsImportExcelVO {
@ExcelProperty(value = "导入说明", index = 1) @ExcelProperty(value = "导入说明", index = 1)
private String importRemark; private String importRemark;
@ExcelProperty(value = "行号", index = 2)
private String rowNumber;
} }

2
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/location/vo/LocationImportExcelVo.java

@ -16,7 +16,7 @@ import java.math.BigDecimal;
@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题 @Accessors(chain = false) // 设置 chain = false,避免用户导入有问题
public class LocationImportExcelVo { public class LocationImportExcelVo {
@ExcelProperty("库位编") @ExcelProperty("库位编")
@ExcelValid(message = "必填") @ExcelValid(message = "必填")
@ColumnWidth(value = 20) @ColumnWidth(value = 20)
private String number; private String number;

2
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemaccounts/ItemAccountsService.java

@ -108,7 +108,7 @@ public interface ItemAccountsService {
* @param updatePart 是否支持更新 * @param updatePart 是否支持更新
* @return 导入结果 * @return 导入结果
*/ */
public List<ItemAccountsImportExcelVO> importItemAccountsList(List<ItemAccountsImportExcelVO> datas, Integer mode, boolean updatePart); public List<ItemAccountsErrorVO> importItemAccountsList(List<ItemAccountsImportExcelVO> datas, Integer mode, boolean updatePart);
/** /**
* 获得备件台账分页 * 获得备件台账分页

23
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/itemaccounts/ItemAccountsServiceImpl.java

@ -7,14 +7,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.win.framework.common.exception.util.ServiceExceptionUtil; import com.win.framework.common.exception.util.ServiceExceptionUtil;
import com.win.framework.common.pojo.CustomConditions; import com.win.framework.common.pojo.CustomConditions;
import com.win.framework.common.pojo.PageResult; import com.win.framework.common.pojo.PageResult;
import com.win.module.eam.controller.item.vo.ItemBaseVO;
import com.win.module.eam.controller.itemaccounts.vo.*; import com.win.module.eam.controller.itemaccounts.vo.*;
import com.win.module.eam.controller.transaction.vo.TransactionCreateReqVO; import com.win.module.eam.controller.transaction.vo.TransactionCreateReqVO;
import com.win.module.eam.convert.itemaccounts.ItemAccountsConvert; import com.win.module.eam.convert.itemaccounts.ItemAccountsConvert;
import com.win.module.eam.dal.dataobject.devicemaintenancejob.DeviceMaintenanceJobMainDO;
import com.win.module.eam.dal.dataobject.item.ItemDO; import com.win.module.eam.dal.dataobject.item.ItemDO;
import com.win.module.eam.dal.dataobject.itemaccounts.ItemAccountsDO; import com.win.module.eam.dal.dataobject.itemaccounts.ItemAccountsDO;
import com.win.module.eam.dal.dataobject.iteminlocation.ItemInLocationDO;
import com.win.module.eam.dal.dataobject.itemlocationreplace.ItemLocationReplaceDO; import com.win.module.eam.dal.dataobject.itemlocationreplace.ItemLocationReplaceDO;
import com.win.module.eam.dal.dataobject.itemnewturnin.ItemNewTurnInDO; import com.win.module.eam.dal.dataobject.itemnewturnin.ItemNewTurnInDO;
import com.win.module.eam.dal.dataobject.location.LocationDO; import com.win.module.eam.dal.dataobject.location.LocationDO;
@ -39,6 +36,7 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.win.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; import static com.win.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
@ -344,14 +342,24 @@ public class ItemAccountsServiceImpl implements ItemAccountsService {
@Override @Override
@Transactional @Transactional
public List<ItemAccountsImportExcelVO> importItemAccountsList(List<ItemAccountsImportExcelVO> datas, Integer mode, boolean updatePart) { public List<ItemAccountsErrorVO> importItemAccountsList(List<ItemAccountsImportExcelVO> datas, Integer mode, boolean updatePart) {
//备件编号+库位编码+类型唯一 //备件编号+库位编码+类型唯一
if (CollUtil.isEmpty(datas)) { if (CollUtil.isEmpty(datas)) {
throw exception(ITEM_NEW_TURN_IN_IMPORT_LIST_IS_EMPTY);//导入数据不能为空 throw exception(ITEM_NEW_TURN_IN_IMPORT_LIST_IS_EMPTY);//导入数据不能为空
} }
AtomicInteger count = new AtomicInteger();
List<TransactionCreateReqVO> list = new ArrayList<>(); List<TransactionCreateReqVO> list = new ArrayList<>();
List<ItemAccountsImportExcelVO> errorList = new ArrayList<>(); List<ItemAccountsErrorVO> errorList = new ArrayList<>();
datas.forEach(item -> { datas.forEach(item -> {
count.getAndIncrement();
if(item.getItemNumber()==null|| item.getItemNumber().trim().isEmpty() || item.getLocationNumber()==null|| item.getLocationNumber().trim().isEmpty() || item.getType()==null|| item.getType().trim().isEmpty()){//备件号为空
ItemAccountsErrorVO convert = ItemAccountsConvert.INSTANCE.convert(item);
convert.setImportStatus("失败");
convert.setImportRemark("数据为空");
convert.setRowNumber(String.valueOf(count));
errorList.add(convert);
return;
}
//判断该备件是否在备件基础数据中无则报错 //判断该备件是否在备件基础数据中无则报错
QueryWrapper<ItemDO> queryWrapper = new QueryWrapper<>(); QueryWrapper<ItemDO> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("number",item.getItemNumber()); queryWrapper.eq("number",item.getItemNumber());
@ -361,6 +369,7 @@ public class ItemAccountsServiceImpl implements ItemAccountsService {
ItemAccountsErrorVO convert = ItemAccountsConvert.INSTANCE.convert(item); ItemAccountsErrorVO convert = ItemAccountsConvert.INSTANCE.convert(item);
convert.setImportStatus("失败"); convert.setImportStatus("失败");
convert.setImportRemark("该备件在基础数据中不存在"); convert.setImportRemark("该备件在基础数据中不存在");
convert.setRowNumber(String.valueOf(count));
errorList.add(convert); errorList.add(convert);
return; return;
} }
@ -370,6 +379,7 @@ public class ItemAccountsServiceImpl implements ItemAccountsService {
ItemAccountsErrorVO convert = ItemAccountsConvert.INSTANCE.convert(item); ItemAccountsErrorVO convert = ItemAccountsConvert.INSTANCE.convert(item);
convert.setImportStatus("失败"); convert.setImportStatus("失败");
convert.setImportRemark("该库位在基础数据中不存在"); convert.setImportRemark("该库位在基础数据中不存在");
convert.setRowNumber(String.valueOf(count));
errorList.add(convert); errorList.add(convert);
return; return;
} }
@ -379,6 +389,7 @@ public class ItemAccountsServiceImpl implements ItemAccountsService {
ItemAccountsErrorVO convert = ItemAccountsConvert.INSTANCE.convert(item); ItemAccountsErrorVO convert = ItemAccountsConvert.INSTANCE.convert(item);
convert.setImportStatus("失败"); convert.setImportStatus("失败");
convert.setImportRemark("该库位已存在其他类型数据"); convert.setImportRemark("该库位已存在其他类型数据");
convert.setRowNumber(String.valueOf(count));
errorList.add(convert); errorList.add(convert);
return; return;
} }
@ -387,6 +398,7 @@ public class ItemAccountsServiceImpl implements ItemAccountsService {
ItemAccountsErrorVO convert = ItemAccountsConvert.INSTANCE.convert(item); ItemAccountsErrorVO convert = ItemAccountsConvert.INSTANCE.convert(item);
convert.setImportStatus("失败"); convert.setImportStatus("失败");
convert.setImportRemark("数据为空"); convert.setImportRemark("数据为空");
convert.setRowNumber(String.valueOf(count));
errorList.add(convert); errorList.add(convert);
} }
ItemAccountsDO itemAccountsDO = validateItemAndTypeAndLocation(item.getItemNumber(), item.getType(), item.getLocationNumber());//查询重复数据 ItemAccountsDO itemAccountsDO = validateItemAndTypeAndLocation(item.getItemNumber(), item.getType(), item.getLocationNumber());//查询重复数据
@ -455,6 +467,7 @@ public class ItemAccountsServiceImpl implements ItemAccountsService {
ItemAccountsErrorVO convert = ItemAccountsConvert.INSTANCE.convert(item); ItemAccountsErrorVO convert = ItemAccountsConvert.INSTANCE.convert(item);
convert.setImportStatus("失败"); convert.setImportStatus("失败");
convert.setImportRemark("数据错误"); convert.setImportRemark("数据错误");
convert.setRowNumber(String.valueOf(count));
errorList.add(convert); errorList.add(convert);
} }
}); });

Loading…
Cancel
Save