| | |
| | | import com.consum.base.core.CodeGeneratorService; |
| | | import com.consum.base.core.WhBusinessEnum; |
| | | import com.consum.base.core.utils.CommonUtil; |
| | | import com.consum.base.core.utils.IdUtil; |
| | | import com.consum.base.core.utils.MapUtils; |
| | | import com.consum.base.core.utils.MapperUtil; |
| | | import com.consum.base.core.utils.PageUtil; |
| | | import com.consum.base.pojo.LWhFormProcureGoodsInfoParam; |
| | | import com.consum.base.pojo.LWhFormProcureParam; |
| | | import com.consum.base.pojo.LWhProcureModelParam; |
| | | import com.consum.base.pojo.excel.ProcureExcelTemplate; |
| | | import com.consum.base.pojo.query.FormProcureQry; |
| | | import com.consum.base.pojo.response.FormProcureVO; |
| | | import com.consum.base.pojo.response.FromProcureTemplateInfoVO; |
| | | import com.consum.base.pojo.response.GoodsModelVO; |
| | | import com.consum.base.pojo.response.LWhFormProcureExtendVO; |
| | | import com.consum.base.pojo.response.LWhFormProcureGoodsVO; |
| | | import com.consum.base.service.BaseGoodsTemplateServiceImpl; |
| | | import com.consum.base.service.BaseWarehouseServiceImpl; |
| | | import com.consum.base.service.BaseGoodsTemplateService; |
| | | import com.consum.base.service.BaseWarehouseService; |
| | | import com.consum.base.service.LOrgSupplierServiceImpl; |
| | | import com.consum.base.service.LWhFormProcureCoreService; |
| | | import com.consum.base.service.LWhFormProcureGoodsService; |
| | |
| | | import com.iplatform.model.po.S_user_core; |
| | | import com.walker.db.page.GenericPager; |
| | | import com.walker.infrastructure.utils.CollectionUtils; |
| | | import com.walker.infrastructure.utils.NumberGenerator; |
| | | import com.walker.infrastructure.utils.DateUtils; |
| | | import com.walker.web.ResponseValue; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.lang.reflect.Field; |
| | | import java.net.URLEncoder; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Optional; |
| | | import java.util.Set; |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | |
| | | @Resource |
| | | private LWhFormProcureService lWhFormProcureService; |
| | | @Resource |
| | | private BaseWarehouseServiceImpl baseWarehouseService; |
| | | private BaseWarehouseService baseWarehouseService; |
| | | @Resource |
| | | private CodeGeneratorService codeGeneratorService; |
| | | @Resource |
| | |
| | | @Resource |
| | | private LWhGoodsService lWhGoodsService; |
| | | @Resource |
| | | private BaseGoodsTemplateServiceImpl baseGoodsTemplateService; |
| | | private BaseGoodsTemplateService baseGoodsTemplateService; |
| | | @Resource |
| | | private LWhProcureModelService lWhProcureModelService; |
| | | @Resource |
| | |
| | | // 采购单id |
| | | Long whFormProcureId = param.getId(); |
| | | if (whFormProcureId == null) { |
| | | whFormProcureId = NumberGenerator.getLongSequenceNumber(); |
| | | whFormProcureId = IdUtil.generateId(); |
| | | } |
| | | long procureTime = Long.valueOf(param.getProcureTime()); |
| | | |
| | |
| | | return ResponseValue.error("采购单不能为空"); |
| | | } |
| | | LWhFormProcureGoods procureGood = new LWhFormProcureGoods(); |
| | | long fromProcureGoodsId = NumberGenerator.getLongSequenceNumber(); |
| | | long fromProcureGoodsId = IdUtil.generateId(); |
| | | procureGood.setId(fromProcureGoodsId); |
| | | procureGood.setWhFormProcureId(whFormProcureId); |
| | | procureGood.setBaseCategoryId(baseCategoryId); |
| | |
| | | // 查询型号库存 |
| | | int goodsModelNum = lWhGoodsService.queryGoodsModelNum(0, warehouseId, baseGoodsModelsId, 1, null); |
| | | LWhProcureModel model = new LWhProcureModel(); |
| | | model.setId(NumberGenerator.getLongSequenceNumber()); |
| | | model.setId(IdUtil.generateId()); |
| | | model.setFromProcureGoodsId(fromProcureGoodsId); |
| | | model.setBusinessType(WhBusinessEnum.CAIGOU.getValue() + 0); |
| | | model.setBusinessId(whFormProcureId); |
| | |
| | | |
| | | supplierList.forEach(supplier -> { |
| | | LOrgSupplier lOrgSupplier = new LOrgSupplier(); |
| | | lOrgSupplier.setId(NumberGenerator.getLongSequenceNumber()); |
| | | lOrgSupplier.setId(IdUtil.generateId()); |
| | | lOrgSupplier.setAgencyId(tenantId); |
| | | lOrgSupplier.setAgencyName(tenantName); |
| | | lOrgSupplier.setSupplier(supplier); |
| | |
| | | } |
| | | |
| | | @ApiOperation(value = "采购单导出", notes = "采购单导出") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "采购单id", required = true, dataType = "Long", paramType = "query") |
| | | }) |
| | | @GetMapping("/list/export") |
| | | public void export(Long id, HttpServletResponse response) throws IOException { |
| | | public void export(Long id, HttpServletResponse response) throws Exception { |
| | | TemplateExportParams params = new TemplateExportParams( |
| | | "import/采购入库单.xls"); |
| | | |
| | | params.setHeadingStartRow(2); |
| | | FinSysTenantUser sysInfo = this.getSysInfo(); |
| | | String userName = sysInfo.getUserName(); |
| | | if (sysInfo == null) { |
| | | throw new RuntimeException("登录用户信息不存在"); |
| | | } |
| | | |
| | | Map<String, Object> map = lWhFormProcureService.getExportList(id, userName); |
| | | if (CollectionUtils.isEmpty(map)) { |
| | | List<ProcureExcelTemplate> exportList = lWhFormProcureService.getExportList(id); |
| | | if (CollectionUtils.isEmpty(exportList)) { |
| | | throw new RuntimeException("数据为空"); |
| | | } |
| | | Workbook workbook = ExcelExportUtil.exportExcel(params, map); |
| | | |
| | | try (OutputStream outputStream = response.getOutputStream()) { |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"); |
| | | response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode("采购入库单.xls", "utf-8")); |
| | | workbook.write(outputStream); |
| | | workbook.close(); |
| | | } |
| | | int countNum = exportList.stream().filter(item -> item.getNum() != null).mapToInt(ProcureExcelTemplate::getNum).sum(); |
| | | int totalAmount = exportList.stream().filter(export -> export.getTotalAmount() != null).mapToInt(ProcureExcelTemplate::getTotalAmount).sum(); |
| | | Optional<ProcureExcelTemplate> first = exportList.stream().findFirst(); |
| | | ProcureExcelTemplate templateExcelExport = first.get(); |
| | | String businessFormCode = templateExcelExport.getBusinessFormCode(); |
| | | Long createTime = templateExcelExport.getCreateTime(); |
| | | String operatorName = templateExcelExport.getOperatorName(); |
| | | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("code", businessFormCode); |
| | | map.put("date", DateUtils.toShowDate(createTime)); |
| | | map.put("name", operatorName); |
| | | map.put("countNum", countNum); |
| | | map.put("totalAmount", totalAmount); |
| | | |
| | | Workbook workbook = ExcelExportUtil.exportExcel(params, ProcureExcelTemplate.class, exportList, map); |
| | | downLoadExcel("采购入库单", response, workbook); |
| | | |
| | | } |
| | | } |