|
|
@ -1,42 +1,27 @@ |
|
|
|
package com.win.module.wms.controller.rule; |
|
|
|
|
|
|
|
import com.win.framework.dict.core.util.DictFrameworkUtils; |
|
|
|
import com.win.framework.common.pojo.CommonResult; |
|
|
|
import com.win.framework.common.pojo.PageResult; |
|
|
|
import com.win.module.system.api.user.AdminUserApi; |
|
|
|
import com.win.module.system.api.user.dto.AdminUserRespDTO; |
|
|
|
import com.win.module.wms.controller.rule.vo.*; |
|
|
|
import com.win.module.wms.controller.rule.vo.RuleImportExcelVo; |
|
|
|
import com.win.module.wms.enums.DictTypeConstants; |
|
|
|
import io.swagger.v3.oas.annotations.Parameters; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import org.springframework.validation.annotation.Validated; |
|
|
|
import org.springframework.security.access.prepost.PreAuthorize; |
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag; |
|
|
|
import io.swagger.v3.oas.annotations.Parameter; |
|
|
|
import com.win.module.wms.controller.rule.vo.RuleCreateReqVO; |
|
|
|
import com.win.module.wms.controller.rule.vo.RulePageReqVO; |
|
|
|
import com.win.module.wms.controller.rule.vo.RuleRespVO; |
|
|
|
import com.win.module.wms.controller.rule.vo.RuleUpdateReqVO; |
|
|
|
import com.win.module.wms.convert.rule.RuleConvert; |
|
|
|
import com.win.module.wms.dal.dataobject.rule.RuleDO; |
|
|
|
import com.win.module.wms.service.rule.RuleService; |
|
|
|
import io.swagger.v3.oas.annotations.Operation; |
|
|
|
import io.swagger.v3.oas.annotations.Parameter; |
|
|
|
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 javax.validation.*; |
|
|
|
import javax.servlet.http.*; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.ZoneOffset; |
|
|
|
import java.util.*; |
|
|
|
import java.io.IOException; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.validation.Valid; |
|
|
|
|
|
|
|
import com.win.framework.common.pojo.PageResult; |
|
|
|
import com.win.framework.common.pojo.CommonResult; |
|
|
|
import static com.win.framework.common.pojo.CommonResult.success; |
|
|
|
|
|
|
|
import com.win.framework.excel.core.util.ExcelUtils; |
|
|
|
|
|
|
|
import com.win.framework.operatelog.core.annotations.OperateLog; |
|
|
|
import static com.win.framework.operatelog.core.enums.OperateTypeEnum.*; |
|
|
|
|
|
|
|
import com.win.module.wms.controller.rule.vo.*; |
|
|
|
import com.win.module.wms.dal.dataobject.rule.RuleDO; |
|
|
|
import com.win.module.wms.convert.rule.RuleConvert; |
|
|
|
import com.win.module.wms.service.rule.RuleService; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
@Tag(name = "管理后台 - 规则") |
|
|
|
@RestController |
|
|
|
@RequestMapping("/wms/rule") |
|
|
@ -82,15 +67,6 @@ public class RuleController { |
|
|
|
return success(RuleConvert.INSTANCE.convert(rule)); |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/list") |
|
|
|
@Operation(summary = "获得规则列表") |
|
|
|
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") |
|
|
|
@PreAuthorize("@ss.hasPermission('wms:rule:query')") |
|
|
|
public CommonResult<List<RuleRespVO>> getRuleList(@RequestParam("ids") Collection<Long> ids) { |
|
|
|
List<RuleDO> list = ruleService.getRuleList(ids); |
|
|
|
return success(RuleConvert.INSTANCE.convertList(list)); |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/page") |
|
|
|
@Operation(summary = "获得规则分页") |
|
|
|
@PreAuthorize("@ss.hasPermission('wms:rule:query')") |
|
|
@ -99,63 +75,4 @@ public class RuleController { |
|
|
|
return success(RuleConvert.INSTANCE.convertPage(pageResult)); |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/export-excel") |
|
|
|
@Operation(summary = "导出规则 Excel") |
|
|
|
@PreAuthorize("@ss.hasPermission('wms:rule:export')") |
|
|
|
@OperateLog(type = EXPORT) |
|
|
|
public void exportRuleExcel(@Valid RuleExportReqVO exportReqVO, |
|
|
|
HttpServletResponse response) throws IOException { |
|
|
|
List<RuleDO> list = ruleService.getRuleList(exportReqVO); |
|
|
|
// 导出 Excel
|
|
|
|
List<RuleExcelVO> datas = RuleConvert.INSTANCE.convertList02(list); |
|
|
|
for(RuleExcelVO vo : datas) { |
|
|
|
AdminUserRespDTO user = userApi.getUser(Long.valueOf(vo.getCreator())); |
|
|
|
//后端创建个字段作为前端展示的虚拟字段
|
|
|
|
vo.setCreator(user.getNickname()); |
|
|
|
} |
|
|
|
ExcelUtils.write(response, "规则.xls", "数据", RuleExcelVO.class, datas); |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/get-import-template") |
|
|
|
@Operation(summary = "获得导入规则信息模板") |
|
|
|
public void importTemplate(HttpServletResponse response) throws IOException { |
|
|
|
// 手动创建导出 demo
|
|
|
|
List<RuleImportExcelVo> list = Arrays.asList( |
|
|
|
); |
|
|
|
// 手动创建导出 demo
|
|
|
|
Map<Integer, String[]> mapDropDown = new HashMap<>(); |
|
|
|
|
|
|
|
// 输出
|
|
|
|
|
|
|
|
// 输出
|
|
|
|
ExcelUtils.write(response, "规则导入模板.xls", "规则列表", RuleImportExcelVo.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('wms:rule: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<RuleImportExcelVo> list = ExcelUtils.read(file, RuleImportExcelVo.class); |
|
|
|
List<RuleImportExcelVo> errorList = ruleService.importRuleList(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); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|