Browse Source

库位组管理

master
廉洪喜 2 years ago
parent
commit
673d090cb9
  1. 29
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/locationgroup/LocationgroupController.java
  2. 57
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/locationgroup/vo/LocationGroupImportErrorVO.java
  3. 8
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/locationgroup/vo/LocationGroupImportExcelVO.java
  4. 12
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/locationgroup/LocationgroupConvert.java
  5. 2
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/locationgroup/LocationgroupService.java
  6. 90
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/locationgroup/LocationgroupServiceImpl.java

29
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/locationgroup/LocationgroupController.java

@ -8,13 +8,9 @@ import com.win.framework.excel.core.util.ExcelUtils;
import com.win.framework.operatelog.core.annotations.OperateLog; import com.win.framework.operatelog.core.annotations.OperateLog;
import com.win.module.system.api.user.AdminUserApi; import com.win.module.system.api.user.AdminUserApi;
import com.win.module.system.api.user.dto.AdminUserRespDTO; import com.win.module.system.api.user.dto.AdminUserRespDTO;
import com.win.module.wms.controller.areabasic.vo.AreabasicRespVO; import com.win.module.wms.controller.bom.vo.BomImportErrorVO;
import com.win.module.wms.controller.itembasic.vo.ItembasicExcelVO;
import com.win.module.wms.controller.locationgroup.vo.*; import com.win.module.wms.controller.locationgroup.vo.*;
import com.win.module.wms.convert.areabasic.AreabasicConvert;
import com.win.module.wms.convert.itembasic.ItembasicConvert;
import com.win.module.wms.convert.locationgroup.LocationgroupConvert; import com.win.module.wms.convert.locationgroup.LocationgroupConvert;
import com.win.module.wms.dal.dataobject.itembasic.ItembasicDO;
import com.win.module.wms.dal.dataobject.locationgroup.LocationgroupDO; import com.win.module.wms.dal.dataobject.locationgroup.LocationgroupDO;
import com.win.module.wms.enums.DictTypeConstants; import com.win.module.wms.enums.DictTypeConstants;
import com.win.module.wms.service.locationgroup.LocationgroupService; import com.win.module.wms.service.locationgroup.LocationgroupService;
@ -139,11 +135,7 @@ public class LocationgroupController {
ExcelUtils.write(response, "库位组.xlsx", "数据", LocationgroupExcelVO.class, resultList, mapDropDown); ExcelUtils.write(response, "库位组.xlsx", "数据", LocationgroupExcelVO.class, resultList, mapDropDown);
} }
private List<LocationgroupExcelVO> getExcelVo(List<LocationgroupDO> list, Map<Integer, String[]> mapDropDown) { private List<LocationgroupExcelVO> getExcelVo(List<LocationgroupDO> list, Map<Integer, String[]> mapDropDown) {
String[] warehouseCode = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.WAREHOUSE_TYPE); String[] available = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.TRUE_FALSE);
mapDropDown.put(3, warehouseCode);
String[] areaCode = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.AREA_TYPE);
mapDropDown.put(4, areaCode);
String[] available = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.PACK_UNIT);
mapDropDown.put(5, available);; mapDropDown.put(5, available);;
// 导出 Excel // 导出 Excel
List<LocationgroupExcelVO> resultList = LocationgroupConvert.INSTANCE.convertList02(list); List<LocationgroupExcelVO> resultList = LocationgroupConvert.INSTANCE.convertList02(list);
@ -161,11 +153,7 @@ public class LocationgroupController {
// 手动创建导出 demo // 手动创建导出 demo
List<LocationGroupImportExcelVO> list = Arrays.asList(); List<LocationGroupImportExcelVO> list = Arrays.asList();
Map<Integer, String[]> mapDropDown = new HashMap<>(); Map<Integer, String[]> mapDropDown = new HashMap<>();
String[] warehouseCode = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.WAREHOUSE_TYPE); String[] available = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.TRUE_FALSE);
mapDropDown.put(3, warehouseCode);
String[] areaCode = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.AREA_TYPE);
mapDropDown.put(4, areaCode);
String[] available = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.PACK_UNIT);
mapDropDown.put(5, available);; mapDropDown.put(5, available);;
// 输出 // 输出
ExcelUtils.write(response, "库位组导入模板.xls", "库位组列表", LocationGroupImportExcelVO.class, list,mapDropDown); ExcelUtils.write(response, "库位组导入模板.xls", "库位组列表", LocationGroupImportExcelVO.class, list,mapDropDown);
@ -179,17 +167,18 @@ public class LocationgroupController {
@Parameter(name = "updatePart", description = "部分更新,默认为 true", example = "true") @Parameter(name = "updatePart", description = "部分更新,默认为 true", example = "true")
}) })
@PreAuthorize("@ss.hasPermission('wms:location:import')") @PreAuthorize("@ss.hasPermission('wms:location:import')")
public void importExcel(HttpServletResponse response, public CommonResult<Map<String, Object>> importExcel(HttpServletResponse response,
@RequestParam("file") MultipartFile file, @RequestParam("file") MultipartFile file,
@RequestParam(value = "mode") Integer mode, @RequestParam(value = "mode") Integer mode,
@RequestParam(value = "updatePart", required = false, defaultValue = "false") Boolean updatePart) throws Exception { @RequestParam(value = "updatePart", required = false, defaultValue = "false") Boolean updatePart) throws Exception {
List<LocationGroupImportExcelVO> list = ExcelUtils.read(file, LocationGroupImportExcelVO.class); List<LocationGroupImportExcelVO> list = ExcelUtils.read(file, LocationGroupImportExcelVO.class);
List<LocationGroupImportExcelVO> errorList = locationgroupService.importLocationGroupList(list, mode, updatePart); List<LocationGroupImportErrorVO> errorList = locationgroupService.importLocationGroupList(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());
if(!errorList.isEmpty()) { if(!errorList.isEmpty()) {
String url = ExcelUtils.writeLocalFile("库位导入错误数据" + LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8")) + ".xls", "错误列表", errorList); String url = ExcelUtils.writeLocalFile("库位导入错误数据" + LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8")) + ".xls", "错误列表", errorList);
returnMap.put("errorFile", url); returnMap.put("errorFile", url);
} }
return success(returnMap);
} }
} }

