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.module.system.api.user.AdminUserApi;
import com.win.module.system.api.user.dto.AdminUserRespDTO;
import com.win.module.wms.controller.areabasic.vo.AreabasicRespVO;
import com.win.module.wms.controller.itembasic.vo.ItembasicExcelVO;
import com.win.module.wms.controller.bom.vo.BomImportErrorVO;
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.dal.dataobject.itembasic.ItembasicDO;
import com.win.module.wms.dal.dataobject.locationgroup.LocationgroupDO;
import com.win.module.wms.enums.DictTypeConstants;
import com.win.module.wms.service.locationgroup.LocationgroupService;
@ -139,11 +135,7 @@ public class LocationgroupController {
ExcelUtils.write(response, "库位组.xlsx", "数据", LocationgroupExcelVO.class, resultList, mapDropDown);
}
private List<LocationgroupExcelVO> getExcelVo(List<LocationgroupDO> list, Map<Integer, String[]> mapDropDown) {
String[] warehouseCode = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.WAREHOUSE_TYPE);
mapDropDown.put(3, warehouseCode);
String[] areaCode = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.AREA_TYPE);
mapDropDown.put(4, areaCode);
String[] available = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.PACK_UNIT);
String[] available = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.TRUE_FALSE);
mapDropDown.put(5, available);;
// 导出 Excel
List<LocationgroupExcelVO> resultList = LocationgroupConvert.INSTANCE.convertList02(list);
@ -161,11 +153,7 @@ public class LocationgroupController {
// 手动创建导出 demo
List<LocationGroupImportExcelVO> list = Arrays.asList();
Map<Integer, String[]> mapDropDown = new HashMap<>();
String[] warehouseCode = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.WAREHOUSE_TYPE);
mapDropDown.put(3, warehouseCode);
String[] areaCode = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.AREA_TYPE);
mapDropDown.put(4, areaCode);
String[] available = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.PACK_UNIT);
String[] available = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.TRUE_FALSE);
mapDropDown.put(5, available);;
// 输出
ExcelUtils.write(response, "库位组导入模板.xls", "库位组列表", LocationGroupImportExcelVO.class, list,mapDropDown);
@ -179,17 +167,18 @@ public class LocationgroupController {
@Parameter(name = "updatePart", description = "部分更新,默认为 true", example = "true")
})
@PreAuthorize("@ss.hasPermission('wms:location:import')")
public void importExcel(HttpServletResponse response,
@RequestParam("file") MultipartFile file,
@RequestParam(value = "mode") Integer mode,
@RequestParam(value = "updatePart", required = false, defaultValue = "false") Boolean updatePart) throws Exception {
public CommonResult<Map<String, Object>> importExcel(HttpServletResponse response,
@RequestParam("file") MultipartFile file,
@RequestParam(value = "mode") Integer mode,
@RequestParam(value = "updatePart", required = false, defaultValue = "false") Boolean updatePart) throws Exception {
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<>();
returnMap.put("errorCount", errorList.size());
if(!errorList.isEmpty()) {
String url = ExcelUtils.writeLocalFile("库位导入错误数据" + LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8")) + ".xls", "错误列表", errorList);
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("描述")
private String description;
@ExcelProperty(value = "仓库代码", converter = DictConvert.class)
@DictFormat(DictTypeConstants.WAREHOUSE_TYPE)
@ExcelProperty( "仓库代码")
private String warehouseCode;
@ExcelProperty(value = "区域代码", converter = DictConvert.class)
@DictFormat(DictTypeConstants.AREA_TYPE)
@ExcelProperty( "区域代码")
private String areaCode;
@ExcelProperty(value = "是否可用", converter = DictConvert.class)
@DictFormat(DictTypeConstants.LOCATION_TYPE)
@DictFormat(DictTypeConstants.TRUE_FALSE)
private String available;
@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.module.wms.controller.locationgroup.vo.LocationgroupCreateReqVO;
import com.win.module.wms.controller.locationgroup.vo.LocationgroupExcelVO;
import com.win.module.wms.controller.locationgroup.vo.LocationgroupRespVO;
import com.win.module.wms.controller.locationgroup.vo.LocationgroupUpdateReqVO;
import com.win.module.wms.controller.bom.vo.BomImportErrorVO;
import com.win.module.wms.controller.bom.vo.BomImportExcelVo;
import com.win.module.wms.controller.locationgroup.vo.*;
import com.win.module.wms.dal.dataobject.bom.BomDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import com.win.module.wms.dal.dataobject.locationgroup.LocationgroupDO;
@ -24,6 +24,8 @@ public interface LocationgroupConvert {
LocationgroupDO convert(LocationgroupCreateReqVO bean);
LocationgroupDO convert(LocationGroupImportExcelVO bean);
LocationgroupDO convert(LocationgroupUpdateReqVO bean);
LocationgroupRespVO convert(LocationgroupDO bean);
@ -34,4 +36,6 @@ public interface LocationgroupConvert {
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<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.PageResult;
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.convert.bom.BomConvert;
import com.win.module.wms.convert.location.LocationConvert;
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.mysql.locationgroup.LocationgroupMapper;
import org.springframework.stereotype.Service;
@ -88,62 +91,69 @@ public class LocationgroupServiceImpl implements LocationgroupService {
public PageResult<LocationgroupDO> getLocationgroupSenior(CustomConditions 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
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)) {
throw exception(LOCATIONGROUP_IMPORT_LIST_IS_EMPTY);
}
List<LocationGroupImportExcelVO> errorList = new ArrayList<>();
List<LocationGroupImportErrorVO> errorList = new ArrayList<>();
locationGroups.forEach(locationGroup -> {
// 校验,判断是否有不符合的原因
String massage = "";
if(mode != null){
try {
validateLocationgroupExists(null);
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
try {
validateCodeExists(null,locationGroup.getCode());
} catch (ServiceException ex) {
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);
LocationgroupDO locationgroupDO = LocationgroupConvert.INSTANCE.convert(locationGroup);
String message = this.validateLocationGroupImport(locationgroupDO);
boolean flag = true;
if(!message.isEmpty()){
LocationGroupImportErrorVO importErrorVO = LocationgroupConvert.INSTANCE.convert2(locationgroupDO);
importErrorVO.setImportStatus("失败");
importErrorVO.setImportRemark(message.substring(0, message.length() - 1));
errorList.add(importErrorVO);
flag = false;
}
if(errorList == null){
LocationgroupDO existConfigurationSetting = null;
if(flag){
LocationgroupDO existConfigurationSetting = locationgroupMapper.selectByCode(locationgroupDO.getCode());
if (existConfigurationSetting == null&& mode != 3) {
locationgroupMapper.insert(LocationConvert.INSTANCE.convert(locationGroup));
}
else if (existConfigurationSetting != null && mode != 2) {// 如果存在,判断是否允许更新
LocationgroupDO locationgroupDO = LocationConvert.INSTANCE.convert(locationGroup);
locationgroupDO.setId(existConfigurationSetting.getId());
locationgroupMapper.updateById(locationgroupDO);
}
}
});
//错误不为空并非部分更新,手工回滚
if(!errorList.isEmpty() && !updatePart) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
return errorList;
}
private void validateLocationForCreateOrUpdate(Long id, String code,String warehouseCode, String areaCode,String available) {

Loading…
Cancel
Save