| | |
| | | import com.consum.base.core.CodeGeneratorEnum; |
| | | import com.consum.base.core.CodeGeneratorService; |
| | | 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.dto.UsingFormBackDetailDTO; |
| | | import com.consum.base.pojo.query.UsingFormBackQry; |
| | | import com.consum.base.pojo.request.UsingFormBackGoodsInfo; |
| | | import com.consum.base.pojo.request.UsingFormBackParam; |
| | | import com.consum.base.pojo.request.baseGoodModel; |
| | | import com.consum.base.pojo.response.BaseGoodsTemplateInfo; |
| | | import com.consum.base.pojo.response.UseInfo; |
| | | import com.consum.base.pojo.response.UsingFormBackDetailListVO; |
| | | import com.consum.base.pojo.response.UsingFormBackDetailVO; |
| | | import com.consum.base.pojo.response.UsingFormBackGoodsTemplateInfo; |
| | | import com.consum.base.pojo.response.UsingFormBackModelInfo; |
| | | import com.consum.base.pojo.response.UsingFormBackVO; |
| | | import com.consum.base.service.BaseCategoryServiceImpl; |
| | | import com.consum.base.service.UsingFormBackGoodsService; |
| | | import com.consum.base.service.UsingFormBackModelService; |
| | | import com.consum.base.service.UsingFormBackService; |
| | | import com.consum.model.po.BaseCategory; |
| | | import com.consum.model.po.FinSysTenantUser; |
| | | import com.consum.model.po.UsingFormBack; |
| | | import com.consum.model.po.UsingFormBackGoods; |
| | | import com.consum.model.po.UsingFormBackModel; |
| | | import com.walker.db.page.GenericPager; |
| | | import com.walker.infrastructure.utils.CollectionUtils; |
| | | import com.walker.infrastructure.utils.DateUtils; |
| | | import com.walker.infrastructure.utils.StringUtils; |
| | | import com.walker.jdbc.service.BaseServiceImpl; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | import org.apache.commons.compress.utils.Lists; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | private CodeGeneratorService codeGeneratorService; |
| | | @Autowired |
| | | private BaseCategoryServiceImpl baseCategoryService; |
| | | @Autowired |
| | | private UsingFormBackModelService usingFormBackModelService; |
| | | @Autowired |
| | | private UsingFormBackGoodsService usingFormBackGoodsService; |
| | | |
| | | |
| | | @Override |
| | | public void add(UsingFormBackParam usingFormBackParam, FinSysTenantUser sysInfo) { |
| | |
| | | Long transBusinessId = backingGoodsInfo.getTransBusinessId(); |
| | | String businessFormCode = backingGoodsInfo.getBusinessFormCode(); |
| | | |
| | | Map<String, List<baseGoodModel>> collect = backingGoodsInfo.getModels().stream() |
| | | .collect(Collectors.groupingBy(baseGoodModel::getBaseGoodsModelsId)); |
| | | |
| | | UsingFormBackGoods usingFormBackGoods = new UsingFormBackGoods(); |
| | | usingFormBackGoods.setId(IdUtil.generateId()); |
| | | usingFormBackGoods.setUsingFormBackId(usingFormBackId); |
| | |
| | | usingFormBackGoods.setClassification(classification); |
| | | usingFormBackGoods.setTransBusinessId(transBusinessId); |
| | | usingFormBackGoods.setBusinessFormCode(businessFormCode); |
| | | |
| | | // usingFormBackGoods.setTransOutWarehouseType(); |
| | | // usingFormBackGoods.setTransOutWarehouseId(); |
| | | |
| | | usingFormBackModelService.insert(usingFormBackGoods); |
| | | for (baseGoodModel model : backingGoodsInfo.getModels()) { |
| | | |
| | | UsingFormBackModel usingFormBackModel = new UsingFormBackModel(); |
| | | usingFormBackModel.setId(IdUtil.generateId()); |
| | | usingFormBackModel.setUsingFormBackId(usingFormBackId); |
| | | usingFormBackModel.setUsingFormBackGoodsId(usingFormBackGoods.getId()); |
| | | usingFormBackModel.setBaseGoodsTemplateId(model.getGoodsTemplatesId()); |
| | | usingFormBackModel.setBaseGoodsTemplateName(goodsTemplateName); |
| | | usingFormBackModel.setClassification(model.getClassification()); |
| | | usingFormBackModel.setUnit(model.getUnit()); |
| | | usingFormBackModel.setBaseGoodsModelsId(model.getBaseGoodsModelsId()); |
| | | usingFormBackModel.setBaseGoodsModelsName(model.getModelName()); |
| | | usingFormBackModel.setProcureModelUserId(model.getModelUserId()); |
| | | usingFormBackModel.setInitialCount(model.getGoodsNum()); |
| | | usingFormBackModel.setUseCount(model.getUserUseCount()); |
| | | usingFormBackModel.setCounts(model.getCounts()); |
| | | usingFormBackModel.setGoodsUserName(model.getNowUserName()); |
| | | |
| | | usingFormBackGoodsService.insert(usingFormBackModel); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public PageUtil selectPageByList(UsingFormBackQry usingFormBackParam) { |
| | | |
| | | StringBuilder sql = new StringBuilder("SELECT\n" |
| | | + "\tDISTINCT ufb.ID,\n" |
| | | + "\tufb.BUSINESS_FORM_CODE,\n" |
| | | + "\tufb.DEPARTMENT_NAME,\n" |
| | | + "\tufb.OPERATOR_NAME,\n" |
| | | + "\tufb.DEAL_TIME\n" |
| | | + "FROM\n" |
| | | + "\tusing_form_back ufb\n" |
| | | + "\tLEFT JOIN using_form_back_goods ufbg ON ufb.ID = ufbg.USING_FORM_BACK_ID\n" |
| | | + "\tLEFT JOIN using_form_back_model ufbm ON ufbg.ID = ufbm.USING_FORM_BACK_GOODS_ID\n" |
| | | + "where 1=1 "); |
| | | |
| | | String businessFormCode = usingFormBackParam.getBusinessFormCode(); |
| | | Long departmentId = usingFormBackParam.getDepartmentId(); |
| | | String goodsTemplateName = usingFormBackParam.getGoodsTemplateName(); |
| | | String goodsTemplateId = usingFormBackParam.getGoodsTemplateId(); |
| | | Long startTime = usingFormBackParam.getStartTime(); |
| | | Long endTime = usingFormBackParam.getEndTime(); |
| | | Long baseGoodsModelsId = usingFormBackParam.getBaseGoodsModelsId(); |
| | | Long agencyId = usingFormBackParam.getAgencyId(); |
| | | String createName = usingFormBackParam.getCreateName(); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | if (StringUtils.isNotEmpty(businessFormCode)) { |
| | | sql.append("AND ufb.BUSINESS_FORM_CODE = :businessFormCode "); |
| | | map.put("businessFormCode", businessFormCode); |
| | | } |
| | | if (departmentId != null) { |
| | | sql.append("AND ufb.DEPARTMENT_ID = :departmentId "); |
| | | map.put("departmentId", departmentId); |
| | | } |
| | | if (StringUtils.isNotEmpty(goodsTemplateName)) { |
| | | sql.append("AND ufbg.BASE_GOODS_TEMPLATE_NAME = :goodsTemplateName "); |
| | | map.put("goodsTemplateName", goodsTemplateName); |
| | | } |
| | | if (StringUtils.isNotEmpty(goodsTemplateId)) { |
| | | sql.append("AND ufbg.BASE_GOODS_TEMPLATE_ID = :goodsTemplateId "); |
| | | map.put("goodsTemplateId", goodsTemplateId); |
| | | } |
| | | if (startTime != null) { |
| | | sql.append("AND ufb.CREATE_TIME >= :startTime "); |
| | | map.put("startTime", startTime * 1000000); |
| | | } |
| | | if (endTime != null) { |
| | | sql.append("AND ufb.CREATE_TIME < :endTime "); |
| | | map.put("endTime", endTime * 1000000 + 240000); |
| | | } |
| | | if (baseGoodsModelsId != null) { |
| | | sql.append("AND ufbm.BASE_GOODS_MODELS_ID = :baseGoodsModelsId "); |
| | | map.put("baseGoodsModelsId", baseGoodsModelsId); |
| | | } |
| | | if (agencyId != null) { |
| | | sql.append("AND ufb.AGENCY_ID like :agencyId"); |
| | | map.put("agencyId", agencyId); |
| | | } |
| | | if (StringUtils.isNotEmpty(createName)) { |
| | | sql.append("AND ufb.CREATE_NAME = :createName "); |
| | | map.put("createName", createName); |
| | | } |
| | | sql.append("ORDER BY ufb.CREATE_TIME DESC "); |
| | | GenericPager<Map<String, Object>> mapGenericPager = this.selectSplit(sql.toString(), map, usingFormBackParam.getPageNum(), |
| | | usingFormBackParam.getPageSize(), new MapperUtil()); |
| | | PageUtil pageUtil = new PageUtil(mapGenericPager); |
| | | List<UsingFormBackVO> pageList = Lists.newArrayList(); |
| | | mapGenericPager.getDatas().forEach(item -> { |
| | | UsingFormBackVO usingFormBackVO = MapUtils.convertMapToObj(item, UsingFormBackVO.class); |
| | | |
| | | Long id = usingFormBackVO.getId(); |
| | | StringBuilder countSql = new StringBuilder("SELECT \n" |
| | | + "\tufbg.BASE_GOODS_TEMPLATE_NAME,\n" |
| | | + "\tsum(ufbm.COUNTS) count\n" |
| | | + "FROM\n" |
| | | + "\tusing_form_back_goods ufbg\n" |
| | | + "\tLEFT JOIN using_form_back_model ufbm ON ufbg.ID = ufbm.USING_FORM_BACK_GOODS_ID\n" |
| | | + "where ufbg.USING_FORM_BACK_ID = :id group by ufbg.BASE_GOODS_TEMPLATE_ID "); |
| | | Map<String, Object> countSqlMap = new HashMap<>(); |
| | | countSqlMap.put("id", id); |
| | | List<Map<String, Object>> select = this.select(countSql.toString(), countSqlMap, new MapperUtil()); |
| | | List<BaseGoodsTemplateInfo> baseGoodsTemplateInfoList = Lists.newArrayList(); |
| | | select.forEach(entity -> { |
| | | BaseGoodsTemplateInfo baseGoodsTemplateInfo = MapUtils.convertMapToObj(entity, BaseGoodsTemplateInfo.class); |
| | | baseGoodsTemplateInfoList.add(baseGoodsTemplateInfo); |
| | | }); |
| | | usingFormBackVO.setGoodsTemplateInfoList(baseGoodsTemplateInfoList); |
| | | pageList.add(usingFormBackVO); |
| | | }); |
| | | pageUtil.setDatas(pageList); |
| | | return pageUtil; |
| | | } |
| | | |
| | | @Override |
| | | public UsingFormBackDetailVO getDetail(Long id) { |
| | | StringBuilder sql = new StringBuilder("SELECT\n" |
| | | + "\tDISTINCT ufb.ID,\n" |
| | | + "\tufb.BUSINESS_FORM_CODE,\n" |
| | | + "\tufb.AGENCY_NAME,\n" |
| | | + "\tufb.DEPARTMENT_NAME,\n" |
| | | + "\tufb.OPERATOR_NAME,\n" |
| | | + "\tufb.DEAL_TIME,\n" |
| | | + "\tufb.PROCURE_DOC,\n" |
| | | + "\tufbg.CATEGORY_NAME,\n" |
| | | + "\tufbg.BASE_GOODS_TEMPLATE_NAME,\n" |
| | | + "\tufbg.CLASSIFICATION,\n" |
| | | + "\tufbg.BUSINESS_FORM_CODE,\n" |
| | | + "\tufbm.BASE_GOODS_MODELS_NAME,\n" |
| | | + "\tufbm.BASE_GOODS_TEMPLATE_ID,\n" |
| | | + "\tufbm.BASE_GOODS_MODELS_ID,\n" |
| | | + "\tufbm.UNIT,\n" |
| | | + "\tufbm.COUNTS,\n" |
| | | + "\tufbm.USE_COUNT,\n" |
| | | + "\tufbm.GOODS_USER_NAME\n" |
| | | + "FROM\n" |
| | | + "\tusing_form_back ufb\n" |
| | | + "\tLEFT JOIN using_form_back_goods ufbg ON ufb.ID = ufbg.USING_FORM_BACK_ID\n" |
| | | + "\tLEFT JOIN using_form_back_model ufbm ON ufbg.ID = ufbm.USING_FORM_BACK_GOODS_ID where ufb.id =:id"); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("id", id); |
| | | List<Map<String, Object>> select = this.select(sql.toString(), map, new MapperUtil()); |
| | | if (CollectionUtils.isEmpty(select)) { |
| | | return null; |
| | | } |
| | | List<UsingFormBackDetailDTO> usingFormBackDetailDTOList = Lists.newArrayList(); |
| | | select.forEach(item -> { |
| | | UsingFormBackDetailDTO usingFormBackDetailDTO = MapUtils.convertMapToObj(item, UsingFormBackDetailDTO.class); |
| | | usingFormBackDetailDTOList.add(usingFormBackDetailDTO); |
| | | }); |
| | | |
| | | UsingFormBackDetailVO usingFormBackDetailVO = new UsingFormBackDetailVO(); |
| | | List<UsingFormBackGoodsTemplateInfo> goodsTemplateInfoList = Lists.newArrayList(); |
| | | usingFormBackDetailDTOList.stream().collect(Collectors.groupingBy(UsingFormBackDetailDTO::getBaseGoodsTemplateId)) |
| | | .forEach((templateId, templateInfo) -> { |
| | | UsingFormBackDetailDTO templateInfoDTO = templateInfo.get(0); |
| | | BeanUtils.copyProperties(templateInfoDTO, usingFormBackDetailVO); |
| | | UsingFormBackGoodsTemplateInfo usingFormBackGoodsTemplateInfo = new UsingFormBackGoodsTemplateInfo(); |
| | | usingFormBackGoodsTemplateInfo.setId(templateId); |
| | | usingFormBackGoodsTemplateInfo.setCategoryName(templateInfoDTO.getCategoryName()); |
| | | usingFormBackGoodsTemplateInfo.setBaseGoodsTemplateName(templateInfoDTO.getBaseGoodsTemplateName()); |
| | | usingFormBackGoodsTemplateInfo.setType(templateInfoDTO.getClassification()); |
| | | usingFormBackGoodsTemplateInfo.setBusinessFormCode(templateInfoDTO.getBusinessFormCode()); |
| | | goodsTemplateInfoList.add(usingFormBackGoodsTemplateInfo); |
| | | usingFormBackDetailVO.setGoodsTemplateInfoList(goodsTemplateInfoList); |
| | | List<UsingFormBackModelInfo> modelInfoList = Lists.newArrayList(); |
| | | templateInfo.stream().collect(Collectors.groupingBy(UsingFormBackDetailDTO::getBaseGoodsModelsId)).forEach((modelId, modelInfo) -> { |
| | | UsingFormBackDetailDTO modelInfoDTO = modelInfo.get(0); |
| | | UsingFormBackModelInfo usingFormBackModelInfo = new UsingFormBackModelInfo(); |
| | | usingFormBackModelInfo.setBaseGoodsModelsName(modelInfoDTO.getBaseGoodsModelsName()); |
| | | usingFormBackModelInfo.setUnit(modelInfoDTO.getUnit()); |
| | | usingFormBackModelInfo.setId(modelId); |
| | | modelInfoList.add(usingFormBackModelInfo); |
| | | usingFormBackGoodsTemplateInfo.setModelInfoList(modelInfoList); |
| | | List<UseInfo> useInfoList = Lists.newArrayList(); |
| | | for (UsingFormBackDetailDTO useInfoDTO : modelInfo) { |
| | | UseInfo useInfo = new UseInfo(); |
| | | useInfo.setUseName(useInfoDTO.getGoodsUserName()); |
| | | useInfo.setReturnNum(useInfoDTO.getCounts()); |
| | | useInfo.setUseUnm(useInfoDTO.getUseCount()); |
| | | useInfoList.add(useInfo); |
| | | usingFormBackModelInfo.setUseInfoList(useInfoList); |
| | | } |
| | | }); |
| | | }); |
| | | |
| | | return usingFormBackDetailVO; |
| | | } |
| | | |
| | | @Override |
| | | public PageUtil selectPageByDetail(UsingFormBackQry usingFormBackParam) { |
| | | StringBuilder sql = new StringBuilder("SELECT\n" |
| | | + "\tufb.ID,\n" |
| | | + "\tufb.BUSINESS_FORM_CODE,\n" |
| | | + "\tufbm.BASE_GOODS_TEMPLATE_NAME,\n" |
| | | + "\tufbm.BASE_GOODS_MODELS_NAME,\n" |
| | | + "\tufbm.counts,\n" |
| | | + "\tufb.AGENCY_NAME,\n" |
| | | + "\tufb.DEPARTMENT_NAME,\n" |
| | | + "\tufb.OPERATOR_NAME,\n" |
| | | + "\tufb.DEAL_TIME\n" |
| | | + "FROM\n" |
| | | + "\tusing_form_back ufb\n" |
| | | + "\tLEFT JOIN using_form_back_goods ufbg ON ufb.ID = ufbg.USING_FORM_BACK_ID\n" |
| | | + "\tLEFT JOIN using_form_back_model ufbm ON ufbg.ID = ufbm.USING_FORM_BACK_GOODS_ID\n" |
| | | + "where 1=1 "); |
| | | |
| | | String businessFormCode = usingFormBackParam.getBusinessFormCode(); |
| | | Long departmentId = usingFormBackParam.getDepartmentId(); |
| | | String goodsTemplateName = usingFormBackParam.getGoodsTemplateName(); |
| | | String goodsTemplateId = usingFormBackParam.getGoodsTemplateId(); |
| | | Long startTime = usingFormBackParam.getStartTime(); |
| | | Long endTime = usingFormBackParam.getEndTime(); |
| | | Long baseGoodsModelsId = usingFormBackParam.getBaseGoodsModelsId(); |
| | | Long agencyId = usingFormBackParam.getAgencyId(); |
| | | String createName = usingFormBackParam.getCreateName(); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | if (StringUtils.isNotEmpty(businessFormCode)) { |
| | | sql.append("AND ufb.BUSINESS_FORM_CODE = :businessFormCode "); |
| | | map.put("businessFormCode", businessFormCode); |
| | | } |
| | | if (departmentId != null) { |
| | | sql.append("AND ufb.DEPARTMENT_ID = :departmentId "); |
| | | map.put("departmentId", departmentId); |
| | | } |
| | | if (StringUtils.isNotEmpty(goodsTemplateName)) { |
| | | sql.append("AND ufbg.BASE_GOODS_TEMPLATE_NAME = :goodsTemplateName "); |
| | | map.put("goodsTemplateName", goodsTemplateName); |
| | | } |
| | | if (StringUtils.isNotEmpty(goodsTemplateId)) { |
| | | sql.append("AND ufbg.BASE_GOODS_TEMPLATE_ID = :goodsTemplateId "); |
| | | map.put("goodsTemplateId", goodsTemplateId); |
| | | } |
| | | if (startTime != null) { |
| | | sql.append("AND ufb.CREATE_TIME >= :startTime "); |
| | | map.put("startTime", startTime * 1000000); |
| | | } |
| | | if (endTime != null) { |
| | | sql.append("AND ufb.CREATE_TIME < :endTime "); |
| | | map.put("endTime", endTime * 1000000 + 240000); |
| | | } |
| | | if (baseGoodsModelsId != null) { |
| | | sql.append("AND ufbm.BASE_GOODS_MODELS_ID = :baseGoodsModelsId "); |
| | | map.put("baseGoodsModelsId", baseGoodsModelsId); |
| | | } |
| | | if (agencyId != null) { |
| | | sql.append("AND ufb.AGENCY_ID like :agencyId "); |
| | | map.put("agencyId", agencyId); |
| | | } |
| | | if (StringUtils.isNotEmpty(createName)) { |
| | | sql.append("AND ufb.CREATE_NAME = :createName "); |
| | | map.put("createName", createName); |
| | | } |
| | | sql.append("ORDER BY ufb.CREATE_TIME DESC "); |
| | | GenericPager<Map<String, Object>> mapGenericPager = this.selectSplit(sql.toString(), map, usingFormBackParam.getPageNum(), |
| | | usingFormBackParam.getPageSize(), new MapperUtil()); |
| | | PageUtil pageUtil = new PageUtil(mapGenericPager); |
| | | List<UsingFormBackDetailListVO> pageList = Lists.newArrayList(); |
| | | mapGenericPager.getDatas().forEach(item -> { |
| | | UsingFormBackDetailListVO usingFormBackVO = MapUtils.convertMapToObj(item, UsingFormBackDetailListVO.class); |
| | | pageList.add(usingFormBackVO); |
| | | }); |
| | | pageUtil.setDatas(pageList); |
| | | return pageUtil; |
| | | } |
| | | |
| | | |
| | | @Transactional |
| | | public Long addUsingFormBack(FinSysTenantUser sysInfo, Long departmentId, String departmentName, Long operatorId, String operatorName, Long backTime, |
| | | String procureDoc) { |