Browse Source

基础数据

master
parent
commit
466e078436
  1. 21
      win-framework/win-spring-boot-starter-excel/src/main/java/com/win/framework/excel/core/annotations/Colour.java
  2. 17
      win-framework/win-spring-boot-starter-excel/src/main/java/com/win/framework/excel/core/annotations/ExcelValid.java
  3. 22
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/item/ItemController.java
  4. 22
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/item/vo/ItemImportErrorVO.java
  5. 60
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/item/vo/ItemImportExcelVo.java
  6. 65
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/item/vo/ItemImportVO.java
  7. 39
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/location/LocationController.java
  8. 22
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/location/vo/LocationImportErrorVO.java
  9. 35
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/location/vo/LocationImportExcelVo.java
  10. 40
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/location/vo/LocationImportVO.java
  11. 47
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/locationarea/LocationAreaController.java
  12. 22
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/locationarea/vo/LocationAreaImportErrorVO.java
  13. 23
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/locationarea/vo/LocationAreaImportExcelVO.java
  14. 34
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/locationarea/vo/LocationAreaImportVO.java
  15. 7
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/convert/item/ItemConvert.java
  16. 13
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/convert/location/LocationConvert.java
  17. 12
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/convert/locationarea/LocationAreaConvert.java
  18. 4
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/item/ItemService.java
  19. 57
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/item/ItemServiceImpl.java
  20. 12
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/location/LocationService.java
  21. 58
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/location/LocationServiceImpl.java
  22. 12
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/locationarea/LocationAreaService.java
  23. 59
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/locationarea/LocationAreaServiceImpl.java

21
win-framework/win-spring-boot-starter-excel/src/main/java/com/win/framework/excel/core/annotations/Colour.java

@ -0,0 +1,21 @@
package com.win.framework.excel.core.annotations;
import org.apache.poi.ss.usermodel.IndexedColors;
import java.lang.annotation.*;
/**
* 导出excel头部颜色设置
*/
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface Colour {
/**
* 颜色值
*
* @return 颜色字典类型
*/
IndexedColors value();
}

17
win-framework/win-spring-boot-starter-excel/src/main/java/com/win/framework/excel/core/annotations/ExcelValid.java

@ -0,0 +1,17 @@
package com.win.framework.excel.core.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 导入必填字段
*/
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface ExcelValid {
String message() default "导入有未填入的字段";
}

22
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/item/ItemController.java

