|
|
@ -1,41 +1,40 @@ |
|
|
|
package com.win.module.wms.controller.inspectRequest; |
|
|
|
|
|
|
|
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.ConvertUtil; |
|
|
|
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.inspectRequest.vo.*; |
|
|
|
import com.win.module.wms.convert.inspectRequest.InspectRequestMainConvert; |
|
|
|
import com.win.module.wms.dal.dataobject.inspectRequest.InspectRequestDetailDO; |
|
|
|
import com.win.module.wms.dal.dataobject.inspectRequest.InspectRequestMainDO; |
|
|
|
import com.win.module.wms.enums.DictTypeConstants; |
|
|
|
import com.win.module.wms.service.inspectRequest.InspectRequestDetailService; |
|
|
|
import com.win.module.wms.service.inspectRequest.InspectRequestMainService; |
|
|
|
import io.swagger.v3.oas.annotations.Operation; |
|
|
|
import io.swagger.v3.oas.annotations.Parameter; |
|
|
|
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 io.swagger.v3.oas.annotations.Operation; |
|
|
|
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.validation.*; |
|
|
|
import javax.servlet.http.*; |
|
|
|
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 java.io.IOException; |
|
|
|
|
|
|
|
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.dal.dataobject.inspectRequest.InspectRequestMainDO; |
|
|
|
import com.win.module.wms.convert.inspectRequest.InspectRequestMainConvert; |
|
|
|
import com.win.module.wms.service.inspectRequest.InspectRequestMainService; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
import static com.win.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; |
|
|
|
|
|
|
|
@Tag(name = "管理后台 - 检验申请主") |
|
|
|
@RestController |
|
|
@ -46,6 +45,8 @@ public class InspectRequestMainController { |
|
|
|
@Resource |
|
|
|
private InspectRequestMainService inspectRequestMainService; |
|
|
|
@Resource |
|
|
|
private InspectRequestDetailService inspectRequestDetailService; |
|
|
|
@Resource |
|
|
|
private AdminUserApi userApi; |
|
|
|
|
|
|
|
@PostMapping("/create") |
|
|
@ -59,8 +60,8 @@ public class InspectRequestMainController { |
|
|
|
@Operation(summary = "更新检验申请主") |
|
|
|
@PreAuthorize("@ss.hasPermission('wms:inspect-request-main:update')") |
|
|
|
public CommonResult<Boolean> updateInspectRequestMain(@Valid @RequestBody InspectRequestMainUpdateReqVO updateReqVO) { |
|
|
|
inspectRequestMainService.updateInspectRequestMain(updateReqVO); |
|
|
|
return success(true); |
|
|
|
int result = inspectRequestMainService.updateInspectRequestMain(updateReqVO); |
|
|
|
return success(result > 0); |
|
|
|
} |
|
|
|
|
|
|
|
@DeleteMapping("/delete") |
|
|
@ -68,8 +69,8 @@ public class InspectRequestMainController { |
|
|
|
@Parameter(name = "id", description = "编号", required = true) |
|
|
|
@PreAuthorize("@ss.hasPermission('wms:inspect-request-main:delete')") |
|
|
|
public CommonResult<Boolean> deleteInspectRequestMain(@RequestParam("id") Long id) { |
|
|
|
inspectRequestMainService.deleteInspectRequestMain(id); |
|
|
|
return success(true); |
|
|
|
int result = inspectRequestMainService.deleteInspectRequestMain(id); |
|
|
|
return success(result > 0); |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/get") |
|
|
@ -110,21 +111,57 @@ public class InspectRequestMainController { |
|
|
|
} |
|
|
|
return success(result); |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/export-excel") |
|
|
|
@Operation(summary = "导出检验申请主 Excel") |
|
|
|
@PreAuthorize("@ss.hasPermission('wms:inspect-request-main:export')") |
|
|
|
@OperateLog(type = EXPORT) |
|
|
|
public void exportInspectRequestMainExcel(@Valid InspectRequestMainExportReqVO exportReqVO, |
|
|
|
HttpServletResponse response) throws IOException { |
|
|
|
public void exportInspectRequestMainExcel(@Valid InspectRequestMainExportReqVO exportReqVO, HttpServletResponse response) throws IOException { |
|
|
|
List<InspectRequestMainDO> list = inspectRequestMainService.getInspectRequestMainList(exportReqVO); |
|
|
|
Map<Integer, String[]> mapDropDown = new HashMap<>(); |
|
|
|
List<InspectRequestMainExcelVO> resultList = this.getExcelVo(list, mapDropDown); |
|
|
|
ExcelUtils.write(response, "到货检验申请主.xls", "检验申请信息列表", InspectRequestMainExcelVO.class, resultList, mapDropDown); |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/export-excel-senior") |
|
|
|
@Operation(summary = "导出检验申请主 Excel") |
|
|
|
@PreAuthorize("@ss.hasPermission('wms:inspect-request-main:export')") |
|
|
|
@OperateLog(type = EXPORT) |
|
|
|
public void exportInspectRequestMainSeniorExcel(@Valid @RequestBody CustomConditions conditions, HttpServletResponse response) throws IOException { |
|
|
|
List<InspectRequestMainDO> list = inspectRequestMainService.getInspectRequestMainList(conditions); |
|
|
|
Map<Integer, String[]> mapDropDown = new HashMap<>(); |
|
|
|
List<InspectRequestMainExcelVO> resultList = this.getExcelVo(list, mapDropDown); |
|
|
|
ExcelUtils.write(response, "到货检验申请主.xls", "检验申请信息列表", InspectRequestMainExcelVO.class, resultList, mapDropDown); |
|
|
|
} |
|
|
|
|
|
|
|
private List<InspectRequestMainExcelVO> getExcelVo(List<InspectRequestMainDO> list, Map<Integer, String[]> mapDropDown) { |
|
|
|
String[] locationType = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.LOCATION_TYPE); |
|
|
|
mapDropDown.put(6, locationType); |
|
|
|
String[] requestStatus = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.REQUEST_STATUS); |
|
|
|
mapDropDown.put(11, requestStatus); |
|
|
|
String[] inspectType = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.INSPECT_TYPE); |
|
|
|
mapDropDown.put(15, inspectType); |
|
|
|
String[] nextAction = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.NEXT_ACTION); |
|
|
|
mapDropDown.put(16, nextAction); |
|
|
|
String[] sampleMethod = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.SAMPLE_METHOD); |
|
|
|
mapDropDown.put(17, sampleMethod); |
|
|
|
String[] uom = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.UOM); |
|
|
|
mapDropDown.put(18, uom); |
|
|
|
String[] inventoryStatus = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.INVENTORY_STATUS); |
|
|
|
mapDropDown.put(28, inventoryStatus); |
|
|
|
// 导出 Excel
|
|
|
|
List<InspectRequestMainExcelVO> datas = InspectRequestMainConvert.INSTANCE.convertList02(list); |
|
|
|
for(InspectRequestMainExcelVO vo : datas) { |
|
|
|
AdminUserRespDTO user = userApi.getUser(Long.valueOf(vo.getCreator())); |
|
|
|
//后端创建个字段作为前端展示的虚拟字段
|
|
|
|
vo.setCreator(user.getNickname()); |
|
|
|
List<InspectRequestMainExcelVO> resultList = new ArrayList<>(); |
|
|
|
for(InspectRequestMainDO mainDO : list) { |
|
|
|
List<InspectRequestDetailDO> subList = inspectRequestDetailService.selectList(mainDO.getId()); |
|
|
|
for(InspectRequestDetailDO detailDO : subList) { |
|
|
|
InspectRequestMainExcelVO vo = InspectRequestMainConvert.INSTANCE.convert(mainDO, detailDO); |
|
|
|
AdminUserRespDTO user = userApi.getUser(Long.valueOf(vo.getCreator())); |
|
|
|
//后端创建个字段作为前端展示的虚拟字段
|
|
|
|
vo.setCreator(user.getNickname()); |
|
|
|
resultList.add(vo); |
|
|
|
} |
|
|
|
} |
|
|
|
ExcelUtils.write(response, "检验申请主.xls", "数据", InspectRequestMainExcelVO.class, datas); |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/get-import-template") |
|
|
@ -161,9 +198,55 @@ public class InspectRequestMainController { |
|
|
|
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); |
|
|
|
String url = ExcelUtils.writeLocalFile("到货检验申请基本信息导入错误数据" + LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8")) + ".xlsx", "错误列表", errorList); |
|
|
|
returnMap.put("errorFile", url); |
|
|
|
} |
|
|
|
return success(returnMap); |
|
|
|
} |
|
|
|
|
|
|
|
@PutMapping("/close") |
|
|
|
@Operation(summary = "关闭到货检验申请主") |
|
|
|
@Parameter(name = "id", description = "编号", required = true) |
|
|
|
@PreAuthorize("@ss.hasPermission('wms:inspect-request-main:close')") |
|
|
|
public CommonResult<Boolean> closeInspectRequestMain(@RequestParam("id") Long id) { |
|
|
|
Integer count = inspectRequestMainService.closeInspectRequestMain(id); |
|
|
|
return success(count > 0); |
|
|
|
} |
|
|
|
|
|
|
|
@PutMapping("/submit") |
|
|
|
@Operation(summary = "提交到货检验申请主") |
|
|
|
@Parameter(name = "id", description = "编号", required = true) |
|
|
|
@PreAuthorize("@ss.hasPermission('wms:inspect-request-main:submit')") |
|
|
|
public CommonResult<Boolean> submitInspectRequestMain(@RequestParam("id") Long id) { |
|
|
|
Integer count = inspectRequestMainService.submitInspectRequestMain(id); |
|
|
|
return success(count > 0); |
|
|
|
} |
|
|
|
|
|
|
|
@PutMapping("/agree") |
|
|
|
@Operation(summary = "审批通过到货检验申请主") |
|
|
|
@Parameter(name = "id", description = "编号", required = true) |
|
|
|
@PreAuthorize("@ss.hasPermission('wms:inspect-request-main:agree')") |
|
|
|
public CommonResult<Boolean> agreeInspectRequestMain(@RequestParam("id") Long id) { |
|
|
|
Integer count = inspectRequestMainService.agreeInspectRequestMain(id); |
|
|
|
return success(count > 0); |
|
|
|
} |
|
|
|
|
|
|
|
@PutMapping("/handle") |
|
|
|
@Operation(summary = "执行到货检验申请主") |
|
|
|
@Parameter(name = "id", description = "编号", required = true) |
|
|
|
@PreAuthorize("@ss.hasPermission('wms:inspect-request-main:handle')") |
|
|
|
public CommonResult<Boolean> handleInspectRequestMain(@RequestParam("id") Long id) { |
|
|
|
Integer count = inspectRequestMainService.handleInspectRequestMain(id); |
|
|
|
return success(count > 0); |
|
|
|
} |
|
|
|
|
|
|
|
@PutMapping("/abort") |
|
|
|
@Operation(summary = "审批拒绝到货检验申请主") |
|
|
|
@Parameter(name = "id", description = "编号", required = true) |
|
|
|
@PreAuthorize("@ss.hasPermission('wms:inspect-request-main:abort')") |
|
|
|
public CommonResult<Boolean> abortInspectRequestMain(@RequestParam("id") Long id) { |
|
|
|
Integer count = inspectRequestMainService.abortInspectRequestMain(id); |
|
|
|
return success(count > 0); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|