|
|
@ -1,8 +1,12 @@ |
|
|
|
package com.win.module.wms.controller.issueRecord; |
|
|
|
|
|
|
|
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.dal.dataobject.issueRecord.IssueRecordDetailDO; |
|
|
|
import com.win.module.wms.enums.DictTypeConstants; |
|
|
|
import com.win.module.wms.service.issueRecord.IssueRecordDetailService; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import org.springframework.validation.annotation.Validated; |
|
|
@ -36,36 +40,14 @@ import com.win.module.wms.service.issueRecord.IssueRecordMainService; |
|
|
|
@Validated |
|
|
|
public class IssueRecordMainController { |
|
|
|
|
|
|
|
@Resource |
|
|
|
private IssueRecordDetailService issueRecordDetailService; |
|
|
|
@Resource |
|
|
|
private IssueRecordMainService issueRecordMainService; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private AdminUserApi userApi; |
|
|
|
|
|
|
|
@PostMapping("/create") |
|
|
|
@Operation(summary = "创建发料记录主") |
|
|
|
@PreAuthorize("@ss.hasPermission('wms:issue-record-main:create')") |
|
|
|
public CommonResult<Long> createIssueRecordMain(@Valid @RequestBody IssueRecordMainCreateReqVO createReqVO) { |
|
|
|
return success(issueRecordMainService.createIssueRecordMain(createReqVO)); |
|
|
|
} |
|
|
|
|
|
|
|
@PutMapping("/update") |
|
|
|
@Operation(summary = "更新发料记录主") |
|
|
|
@PreAuthorize("@ss.hasPermission('wms:issue-record-main:update')") |
|
|
|
public CommonResult<Boolean> updateIssueRecordMain(@Valid @RequestBody IssueRecordMainUpdateReqVO updateReqVO) { |
|
|
|
issueRecordMainService.updateIssueRecordMain(updateReqVO); |
|
|
|
return success(true); |
|
|
|
} |
|
|
|
|
|
|
|
@DeleteMapping("/delete") |
|
|
|
@Operation(summary = "删除发料记录主") |
|
|
|
@Parameter(name = "id", description = "编号", required = true) |
|
|
|
@PreAuthorize("@ss.hasPermission('wms:issue-record-main:delete')") |
|
|
|
public CommonResult<Boolean> deleteIssueRecordMain(@RequestParam("id") Long id) { |
|
|
|
issueRecordMainService.deleteIssueRecordMain(id); |
|
|
|
return success(true); |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/get") |
|
|
|
@Operation(summary = "获得发料记录主") |
|
|
|
@Parameter(name = "id", description = "编号", required = true, example = "1024") |
|
|
@ -105,21 +87,53 @@ public class IssueRecordMainController { |
|
|
|
} |
|
|
|
return success(result); |
|
|
|
} |
|
|
|
|
|
|
|
private List<IssueRecordMainExcelVO> getExcelVo(List<IssueRecordMainDO> list, Map<Integer, String[]> mapDropDown) { |
|
|
|
String[] useOnTheWayLocation = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.TRUE_FALSE); |
|
|
|
mapDropDown.put(21, useOnTheWayLocation); |
|
|
|
String[] inventoryStatus = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.INVENTORY_STATUS); |
|
|
|
mapDropDown.put(28, inventoryStatus); |
|
|
|
String[] uom = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.UOM); |
|
|
|
mapDropDown.put(49, uom); |
|
|
|
List<IssueRecordMainExcelVO> resultList = new ArrayList<>(); |
|
|
|
// 导出
|
|
|
|
for(IssueRecordMainDO mainDO : list) { |
|
|
|
List<IssueRecordDetailDO> subList = issueRecordDetailService.selectList(mainDO.getId()); |
|
|
|
for(IssueRecordDetailDO detailDO : subList) { |
|
|
|
IssueRecordMainExcelVO vo = IssueRecordMainConvert.INSTANCE.convert(mainDO, detailDO); |
|
|
|
AdminUserRespDTO user = userApi.getUser(Long.valueOf(mainDO.getCreator())); |
|
|
|
vo.setCreator(user.getNickname()); |
|
|
|
resultList.add(vo); |
|
|
|
} |
|
|
|
} |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/export-excel") |
|
|
|
@Operation(summary = "导出发料记录主 Excel") |
|
|
|
@Operation(summary = "导出发料记录 Excel") |
|
|
|
@PreAuthorize("@ss.hasPermission('wms:issue-record-main:export')") |
|
|
|
@OperateLog(type = EXPORT) |
|
|
|
public void exportIssueRecordMainExcel(@Valid IssueRecordMainExportReqVO exportReqVO, |
|
|
|
HttpServletResponse response) throws IOException { |
|
|
|
List<IssueRecordMainDO> list = issueRecordMainService.getIssueRecordMainList(exportReqVO); |
|
|
|
//组装vo
|
|
|
|
Map<Integer, String[]> mapDropDown = new HashMap<>(); |
|
|
|
List<IssueRecordMainExcelVO> resultList = this.getExcelVo(list, mapDropDown); |
|
|
|
// 导出 Excel
|
|
|
|
List<IssueRecordMainExcelVO> datas = IssueRecordMainConvert.INSTANCE.convertList02(list); |
|
|
|
for(IssueRecordMainExcelVO vo : datas) { |
|
|
|
AdminUserRespDTO user = userApi.getUser(Long.valueOf(vo.getCreator())); |
|
|
|
//后端创建个字段作为前端展示的虚拟字段
|
|
|
|
vo.setCreator(user.getNickname()); |
|
|
|
} |
|
|
|
ExcelUtils.write(response, "发料记录主.xls", "数据", IssueRecordMainExcelVO.class, datas); |
|
|
|
ExcelUtils.write(response, "发料记录.xlsx", "发料记录", IssueRecordMainExcelVO.class, resultList, mapDropDown); |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("/export-excel-senior") |
|
|
|
@Operation(summary = "导出发料记录 Excel") |
|
|
|
@PreAuthorize("@ss.hasPermission('wms:issue-record-main:export')") |
|
|
|
@OperateLog(type = EXPORT) |
|
|
|
public void exportIssueRecordMainSeniorExcel(@Valid @RequestBody CustomConditions conditions, HttpServletResponse response) throws IOException { |
|
|
|
List<IssueRecordMainDO> list = issueRecordMainService.getIssueRecordMainList(conditions); |
|
|
|
//组装vo
|
|
|
|
Map<Integer, String[]> mapDropDown = new HashMap<>(); |
|
|
|
List<IssueRecordMainExcelVO> resultList = this.getExcelVo(list, mapDropDown); |
|
|
|
// 导出 Excel
|
|
|
|
ExcelUtils.write(response, "发料记录.xlsx", "发料记录", IssueRecordMainExcelVO.class, resultList, mapDropDown); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|