57
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/locationgroup/vo/LocationGroupImportErrorVO.java

@ -0,0 +1,57 @@
package com.win.module.wms.controller.locationgroup.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.win.framework.excel.core.annotations.DictFormat;
import com.win.framework.excel.core.convert.DictConvert;
import com.win.module.wms.enums.DictTypeConstants;
import lombok.Builder;
import lombok.Data;
import lombok.ToString;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Data
@Builder
@ToString(callSuper = true)
public class LocationGroupImportErrorVO {
@ExcelProperty("代码")
private String code;
@ExcelProperty("名称")
private String name;
@ExcelProperty("描述")
private String description;
@ExcelProperty(value = "仓库代码", converter = DictConvert.class)
@DictFormat(DictTypeConstants.WAREHOUSE_TYPE)
private String warehouseCode;
@ExcelProperty(value = "区域代码", converter = DictConvert.class)
@DictFormat(DictTypeConstants.AREA_TYPE)
private String areaCode;
@ExcelProperty(value = "是否可用", converter = DictConvert.class)
@DictFormat(DictTypeConstants.LOCATION_TYPE)
private String available;
@ExcelProperty(value = "生效时间")
@ColumnWidth(value = 16)
private LocalDateTime activeTime;
@ExcelProperty(value = "失效时间")
@ColumnWidth(value = 16)
private LocalDateTime expireTime;
@ExcelProperty(value = "备注")
private String remark;
@ExcelProperty(value = "导入状态", index = 0)
private String importStatus;
@ExcelProperty(value = "导入说明", index = 1)
private String importRemark;
}

8
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/locationgroup/vo/LocationGroupImportExcelVO.java