@ -3,11 +3,13 @@ package com.win.module.eam.controller.item;
import com.win.framework.common.pojo.CommonResult;
import com.win.framework.common.pojo.CustomConditions;
import com.win.framework.common.pojo.PageResult;
import com.win.framework.dict.core.util.DictFrameworkUtils;
import com.win.framework.excel.core.util.ExcelUtils;
import com.win.framework.operatelog.core.annotations.OperateLog;
import com.win.module.eam.controller.item.vo.*;
import com.win.module.eam.convert.item.ItemConvert;
import com.win.module.eam.dal.dataobject.item.ItemDO;
import com.win.module.eam.enums.DictTypeConstants;
import com.win.module.eam.service.item.ItemService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
@ -24,10 +26,7 @@ import javax.validation.Valid;
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import static com.win.framework.common.pojo.CommonResult.success;
import static com.win.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
@ -183,6 +182,16 @@ public class ItemController {
return success(ItemConvert.INSTANCE.convertList(pageResult));
}
@GetMapping("/get-import-template")
@Operation(summary = "获得导入采购订单模板")
public void importTemplate(HttpServletResponse response) throws IOException {
// 手动创建导出 demo
List<ItemImportVO> list = new ArrayList<>();
Map<Integer, String[]> mapDropDown = new HashMap<>();
// // 输出
ExcelUtils.write(response, "备件导入模板.xlsx", "备件表", ItemImportVO.class, list, mapDropDown);
}
@PostMapping("/import")
@Operation(summary = "导入备件基本信息")
@Parameters({
@ -196,9 +205,8 @@ public class ItemController {
@RequestParam(value = "mode") Integer mode,
@RequestParam(value = "updatePart", required = false, defaultValue = "false") Boolean updatePart) throws Exception {
List<ItemExcelVO> list = ExcelUtils.read(file, ItemExcelVO.class);
List<ItemExcelVO> errorList = itemService.importItemList(list, mode, updatePart);
List<ItemImportExcelVo> list = ExcelUtils.read(file, ItemImportExcelVo.class);
List<ItemImportErrorVO> errorList = itemService.importItemList(list, mode, updatePart);
Map<String, Object> returnMap = new HashMap<>();
returnMap.put("errorCount", errorList.size());
if(!errorList.isEmpty()) {

22
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/item/vo/ItemImportErrorVO.java

@ -0,0 +1,22 @@
package com.win.module.eam.controller.item.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Builder;
import lombok.Data;
import lombok.ToString;
@Data
@Builder
@ToString(callSuper = true)
public class ItemImportErrorVO extends ItemImportExcelVo {
@ExcelProperty(value = "导入状态", index = 0)
private String importStatus;
@ExcelProperty(value = "导入说明", index = 2)
private String importRemark;
@ExcelProperty(value = "行号", index = 1)
private String rowNumber;
}

60
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/item/vo/ItemImportExcelVo.java

@ -0,0 +1,60 @@
package com.win.module.eam.controller.item.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.win.framework.excel.core.annotations.ExcelValid;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题
public class ItemImportExcelVo {
@ExcelProperty("零件编码")
@ExcelValid(message = "必填")
private String number;
@ExcelProperty("零件名称")
private String name;
@ExcelProperty("规格型号")
private String specifications;
@ExcelProperty("单位")
private String uom;
@ExcelProperty("供应商名称")
private String supplierName;
@ExcelProperty("生产厂家(品牌)")
private String brand;
@ExcelProperty("最高库存")
private Integer maxInventory;
@ExcelProperty("最低库存")
private Integer minInventory;
@ExcelProperty("采购周期(周)")
private Integer procurementCycle;
@ExcelProperty("ABC分类")
private String classification;
@ExcelProperty("使用地点")
private String usePlace;
@ExcelProperty("项目")
private String project;
@ExcelProperty("价格")
private BigDecimal price;
@ExcelProperty("描述")
private String describes;
}

65
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/item/vo/ItemImportVO.java

@ -0,0 +1,65 @@
package com.win.module.eam.controller.item.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
/**
* 采购索赔申请子 Excel VO
*
* @author 超级管理员
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题
public class ItemImportVO {
@ExcelProperty("零件编码")
private String number;
@ExcelProperty("零件名称")
private String name;
@ExcelProperty("规格型号")
private String specifications;
@ExcelProperty("单位")
private String uom;
@ExcelProperty("供应商名称")
private String supplierName;
@ExcelProperty("生产厂家(品牌)")
private String brand;
@ExcelProperty("最高库存")
private Integer maxInventory;
@ExcelProperty("最低库存")
private Integer minInventory;
@ExcelProperty("采购周期(周)")
private Integer procurementCycle;
@ExcelProperty("ABC分类")
private String classification;
@ExcelProperty("使用地点")
private String usePlace;
@ExcelProperty("项目")
private String project;
@ExcelProperty("价格")
private BigDecimal price;
@ExcelProperty("描述")
private String describes;
}

39
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/location/LocationController.java

@ -6,7 +6,6 @@ import com.win.framework.common.pojo.PageResult;
import com.win.framework.dict.core.util.DictFrameworkUtils;
import com.win.framework.excel.core.util.ExcelUtils;
import com.win.framework.operatelog.core.annotations.OperateLog;
import com.win.module.eam.controller.item.vo.ItemExcelVO;
import com.win.module.eam.controller.location.vo.*;
import com.win.module.eam.convert.location.LocationConvert;
import com.win.module.eam.dal.dataobject.location.LocationDO;
@ -27,10 +26,7 @@ import javax.validation.Valid;
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import static com.win.framework.common.pojo.CommonResult.success;
import static com.win.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
@ -161,7 +157,38 @@ public class LocationController {
return success(LocationConvert.INSTANCE.convertList(locationDOS));
}
@GetMapping("/get-import-template")
@Operation(summary = "获得导入采购订单模板")
public void importTemplate(HttpServletResponse response) throws IOException {
// 手动创建导出 demo
List<LocationImportVO> list = new ArrayList<>();
Map<Integer, String[]> mapDropDown = new HashMap<>();
// // 输出
ExcelUtils.write(response, "备件导入模板.xlsx", "备件表", LocationImportVO.class, list, mapDropDown);
}
@PostMapping("/import")
@Operation(summary = "导入备件基本信息")
@Parameters({
@Parameter(name = "file", description = "Excel 文件", required = true),
@Parameter(name = "mode", description = "导入模式1更新2追加3覆盖", example = "1"),
@Parameter(name = "updatePart", description = "部分更新,默认为 true", example = "true")
})
@PreAuthorize("@ss.hasPermission('basic:location:import')")
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<LocationImportExcelVo> list = ExcelUtils.read(file, LocationImportExcelVo.class);
List<LocationImportErrorVO> errorList = locationService.importLocationList(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")) + ".xlsx", "错误列表", errorList);
returnMap.put("errorFile", url);
}
return success(returnMap);
}
}

22
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/location/vo/LocationImportErrorVO.java

@ -0,0 +1,22 @@
package com.win.module.eam.controller.location.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Builder;
import lombok.Data;
import lombok.ToString;
@Data
@Builder
@ToString(callSuper = true)
public class LocationImportErrorVO extends LocationImportExcelVo {
@ExcelProperty(value = "导入状态", index = 0)
private String importStatus;
@ExcelProperty(value = "导入说明", index = 2)
private String importRemark;
@ExcelProperty(value = "行号", index = 1)
private String rowNumber;
}

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

@ -0,0 +1,35 @@
package com.win.module.eam.controller.location.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.win.framework.excel.core.annotations.ExcelValid;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题
public class LocationImportExcelVo {
@ExcelProperty("库位编码")
@ExcelValid(message = "必填")
private String number;
@ExcelProperty("库位名称")
@ColumnWidth(value = 20)
private String name;
@ExcelProperty("库区编号")
@ColumnWidth(value = 20)
private String areaNumber;
@ExcelProperty("描述")
@ColumnWidth(value = 30)
private String description;
}

40
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/location/vo/LocationImportVO.java

@ -0,0 +1,40 @@
package com.win.module.eam.controller.location.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
/**
* 采购索赔申请子 Excel VO
*
* @author 超级管理员
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题
public class LocationImportVO {
@ExcelProperty("库位编号")
@ColumnWidth(value = 20)
private String number;
@ExcelProperty("库位名称")
@ColumnWidth(value = 20)
private String name;
@ExcelProperty("库区编号")
@ColumnWidth(value = 20)
private String areaNumber;
@ExcelProperty("描述")
@ColumnWidth(value = 30)
private String description;
}

47
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/locationarea/LocationAreaController.java

@ -13,15 +13,19 @@ import com.win.module.eam.enums.DictTypeConstants;
import com.win.module.eam.service.locationarea.LocationAreaService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.*;
import static com.win.framework.common.pojo.CommonResult.success;
@ -108,14 +112,6 @@ public class LocationAreaController {
return resultList;
}
@GetMapping("/get-import-template")
@Operation(summary = "获得导入库区模板")
public void importTemplate(HttpServletResponse response) throws IOException {
List<LocationAreaExcelVO> list = Arrays.asList();
// 输出
ExcelUtils.write(response, "库区基本信息导入模板.xls", "库区基本信息列表", LocationAreaExcelVO.class, list);
}
@PostMapping("/senior")
@Operation(summary = "高级搜索获得库位分页")
// @PreAuthorize("@ss.hasPermission('basic:locationArea:query')")
@ -124,5 +120,40 @@ public class LocationAreaController {
PageResult<LocationAreaRespVO> result = LocationAreaConvert.INSTANCE.convertPage(pageResult);
return success(result);
}
@GetMapping("/get-import-template")
@Operation(summary = "获得导入采购订单模板")
public void importTemplate(HttpServletResponse response) throws IOException {
// 手动创建导出 demo
List<LocationAreaImportVO> list = new ArrayList<>();
Map<Integer, String[]> mapDropDown = new HashMap<>();
// // 输出
ExcelUtils.write(response, "备件导入模板.xlsx", "备件表", LocationAreaImportVO.class, list, mapDropDown);
}
@PostMapping("/import")
@Operation(summary = "导入备件基本信息")
@Parameters({
@Parameter(name = "file", description = "Excel 文件", required = true),
@Parameter(name = "mode", description = "导入模式1更新2追加3覆盖", example = "1"),
@Parameter(name = "updatePart", description = "部分更新,默认为 true", example = "true")
})
@PreAuthorize("@ss.hasPermission('basic:locationArea:import')")
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<LocationAreaImportExcelVO> list = ExcelUtils.read(file, LocationAreaImportExcelVO.class);
List<LocationAreaImportErrorVO> errorList = locationAreaService.importLocationAreaList(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")) + ".xlsx", "错误列表", errorList);
returnMap.put("errorFile", url);
}
return success(returnMap);
}
}

22
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/locationarea/vo/LocationAreaImportErrorVO.java

@ -0,0 +1,22 @@
package com.win.module.eam.controller.locationarea.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Builder;
import lombok.Data;
import lombok.ToString;
@Data
@Builder
@ToString(callSuper = true)
public class LocationAreaImportErrorVO extends LocationAreaImportExcelVO {
@ExcelProperty(value = "导入状态", index = 0)
private String importStatus;
@ExcelProperty(value = "导入说明", index = 2)
private String importRemark;
@ExcelProperty(value = "行号", index = 1)
private String rowNumber;
}

23
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/locationarea/vo/LocationAreaImportExcelVO.java

@ -0,0 +1,23 @@
package com.win.module.eam.controller.locationarea.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题
public class LocationAreaImportExcelVO {
@ExcelProperty("库区编号")
private String number;
@ExcelProperty("库区名称")
private String name;
@ExcelProperty("描述")
private String description;
}

34
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/locationarea/vo/LocationAreaImportVO.java

@ -0,0 +1,34 @@
package com.win.module.eam.controller.locationarea.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
/**
* 采购索赔申请子 Excel VO
*
* @author 超级管理员
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题
public class LocationAreaImportVO {
@ExcelProperty("库区编号")
@ColumnWidth(value = 20)
private String number;
@ExcelProperty("库区名称")
@ColumnWidth(value = 20)
private String name;
@ExcelProperty("描述")
@ColumnWidth(value = 30)
private String description;
}

7
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/convert/item/ItemConvert.java

@ -1,10 +1,7 @@
package com.win.module.eam.convert.item;
import com.win.framework.common.pojo.PageResult;
import com.win.module.eam.controller.item.vo.ItemCreateReqVO;
import com.win.module.eam.controller.item.vo.ItemExcelVO;
import com.win.module.eam.controller.item.vo.ItemRespVO;
import com.win.module.eam.controller.item.vo.ItemUpdateReqVO;
import com.win.module.eam.controller.item.vo.*;
import com.win.module.eam.dal.dataobject.item.ItemDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@ -34,5 +31,7 @@ public interface ItemConvert {
PageResult<ItemRespVO> convertPage(PageResult<ItemDO> page);
List<ItemExcelVO> convertList02(List<ItemDO> list);
ItemDO convert(ItemImportExcelVo bean);
ItemImportErrorVO convert2(ItemDO itemDO);
}

13
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/convert/location/LocationConvert.java

@ -1,10 +1,10 @@
package com.win.module.eam.convert.location;
import com.win.framework.common.pojo.PageResult;
import com.win.module.eam.controller.location.vo.LocationCreateReqVO;
import com.win.module.eam.controller.location.vo.LocationExcelVO;
import com.win.module.eam.controller.location.vo.LocationRespVO;
import com.win.module.eam.controller.location.vo.LocationUpdateReqVO;
import com.win.module.eam.controller.item.vo.ItemImportErrorVO;
import com.win.module.eam.controller.item.vo.ItemImportExcelVo;
import com.win.module.eam.controller.location.vo.*;
import com.win.module.eam.dal.dataobject.item.ItemDO;
import com.win.module.eam.dal.dataobject.location.LocationDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@ -22,7 +22,7 @@ public interface LocationConvert {
LocationConvert INSTANCE = Mappers.getMapper(LocationConvert.class);
LocationDO convert(LocationCreateReqVO bean);
LocationDO convert(LocationExcelVO bean);
LocationDO convert(LocationUpdateReqVO bean);
LocationRespVO convert(LocationDO bean);
@ -33,4 +33,7 @@ public interface LocationConvert {
List<LocationExcelVO> convertList02(List<LocationDO> list);
LocationDO convert(LocationImportExcelVo bean);
LocationImportErrorVO convert2(LocationDO locationDO);
}

12
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/convert/locationarea/LocationAreaConvert.java

@ -1,10 +1,10 @@
package com.win.module.eam.convert.locationarea;
import com.win.framework.common.pojo.PageResult;
import com.win.module.eam.controller.locationarea.vo.LocationAreaCreateReqVO;
import com.win.module.eam.controller.locationarea.vo.LocationAreaExcelVO;
import com.win.module.eam.controller.locationarea.vo.LocationAreaRespVO;
import com.win.module.eam.controller.locationarea.vo.LocationAreaUpdateReqVO;
import com.win.module.eam.controller.location.vo.LocationImportErrorVO;
import com.win.module.eam.controller.location.vo.LocationImportExcelVo;
import com.win.module.eam.controller.locationarea.vo.*;
import com.win.module.eam.dal.dataobject.location.LocationDO;
import com.win.module.eam.dal.dataobject.locationarea.LocationAreaDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@ -22,7 +22,7 @@ public interface LocationAreaConvert {
LocationAreaConvert INSTANCE = Mappers.getMapper(LocationAreaConvert.class);
LocationAreaDO convert(LocationAreaCreateReqVO bean);
LocationAreaDO convert(LocationAreaExcelVO bean);
LocationAreaDO convert(LocationAreaUpdateReqVO bean);
LocationAreaRespVO convert(LocationAreaDO bean);
@ -32,5 +32,7 @@ public interface LocationAreaConvert {
PageResult<LocationAreaRespVO> convertPage(PageResult<LocationAreaDO> page);
List<LocationAreaExcelVO> convertList02(List<LocationAreaDO> list);
LocationAreaDO convert(LocationAreaImportExcelVO bean);
LocationAreaImportErrorVO convert2(LocationAreaDO locationAreaDO);
}

4
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/item/ItemService.java

@ -130,10 +130,10 @@ public interface ItemService {
/**
* 导入备件主信息
*
* @param datas 导入备件主信息列表
* @param importItembasics 导入备件主信息列表
* @param mode 导入模式1更新2追加3覆盖
* @param updatePart 是否支持更新
* @return 导入结果
*/
public List<ItemExcelVO> importItemList(List<ItemExcelVO> datas, Integer mode, boolean updatePart);
public List<ItemImportErrorVO> importItemList(List<ItemImportExcelVo> importItembasics, Integer mode, boolean updatePart);
}

57
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/item/ItemServiceImpl.java

@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.win.framework.common.exception.ServiceException;
import com.win.framework.common.exception.util.ServiceExceptionUtil;
import com.win.framework.common.pojo.CustomConditions;
import com.win.framework.common.pojo.PageResult;
@ -257,28 +258,52 @@ public class ItemServiceImpl implements ItemService {
}
@Override
public List<ItemExcelVO> importItemList(List<ItemExcelVO> datas, Integer mode, boolean updatePart) {
if (CollUtil.isEmpty(datas)) {
public List<ItemImportErrorVO> importItemList(List<ItemImportExcelVo> importItembasics, Integer mode, boolean updatePart) {
if (CollUtil.isEmpty(importItembasics)) {
throw exception(ITEM_NOT_EXISTS);
}
List<ItemExcelVO> errorList = new ArrayList<>();
datas.forEach(item -> {
if(errorList == null){
List<ItemImportErrorVO> errorList = new ArrayList<>();
for (int i = 0; i < importItembasics.size(); i++) {
ItemDO itemDO = ItemConvert.INSTANCE.convert(importItembasics.get(i));
String massage = validateItembasicImport(itemDO);
boolean flag = true;
if (!massage.isEmpty()) {
ItemImportErrorVO importErrorVO = ItemConvert.INSTANCE.convert2(itemDO);
importErrorVO.setImportStatus("失败");
importErrorVO.setImportRemark(massage.substring(0, massage.length() - 1));
Integer rowNumber = i + 1;
importErrorVO.setRowNumber("第" + rowNumber + "行");
errorList.add(importErrorVO);
flag = false;
}
if (flag) {
// 判断如果不存在,在进行插入
QueryWrapper<ItemDO> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("number", item.getNumber());
ItemDO obj = itemMapper.selectOne(queryWrapper);
if (obj == null&& mode != 3) {
itemMapper.insert(ItemConvert.INSTANCE.convert(item));
}
else if (obj != null && mode != 2) {// 如果存在,判断是否允许更新
ItemDO itemDO = ItemConvert.INSTANCE.convert(item);
itemDO.setId(obj.getId());
itemMapper.updateById(obj);
queryWrapper.eq("number", itemDO.getNumber());
ItemDO existItembasic = itemMapper.selectOne(queryWrapper);
if (existItembasic == null && mode != 3) {
itemMapper.insert(ItemConvert.INSTANCE.convert(importItembasics.get(i)));
} else if (existItembasic != null && mode != 2) {// 如果存在,判断是否允许更新
itemDO.setId(existItembasic.getId());
itemMapper.updateById(itemDO);
} else if (existItembasic != null && mode == 2) {
ItemImportErrorVO importErrorVO = ItemConvert.INSTANCE.convert2(existItembasic);
importErrorVO.setImportStatus("失败");
importErrorVO.setImportRemark("物料号" + existItembasic.getNumber() + "该条数据已存在,请重新编辑备件编号并重新导入");
errorList.add(importErrorVO);
}
}
});
}
return errorList;
}
private String validateItembasicImport(ItemDO itembasicDO) {
String massage = "";
// 校验,判断是否有不符合的原因
if(itembasicDO.getNumber().isEmpty()){
massage += "物料号不能为空" + ",";
}
return massage.toString();
}
}

12
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/location/LocationService.java

@ -2,6 +2,8 @@ package com.win.module.eam.service.location;
import com.win.framework.common.pojo.CustomConditions;
import com.win.framework.common.pojo.PageResult;
import com.win.module.eam.controller.item.vo.ItemImportErrorVO;
import com.win.module.eam.controller.item.vo.ItemImportExcelVo;
import com.win.module.eam.controller.location.vo.*;
import com.win.module.eam.dal.dataobject.location.LocationDO;
@ -108,4 +110,14 @@ public interface LocationService {
* @return 分页列表
*/
PageResult<LocationDO> getLocationSenior(CustomConditions conditions);
/**
* 导入备件主信息
*
* @param importItembasics 导入备件主信息列表
* @param mode 导入模式1更新2追加3覆盖
* @param updatePart 是否支持更新
* @return 导入结果
*/
List<LocationImportErrorVO> importLocationList(List<LocationImportExcelVo> importItembasics, Integer mode, boolean updatePart);
}

58
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/location/LocationServiceImpl.java

@ -1,11 +1,16 @@
package com.win.module.eam.service.location;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.win.framework.common.exception.util.ServiceExceptionUtil;
import com.win.framework.common.pojo.CustomConditions;
import com.win.framework.common.pojo.PageResult;
import com.win.module.eam.controller.item.vo.ItemImportErrorVO;
import com.win.module.eam.controller.item.vo.ItemImportExcelVo;
import com.win.module.eam.controller.location.vo.*;
import com.win.module.eam.convert.item.ItemConvert;
import com.win.module.eam.convert.location.LocationConvert;
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.itemapplyrequest.ItemApplyRequestDetailDO;
import com.win.module.eam.dal.dataobject.location.LocationDO;
@ -20,10 +25,7 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.*;
import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.win.module.eam.enums.ErrorCodeConstants.*;
@ -211,5 +213,53 @@ public class LocationServiceImpl implements LocationService {
return locationMapper.selectSenior(conditions);
}
@Override
public List<LocationImportErrorVO> importLocationList(List<LocationImportExcelVo> importLocationbasics, Integer mode, boolean updatePart) {
if (CollUtil.isEmpty(importLocationbasics)) {
throw exception(ITEM_NOT_EXISTS);
}
List<LocationImportErrorVO> errorList = new ArrayList<>();
for (int i = 0; i < importLocationbasics.size(); i++) {
LocationDO locationDO = LocationConvert.INSTANCE.convert(importLocationbasics.get(i));
String massage = validateLocationbasicImport(locationDO);
boolean flag = true;
if (!massage.isEmpty()) {
LocationImportErrorVO importErrorVO = LocationConvert.INSTANCE.convert2(locationDO);
importErrorVO.setImportStatus("失败");
importErrorVO.setImportRemark(massage.substring(0, massage.length() - 1));
Integer rowNumber = i + 1;
importErrorVO.setRowNumber("第" + rowNumber + "行");
errorList.add(importErrorVO);
flag = false;
}
if (flag) {
// 判断如果不存在,在进行插入
QueryWrapper<LocationDO> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("number", locationDO.getNumber());
LocationDO existLocationbasic = locationMapper.selectOne(queryWrapper);
if (existLocationbasic == null && mode != 3) {
locationMapper.insert(LocationConvert.INSTANCE.convert(importLocationbasics.get(i)));
} else if (existLocationbasic != null && mode != 2) {// 如果存在,判断是否允许更新
locationDO.setId(existLocationbasic.getId());
locationMapper.updateById(locationDO);
} else if (existLocationbasic != null && mode == 2) {
LocationImportErrorVO importErrorVO = LocationConvert.INSTANCE.convert2(existLocationbasic);
importErrorVO.setImportStatus("失败");
importErrorVO.setImportRemark("物料号" + existLocationbasic.getNumber() + "该条数据已存在,请重新编辑备件编号并重新导入");
errorList.add(importErrorVO);
}
}
}
return errorList;
}
private String validateLocationbasicImport( LocationDO locationDO) {
String massage = "";
// 校验,判断是否有不符合的原因
if(locationDO.getNumber().isEmpty()){
massage += "库位编号号不能为空" + ",";
}
return massage.toString();
}
}

12
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/locationarea/LocationAreaService.java

@ -2,6 +2,8 @@ package com.win.module.eam.service.locationarea;
import com.win.framework.common.pojo.CustomConditions;
import com.win.framework.common.pojo.PageResult;
import com.win.module.eam.controller.item.vo.ItemImportErrorVO;
import com.win.module.eam.controller.item.vo.ItemImportExcelVo;
import com.win.module.eam.controller.locationarea.vo.*;
import com.win.module.eam.dal.dataobject.locationarea.LocationAreaDO;
@ -77,4 +79,14 @@ public interface LocationAreaService {
* @return 分页列表
*/
PageResult<LocationAreaDO> getLocationAreaSenior(CustomConditions conditions);
/**
* 导入备件主信息
*
* @param importLocationAreabasics 导入备件主信息列表
* @param mode 导入模式1更新2追加3覆盖
* @param updatePart 是否支持更新
* @return 导入结果
*/
public List<LocationAreaImportErrorVO> importLocationAreaList(List<LocationAreaImportExcelVO> importLocationAreabasics, Integer mode, boolean updatePart);
}

59
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/locationarea/LocationAreaServiceImpl.java

@ -1,13 +1,11 @@
package com.win.module.eam.service.locationarea;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.win.framework.common.exception.util.ServiceExceptionUtil;
import com.win.framework.common.pojo.CustomConditions;
import com.win.framework.common.pojo.PageResult;
import com.win.module.eam.controller.locationarea.vo.LocationAreaCreateReqVO;
import com.win.module.eam.controller.locationarea.vo.LocationAreaExportReqVO;
import com.win.module.eam.controller.locationarea.vo.LocationAreaPageReqVO;
import com.win.module.eam.controller.locationarea.vo.LocationAreaUpdateReqVO;
import com.win.module.eam.controller.locationarea.vo.*;
import com.win.module.eam.convert.locationarea.LocationAreaConvert;
import com.win.module.eam.dal.dataobject.location.LocationDO;
import com.win.module.eam.dal.dataobject.locationarea.LocationAreaDO;
@ -20,9 +18,11 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.win.module.eam.enums.ErrorCodeConstants.LOCATION_AREA_HAVE_EXISTS;
import static com.win.module.eam.enums.ErrorCodeConstants.LOCATION_CAN_NOT_DELETE;
@ -54,7 +54,7 @@ public class LocationAreaServiceImpl implements LocationAreaService {
objectQueryWrapper.eq("deleted", 0);
List<LocationAreaDO> locationAreaList = locationAreaMapper.selectList(objectQueryWrapper);
if (locationAreaList.size() > 0) {
throw ServiceExceptionUtil.exception(LOCATION_AREA_HAVE_EXISTS);
throw exception(LOCATION_AREA_HAVE_EXISTS);
}
locationArea.setCreateTime(LocalDateTime.now());
locationAreaMapper.insert(locationArea);
@ -117,4 +117,53 @@ public class LocationAreaServiceImpl implements LocationAreaService {
public PageResult<LocationAreaDO> getLocationAreaSenior(CustomConditions conditions) {
return locationAreaMapper.selectSenior(conditions);
}
@Override
public List<LocationAreaImportErrorVO> importLocationAreaList(List<LocationAreaImportExcelVO> importLocationAreabasics, Integer mode, boolean updatePart) {
if (CollUtil.isEmpty(importLocationAreabasics)) {
throw exception(LOCATION_AREA_HAVE_EXISTS);
}
List<LocationAreaImportErrorVO> errorList = new ArrayList<>();
for (int i = 0; i < importLocationAreabasics.size(); i++) {
LocationAreaDO locationAreaDO = LocationAreaConvert.INSTANCE.convert(importLocationAreabasics.get(i));
String massage = validateLocationAreabasicImport(locationAreaDO);
boolean flag = true;
if (!massage.isEmpty()) {
LocationAreaImportErrorVO importErrorVO = LocationAreaConvert.INSTANCE.convert2(locationAreaDO);
importErrorVO.setImportStatus("失败");
importErrorVO.setImportRemark(massage.substring(0, massage.length() - 1));
Integer rowNumber = i + 1;
importErrorVO.setRowNumber("第" + rowNumber + "行");
errorList.add(importErrorVO);
flag = false;
}
if (flag) {
// 判断如果不存在,在进行插入
QueryWrapper<LocationAreaDO> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("number", locationAreaDO.getNumber());
LocationAreaDO existLocationAreabasic = locationAreaMapper.selectOne(queryWrapper);
if (existLocationAreabasic == null && mode != 3) {
locationAreaMapper.insert(LocationAreaConvert.INSTANCE.convert(importLocationAreabasics.get(i)));
} else if (existLocationAreabasic != null && mode != 2) {// 如果存在,判断是否允许更新
locationAreaDO.setId(existLocationAreabasic.getId());
locationAreaMapper.updateById(locationAreaDO);
} else if (existLocationAreabasic != null && mode == 2) {
LocationAreaImportErrorVO importErrorVO = LocationAreaConvert.INSTANCE.convert2(existLocationAreabasic);
importErrorVO.setImportStatus("失败");
importErrorVO.setImportRemark("物料号" + existLocationAreabasic.getNumber() + "该条数据已存在,请重新编辑备件编号并重新导入");
errorList.add(importErrorVO);
}
}
}
return errorList;
}
private String validateLocationAreabasicImport(LocationAreaDO locationAreaDO) {
String massage = "";
// 校验,判断是否有不符合的原因
if(locationAreaDO.getNumber().isEmpty()){
massage += "物料号不能为空" + ",";
}
return massage.toString();
}
}

Loading…
Cancel
Save