| | |
| | | import com.consum.base.pojo.LWhFormTransferGoodsInfoParam; |
| | | import com.consum.base.pojo.LWhProcureModelUserParam; |
| | | import com.consum.base.pojo.LWhTransferModelParam; |
| | | import com.consum.base.pojo.excel.TemplateExcelTransfer; |
| | | import com.consum.base.pojo.query.TransferQry; |
| | | import com.consum.base.pojo.request.LWhFormTransferParam; |
| | | import com.consum.base.pojo.response.DepartGoodsUseInfo; |
| | | import com.consum.base.pojo.response.FormTransferGoodsVO; |
| | | import com.consum.base.pojo.response.GoodsModelVO; |
| | | import com.consum.base.pojo.response.LWHFromTransferExtendVO; |
| | | import com.consum.model.po.BaseGoodsModels; |
| | | import com.consum.model.po.BaseWarehouse; |
| | | import com.consum.model.po.BaseWarehouseManager; |
| | | import com.consum.model.po.FinSysTenant; |
| | | import com.consum.model.po.FinSysTenantUser; |
| | | import com.consum.model.po.LWhFormOutput; |
| | | import com.consum.model.po.LWhFormTransfer; |
| | | import com.consum.model.po.LWhGoodsRecord; |
| | | import com.consum.model.po.LWhProcureModel; |
| | | import com.consum.model.po.LWhProcureModelUser; |
| | | import com.consum.model.po.LWhProcureModelUserRecord; |
| | | import com.consum.model.vo.LWhFormOutputVo; |
| | | import com.consum.model.vo.LWhGoodsRecordVo; |
| | | import com.iplatform.model.po.S_user_core; |
| | | import com.walker.db.page.GenericPager; |
| | | import com.walker.infrastructure.utils.DateUtils; |
| | | import com.walker.infrastructure.utils.StringUtils; |
| | |
| | | private LWhProcureModelUserRecordServiceImpl lWhProcureModelUserRecordService; |
| | | @Autowired |
| | | private BaseWarehouseManagerServiceImpl baseWarehouseManagerService; |
| | | @Autowired |
| | | private BaseGoodsTemplateServiceImpl baseGoodsTemplateService; |
| | | |
| | | private static String QUERY_FORM_TRANSFER_LIST = "SELECT ft.* FROM l_wh_form_transfer ft " |
| | | + "left join L_WH_PROCURE_MODEL pm on pm.BUSINESS_ID = ft.id " |
| | |
| | | * @Author 卢庆阳 |
| | | * @Date 2023/10/30 |
| | | */ |
| | | public int add(LWhFormTransferParam param, FinSysTenantUser sysInfo) throws Exception { |
| | | public long add(LWhFormTransferParam param, FinSysTenantUser sysInfo) throws Exception { |
| | | //1.新增调拨单记录 |
| | | LWhFormTransfer lWhFormTransfer = new LWhFormTransfer(); |
| | | //调拨单id |
| | |
| | | // 单据类型。0仓库调拨;1部门分发;2部门物品回退 |
| | | // TODO 枚举字典 |
| | | lWhFormTransfer.setBusinessType(businessType); |
| | | CodeGeneratorEnum codeGeneratorEnum = null; |
| | | if (businessType == 0) { |
| | | codeGeneratorEnum = CodeGeneratorEnum.Transfer; |
| | | } else if (businessType == 1) { |
| | | codeGeneratorEnum = CodeGeneratorEnum.Distribute; |
| | | } else if (businessType == 2) { |
| | | codeGeneratorEnum = CodeGeneratorEnum.GOBACK; |
| | | } |
| | | |
| | | lWhFormTransfer.setBusinessFormCode(codeGeneratorService.createBusinessFormCode(CodeGeneratorEnum.Transfer)); |
| | | lWhFormTransfer.setBusinessFormCode(codeGeneratorService.createBusinessFormCode(codeGeneratorEnum)); |
| | | |
| | | Long warehouseId = param.getInWarehouseId(); |
| | | // 调拨类型单据 |
| | |
| | | FinSysTenant finSysTenant = finSysTenantService.get(new FinSysTenant(param.getOutAgencyId())); |
| | | if (finSysTenant == null) { |
| | | log.error("调拨机构不存在"); |
| | | return 0; |
| | | } |
| | | lWhFormTransfer.setOutAgencyId(finSysTenant.getId()); |
| | | lWhFormTransfer.setOutAgencyName(finSysTenant.getName()); |
| | |
| | | int flag1 = this.insert(lWhFormTransfer); |
| | | if (flag1 == 0) { |
| | | log.error("新增调拨单失败"); |
| | | return 0; |
| | | } |
| | | |
| | | //2.新增物品型号记录 |
| | |
| | | for (LWhTransferModelParam model : transferGoodsInfo.getModels()) { |
| | | LWhProcureModel lWhProcureModel = new LWhProcureModel(); |
| | | lWhProcureModel.setId(IdUtil.generateId()); |
| | | // 挑拨业务类型转换到物品类型 |
| | | // 调拨业务类型转换到物品类型 |
| | | // 物品类型 1 采购2 调拨 3出库4部门分发 |
| | | Long baseGoodsModelsId = model.getBaseGoodsModelsId(); |
| | | if (businessType == 0) { |
| | |
| | | lWhProcureModel.setBusinessId(lWhFormTransferId); |
| | | lWhProcureModel.setBaseGoodsModelsId(baseGoodsModelsId); |
| | | //根据型号id查询型号 |
| | | BaseGoodsModels baseGoodsModels = this.baseGoodsModelsService.get(new BaseGoodsModels(baseGoodsModelsId)); |
| | | if (baseGoodsModels != null) { |
| | | lWhProcureModel.setBaseGoodsModelsName(baseGoodsModels.getModelName()); |
| | | List<Map<String, Object>> baseGoodsModels = this.baseGoodsModelsService.queryGoodsModelInfo(baseGoodsModelsId); |
| | | Map<String, Object> baseModelMap = baseGoodsModels.get(0); |
| | | if (baseGoodsModels != null && !CollectionUtils.isEmpty(baseModelMap)) { |
| | | Object modelName = baseModelMap.get("modelName"); |
| | | lWhProcureModel.setBaseGoodsModelsName(modelName.toString()); |
| | | } |
| | | lWhProcureModel.setSupplier(transferGoodsInfo.getSupplier()); |
| | | |
| | | //3.当业务类型为部门分发时 添加部门分发记录和使用人 |
| | | // 单据类型 1 采购2 调拨 3出库4部门分发 |
| | | //部门分发类型 |
| | | if (businessType == 1) { |
| | | if (businessType == 1 && "A".equals(baseModelMap.get("type"))) { |
| | | lWhProcureModel.setBusinessType(4); |
| | | LWhProcureModelUserRecord lWhProcureModelUserRecord = new LWhProcureModelUserRecord(); |
| | | lWhProcureModelUserRecord.setId(IdUtil.generateId()); |
| | |
| | | if (procureInsertNum != procureModelUserList.size()) { |
| | | log.error("新增物品使用信息失败"); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | return 0; |
| | | } |
| | | |
| | | } |
| | |
| | | if (flag2 != modelList.size()) { |
| | | log.error("新增物品型号失败"); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | return 0; |
| | | } |
| | | |
| | | return 1; |
| | | return lWhFormTransferId; |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | //状态 |
| | | if (param.getStates() != null) { |
| | | sql.append(" and states =:states "); |
| | | sql.append(" and ft.states =:states "); |
| | | paramts.put("states", param.getStates()); |
| | | } |
| | | //创建人 |
| | |
| | | if (param.getEndTime() != null) { |
| | | sql.append(" and IN_TIME <:inTimeEnd "); |
| | | paramts.put("inTimeEnd", param.getEndTime() * 1000000 + 240000); |
| | | } |
| | | //分发部门 |
| | | if (param.getInWarehouseId() != null) { |
| | | sql.append("and ft.IN_WAREHOUSE_ID = :inWarehouseId "); |
| | | paramts.put("inWarehouseId", param.getInWarehouseId()); |
| | | } |
| | | |
| | | sql.append(" ORDER BY ft.CREATE_TIME DESC"); |
| | |
| | | * @Author 卢庆阳 |
| | | * @Date 2023/10/31 |
| | | */ |
| | | public LWhFormOutputVo export(Long id, S_user_core currentUser) { |
| | | LWhFormOutputVo result = new LWhFormOutputVo(); |
| | | long dealTime = DateUtils.getDateTimeNumber(System.currentTimeMillis()); |
| | | //1.根据调拨单生成出库单 |
| | | Long outWarehouseFormId = this.lWhFormOutputCoreService.createOutFormByTransId(id, currentUser, dealTime); |
| | | //2.出库单id查询出库单 |
| | | LWhFormOutput lWhFormOutput = this.lWhFormOutputService.get(new LWhFormOutput(outWarehouseFormId)); |
| | | if (lWhFormOutput != null) { |
| | | BeanUtils.copyProperties(lWhFormOutput, result); |
| | | } |
| | | //3.根据进出库流水总表id查询l_wh_goods_record |
| | | LWhGoodsRecord record = new LWhGoodsRecord(); |
| | | record.setWarehouseFlowId(lWhFormOutput.getWarehouseFlowId()); |
| | | List<LWhGoodsRecord> recordList = this.lWhGoodsRecordService.select(record); |
| | | List<LWhGoodsRecordVo> voList = new ArrayList<>(); |
| | | if (!CollectionUtils.isEmpty(recordList)) { |
| | | for (LWhGoodsRecord lWhGoodsRecord : recordList) { |
| | | LWhGoodsRecordVo vo = new LWhGoodsRecordVo(); |
| | | BeanUtils.copyProperties(lWhGoodsRecord, vo); |
| | | //根据型号id查询型号 |
| | | BaseGoodsModels baseGoodsModels = baseGoodsModelsService.get(new BaseGoodsModels(id)); |
| | | if (baseGoodsModels != null) { |
| | | vo.setUnit(baseGoodsModels.getUnit()); |
| | | } |
| | | voList.add(vo); |
| | | } |
| | | } |
| | | result.setRecordVoList(voList); |
| | | public Map<String, Object> export(Long id) { |
| | | String sql = "SELECT\n" |
| | | + "\tft.BUSINESS_FORM_CODE,\n" |
| | | + "\tft.OPERATOR_NAME,\n" |
| | | + "\tft.CREATE_TIME,\n" |
| | | + "\tft.OUT_AGENCY_NAME,\n" |
| | | + "\tGOODS_NAME,\n" |
| | | + "\tpm.BASE_GOODS_MODELS_NAME,\n" |
| | | + "\tpm.COUNTS num,\n" |
| | | + "\tpm.PRICE,\n" |
| | | + "\tpm.total_amount,\n" |
| | | + "\tft.BEIZ1 remark\n" |
| | | + "FROM\n" |
| | | + "\tl_wh_form_transfer ft\n" |
| | | + "\tINNER JOIN l_wh_procure_model pm ON ft.ID = pm.BUSINESS_ID\n" |
| | | + "\tINNER JOIN base_goods_models bgm ON bgm.ID = pm.BASE_GOODS_MODELS_ID\n" |
| | | + "\tINNER JOIN base_goods_template bgt ON bgt.ID = bgm.GOODS_TEMPLATES_ID\n" |
| | | + "WHERE\n" |
| | | + "\tft.id = :id"; |
| | | Map<String, Object> paramts = new HashMap<>(); |
| | | paramts.put("id", id); |
| | | List<Map<String, Object>> select = this.select(sql, paramts, new MapperUtil()); |
| | | List<TemplateExcelTransfer> list = Lists.newArrayList(); |
| | | select.forEach(item -> { |
| | | TemplateExcelTransfer templateExcelTransfer = MapUtils.convertMapToObj(item, TemplateExcelTransfer.class); |
| | | list.add(templateExcelTransfer); |
| | | }); |
| | | |
| | | return result; |
| | | int countNum = list.stream().filter(item -> item.getNum() != null).mapToInt(TemplateExcelTransfer::getNum).sum(); |
| | | int totalAmount = list.stream().filter(export -> export.getTotalAmount() != null).mapToInt(TemplateExcelTransfer::getTotalAmount).sum(); |
| | | Optional<TemplateExcelTransfer> first = list.stream().findFirst(); |
| | | TemplateExcelTransfer entity = first.get(); |
| | | String businessFormCode = entity.getBusinessFormCode(); |
| | | Long createTime = entity.getCreateTime(); |
| | | String operatorName = entity.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); |
| | | map.put("data", list); |
| | | |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | |
| | | sql.append("AND OUT_AGENCY_ID = :OUT_AGENCY_ID "); |
| | | paramts.put("OUT_AGENCY_ID", transferQry.getOutAgencyId()); |
| | | } |
| | | |
| | | //分发部门 |
| | | if (transferQry.getInWarehouseId() != null) { |
| | | sql.append("and ft.IN_WAREHOUSE_ID = :inWarehouseId "); |
| | | paramts.put("inWarehouseId", transferQry.getInWarehouseId()); |
| | | } |
| | | //创建人 |
| | | if (StringUtils.isNotEmpty(transferQry.getOperatorName())) { |
| | | sql.append("AND ft.OPERATOR_NAME =:OPERATOR_NAME "); |