@ -29,16 +29,14 @@ public class LocationGroupImportExcelVO {
@ExcelProperty("描述") @ExcelProperty("描述")
private String description; private String description;
@ExcelProperty(value = "仓库代码", converter = DictConvert.class) @ExcelProperty( "仓库代码")
@DictFormat(DictTypeConstants.WAREHOUSE_TYPE)
private String warehouseCode; private String warehouseCode;
@ExcelProperty(value = "区域代码", converter = DictConvert.class) @ExcelProperty( "区域代码")
@DictFormat(DictTypeConstants.AREA_TYPE)
private String areaCode; private String areaCode;
@ExcelProperty(value = "是否可用", converter = DictConvert.class) @ExcelProperty(value = "是否可用", converter = DictConvert.class)
@DictFormat(DictTypeConstants.LOCATION_TYPE) @DictFormat(DictTypeConstants.TRUE_FALSE)
private String available; private String available;
@ExcelProperty(value = "生效时间") @ExcelProperty(value = "生效时间")

12
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/locationgroup/LocationgroupConvert.java

@ -4,10 +4,10 @@ import java.util.*;
import com.win.framework.common.pojo.PageResult; import com.win.framework.common.pojo.PageResult;
import com.win.module.wms.controller.locationgroup.vo.LocationgroupCreateReqVO; import com.win.module.wms.controller.bom.vo.BomImportErrorVO;
import com.win.module.wms.controller.locationgroup.vo.LocationgroupExcelVO; import com.win.module.wms.controller.bom.vo.BomImportExcelVo;
import com.win.module.wms.controller.locationgroup.vo.LocationgroupRespVO; import com.win.module.wms.controller.locationgroup.vo.*;
import com.win.module.wms.controller.locationgroup.vo.LocationgroupUpdateReqVO; import com.win.module.wms.dal.dataobject.bom.BomDO;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
import com.win.module.wms.dal.dataobject.locationgroup.LocationgroupDO; import com.win.module.wms.dal.dataobject.locationgroup.LocationgroupDO;
@ -24,6 +24,8 @@ public interface LocationgroupConvert {
LocationgroupDO convert(LocationgroupCreateReqVO bean); LocationgroupDO convert(LocationgroupCreateReqVO bean);
LocationgroupDO convert(LocationGroupImportExcelVO bean);
LocationgroupDO convert(LocationgroupUpdateReqVO bean); LocationgroupDO convert(LocationgroupUpdateReqVO bean);
LocationgroupRespVO convert(LocationgroupDO bean); LocationgroupRespVO convert(LocationgroupDO bean);
@ -34,4 +36,6 @@ public interface LocationgroupConvert {
List<LocationgroupExcelVO> convertList02(List<LocationgroupDO> list); List<LocationgroupExcelVO> convertList02(List<LocationgroupDO> list);
LocationGroupImportErrorVO convert2(LocationgroupDO bean);
} }

2
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/locationgroup/LocationgroupService.java

@ -79,5 +79,5 @@ public interface LocationgroupService {
*/ */
List<LocationgroupDO> getLocationgroupList(LocationgroupExportReqVO exportReqVO); List<LocationgroupDO> getLocationgroupList(LocationgroupExportReqVO exportReqVO);
List<LocationGroupImportExcelVO> importLocationGroupList(List<LocationGroupImportExcelVO> locationGroups, Integer mode, Boolean updatePart); List<LocationGroupImportErrorVO> importLocationGroupList(List<LocationGroupImportExcelVO> locationGroups, Integer mode, Boolean updatePart);
} }

90
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/locationgroup/LocationgroupServiceImpl.java

