|
|
@ -1,6 +1,15 @@ |
|
|
|
package com.win.module.wms.controller.itemarea; |
|
|
|
|
|
|
|
import com.win.framework.common.pojo.CustomConditions; |
|
|
|
import com.win.framework.dict.core.util.DictFrameworkUtils; |
|
|
|
import com.win.module.system.api.user.AdminUserApi; |
|
|
|
import com.win.module.system.api.user.dto.AdminUserRespDTO; |
|
|
|
import com.win.module.wms.controller.itemarea.vo.*; |
|
|
|
import com.win.module.wms.controller.itembasic.vo.ItembasicExcelVO; |
|
|
|
import com.win.module.wms.convert.itembasic.ItembasicConvert; |
|
|
|
import com.win.module.wms.dal.dataobject.itemarea.ItemareaDetailDO; |
|
|
|
import com.win.module.wms.enums.DictTypeConstants; |
|
|
|
import com.win.module.wms.service.itemarea.ItemareaDetailService; |
|
|
|
import io.swagger.v3.oas.annotations.Parameters; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
@ -30,7 +39,6 @@ import com.win.framework.operatelog.core.annotations.OperateLog; |
|
|
|
|
|
|
|
import static com.win.framework.operatelog.core.enums.OperateTypeEnum.*; |
|
|
|
|
|
|
|
import com.win.module.wms.controller.itemarea.vo.*; |
|
|
|
import com.win.module.wms.dal.dataobject.itemarea.ItemareaDO; |
|
|
|
import com.win.module.wms.convert.itemarea.ItemareaConvert; |
|
|
|
import com.win.module.wms.service.itemarea.ItemareaService; |
|
|
@ -45,6 +53,12 @@ public class ItemareaController { |
|
|
|
@Resource |
|
|
|
private ItemareaService itemareaService; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private ItemareaDetailService itemareaDetailService; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private AdminUserApi userApi; |
|
|
|
|
|
|
|
@PostMapping("/create") |
|
|
|
@Operation(summary = "创建物料库区配置") |
|
|
|
@PreAuthorize("@ss.hasPermission('wms:itemarea:create')") |
|
|
@ -95,6 +109,21 @@ public class ItemareaController { |
|
|
|
return success(ItemareaConvert.INSTANCE.convertPage(pageResult)); |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("/senior") |
|
|
|
@Operation(summary = "高级搜索获得库存修改申请主分页") |
|
|
|
@PreAuthorize("@ss.hasPermission('wms:itemarea:query')") |
|
|
|
public CommonResult<PageResult<ItemareaRespVO>> getItemareaPageSenior(@Valid @RequestBody CustomConditions conditions) { |
|
|
|
PageResult<ItemareaDO> pageResult = itemareaService.getItemareaPageSenior(conditions); |
|
|
|
PageResult<ItemareaRespVO> result = ItemareaConvert.INSTANCE.convertPage(pageResult); |
|
|
|
for(ItemareaRespVO vo : result.getList()) { |
|
|
|
AdminUserRespDTO user = userApi.getUser(Long.valueOf(vo.getCreator())); |
|
|
|
//后端创建个字段作为前端展示的虚拟字段
|
|
|
|
vo.setCreator(user.getNickname()); |
|
|
|
vo.setUpdater(userApi.getUser(Long.valueOf(vo.getUpdater())).getNickname()); |
|
|
|
} |
|
|
|
return success(result); |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/export-excel") |
|
|
|
@Operation(summary = "导出物料库区配置 Excel") |
|
|
|
@PreAuthorize("@ss.hasPermission('wms:itemarea:export')") |
|
|
@ -102,16 +131,51 @@ public class ItemareaController { |
|
|
|
public void exportItemareaExcel(@Valid ItemareaExportReqVO exportReqVO, HttpServletResponse response) throws IOException { |
|
|
|
List<ItemareaDO> list = itemareaService.getItemareaList(exportReqVO); |
|
|
|
// 导出 Excel
|
|
|
|
List<ItemareaExcelVO> datas = ItemareaConvert.INSTANCE.convertList02(list); |
|
|
|
ExcelUtils.write(response, "物料库区配置.xls", "数据", ItemareaExcelVO.class, datas); |
|
|
|
//组装vo
|
|
|
|
Map<Integer, String[]> mapDropDown = new HashMap<>(); |
|
|
|
List<ItemareaExcelVO> resultList = this.getExcelVo(list, mapDropDown); |
|
|
|
ExcelUtils.write(response, "物料库区配置.xls", "数据", ItemareaExcelVO.class, resultList, mapDropDown); |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("/export-excel-senior") |
|
|
|
@Operation(summary = "导出物料库区配置高级筛选Excel") |
|
|
|
@PreAuthorize("@ss.hasPermission('wms:itemarea:export')") |
|
|
|
@OperateLog(type = EXPORT) |
|
|
|
public void exportItemareaSeniorExcel(@Valid @RequestBody CustomConditions conditions, HttpServletResponse response) throws IOException { |
|
|
|
List<ItemareaDO> list = itemareaService.getItemareaList(conditions); |
|
|
|
//组装vo
|
|
|
|
Map<Integer, String[]> mapDropDown = new HashMap<>(); |
|
|
|
List<ItemareaExcelVO> resultList = this.getExcelVo(list, mapDropDown); |
|
|
|
// 导出 Excel
|
|
|
|
ExcelUtils.write(response, "库存修改申请主.xlsx", "数据", ItemareaExcelVO.class, resultList, mapDropDown); |
|
|
|
} |
|
|
|
|
|
|
|
private List<ItemareaExcelVO> getExcelVo(List<ItemareaDO> list, Map<Integer, String[]> mapDropDown) { |
|
|
|
String[] autoRepleinsh = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.TRUE_FALSE); |
|
|
|
mapDropDown.put(7, autoRepleinsh); |
|
|
|
mapDropDown.put(10, autoRepleinsh); |
|
|
|
mapDropDown.put(11, autoRepleinsh); |
|
|
|
mapDropDown.put(15, autoRepleinsh); |
|
|
|
mapDropDown.put(16, autoRepleinsh); |
|
|
|
String[] manageMode = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.MANAGE_MODE); |
|
|
|
mapDropDown.put(14, manageMode); |
|
|
|
// 导出
|
|
|
|
List<ItemareaExcelVO> datas = ItemareaConvert.INSTANCE.convertList02(list); |
|
|
|
return datas; |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/get-import-template") |
|
|
|
@Operation(summary = "获得导入物料库区配置模板") |
|
|
|
public void importTemplate(HttpServletResponse response) throws IOException { |
|
|
|
List<ItemareaExcelVO> list = Arrays.asList(); |
|
|
|
List<ItemareaImportVO> list = Arrays.asList(); |
|
|
|
Map<Integer, String[]> mapDropDown = new HashMap<>(); |
|
|
|
String[] manageMode = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.MANAGE_MODE); |
|
|
|
mapDropDown.put(3, manageMode); |
|
|
|
String[] trueFalse = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.TRUE_FALSE); |
|
|
|
mapDropDown.put(6, trueFalse); |
|
|
|
mapDropDown.put(7, trueFalse); |
|
|
|
// 输出
|
|
|
|
ExcelUtils.write(response, "物料库区配置基本信息导入模板.xls", "物料库区配置基本信息列表", ItemareaExcelVO.class, list); |
|
|
|
ExcelUtils.write(response, "物料库区配置基本信息导入模板.xls", "物料库区配置基本信息列表", ItemareaImportVO.class, list,mapDropDown); |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("/import") |
|
|
@ -119,17 +183,14 @@ public class ItemareaController { |
|
|
|
@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('wms:itemarea: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<ItemareaExcelVO> list = ExcelUtils.read(file, ItemareaExcelVO.class); |
|
|
|
List<ItemareaExcelVO> errorList = itemareaService.importItemareaList(list, mode, updatePart); |
|
|
|
|
|
|
|
List<ItemareaImportVO> list = ExcelUtils.read(file, ItemareaImportVO.class); |
|
|
|
List<ItemareaImportVO> errorList = itemareaService.importItemareaList(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); |
|
|
|
} |
|
|
|
} |
|
|
|