|
|
@ -3,14 +3,19 @@ package com.win.module.wms.controller.demandforecasting; |
|
|
|
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.demandforecasting.vo.DemandforecastingMainExcelVO; |
|
|
|
import com.win.module.wms.controller.demandforecasting.vo.*; |
|
|
|
import com.win.module.wms.convert.demandforecasting.DemandforecastingMainConvert; |
|
|
|
import com.win.module.wms.dal.dataobject.demandforecasting.DemandforecastingDetailDO; |
|
|
|
import com.win.module.wms.dal.dataobject.demandforecasting.DemandforecastingMainDO; |
|
|
|
import com.win.module.wms.enums.DictTypeConstants; |
|
|
|
import com.win.module.wms.service.demandforecasting.DemandforecastingDetailService; |
|
|
|
import com.win.module.wms.service.demandforecasting.DemandforecastingMainService; |
|
|
|
import io.swagger.v3.oas.annotations.Operation; |
|
|
|
import io.swagger.v3.oas.annotations.Parameter; |
|
|
@ -40,6 +45,8 @@ public class DemandforecastingMainController { |
|
|
|
|
|
|
|
@Resource |
|
|
|
private DemandforecastingMainService demandforecastingMainService; |
|
|
|
@Resource |
|
|
|
private DemandforecastingDetailService demandforecastingDetailService; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private AdminUserApi userApi; |
|
|
@ -114,14 +121,45 @@ public class DemandforecastingMainController { |
|
|
|
public void exportDemandforecastingMainExcel(@Valid DemandforecastingMainExportReqVO exportReqVO, |
|
|
|
HttpServletResponse response) throws IOException { |
|
|
|
List<DemandforecastingMainDO> list = demandforecastingMainService.getDemandforecastingMainList(exportReqVO); |
|
|
|
//组装vo
|
|
|
|
Map<Integer, String[]> mapDropDown = new HashMap<>(); |
|
|
|
List<DemandforecastingMainExcelVO> resultList = this.getExcelVo(list, mapDropDown); |
|
|
|
ExcelUtils.write(response, "要货预测主.xls", "数据", DemandforecastingMainExcelVO.class, resultList,mapDropDown); |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("/export-excel-senior") |
|
|
|
@Operation(summary = "导出要货预测主 Excel") |
|
|
|
@PreAuthorize("@ss.hasPermission('wms:demandforecasting-main:export')") |
|
|
|
@OperateLog(type = EXPORT) |
|
|
|
public void exportDemandforecastingMainSeniorExcel(@Valid @RequestBody CustomConditions conditions, HttpServletResponse response) throws IOException { |
|
|
|
List<DemandforecastingMainDO> list = demandforecastingMainService.getDemandforecastingMainList(conditions); |
|
|
|
//组装vo
|
|
|
|
Map<Integer, String[]> mapDropDown = new HashMap<>(); |
|
|
|
List<DemandforecastingMainExcelVO> resultList = this.getExcelVo(list, mapDropDown); |
|
|
|
// 导出 Excel
|
|
|
|
List<DemandforecastingMainExcelVO> datas = DemandforecastingMainConvert.INSTANCE.convertList02(list); |
|
|
|
for(DemandforecastingMainExcelVO vo : datas) { |
|
|
|
AdminUserRespDTO user = userApi.getUser(Long.valueOf(vo.getCreator())); |
|
|
|
//后端创建个字段作为前端展示的虚拟字段
|
|
|
|
ExcelUtils.write(response, "发货申请.xlsx", "数据", DemandforecastingMainExcelVO.class, resultList, mapDropDown); |
|
|
|
} |
|
|
|
|
|
|
|
private List<DemandforecastingMainExcelVO> getExcelVo(List<DemandforecastingMainDO> list, Map<Integer, String[]> mapDropDown) { |
|
|
|
String[] available = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.TRUE_FALSE); |
|
|
|
mapDropDown.put(13, available); |
|
|
|
mapDropDown.put(26, available); |
|
|
|
String[] predictTimeType = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.PREDICT_TIME_TYPE); |
|
|
|
mapDropDown.put(14, predictTimeType); |
|
|
|
String[] uom = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.UOM); |
|
|
|
mapDropDown.put(23, uom); |
|
|
|
List<DemandforecastingMainExcelVO> resultList = new ArrayList<>(); |
|
|
|
// 导出
|
|
|
|
for(DemandforecastingMainDO mainDO : list) { |
|
|
|
List<DemandforecastingDetailDO> subList = demandforecastingDetailService.selectListByID(mainDO.getId()); |
|
|
|
for(DemandforecastingDetailDO detailDO : subList) { |
|
|
|
DemandforecastingMainExcelVO vo = DemandforecastingMainConvert.INSTANCE.convert(mainDO, detailDO); |
|
|
|
AdminUserRespDTO user = userApi.getUser(Long.valueOf(mainDO.getCreator())); |
|
|
|
vo.setCreator(user.getNickname()); |
|
|
|
resultList.add(vo); |
|
|
|
} |
|
|
|
} |
|
|
|
ExcelUtils.write(response, "要货预测主.xls", "数据", DemandforecastingMainExcelVO.class, datas); |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/get-import-template") |
|
|
@ -132,8 +170,6 @@ public class DemandforecastingMainController { |
|
|
|
Map<Integer, String[]> mapDropDown = new HashMap<>(); |
|
|
|
// String[] purchaseReturnReason = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.PURCHASE_RETURN_REASON);
|
|
|
|
// mapDropDown.put(16, purchaseReturnReason);
|
|
|
|
// String[] uom = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.UOM);
|
|
|
|
// mapDropDown.put(25, uom);
|
|
|
|
// 输出
|
|
|
|
ExcelUtils.write(response, "要货预测信息导入模板.xlsx", "要货预测信息列表", DemandforecastingImportVO.class, list, mapDropDown); |
|
|
|
} |
|
|
|