@ -7,9 +7,12 @@ import com.win.framework.common.exception.ServiceException;
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.framework.datapermission.core.util.DataPermissionUtils; import com.win.framework.datapermission.core.util.DataPermissionUtils;
import com.win.module.wms.controller.bom.vo.BomImportErrorVO;
import com.win.module.wms.controller.locationgroup.vo.*; import com.win.module.wms.controller.locationgroup.vo.*;
import com.win.module.wms.convert.bom.BomConvert;
import com.win.module.wms.convert.location.LocationConvert; import com.win.module.wms.convert.location.LocationConvert;
import com.win.module.wms.convert.locationgroup.LocationgroupConvert; import com.win.module.wms.convert.locationgroup.LocationgroupConvert;
import com.win.module.wms.dal.dataobject.bom.BomDO;
import com.win.module.wms.dal.dataobject.locationgroup.LocationgroupDO; import com.win.module.wms.dal.dataobject.locationgroup.LocationgroupDO;
import com.win.module.wms.dal.mysql.locationgroup.LocationgroupMapper; import com.win.module.wms.dal.mysql.locationgroup.LocationgroupMapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -88,62 +91,69 @@ public class LocationgroupServiceImpl implements LocationgroupService {
public PageResult<LocationgroupDO> getLocationgroupSenior(CustomConditions conditions) { public PageResult<LocationgroupDO> getLocationgroupSenior(CustomConditions conditions) {
return locationgroupMapper.selectSenior(conditions); return locationgroupMapper.selectSenior(conditions);
} }
private String validateLocationGroupImport( LocationgroupDO locationGroup ){
StringBuilder message = new StringBuilder();
try {
validateLocationgroupExists(null);
} catch (ServiceException ex) {
message.append(ex.getMessage()).append(",");
}
try {
validateCodeExists(null,locationGroup.getCode());
} catch (ServiceException ex) {
message.append(ex.getMessage()).append(",");
}
try {
validateWarehouseCodeExists(locationGroup.getWarehouseCode());
} catch (ServiceException ex) {
message.append(ex.getMessage()).append(",");
}
try {
validateAreaCodeExists(locationGroup.getAreaCode());
} catch (ServiceException ex) {
message.append(ex.getMessage()).append(",");
}
try {
validateAvailableExists(locationGroup.getAvailable());
} catch (ServiceException ex) {
message.append(ex.getMessage()).append(",");
}
return message.toString();
}
@Override @Override
public List<LocationGroupImportExcelVO> importLocationGroupList(List<LocationGroupImportExcelVO> locationGroups, Integer mode, Boolean updatePart) { public List<LocationGroupImportErrorVO> importLocationGroupList(List<LocationGroupImportExcelVO> locationGroups, Integer mode, Boolean updatePart) {
if (CollUtil.isEmpty(locationGroups)) { if (CollUtil.isEmpty(locationGroups)) {
throw exception(LOCATIONGROUP_IMPORT_LIST_IS_EMPTY); throw exception(LOCATIONGROUP_IMPORT_LIST_IS_EMPTY);
} }
List<LocationGroupImportExcelVO> errorList = new ArrayList<>(); List<LocationGroupImportErrorVO> errorList = new ArrayList<>();
locationGroups.forEach(locationGroup -> { locationGroups.forEach(locationGroup -> {
// 校验,判断是否有不符合的原因 // 校验,判断是否有不符合的原因
String massage = "";
if(mode != null){ LocationgroupDO locationgroupDO = LocationgroupConvert.INSTANCE.convert(locationGroup);
try { String message = this.validateLocationGroupImport(locationgroupDO);
validateLocationgroupExists(null); boolean flag = true;
} catch (ServiceException ex) { if(!message.isEmpty()){
massage += ex.getMessage() + ","; LocationGroupImportErrorVO importErrorVO = LocationgroupConvert.INSTANCE.convert2(locationgroupDO);
} importErrorVO.setImportStatus("失败");
try { importErrorVO.setImportRemark(message.substring(0, message.length() - 1));
validateCodeExists(null,locationGroup.getCode()); errorList.add(importErrorVO);
} catch (ServiceException ex) { flag = false;
massage += ex.getMessage() + ",";
}
try {
validateWarehouseCodeExists(locationGroup.getWarehouseCode());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
try {
validateAreaCodeExists(locationGroup.getAreaCode());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
try {
validateAvailableExists(locationGroup.getAvailable());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
}
if(StrUtil.isNotEmpty(massage)){
massage.substring(0,massage.length()-1);
errorList.add(locationGroup);
} }
if(errorList == null){ if(flag){
LocationgroupDO existConfigurationSetting = null; LocationgroupDO existConfigurationSetting = locationgroupMapper.selectByCode(locationgroupDO.getCode());
if (existConfigurationSetting == null&& mode != 3) { if (existConfigurationSetting == null&& mode != 3) {
locationgroupMapper.insert(LocationConvert.INSTANCE.convert(locationGroup)); locationgroupMapper.insert(LocationConvert.INSTANCE.convert(locationGroup));
} }
else if (existConfigurationSetting != null && mode != 2) {// 如果存在,判断是否允许更新 else if (existConfigurationSetting != null && mode != 2) {// 如果存在,判断是否允许更新
LocationgroupDO locationgroupDO = LocationConvert.INSTANCE.convert(locationGroup);
locationgroupDO.setId(existConfigurationSetting.getId()); locationgroupDO.setId(existConfigurationSetting.getId());
locationgroupMapper.updateById(locationgroupDO); locationgroupMapper.updateById(locationgroupDO);
} }
} }
}); });
//错误不为空并非部分更新,手工回滚
if(!errorList.isEmpty() && !updatePart) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
return errorList; return errorList;
} }
private void validateLocationForCreateOrUpdate(Long id, String code,String warehouseCode, String areaCode,String available) { private void validateLocationForCreateOrUpdate(Long id, String code,String warehouseCode, String areaCode,String available) {

Loading…
Cancel
Save