| | |
| | | package com.consum.base.controller; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.Comparator; |
| | | import java.util.HashMap; |
| | |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.alibaba.excel.EasyExcelFactory; |
| | | import com.alibaba.excel.context.AnalysisContext; |
| | | import com.alibaba.excel.event.AnalysisEventListener; |
| | | import com.alibaba.excel.exception.ExcelAnalysisException; |
| | | import com.alibaba.excel.exception.ExcelDataConvertException; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.consum.base.pojo.*; |
| | | import com.consum.base.pojo.excel.ImportProcureOrderTemplate; |
| | | import com.consum.base.pojo.excel.LWhFormTransferTemplate; |
| | | import com.consum.base.pojo.query.WarehouseQry; |
| | | import com.consum.base.service.*; |
| | | import com.consum.base.util.DateUtil; |
| | | import com.consum.base.util.ExcelStyleUtil; |
| | | import com.consum.model.po.*; |
| | | import org.apache.commons.compress.utils.Lists; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | |
| | | import com.consum.base.core.type.TransferStatesType; |
| | | import com.consum.base.core.utils.CommonUtil; |
| | | import com.consum.base.core.utils.IdUtil; |
| | | import com.consum.base.pojo.GoodsUseRecordVO; |
| | | import com.consum.base.pojo.LWhFormTransferGoodsInfoParam; |
| | | import com.consum.base.pojo.RecordUserInfoVO; |
| | | import com.consum.base.pojo.UseRecordSkuVO; |
| | | import com.consum.base.pojo.dto.GoodsInfoDTO; |
| | | import com.consum.base.pojo.dto.UseRecordDTO; |
| | | import com.consum.base.pojo.excel.TransferExcelTemplate; |
| | |
| | | import com.consum.base.pojo.response.GoodsTemplateCountVO; |
| | | import com.consum.base.pojo.response.LWHFromTransferExtendVO; |
| | | import com.consum.base.pojo.response.TransferInfoVO; |
| | | import com.consum.base.service.BaseWarehouseService; |
| | | import com.consum.base.service.LGoodsUserRecordCoreService; |
| | | import com.consum.base.service.LWhFormTransferService; |
| | | import com.consum.base.service.LWhGoodsService; |
| | | import com.consum.base.service.LWhProcureModelService; |
| | | import com.consum.base.service.LWhProcureModelUserRecordService; |
| | | import com.consum.base.service.LWhProcureModelUserService; |
| | | import com.consum.base.service.core.LWhFormTransferCoreService; |
| | | import com.consum.model.po.BaseWarehouse; |
| | | import com.consum.model.po.FinSysTenantUser; |
| | | import com.consum.model.po.LWhFormTransfer; |
| | | import com.consum.model.po.LWhProcureModel; |
| | | import com.consum.model.po.LWhProcureModelUser; |
| | | import com.consum.model.po.LWhProcureModelUserRecord; |
| | | import com.iplatform.model.po.S_user_core; |
| | | import com.walker.db.page.GenericPager; |
| | | import com.walker.infrastructure.utils.CollectionUtils; |
| | |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | /** |
| | | * @Description 调拨管理 |
| | |
| | | private LWhGoodsService lWhGoodsService; |
| | | @Autowired |
| | | private BaseWarehouseService baseWarehouseService; |
| | | @Autowired |
| | | private FinSysTenantDepartmentService departmentService; |
| | | @Autowired |
| | | private BaseCategoryService baseCategoryService; |
| | | @Autowired |
| | | private BaseGoodsTemplateService baseGoodsTemplateService; |
| | | @Autowired |
| | | private BaseGoodsModelsService baseGoodsModelsService; |
| | | |
| | | /** |
| | | * @Description 新增 |
| | |
| | | return ResponseValue.error("调拨单不能为空"); |
| | | } |
| | | long id = this.lWhFormTransferService.add(param, this.getSysInfo(), StrUtil.isEmpty(param.getProcureDoc())); |
| | | if(id == -1L){ |
| | | if (id == -1L) { |
| | | return ResponseValue.error("您不是库管员"); |
| | | } |
| | | if(id == -2L){ |
| | | if (id == -2L) { |
| | | return ResponseValue.error("仓库不存在"); |
| | | } |
| | | |
| | | Integer transferBusinessType = param.getTransferBusinessType(); |
| | | // 部门分发业务需要处理 |
| | | // 拆分 新逻辑 |
| | | if (transferBusinessType == 1 && !StrUtil.isEmpty(param.getProcureDoc())) { |
| | | // 先出库,再入库 |
| | | // 出库前 设置出库仓库 |
| | | List<LWhProcureModel> modelByForm = lWhProcureModelService.getModelByForm(WhBusinessEnum.BUMENFENFA, id); |
| | | Set<Long> baseModelIds = |
| | | modelByForm.stream().map(LWhProcureModel::getBaseGoodsModelsId).collect(Collectors.toSet()); |
| | | |
| | | FinSysTenantUser sysTenantUser = this.getSysInfo(); |
| | | String agencyId = sysTenantUser.getTenantId(); |
| | | List<BaseWarehouse> baseWarehouseList = |
| | | baseWarehouseService.getBaseWareHouseList(Long.valueOf(agencyId), StatesType.NORMAL.getValue()); |
| | | Set<Long> wareHouseIds = baseWarehouseList.stream().map(BaseWarehouse::getId).collect(Collectors.toSet()); |
| | | // 通过调拨单中的型号id查询出该型号物品所在的仓库位置 |
| | | List<GoodsInfoDTO> goodsInfoDTOS = lWhGoodsService.queryGoodsInfo(baseModelIds, wareHouseIds, null); |
| | | GoodsInfoDTO goodsInfoDTO = goodsInfoDTOS.stream().findFirst().orElse(null); |
| | | if (ObjectUtils.isEmpty(goodsInfoDTO)) { |
| | | return ResponseValue.error("该型号没有库存可使用"); |
| | | } |
| | | |
| | | Long wareHouseId = goodsInfoDTO.getWarehouseId(); |
| | | String warehouseName = goodsInfoDTO.getWarehouseName(); |
| | | LWhFormTransfer lWhFormTransfer = new LWhFormTransfer(id); |
| | | lWhFormTransfer.setOutWarehouseId(wareHouseId); |
| | | lWhFormTransfer.setOutWarehouseName(warehouseName); |
| | | lWhFormTransferService.update(lWhFormTransfer); |
| | | Long l = lWhFormTransferCoreService.doTransferOutPutNew(id, getCurrentUser(), WhBusinessEnum.BUMENFENFA); |
| | | if (l == -1L) { |
| | | return ResponseValue.error("仓库数量不足"); |
| | | } |
| | | lWhFormTransferCoreService.doTransferInPut(id, getCurrentUser(), param.getOperatorName()); |
| | | } |
| | | |
| | | return ResponseValue.success(); |
| | | } |
| | | |
| | | |
| | | public ResponseValue add2(LWhFormTransferParam param) throws Exception { |
| | | S_user_core currentUser = this.getCurrentUser(); |
| | | if (currentUser == null) { |
| | | return ResponseValue.error("登录用户信息不存在"); |
| | | } |
| | | List<LWhFormTransferGoodsInfoParam> transferGoods = param.getTransferGoods(); |
| | | if (CollectionUtils.isEmpty(transferGoods)) { |
| | | return ResponseValue.error("调拨单不能为空"); |
| | | } |
| | | |
| | | FinSysTenantUser sysInfo = this.getSysInfo(); |
| | | |
| | | long id = this.lWhFormTransferService.add(param, sysInfo, true); |
| | | if (id == -1L) { |
| | | return ResponseValue.error("您不是库管员"); |
| | | } |
| | | if (id == -2L) { |
| | | return ResponseValue.error("仓库不存在"); |
| | | } |
| | | |
| | |
| | | lWhFormTransfer.setOutWarehouseName(warehouseName); |
| | | lWhFormTransferService.update(lWhFormTransfer); |
| | | Long l = lWhFormTransferCoreService.doTransferOutPutNew(id, getCurrentUser(), WhBusinessEnum.BUMENFENFA); |
| | | if(l == -1L){ |
| | | if (l == -1L) { |
| | | return ResponseValue.error("仓库数量不足"); |
| | | } |
| | | lWhFormTransferCoreService.doTransferInPut(id, getCurrentUser(), param.getOperatorName()); |
| | |
| | | if (type == 0) { |
| | | params = new TemplateExportParams("import/调拨入库单.xls"); |
| | | fileName = "调拨入库单"; |
| | | }else if (type == 1) { |
| | | } else if (type == 1) { |
| | | params = new TemplateExportParams("import/调拨入库单1.xls"); |
| | | fileName = "调拨入库单"; |
| | | } else { |
| | |
| | | lWhFormTransferService.queryDepartmentTransferOrder(); |
| | | return ResponseValue.success(transferInfoVO); |
| | | } |
| | | |
| | | /** |
| | | * 分发单导入 |
| | | * |
| | | * @param file |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "分发单导入", notes = "分发单导入") |
| | | @PostMapping("/import2") |
| | | public ResponseValue import2(MultipartFile file) { |
| | | String originalFilename = file.getOriginalFilename(); |
| | | // 文件格式校验 |
| | | // if (!".xls".endsWith(originalFilename)) { |
| | | // return ResponseValue.error("文件格式有误!"); |
| | | // } |
| | | FinSysTenantUser sysInfo = this.getSysInfo(); |
| | | if (sysInfo == null) { |
| | | return ResponseValue.error("当前登录用户为空"); |
| | | } |
| | | try { |
| | | EasyExcelFactory.read(file.getInputStream(), LWhFormTransferTemplate.class, |
| | | new AnalysisEventListener<LWhFormTransferTemplate>() { |
| | | /** |
| | | * 分发单主数据 |
| | | */ |
| | | final List<LWhFormTransferGoodsInfoParam> list = Lists.newArrayList(); |
| | | |
| | | /** |
| | | * 分发单的外层的主数据 |
| | | */ |
| | | final LWhFormTransferParam lWhFormTransferParam = new LWhFormTransferParam(); |
| | | |
| | | /** |
| | | * 行索引 |
| | | */ |
| | | Integer index = 0; |
| | | |
| | | /** |
| | | * 表头信息 |
| | | * @param headMap |
| | | * @param context |
| | | */ |
| | | @Override |
| | | public void invokeHeadMap(Map headMap, AnalysisContext context) { |
| | | // 验证表头数量 |
| | | logger.info("解析分发单的表头长度: {}", headMap.size()); |
| | | if (headMap.size() != 15) { |
| | | throw new ExcelAnalysisException("上传的文件不符!"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 导入主(文件数据处理) |
| | | * @param data |
| | | * @param analysisContext |
| | | */ |
| | | @Override |
| | | public void invoke(LWhFormTransferTemplate data, AnalysisContext analysisContext) { |
| | | index++; |
| | | String categoryOne = data.getCategoryOne(); |
| | | String categoryTwo = data.getCategoryTwo(); |
| | | String categoryThree = data.getCategoryThree(); |
| | | if (StrUtil.isEmpty(categoryThree)) { |
| | | throw new ExcelAnalysisException("第" + index + "条数据,品类名称不能为空:" + categoryThree); |
| | | } |
| | | String goodsName = data.getGoodsName(); |
| | | if (StrUtil.isEmpty(goodsName)) { |
| | | throw new ExcelAnalysisException("第" + index + "条数据,品名不能为空:" + goodsName); |
| | | } |
| | | String goodModelName = data.getGoodModelName(); |
| | | if (StrUtil.isEmpty(goodModelName)) { |
| | | throw new ExcelAnalysisException("第" + index + "条数据,规格型号不能为空:" + goodModelName); |
| | | } |
| | | String unit = data.getUnit(); |
| | | String type = data.getType(); |
| | | if (StrUtil.isEmpty(type)) { |
| | | throw new ExcelAnalysisException("第" + index + "条数据,管理分类不能为空:" + type); |
| | | } |
| | | String agencyName = data.getAgencyName(); |
| | | if (StrUtil.isEmpty(agencyName)) { |
| | | throw new ExcelAnalysisException("第" + index + "条数据,创建机构不能为空:" + agencyName); |
| | | } |
| | | //String warehouseName = data.getWarehouseName(); |
| | | String supplierName = data.getSupplierName(); |
| | | //String price = data.getPrice(); |
| | | String num = data.getNum(); |
| | | if (StrUtil.isEmpty(num)) { |
| | | throw new ExcelAnalysisException("第" + index + "条数据,领用数量不能为空:" + num); |
| | | } |
| | | // 物品类型(自采集采) |
| | | //String goodsType = data.getGoodsType(); |
| | | // 使用人部门 |
| | | String userDepartment = data.getUserDepartment(); |
| | | if (StrUtil.isEmpty(userDepartment)) { |
| | | throw new ExcelAnalysisException("第" + index + "条数据,使用人部门不能为空:" + userDepartment); |
| | | } |
| | | // 填报人 |
| | | String reportedBy = data.getReportedBy(); |
| | | if (StrUtil.isEmpty(reportedBy)) { |
| | | throw new ExcelAnalysisException("第" + index + "条数据,填报人不能为空:" + reportedBy); |
| | | } |
| | | // 使用人 |
| | | String user = data.getUser(); |
| | | if (StrUtil.isEmpty(user)) { |
| | | throw new ExcelAnalysisException("第" + index + "条数据,使用人不能为空:" + user); |
| | | } |
| | | // 联系电话 |
| | | String userContactPhone = data.getUserContactPhone(); |
| | | if (StrUtil.isEmpty(userContactPhone)) { |
| | | throw new ExcelAnalysisException("第" + index + "条数据,联系电话不能为空:" + userContactPhone); |
| | | } |
| | | // 第一次进来把外层的值设置一下 |
| | | if (StrUtil.isEmpty(lWhFormTransferParam.getDepartmentName())) { |
| | | // 机构id (根据 机构名称和部门名称 查找对应的id) |
| | | FinSysTenantDepartment finSysTenantDepartment = departmentService.queryIdByTenDepName(agencyName, userDepartment); |
| | | if (finSysTenantDepartment == null) { |
| | | throw new ExcelAnalysisException("第" + index + "条数据 " + "机构-部门未找到:[" + agencyName + "-" + userDepartment + "]"); |
| | | } |
| | | lWhFormTransferParam.setTransferBusinessType(1); |
| | | lWhFormTransferParam.setDepartmentId(finSysTenantDepartment.getId()); |
| | | lWhFormTransferParam.setDepartmentName(userDepartment); |
| | | lWhFormTransferParam.setOperatorName(reportedBy); |
| | | lWhFormTransferParam.setTel(0L); |
| | | lWhFormTransferParam.setCreateTime(DateUtil.getNowDate()); |
| | | lWhFormTransferParam.setProcureDoc(""); |
| | | lWhFormTransferParam.setOutAgencyId(finSysTenantDepartment.getTenantId()); |
| | | } |
| | | // 查询分类id |
| | | BaseCategory baseCategory = baseCategoryService.getByCategoryByName(categoryThree); |
| | | if (baseCategory == null) { |
| | | throw new ExcelAnalysisException("第" + index + "条数据" + "此分类未找到:" + categoryThree); |
| | | } |
| | | Long categoryId = baseCategory.getId(); |
| | | // 不同采集类型,不同筛选 |
| | | Optional<LWhFormTransferGoodsInfoParam> optional = null; |
| | | // 筛选类型 |
| | | optional = list.stream().filter(item -> item.getBaseCategoryId().equals(categoryId)).findFirst(); |
| | | // 筛选物品名 |
| | | Optional<LWhFormTransferGoodsInfoParam> optional2 = |
| | | list.stream().filter(item -> item.getGoodsTemplateName().equals(goodsName)).findFirst(); |
| | | // 数据第二层-物品的id |
| | | BaseGoodsTemplate goodsTemplate = baseGoodsTemplateService.getByGoodsNameAndCategoryId(goodsName, categoryId); |
| | | if (goodsTemplate == null) { |
| | | throw new ExcelAnalysisException("第" + index + "条数据" + "此物品未找到:" + goodsName); |
| | | } |
| | | if (optional.isPresent() && optional2.isPresent()) { |
| | | // 内层list(领用人) |
| | | List<LWhTransferModelParam> models3 = optional.get().getModels(); |
| | | // 找型号名字一样的 |
| | | Optional<LWhTransferModelParam> optional3 = |
| | | models3.stream().filter(item -> item.getBaseGoodsModelsName().equals(goodModelName)).findFirst(); |
| | | int counts = 0; |
| | | for (LWhTransferModelParam m : models3) { |
| | | int addNum = 0; |
| | | if (m.getNum() != null) { |
| | | addNum = m.getCounts(); |
| | | } |
| | | counts += addNum; |
| | | } |
| | | // 同一个型号的 |
| | | if (optional3.isPresent()) { |
| | | if ("A".equals(type)) { |
| | | LWhProcureModelUserParam lWhProcureModelUserParam = new LWhProcureModelUserParam(); |
| | | lWhProcureModelUserParam.setGoodsNum(Integer.valueOf(num)); |
| | | lWhProcureModelUserParam.setNowUserName(user); |
| | | lWhProcureModelUserParam.setNowUserPhone(new Long(userContactPhone)); |
| | | Integer counts1 = optional3.get().getCounts(); |
| | | Integer num1 = optional3.get().getNum(); |
| | | optional3.get().setCounts(Integer.valueOf(num) + counts1); |
| | | optional3.get().setNum(Integer.valueOf(num) + num1); |
| | | optional3.get().getProcureModelUserList().add(lWhProcureModelUserParam); |
| | | } else { |
| | | Integer counts1 = optional3.get().getCounts(); |
| | | Integer num1 = optional3.get().getNum(); |
| | | optional3.get().setCounts(Integer.valueOf(num) + counts1); |
| | | optional3.get().setNum(Integer.valueOf(num) + num1); |
| | | } |
| | | } else { |
| | | // 此物品另外的规格型号 |
| | | LWhTransferModelParam lWhTransferModelParam = new LWhTransferModelParam(); |
| | | // 模板的id |
| | | BaseGoodsModels selBaseGoodsModels = new BaseGoodsModels(); |
| | | selBaseGoodsModels.setModelName(goodModelName); |
| | | selBaseGoodsModels.setGoodsTemplatesId(goodsTemplate.getId()); |
| | | BaseGoodsModels selByModelNameAndGoodsTemplatesId = baseGoodsModelsService.getByModelNameAndGoodsTemplatesId(selBaseGoodsModels); |
| | | if (selByModelNameAndGoodsTemplatesId == null) { |
| | | throw new ExcelAnalysisException("第" + index + "条数据" + "品名:" + goodsName + ",规格型号:" + goodModelName + "未找到"); |
| | | } |
| | | lWhTransferModelParam.setBaseGoodsModelsId(selByModelNameAndGoodsTemplatesId.getId()); |
| | | // 内层list的数量之和 |
| | | lWhTransferModelParam.setCounts(Integer.valueOf(num)); |
| | | // 模板名称 |
| | | lWhTransferModelParam.setBaseGoodsModelsName(goodModelName); |
| | | List<LWhProcureModelUserParam> addLWhProcureModelUserParam = new ArrayList<>(); |
| | | LWhProcureModelUserParam lWhProcureModelUserParam = new LWhProcureModelUserParam(); |
| | | lWhProcureModelUserParam.setGoodsNum(Integer.valueOf(num)); |
| | | |
| | | // 查询库存数量 |
| | | Integer nowNum = selectAllNumber(lWhFormTransferParam.getOutAgencyId(), selByModelNameAndGoodsTemplatesId.getId()); |
| | | if(nowNum<new Integer(num)){ |
| | | throw new ExcelAnalysisException("第" + index + "条数据" + "品名:[" + goodsName + "] 规格型号:[" + goodModelName + "] 库存数量不足:["+nowNum+"]"); |
| | | } |
| | | lWhProcureModelUserParam.setNowUserName(user); |
| | | lWhProcureModelUserParam.setNowUserPhone(new Long(userContactPhone)); |
| | | addLWhProcureModelUserParam.add(lWhProcureModelUserParam); |
| | | lWhTransferModelParam.setProcureModelUserList(addLWhProcureModelUserParam); |
| | | optional.get().getModels().add(lWhTransferModelParam); |
| | | } |
| | | } else { |
| | | LWhFormTransferGoodsInfoParam lWhFormTransferGoodsInfoParam = new LWhFormTransferGoodsInfoParam(); |
| | | // 分类id |
| | | lWhFormTransferGoodsInfoParam.setBaseCategoryId(categoryId); |
| | | // 数据第二层-物品的id |
| | | //BaseGoodsTemplate goodsTemplate = baseGoodsTemplateService.getByGoodsNameAndCategoryId(goodsName, categoryId); |
| | | BaseGoodsModels selBaseGoodsModels = new BaseGoodsModels(); |
| | | selBaseGoodsModels.setModelName(goodModelName); |
| | | selBaseGoodsModels.setGoodsTemplatesId(goodsTemplate.getId()); |
| | | BaseGoodsModels selByModelNameAndGoodsTemplatesId = baseGoodsModelsService.getByModelNameAndGoodsTemplatesId(selBaseGoodsModels); |
| | | if (selByModelNameAndGoodsTemplatesId == null) { |
| | | throw new ExcelAnalysisException("第" + index + "条数据 " + "品名:" + goodsName + ",规格型号:" + goodModelName + "未找到"); |
| | | } |
| | | // 物品的id :爱玛电动车 |
| | | lWhFormTransferGoodsInfoParam.setBaseGoodsTemplateId(goodsTemplate.getId()); |
| | | lWhFormTransferGoodsInfoParam.setGoodsTemplateName(goodsName); |
| | | // 内层 |
| | | LWhTransferModelParam lWhTransferModelParam = new LWhTransferModelParam(); |
| | | // 规格id |
| | | lWhTransferModelParam.setBaseGoodsModelsId(selByModelNameAndGoodsTemplatesId.getId()); |
| | | // 新增的时候默认一条 |
| | | lWhTransferModelParam.setCounts(new Integer(num)); |
| | | lWhTransferModelParam.setNum(new Integer(num)); |
| | | List<LWhProcureModelUserParam> lWhFormProcureGoodsInfoParam = new ArrayList<>(); |
| | | LWhProcureModelUserParam lWhProcureModelUserParam = new LWhProcureModelUserParam(); |
| | | lWhProcureModelUserParam.setGoodsNum(Integer.valueOf(num)); |
| | | |
| | | // 查询库存数量 |
| | | Integer nowNum = selectAllNumber(lWhFormTransferParam.getOutAgencyId(), selByModelNameAndGoodsTemplatesId.getId()); |
| | | if(nowNum<new Integer(num)){ |
| | | throw new ExcelAnalysisException("第" + index + "条数据 " + "品名:[" + goodsName + "] 规格型号:[" + goodModelName + "] 库存数量不足:["+nowNum+"]"); |
| | | } |
| | | |
| | | lWhProcureModelUserParam.setNowUserName(user); |
| | | lWhProcureModelUserParam.setNowUserPhone(new Long(userContactPhone)); |
| | | lWhFormProcureGoodsInfoParam.add(lWhProcureModelUserParam); |
| | | lWhTransferModelParam.setProcureModelUserList(lWhFormProcureGoodsInfoParam); |
| | | lWhTransferModelParam.setBaseGoodsModelsName(goodModelName); |
| | | List<LWhTransferModelParam> lWhTransferModelParams = new ArrayList<>(); |
| | | lWhTransferModelParams.add(lWhTransferModelParam); |
| | | lWhFormTransferGoodsInfoParam.setModels(lWhTransferModelParams); |
| | | lWhFormTransferGoodsInfoParam.setType(type); |
| | | list.add(lWhFormTransferGoodsInfoParam); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 分发单导入主方法 |
| | | * @param analysisContext |
| | | */ |
| | | @Override |
| | | public void doAfterAllAnalysed(AnalysisContext analysisContext) { |
| | | lWhFormTransferParam.setTransferGoods(list); |
| | | long id = IdUtil.generateId(); |
| | | //lWhFormTransferParam.setProcureDoc("[{\"fileType\":\"png\",\"id\":\"883654049218335\",\"name\":\"微信截图_20240426143552.png\",\"url\":\"http://172.16.60.172:8083/lowConsum/file/2024/5/883654049218335.png\",\"path\":\"2024/5/883654049218335.png\",\"attSize\":6772}]"); |
| | | lWhFormTransferParam.setProcureDoc("-"); |
| | | lWhFormTransferParam.setId(id); |
| | | String jsonString = JSONObject.toJSONString(lWhFormTransferParam); |
| | | logger.info("导入分发单json数据 --------------------"); |
| | | logger.info(jsonString); |
| | | // 分发单据 |
| | | try { |
| | | ResponseValue responseValue = add2(lWhFormTransferParam); |
| | | logger.info(responseValue.toString()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onException(Exception exception, AnalysisContext analysisContext) throws Exception { |
| | | if (exception instanceof ExcelDataConvertException) { |
| | | ExcelDataConvertException excelDataConvertException = (ExcelDataConvertException) exception; |
| | | Integer row = excelDataConvertException.getRowIndex() + 1; |
| | | Integer column = excelDataConvertException.getColumnIndex() + 1; |
| | | throw new ExcelAnalysisException("第" + row + "行,第" + column + "列解析异常,请正确填写"); |
| | | } else { |
| | | throw new ExcelAnalysisException(exception.getMessage()); |
| | | } |
| | | } |
| | | }).sheet(0).doRead(); |
| | | } catch (ExcelAnalysisException e) { |
| | | return ResponseValue.error(e.getMessage()); |
| | | } catch (RuntimeException e) { |
| | | e.printStackTrace(); |
| | | return ResponseValue.error("系统错误"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return ResponseValue.error("系统错误"); |
| | | } |
| | | return ResponseValue.success("导入成功!"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询库存Id |
| | | * @param agencyId |
| | | * @param baseGoodsModelsId |
| | | * @return |
| | | */ |
| | | public Integer selectAllNumber(Long agencyId,Long baseGoodsModelsId) { |
| | | WarehouseQry warehouseQry = new WarehouseQry(); |
| | | warehouseQry.setAgencyId(agencyId); |
| | | warehouseQry.setBaseGoodsModelsId(baseGoodsModelsId); |
| | | List<BaseWarehouse> baseWarehouseList = |
| | | baseWarehouseService.getBaseWareHouseList(agencyId, StatesType.NORMAL.getValue()); |
| | | List<Long> warehouseIdList = baseWarehouseList.stream().map(BaseWarehouse::getId).collect(Collectors.toList()); |
| | | Integer warehouseType = warehouseQry.getWarehouseType(); |
| | | Integer states = warehouseQry.getStates(); |
| | | Integer buyType = warehouseQry.getBuyType(); |
| | | // 调拨时只查机构类型的集采仓库库存 |
| | | // 部门分发时不分机构和部门,因为调拨进来的物品也算在库存里只是类型为部门,同样检视所有仓库该型号的数量 |
| | | int num = lWhGoodsService.queryGoodsModelInWareHouseNum(warehouseType, warehouseIdList, baseGoodsModelsId, |
| | | states, buyType); |
| | | return num; |
| | | } |
| | | |
| | | } |