diff --git a/src/main/java/com/qs/serve/modules/bms/controller/BmsSupplierController.java b/src/main/java/com/qs/serve/modules/bms/controller/BmsSupplierController.java index e312a090..f4e78788 100644 --- a/src/main/java/com/qs/serve/modules/bms/controller/BmsSupplierController.java +++ b/src/main/java/com/qs/serve/modules/bms/controller/BmsSupplierController.java @@ -281,6 +281,94 @@ public class BmsSupplierController { return R.byPageHelperList(list); } + @PostMapping("/exportExcel") + @PreAuthorize("hasRole('bms:supplier:query')") + public R> exportExcel(@RequestBody BmsSupplier param){ + //兼容 前端接错参数 + if(param.getSupplierName()!=null){ + param.setName(param.getSupplierName()); + } + if(param.getSupplierCode()!=null){ + param.setCode(param.getSupplierCode()); + } + + if(StringUtils.hasText(param.getRegion2Label())){ + LambdaQueryWrapper region2LambdaQueryWrapper = new LambdaQueryWrapper<>(); + region2LambdaQueryWrapper.like(BmsRegion2::getPathNames,param.getRegion2Label()); + List region2List = bmsRegion2Service.list(region2LambdaQueryWrapper); + if(region2List.size()>0) { + param.setRegion2Ids(region2List.stream().map(a -> a.getId()).collect(Collectors.toList())); + }else{ + param.setRegion2Ids(Arrays.asList("#")); + } + } + if(StringUtils.hasText(param.getSearchRegion2FirstName())){ + LambdaQueryWrapper region2LambdaQueryWrapper = new LambdaQueryWrapper<>(); + region2LambdaQueryWrapper.like(BmsRegion2::getName,param.getSearchRegion2FirstName()); + List region2List = bmsRegion2Service.list(region2LambdaQueryWrapper); + if(region2List.size()>0) { + param.setSearchRegion2First(region2List.stream().map(a -> a.getId()).collect(Collectors.toList())); + }else{ + param.setSearchRegion2First(Arrays.asList("#")); + } + } + if(StringUtils.hasText(param.getSearchRegion2SecondName())){ + LambdaQueryWrapper region2LambdaQueryWrapper = new LambdaQueryWrapper<>(); + region2LambdaQueryWrapper.like(BmsRegion2::getName,param.getSearchRegion2SecondName()); + List region2List = bmsRegion2Service.list(region2LambdaQueryWrapper); + if(region2List.size()>0) { + param.setSearchRegion2Second(region2List.stream().map(a -> a.getId()).collect(Collectors.toList())); + }else{ + param.setSearchRegion2Second(Arrays.asList("#")); + } + } + if(StringUtils.hasText(param.getSearchRegion2ThirdName())){ + LambdaQueryWrapper region2LambdaQueryWrapper = new LambdaQueryWrapper<>(); + region2LambdaQueryWrapper.like(BmsRegion2::getName,param.getSearchRegion2ThirdName()); + List region2List = bmsRegion2Service.list(region2LambdaQueryWrapper); + if(region2List.size()>0) { + param.setSearchRegion2Third(region2List.stream().map(a -> a.getId()).collect(Collectors.toList())); + }else{ + param.setSearchRegion2Third(Arrays.asList("#")); + } + } + + if(StringUtils.hasText(param.getRegionLabel())){ + LambdaQueryWrapper regionLambdaQueryWrapper = new LambdaQueryWrapper<>(); + regionLambdaQueryWrapper.like(BmsRegion::getPathNames,param.getRegionLabel()); + List regionList = bmsRegionService.list(regionLambdaQueryWrapper); + if(regionList.size()>0) { + param.setRegionIds(regionList.stream().map(a -> a.getId()).collect(Collectors.toList())); + }else{ + param.setRegion2Ids(Arrays.asList("#")); + } + } + if(StringUtils.hasText(param.getSearchRegionFirstName())){ + LambdaQueryWrapper regionLambdaQueryWrapper = new LambdaQueryWrapper<>(); + regionLambdaQueryWrapper.like(BmsRegion::getName,param.getSearchRegionFirstName()); + List regionList = bmsRegionService.list(regionLambdaQueryWrapper); + if(regionList.size()>0) { + param.setSearchRegionFirst(regionList.stream().map(a -> a.getId()).collect(Collectors.toList())); + }else{ + param.setSearchRegionFirst(Arrays.asList("#")); + } + } + if(StringUtils.hasText(param.getSearchRegionSecondName())){ + LambdaQueryWrapper regionLambdaQueryWrapper = new LambdaQueryWrapper<>(); + regionLambdaQueryWrapper.like(BmsRegion::getName,param.getSearchRegionSecondName()); + List regionList = bmsRegionService.list(regionLambdaQueryWrapper); + if(regionList.size()>0) { + param.setSearchRegionSecond(regionList.stream().map(a -> a.getId()).collect(Collectors.toList())); + }else{ + param.setSearchRegionSecond(Arrays.asList("#")); + } + } + + List list = bmsSupplierService.selectSupplierList(param); + initSupplierList(list); + initParentList(list); + return R.ok(list); + } /** * 树查询 diff --git a/src/main/java/com/qs/serve/modules/bms/entity/BmsSupplier.java b/src/main/java/com/qs/serve/modules/bms/entity/BmsSupplier.java index 6ef8753c..2c675fc8 100644 --- a/src/main/java/com/qs/serve/modules/bms/entity/BmsSupplier.java +++ b/src/main/java/com/qs/serve/modules/bms/entity/BmsSupplier.java @@ -106,15 +106,27 @@ public class BmsSupplier implements Serializable { private String otherUserCodes; - /** 停用 */ + /** 闭户 */ private Integer stopFlag; + /** 闭户日期 */ + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private LocalDateTime stopFlagDate; + /** 所属账套 */ private String belong; /** 是否供应商 */ private Integer supplierFlag; + private Integer cooperatePauseFlag; + + /** 暂不合作日期 */ + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private LocalDateTime cooperatePauseFlagDate; + /** 创建时间 */ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") diff --git a/src/main/java/com/qs/serve/modules/bms/entity/bo/BmsSupplierBo.java b/src/main/java/com/qs/serve/modules/bms/entity/bo/BmsSupplierBo.java index bc894872..c3ebef6e 100644 --- a/src/main/java/com/qs/serve/modules/bms/entity/bo/BmsSupplierBo.java +++ b/src/main/java/com/qs/serve/modules/bms/entity/bo/BmsSupplierBo.java @@ -2,11 +2,14 @@ package com.qs.serve.modules.bms.entity.bo; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import org.hibernate.validator.constraints.Length; +import org.springframework.format.annotation.DateTimeFormat; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; +import java.time.LocalDateTime; /** * @author YenHex @@ -55,4 +58,20 @@ public class BmsSupplierBo { private Integer supplierFlag; private String belong; + + /** 闭户 */ + private Integer stopFlag; + + /** 闭户日期 */ + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private LocalDateTime stopFlagDate; + + /** 暂不合作 */ + private Integer cooperatePauseFlag; + + /** 暂不合作日期 */ + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private LocalDateTime cooperatePauseFlagDate; } diff --git a/src/main/java/com/qs/serve/modules/bms/service/impl/BmsSupplierApplicationService.java b/src/main/java/com/qs/serve/modules/bms/service/impl/BmsSupplierApplicationService.java index 40a0b750..e7205b2f 100644 --- a/src/main/java/com/qs/serve/modules/bms/service/impl/BmsSupplierApplicationService.java +++ b/src/main/java/com/qs/serve/modules/bms/service/impl/BmsSupplierApplicationService.java @@ -41,264 +41,263 @@ import java.util.stream.Collectors; @AllArgsConstructor public class BmsSupplierApplicationService { - private BmsRegionMapper regionMapper; - private BmsRegion2Mapper bmsRegion2Mapper; - private TbsBudgetLogService budgetLogService; - private TbsCostUnItemService costUnItemService; - private TbsBudgetMapper budgetMapper; - private TbsBudgetConditionMapper budgetConditionMapper; - private TbsScheduleItemBudgetMapper scheduleItemBudgetMapper; - private TbsActivityMapper activityMapper; +// private BmsRegionMapper regionMapper; +// private BmsRegion2Mapper bmsRegion2Mapper; +// private TbsCostUnItemService costUnItemService; +// private TbsBudgetMapper budgetMapper; +// private TbsBudgetConditionMapper budgetConditionMapper; +// private TbsScheduleItemBudgetMapper scheduleItemBudgetMapper; +// private TbsActivityMapper activityMapper; private BmsSupplierMapper bmsSupplierMapper; - /** - * 客户更新区域时,预算政策统计 - * @param supplierId - * @param regionType - * @param orgRegionId - * @param newRegionId - */ - public void migratePolicyBudget(String supplierId, String regionType, String orgRegionId, String newRegionId){ - - } - - /** - * 客户更新区域时,预算统计调整 - * @param supplierId - * @param regionType - * @param orgRegionId - * @param newRegionId - */ - public void migrateRegion(String supplierId, String regionType, String orgRegionId, String newRegionId) { - LocalDateTime nowTime = LocalDateTime.now(); - String newRegionCode; - String newRegionName; - if(regionType.equals(TbsCenterType.saleRegion.name())){ - BmsRegion bmsRegion = regionMapper.selectById(newRegionId); - newRegionCode = bmsRegion.getCode(); - newRegionName = bmsRegion.getName(); - }else { - BmsRegion2 bmsRegion2 = bmsRegion2Mapper.selectById(newRegionId); - newRegionCode = bmsRegion2.getCode(); - newRegionName = bmsRegion2.getName(); - } - //this.migrateActivityBudget(supplierId, regionType, orgRegionId, newRegionId, nowTime, newRegionCode, newRegionName); - //this.migratePolicyBudget(supplierId, regionType, orgRegionId, newRegionId, nowTime, newRegionCode, newRegionName); - } - - /** - * 调整政策预算 - * @param supplierId - * @param regionType - * @param orgRegionId - * @param newRegionId - * @param nowTime - * @param newRegionCode - * @param newRegionName - */ - private void migratePolicyBudget(String supplierId, String regionType, String orgRegionId, String newRegionId, LocalDateTime nowTime, String newRegionCode, String newRegionName) { - //TODO 方案未落实 - } - - /** - * 调整活动预算 - * @param supplierId - * @param regionType - * @param orgRegionId - * @param newRegionId - * @param nowTime - * @param newRegionCode - * @param newRegionName - */ - private void migrateActivityBudget(String supplierId, String regionType, String orgRegionId, String newRegionId, LocalDateTime nowTime, String newRegionCode, String newRegionName) { - LambdaQueryWrapper lqw4log = new LambdaQueryWrapper<>(); - lqw4log.eq(TbsBudgetLog::getMigrateFlag,0); - lqw4log.eq(TbsBudgetLog::getRollbackFlag,0); - lqw4log.eq(TbsBudgetLog::getSupplierId, supplierId); - lqw4log.eq(TbsBudgetLog::getCenterType, regionType); - lqw4log.eq(TbsBudgetLog::getCenterId, orgRegionId); - lqw4log.isNotNull(TbsBudgetLog::getActivityId); - List budgetLogList = budgetLogService.list(lqw4log); - if(CollectionUtil.isNotEmpty(budgetLogList)){ - //查找符合条件的活动 - final List activityIds = budgetLogList.stream().map(TbsBudgetLog::getActivityId).distinct().collect(Collectors.toList()); - LambdaQueryWrapper lqwAct = new LambdaQueryWrapper<>(); - lqwAct.in(TbsActivity::getId,activityIds); - List activityList = activityMapper.selectList(lqwAct); - //查询符合条件的预算 - final List subjectIds = budgetLogList.stream().map(TbsBudgetLog::getSubjectId).distinct().collect(Collectors.toList()); - LambdaQueryWrapper lqwBudget = new LambdaQueryWrapper<>(); - lqwBudget.eq(TbsBudget::getCenterType, regionType); - lqwBudget.eq(TbsBudget::getCenterId, newRegionId); - lqwBudget.eq(TbsBudget::getBudgetState,1); - lqwBudget.and(wq->{ - wq.eq(TbsBudget::getSubjectId,0).or().in(TbsBudget::getSubjectId,subjectIds); - }); - // 将有科目条件的前置 - lqwBudget.orderByDesc(TbsBudget::getSubjectId); - List budgetList = budgetMapper.selectList(lqwBudget); - //查询预算考核期 - List budgetIds = budgetList.stream().map(TbsBudget::getId).distinct().collect(Collectors.toList()); - Map> scheduleItemBudgetsMap = null; - if(CollectionUtil.isNotEmpty(budgetIds)){ - LambdaQueryWrapper budgetItemLqw = new LambdaQueryWrapper<>(); - budgetItemLqw.in(TbsScheduleItemBudget::getBudgetId,budgetIds); - List scheduleItemBudgets = scheduleItemBudgetMapper.selectList(budgetItemLqw); - scheduleItemBudgetsMap = scheduleItemBudgets.stream().collect(Collectors.groupingBy(TbsScheduleItemBudget::getBudgetId)); - } - //查询预算条件 - List conditionBudgetIds = budgetList.stream() - .filter(a->a.getConditionFlag().equals(1)) - .map(TbsBudget::getId).distinct().collect(Collectors.toList()); - Map> budgetConditionsMap = null; - if(conditionBudgetIds.size()>0){ - LambdaQueryWrapper conditionLqw = new LambdaQueryWrapper<>(); - conditionLqw.in(TbsBudgetCondition::getBudgetId,conditionBudgetIds); - List budgetConditions = budgetConditionMapper.selectList(conditionLqw); - budgetConditionsMap = budgetConditions.stream().collect(Collectors.groupingBy(TbsBudgetCondition::getBudgetId)); - } - //用于循环筛选条件 - TbsGoodsType[] goodsTypes = new TbsGoodsType[]{ - TbsGoodsType.sku, - TbsGoodsType.spu, - TbsGoodsType.series, - TbsGoodsType.category, - TbsGoodsType.brand - }; - //已占用预算进行调增 - final BudgetLogOptFlag optType4Diff = regionType.equals(TbsCenterType.saleRegion.name())? - BudgetLogOptFlag.State_8:BudgetLogOptFlag.State_10; - final BudgetLogOptFlag optType4Add = regionType.equals(TbsCenterType.saleRegion.name())? - BudgetLogOptFlag.State_7:BudgetLogOptFlag.State_9; - List budgetLog4Adds = budgetLogList.stream().map(budgetLog->{ - TbsBudgetLog obj = CopierUtil.copy(budgetLog,new TbsBudgetLog()); - obj.setId(null); - obj.setOptType(optType4Add.getCode()); - obj.setMigrateFlag(1); - obj.setMigrateTime(nowTime); - obj.setAmount(TbsBudgetLogBuildUtil.buildAmount(obj.getAmount(),optType4Add)); - return obj; - }).collect(Collectors.toList()); - //规则:品类条件比科目条件优先级更高 - List budgetLog4Diff = new ArrayList<>(); - //无匹配的费用支出 - List costUnItemList = new ArrayList<>(); - for (TbsBudgetLog budgetLog : budgetLogList) { - //当前活动 - TbsActivity currActivity = null; - for (TbsActivity activity : activityList) { - if(budgetLog.getActivityId().equals(activity.getId())){ - currActivity = activity; - break; - } - } - //(数据结构:value=预算id列表,key=商品类型) - Map> matchConditionBudgetIdsMap = new HashMap<>(); - if(budgetConditionsMap!=null){ - for (Long budgetId : budgetConditionsMap.keySet()) { - List budgetConditions = budgetConditionsMap.get(budgetId); - String pathName = budgetLog.getTargetLevelPathNames(); - for (TbsBudgetCondition condition : budgetConditions) { - if(pathName.contains(condition.getTargetLevelPathNames())){ - List tempList = matchConditionBudgetIdsMap.get(condition.getTargetType()); - if(tempList==null){ - tempList = new ArrayList<>(); - } - tempList.add(budgetId); - matchConditionBudgetIdsMap.put(condition.getTargetType(),tempList); - break; - } - } - } - } - //记录匹配品类条件的预算 - List matchBudgetConditionList = new ArrayList<>(); - List matchBudgetConditionList_tmp = new ArrayList<>(); - for (TbsBudget budget : budgetList) { - if(budget.getConditionFlag().equals(1)){ - for (TbsGoodsType goodsType : goodsTypes) { - List tempList = matchConditionBudgetIdsMap.get(goodsType.name()); - if(CollectionUtil.isNotEmpty(tempList)){ - for (Long budgetId01 : tempList) { - if(budgetId01.equals(budget.getId())){ - matchBudgetConditionList.add(budget); - } - } - } - } - }else { - matchBudgetConditionList_tmp.add(budget); - } - } - //有条件预算优先级更高 - matchBudgetConditionList.addAll(matchBudgetConditionList_tmp); - //第一个预算为最有匹配预算 - TbsBudget matchBudget = null; - TbsScheduleItemBudget matchItemBudget = null; - //记录匹配到的预算 - if(scheduleItemBudgetsMap!=null){ - for (TbsBudget budget : matchBudgetConditionList) { - if(matchBudget!=null){ - break; - } - List scheduleItemBudgets = scheduleItemBudgetsMap.get(budget.getId()); - for (TbsScheduleItemBudget itemBudget : scheduleItemBudgets) { - LocalDateTime actStartDate = currActivity.getPreStartDate().atStartOfDay(); - LocalDateTime actEndDate = LocalDateTime.of(currActivity.getPreStartDate(), LocalTime.MAX); - if(actStartDate.isAfter(itemBudget.getStartDate())&&actEndDate.isBefore(itemBudget.getEndDate())){ - matchBudget = budget; - matchItemBudget = itemBudget; - break; - } - } - } - } - if(matchBudget!=null){ - //有匹配的预算 - TbsBudgetLog newLog = CopierUtil.copy(budgetLog,new TbsBudgetLog()); - newLog.setId(null); - newLog.setOptType(optType4Diff.getCode()); - newLog.setBudgetId(matchBudget.getId()); - newLog.setBudgetCode(matchBudget.getBudgetCode()); - newLog.setScheduleOrgId(budgetLog.getScheduleId()); - newLog.setScheduleItemOrgId(budgetLog.getScheduleItemId()); - newLog.setScheduleItemBudgetOrgId(budgetLog.getScheduleItemBudgetId()); - //匹配到的项 - newLog.setScheduleId(matchItemBudget.getScheduleId()); - newLog.setScheduleItemId(matchItemBudget.getScheduleItemId()); - newLog.setScheduleItemBudgetId(matchItemBudget.getId()); - //设置新的成本中心 - newLog.setCenterOrgId(newLog.getCenterId()); - newLog.setCenterOrgCode(newLog.getCenterCode()); - newLog.setCenterOrgName(newLog.getCenterName()); - newLog.setCenterId(newRegionId); - newLog.setCenterCode(newRegionCode); - newLog.setCenterName(newRegionName); - budgetLog4Diff.add(newLog); - }else { - //无匹配的预算 - TbsCostUnItem costUnItem = budgetLog.toTbsCostUnItem(currActivity); - costUnItemList.add(costUnItem); - } - } - //保存 - budgetLogService.saveBatch(budgetLog4Adds); - if(CollectionUtil.isNotEmpty(budgetLog4Diff)){ - budgetLogService.saveBatch(budgetLog4Diff); - } - if(CollectionUtil.isNotEmpty(costUnItemList)){ - costUnItemService.saveBatch(costUnItemList); - } - //设置已迁移状态 - List budgetLogIds = budgetLogList.stream().map(TbsBudgetLog::getId).collect(Collectors.toList()); - TbsBudgetLog updLogParam = new TbsBudgetLog(); - updLogParam.setMigrateFlag(1); - updLogParam.setMigrateTime(nowTime); - LambdaQueryWrapper updLogLqw = new LambdaQueryWrapper<>(); - updLogLqw.in(TbsBudgetLog::getId,budgetLogIds); - budgetLogService.update(updLogParam,updLogLqw); - } - } +// /** +// * 客户更新区域时,预算政策统计 +// * @param supplierId +// * @param regionType +// * @param orgRegionId +// * @param newRegionId +// */ +// public void migratePolicyBudget(String supplierId, String regionType, String orgRegionId, String newRegionId){ +// +// } +// +// /** +// * 客户更新区域时,预算统计调整 +// * @param supplierId +// * @param regionType +// * @param orgRegionId +// * @param newRegionId +// */ +// public void migrateRegion(String supplierId, String regionType, String orgRegionId, String newRegionId) { +// LocalDateTime nowTime = LocalDateTime.now(); +// String newRegionCode; +// String newRegionName; +// if(regionType.equals(TbsCenterType.saleRegion.name())){ +// BmsRegion bmsRegion = regionMapper.selectById(newRegionId); +// newRegionCode = bmsRegion.getCode(); +// newRegionName = bmsRegion.getName(); +// }else { +// BmsRegion2 bmsRegion2 = bmsRegion2Mapper.selectById(newRegionId); +// newRegionCode = bmsRegion2.getCode(); +// newRegionName = bmsRegion2.getName(); +// } +// //this.migrateActivityBudget(supplierId, regionType, orgRegionId, newRegionId, nowTime, newRegionCode, newRegionName); +// //this.migratePolicyBudget(supplierId, regionType, orgRegionId, newRegionId, nowTime, newRegionCode, newRegionName); +// } +// +// /** +// * 调整政策预算 +// * @param supplierId +// * @param regionType +// * @param orgRegionId +// * @param newRegionId +// * @param nowTime +// * @param newRegionCode +// * @param newRegionName +// */ +// private void migratePolicyBudget(String supplierId, String regionType, String orgRegionId, String newRegionId, LocalDateTime nowTime, String newRegionCode, String newRegionName) { +// //TODO 方案未落实 +// } +// +// /** +// * 调整活动预算 +// * @param supplierId +// * @param regionType +// * @param orgRegionId +// * @param newRegionId +// * @param nowTime +// * @param newRegionCode +// * @param newRegionName +// */ +// private void migrateActivityBudget(String supplierId, String regionType, String orgRegionId, String newRegionId, LocalDateTime nowTime, String newRegionCode, String newRegionName) { +// LambdaQueryWrapper lqw4log = new LambdaQueryWrapper<>(); +// lqw4log.eq(TbsBudgetLog::getMigrateFlag,0); +// lqw4log.eq(TbsBudgetLog::getRollbackFlag,0); +// lqw4log.eq(TbsBudgetLog::getSupplierId, supplierId); +// lqw4log.eq(TbsBudgetLog::getCenterType, regionType); +// lqw4log.eq(TbsBudgetLog::getCenterId, orgRegionId); +// lqw4log.isNotNull(TbsBudgetLog::getActivityId); +// List budgetLogList = budgetLogService.list(lqw4log); +// if(CollectionUtil.isNotEmpty(budgetLogList)){ +// //查找符合条件的活动 +// final List activityIds = budgetLogList.stream().map(TbsBudgetLog::getActivityId).distinct().collect(Collectors.toList()); +// LambdaQueryWrapper lqwAct = new LambdaQueryWrapper<>(); +// lqwAct.in(TbsActivity::getId,activityIds); +// List activityList = activityMapper.selectList(lqwAct); +// //查询符合条件的预算 +// final List subjectIds = budgetLogList.stream().map(TbsBudgetLog::getSubjectId).distinct().collect(Collectors.toList()); +// LambdaQueryWrapper lqwBudget = new LambdaQueryWrapper<>(); +// lqwBudget.eq(TbsBudget::getCenterType, regionType); +// lqwBudget.eq(TbsBudget::getCenterId, newRegionId); +// lqwBudget.eq(TbsBudget::getBudgetState,1); +// lqwBudget.and(wq->{ +// wq.eq(TbsBudget::getSubjectId,0).or().in(TbsBudget::getSubjectId,subjectIds); +// }); +// // 将有科目条件的前置 +// lqwBudget.orderByDesc(TbsBudget::getSubjectId); +// List budgetList = budgetMapper.selectList(lqwBudget); +// //查询预算考核期 +// List budgetIds = budgetList.stream().map(TbsBudget::getId).distinct().collect(Collectors.toList()); +// Map> scheduleItemBudgetsMap = null; +// if(CollectionUtil.isNotEmpty(budgetIds)){ +// LambdaQueryWrapper budgetItemLqw = new LambdaQueryWrapper<>(); +// budgetItemLqw.in(TbsScheduleItemBudget::getBudgetId,budgetIds); +// List scheduleItemBudgets = scheduleItemBudgetMapper.selectList(budgetItemLqw); +// scheduleItemBudgetsMap = scheduleItemBudgets.stream().collect(Collectors.groupingBy(TbsScheduleItemBudget::getBudgetId)); +// } +// //查询预算条件 +// List conditionBudgetIds = budgetList.stream() +// .filter(a->a.getConditionFlag().equals(1)) +// .map(TbsBudget::getId).distinct().collect(Collectors.toList()); +// Map> budgetConditionsMap = null; +// if(conditionBudgetIds.size()>0){ +// LambdaQueryWrapper conditionLqw = new LambdaQueryWrapper<>(); +// conditionLqw.in(TbsBudgetCondition::getBudgetId,conditionBudgetIds); +// List budgetConditions = budgetConditionMapper.selectList(conditionLqw); +// budgetConditionsMap = budgetConditions.stream().collect(Collectors.groupingBy(TbsBudgetCondition::getBudgetId)); +// } +// //用于循环筛选条件 +// TbsGoodsType[] goodsTypes = new TbsGoodsType[]{ +// TbsGoodsType.sku, +// TbsGoodsType.spu, +// TbsGoodsType.series, +// TbsGoodsType.category, +// TbsGoodsType.brand +// }; +// //已占用预算进行调增 +// final BudgetLogOptFlag optType4Diff = regionType.equals(TbsCenterType.saleRegion.name())? +// BudgetLogOptFlag.State_8:BudgetLogOptFlag.State_10; +// final BudgetLogOptFlag optType4Add = regionType.equals(TbsCenterType.saleRegion.name())? +// BudgetLogOptFlag.State_7:BudgetLogOptFlag.State_9; +// List budgetLog4Adds = budgetLogList.stream().map(budgetLog->{ +// TbsBudgetLog obj = CopierUtil.copy(budgetLog,new TbsBudgetLog()); +// obj.setId(null); +// obj.setOptType(optType4Add.getCode()); +// obj.setMigrateFlag(1); +// obj.setMigrateTime(nowTime); +// obj.setAmount(TbsBudgetLogBuildUtil.buildAmount(obj.getAmount(),optType4Add)); +// return obj; +// }).collect(Collectors.toList()); +// //规则:品类条件比科目条件优先级更高 +// List budgetLog4Diff = new ArrayList<>(); +// //无匹配的费用支出 +// List costUnItemList = new ArrayList<>(); +// for (TbsBudgetLog budgetLog : budgetLogList) { +// //当前活动 +// TbsActivity currActivity = null; +// for (TbsActivity activity : activityList) { +// if(budgetLog.getActivityId().equals(activity.getId())){ +// currActivity = activity; +// break; +// } +// } +// //(数据结构:value=预算id列表,key=商品类型) +// Map> matchConditionBudgetIdsMap = new HashMap<>(); +// if(budgetConditionsMap!=null){ +// for (Long budgetId : budgetConditionsMap.keySet()) { +// List budgetConditions = budgetConditionsMap.get(budgetId); +// String pathName = budgetLog.getTargetLevelPathNames(); +// for (TbsBudgetCondition condition : budgetConditions) { +// if(pathName.contains(condition.getTargetLevelPathNames())){ +// List tempList = matchConditionBudgetIdsMap.get(condition.getTargetType()); +// if(tempList==null){ +// tempList = new ArrayList<>(); +// } +// tempList.add(budgetId); +// matchConditionBudgetIdsMap.put(condition.getTargetType(),tempList); +// break; +// } +// } +// } +// } +// //记录匹配品类条件的预算 +// List matchBudgetConditionList = new ArrayList<>(); +// List matchBudgetConditionList_tmp = new ArrayList<>(); +// for (TbsBudget budget : budgetList) { +// if(budget.getConditionFlag().equals(1)){ +// for (TbsGoodsType goodsType : goodsTypes) { +// List tempList = matchConditionBudgetIdsMap.get(goodsType.name()); +// if(CollectionUtil.isNotEmpty(tempList)){ +// for (Long budgetId01 : tempList) { +// if(budgetId01.equals(budget.getId())){ +// matchBudgetConditionList.add(budget); +// } +// } +// } +// } +// }else { +// matchBudgetConditionList_tmp.add(budget); +// } +// } +// //有条件预算优先级更高 +// matchBudgetConditionList.addAll(matchBudgetConditionList_tmp); +// //第一个预算为最有匹配预算 +// TbsBudget matchBudget = null; +// TbsScheduleItemBudget matchItemBudget = null; +// //记录匹配到的预算 +// if(scheduleItemBudgetsMap!=null){ +// for (TbsBudget budget : matchBudgetConditionList) { +// if(matchBudget!=null){ +// break; +// } +// List scheduleItemBudgets = scheduleItemBudgetsMap.get(budget.getId()); +// for (TbsScheduleItemBudget itemBudget : scheduleItemBudgets) { +// LocalDateTime actStartDate = currActivity.getPreStartDate().atStartOfDay(); +// LocalDateTime actEndDate = LocalDateTime.of(currActivity.getPreStartDate(), LocalTime.MAX); +// if(actStartDate.isAfter(itemBudget.getStartDate())&&actEndDate.isBefore(itemBudget.getEndDate())){ +// matchBudget = budget; +// matchItemBudget = itemBudget; +// break; +// } +// } +// } +// } +// if(matchBudget!=null){ +// //有匹配的预算 +// TbsBudgetLog newLog = CopierUtil.copy(budgetLog,new TbsBudgetLog()); +// newLog.setId(null); +// newLog.setOptType(optType4Diff.getCode()); +// newLog.setBudgetId(matchBudget.getId()); +// newLog.setBudgetCode(matchBudget.getBudgetCode()); +// newLog.setScheduleOrgId(budgetLog.getScheduleId()); +// newLog.setScheduleItemOrgId(budgetLog.getScheduleItemId()); +// newLog.setScheduleItemBudgetOrgId(budgetLog.getScheduleItemBudgetId()); +// //匹配到的项 +// newLog.setScheduleId(matchItemBudget.getScheduleId()); +// newLog.setScheduleItemId(matchItemBudget.getScheduleItemId()); +// newLog.setScheduleItemBudgetId(matchItemBudget.getId()); +// //设置新的成本中心 +// newLog.setCenterOrgId(newLog.getCenterId()); +// newLog.setCenterOrgCode(newLog.getCenterCode()); +// newLog.setCenterOrgName(newLog.getCenterName()); +// newLog.setCenterId(newRegionId); +// newLog.setCenterCode(newRegionCode); +// newLog.setCenterName(newRegionName); +// budgetLog4Diff.add(newLog); +// }else { +// //无匹配的预算 +// TbsCostUnItem costUnItem = budgetLog.toTbsCostUnItem(currActivity); +// costUnItemList.add(costUnItem); +// } +// } +// //保存 +// budgetLogService.saveBatch(budgetLog4Adds); +// if(CollectionUtil.isNotEmpty(budgetLog4Diff)){ +// budgetLogService.saveBatch(budgetLog4Diff); +// } +// if(CollectionUtil.isNotEmpty(costUnItemList)){ +// costUnItemService.saveBatch(costUnItemList); +// } +// //设置已迁移状态 +// List budgetLogIds = budgetLogList.stream().map(TbsBudgetLog::getId).collect(Collectors.toList()); +// TbsBudgetLog updLogParam = new TbsBudgetLog(); +// updLogParam.setMigrateFlag(1); +// updLogParam.setMigrateTime(nowTime); +// LambdaQueryWrapper updLogLqw = new LambdaQueryWrapper<>(); +// updLogLqw.in(TbsBudgetLog::getId,budgetLogIds); +// budgetLogService.update(updLogParam,updLogLqw); +// } +// } public List listByRegionIds(List regionIds, Integer level) { if(regionIds.size()>0){ diff --git a/src/main/java/com/qs/serve/modules/bms/service/impl/BmsSupplierServiceImpl.java b/src/main/java/com/qs/serve/modules/bms/service/impl/BmsSupplierServiceImpl.java index e1a14eba..4ca9dd56 100644 --- a/src/main/java/com/qs/serve/modules/bms/service/impl/BmsSupplierServiceImpl.java +++ b/src/main/java/com/qs/serve/modules/bms/service/impl/BmsSupplierServiceImpl.java @@ -81,22 +81,22 @@ public class BmsSupplierServiceImpl extends ServiceImpl> getList(SysOperationManual param){ + SysOperationManual entity = CopierUtil.copy(param,new SysOperationManual()); + LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(entity); + List list = sysOperationManualService.list(lqw); + list.forEach(sysOperationManual->{ + if(CollectionUtil.isNotEmpty(sysOperationManual.getAttachIds())){ + List attachIds = Arrays.asList(sysOperationManual.getAttachIds()); + List attachList = attachService.listByIds(attachIds); + sysOperationManual.setAttachList(attachList); + } + }); + return R.ok(list); + } + + /** + * 翻页 + * @param param + * @return + */ + @GetMapping("/page") + //@PreAuthorize("hasRole('sys:operationManual:query')") + public R> getPage(SysOperationManual param){ + SysOperationManual entity = CopierUtil.copy(param,new SysOperationManual()); + LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(entity); + PageUtil.startPage(); + List list = sysOperationManualService.list(lqw); + list.forEach(sysOperationManual->{ + if(CollectionUtil.isNotEmpty(sysOperationManual.getAttachIds())){ + List attachIds = Arrays.asList(sysOperationManual.getAttachIds()); + List attachList = attachService.listByIds(attachIds); + sysOperationManual.setAttachList(attachList); + } + }); + return R.byPageHelperList(list); + } + + /** + * ID查询 + * @param id + * @return + */ + @GetMapping("/getById/{id}") +// @SysLog(module = SystemModule.${extend.moduleLog}, title = "", biz = BizType.QUERY) + //@PreAuthorize("hasRole('sys:operationManual:query')") + public R getById(@PathVariable("id") String id){ + SysOperationManual sysOperationManual = sysOperationManualService.getById(id); + if(CollectionUtil.isNotEmpty(sysOperationManual.getAttachIds())){ + List attachIds = Arrays.asList(sysOperationManual.getAttachIds()); + List attachList = attachService.listByIds(attachIds); + sysOperationManual.setAttachList(attachList); + } + return R.ok(sysOperationManual); + } + + + + /** + * 更新 + * @param param + * @return + */ + @PostMapping("/updateById") +// @SysLog(module = SystemModule.${extend.moduleLog}, title = "", biz = BizType.UPDATE) + //@PreAuthorize("hasRole('sys:operationManual:update')") + public R updateById(@RequestBody @Valid SysOperationManual param){ + SysOperationManual entity = CopierUtil.copy(param,new SysOperationManual()); + boolean result = sysOperationManualService.updateById(entity); + return R.isTrue(result); + } + + /** + * 新增 + * @param param + * @return + */ + @PostMapping("/save") +// @SysLog(module = SystemModule.${extend.moduleLog}, title = "", biz = BizType.INSERT) + //@PreAuthorize("hasRole('sys:operationManual:insert')") + public R save(@RequestBody @Valid SysOperationManual param){ + SysOperationManual entity = CopierUtil.copy(param,new SysOperationManual()); + boolean result = sysOperationManualService.save(entity); + return R.isTrue(result); + } + + /** + * 删除 + * @param ids + * @return + */ + @DeleteMapping("/deleteById/{ids}") +// @SysLog(module = SystemModule.${extend.moduleLog}, title = "", biz = BizType.DELETE) + //@PreAuthorize("hasRole('sys:operationManual:delete')") + public R deleteById(@PathVariable("ids") String ids){ + List idsLong = StringUtils.splitIdLong(ids); + boolean result = sysOperationManualService.removeByIds(idsLong); + return R.isTrue(result); + } + +} + diff --git a/src/main/java/com/qs/serve/modules/sys/entity/SysOperationManual.java b/src/main/java/com/qs/serve/modules/sys/entity/SysOperationManual.java new file mode 100644 index 00000000..b7bfb984 --- /dev/null +++ b/src/main/java/com/qs/serve/modules/sys/entity/SysOperationManual.java @@ -0,0 +1,54 @@ +package com.qs.serve.modules.sys.entity; + +import java.time.LocalDate; +import java.io.Serializable; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.List; + +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.qs.serve.common.framework.mybatis.handler.meta.SplitStringTypeHandler; +import lombok.Data; +import org.apache.ibatis.type.JdbcType; +import org.hibernate.validator.constraints.Length; +import org.springframework.format.annotation.DateTimeFormat; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.NotBlank; + +/** + * 实体类 + * @author YenHex + * @since 2023-08-11 + */ +@Data +@TableName(value = "sys_operation_manual", autoResultMap = true) +public class SysOperationManual implements Serializable { + + private static final long serialVersionUID = 1L; + + /** */ + @TableId(type = IdType.AUTO) + private Long id; + + /** */ + @Length(max = 255,message = "长度不能超过255字") + private String name; + + /** 附件id */ + @TableField(typeHandler = SplitStringTypeHandler.class,jdbcType= JdbcType.VARCHAR) + private String[] attachIds; + + @TableField(exist = false) + private List attachList; + + /** */ + @JsonIgnore + @JsonProperty + private String delFlag; + +} + diff --git a/src/main/java/com/qs/serve/modules/sys/mapper/SysOperationManualMapper.java b/src/main/java/com/qs/serve/modules/sys/mapper/SysOperationManualMapper.java new file mode 100644 index 00000000..b1968d4f --- /dev/null +++ b/src/main/java/com/qs/serve/modules/sys/mapper/SysOperationManualMapper.java @@ -0,0 +1,14 @@ +package com.qs.serve.modules.sys.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.qs.serve.modules.sys.entity.SysOperationManual; + +/** + * Mapper + * @author YenHex + * @date 2023-08-11 + */ +public interface SysOperationManualMapper extends BaseMapper { + +} + diff --git a/src/main/java/com/qs/serve/modules/sys/service/SysOperationManualService.java b/src/main/java/com/qs/serve/modules/sys/service/SysOperationManualService.java new file mode 100644 index 00000000..af8d2b0f --- /dev/null +++ b/src/main/java/com/qs/serve/modules/sys/service/SysOperationManualService.java @@ -0,0 +1,14 @@ +package com.qs.serve.modules.sys.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.qs.serve.modules.sys.entity.SysOperationManual; + +/** + * 服务接口 + * @author YenHex + * @date 2023-08-11 + */ +public interface SysOperationManualService extends IService { + +} + diff --git a/src/main/java/com/qs/serve/modules/sys/service/impl/SysOperationManualServiceImpl.java b/src/main/java/com/qs/serve/modules/sys/service/impl/SysOperationManualServiceImpl.java new file mode 100644 index 00000000..d2cfafc4 --- /dev/null +++ b/src/main/java/com/qs/serve/modules/sys/service/impl/SysOperationManualServiceImpl.java @@ -0,0 +1,22 @@ +package com.qs.serve.modules.sys.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import com.qs.serve.modules.sys.entity.SysOperationManual; +import com.qs.serve.modules.sys.service.SysOperationManualService; +import com.qs.serve.modules.sys.mapper.SysOperationManualMapper; + +/** + * 服务实现类 + * @author YenHex + * @since 2023-08-11 + */ +@Slf4j +@Service +@AllArgsConstructor +public class SysOperationManualServiceImpl extends ServiceImpl implements SysOperationManualService { + +} + diff --git a/src/main/resources/mapper/bms/BmsSupplierMapper.xml b/src/main/resources/mapper/bms/BmsSupplierMapper.xml index 58463dc0..814ef200 100644 --- a/src/main/resources/mapper/bms/BmsSupplierMapper.xml +++ b/src/main/resources/mapper/bms/BmsSupplierMapper.xml @@ -24,7 +24,6 @@ - @@ -37,7 +36,10 @@ - + + + + @@ -61,7 +63,6 @@ bms_supplier.`other_user_ids`, bms_supplier.`other_user_names`, bms_supplier.`other_user_codes`, - bms_supplier.`stop_flag`, bms_supplier.`belong`, bms_supplier.`create_time`, bms_supplier.`create_by`, @@ -70,6 +71,10 @@ bms_supplier.`tenant_id`, bms_supplier.`cost_flag`, bms_supplier.`supplier_flag`, + bms_supplier.`stop_flag`, + bms_supplier.`cooperate_pause_flag`, + bms_supplier.`stop_flag_date`, + bms_supplier.`cooperate_pause_flag_date`, bms_supplier.`del_flag`