Commit e0f16335579ef05e985d6a1d2abcca026f1040a6
Merge remote-tracking branch 'origin/dev' into dev
Showing
16 changed files
with
427 additions
and
59 deletions
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/inspectionplan/vo/InspectionPlanDetailRespVO.java
| @@ -52,6 +52,14 @@ public class InspectionPlanDetailRespVO { | @@ -52,6 +52,14 @@ public class InspectionPlanDetailRespVO { | ||
| 52 | @ExcelProperty("执行时间") | 52 | @ExcelProperty("执行时间") |
| 53 | private LocalDateTime endTime; | 53 | private LocalDateTime endTime; |
| 54 | 54 | ||
| 55 | + @Schema(description = "计划次数") | ||
| 56 | + @ExcelProperty("计划次数") | ||
| 57 | + private Integer planNum; | ||
| 58 | + | ||
| 59 | + @Schema(description = "完成次数") | ||
| 60 | + @ExcelProperty("完成次数") | ||
| 61 | + private Integer planFinishNum; | ||
| 62 | + | ||
| 55 | @Schema(description = "完成状态 1:未完成;2:进行中;3:已完成", requiredMode = Schema.RequiredMode.REQUIRED) | 63 | @Schema(description = "完成状态 1:未完成;2:进行中;3:已完成", requiredMode = Schema.RequiredMode.REQUIRED) |
| 56 | @ExcelProperty("完成状态 1:未完成;2:进行中;3:已完成") | 64 | @ExcelProperty("完成状态 1:未完成;2:进行中;3:已完成") |
| 57 | private Integer finishState; | 65 | private Integer finishState; |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/maintainplan/vo/MaintainPlanDetailRespVO.java
| @@ -51,6 +51,10 @@ public class MaintainPlanDetailRespVO { | @@ -51,6 +51,10 @@ public class MaintainPlanDetailRespVO { | ||
| 51 | @ExcelProperty("执行时间") | 51 | @ExcelProperty("执行时间") |
| 52 | private LocalDateTime endTime; | 52 | private LocalDateTime endTime; |
| 53 | 53 | ||
| 54 | + @Schema(description = "计划次数") | ||
| 55 | + @ExcelProperty("计划次数") | ||
| 56 | + private Integer planNum; | ||
| 57 | + | ||
| 54 | @Schema(description = "完成百分比", requiredMode = Schema.RequiredMode.REQUIRED) | 58 | @Schema(description = "完成百分比", requiredMode = Schema.RequiredMode.REQUIRED) |
| 55 | @ExcelProperty("完成百分比") | 59 | @ExcelProperty("完成百分比") |
| 56 | private Double finishPercent; | 60 | private Double finishPercent; |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/dataobject/inspectionplan/InspectionPlanDetailDO.java
| @@ -57,6 +57,15 @@ public class InspectionPlanDetailDO extends BaseDO { | @@ -57,6 +57,15 @@ public class InspectionPlanDetailDO extends BaseDO { | ||
| 57 | * 排序号:第n次计划 | 57 | * 排序号:第n次计划 |
| 58 | */ | 58 | */ |
| 59 | private Integer sortNum; | 59 | private Integer sortNum; |
| 60 | + | ||
| 61 | + /** | ||
| 62 | + * 计划次数 | ||
| 63 | + */ | ||
| 64 | + private Integer planNum; | ||
| 65 | + /** | ||
| 66 | + * 已完成次数 | ||
| 67 | + */ | ||
| 68 | + private Integer planFinishNum; | ||
| 60 | /** | 69 | /** |
| 61 | * 执行开始时间 | 70 | * 执行开始时间 |
| 62 | */ | 71 | */ |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/dataobject/maintainplan/MaintainPlanDetailDO.java
| @@ -55,6 +55,7 @@ public class MaintainPlanDetailDO extends BaseDO { | @@ -55,6 +55,7 @@ public class MaintainPlanDetailDO extends BaseDO { | ||
| 55 | * 排序号:第n次计划 | 55 | * 排序号:第n次计划 |
| 56 | */ | 56 | */ |
| 57 | private Integer sortNum; | 57 | private Integer sortNum; |
| 58 | + | ||
| 58 | /** | 59 | /** |
| 59 | * 执行开始时间 | 60 | * 执行开始时间 |
| 60 | */ | 61 | */ |
| @@ -63,6 +64,12 @@ public class MaintainPlanDetailDO extends BaseDO { | @@ -63,6 +64,12 @@ public class MaintainPlanDetailDO extends BaseDO { | ||
| 63 | * 执行时间 | 64 | * 执行时间 |
| 64 | */ | 65 | */ |
| 65 | private LocalDateTime endTime; | 66 | private LocalDateTime endTime; |
| 67 | + | ||
| 68 | + /** | ||
| 69 | + * 计划次数 | ||
| 70 | + */ | ||
| 71 | + private Integer planNum; | ||
| 72 | + | ||
| 66 | /** | 73 | /** |
| 67 | * 完成百分比 | 74 | * 完成百分比 |
| 68 | */ | 75 | */ |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/inspectionplan/InspectionPlanServiceImpl.java
| @@ -90,10 +90,9 @@ public class InspectionPlanServiceImpl implements InspectionPlanService { | @@ -90,10 +90,9 @@ public class InspectionPlanServiceImpl implements InspectionPlanService { | ||
| 90 | log.warn("获取两个时间之间间隔天数错误"); | 90 | log.warn("获取两个时间之间间隔天数错误"); |
| 91 | return CommonResult.error(INSPECTION_CYCLE_ERROR); | 91 | return CommonResult.error(INSPECTION_CYCLE_ERROR); |
| 92 | } | 92 | } |
| 93 | - //计算计划次数 | ||
| 94 | - Integer planNum = calculate.size(); | ||
| 95 | - | ||
| 96 | 93 | ||
| 94 | + //计算计划次数 | ||
| 95 | + int planNum = calculate.stream().mapToInt(PeriodResult::getCount).sum(); | ||
| 97 | //巡检计划list | 96 | //巡检计划list |
| 98 | List<InspectionPlanDO> inspectionPlanList = new ArrayList<>(); | 97 | List<InspectionPlanDO> inspectionPlanList = new ArrayList<>(); |
| 99 | //角色列表 | 98 | //角色列表 |
| @@ -138,13 +137,16 @@ public class InspectionPlanServiceImpl implements InspectionPlanService { | @@ -138,13 +137,16 @@ public class InspectionPlanServiceImpl implements InspectionPlanService { | ||
| 138 | roleList.add(inspectionPlanRoleDO); | 137 | roleList.add(inspectionPlanRoleDO); |
| 139 | }); | 138 | }); |
| 140 | /*3.插入巡查计划明细*/ | 139 | /*3.插入巡查计划明细*/ |
| 140 | + int index = 1; | ||
| 141 | for (PeriodResult periodResult : calculate) { | 141 | for (PeriodResult periodResult : calculate) { |
| 142 | InspectionPlanDetailDO entity = getInspectionPlanDetailDO(batchNo, createReqVO, roadReqVO, now); | 142 | InspectionPlanDetailDO entity = getInspectionPlanDetailDO(batchNo, createReqVO, roadReqVO, now); |
| 143 | ThreadUtil.sleep(2); | 143 | ThreadUtil.sleep(2); |
| 144 | - entity.setSortNum(periodResult.getCount()); | 144 | + entity.setSortNum(index); |
| 145 | + entity.setPlanNum(periodResult.getCount()); | ||
| 145 | entity.setBeginTime(LocalDateTime.parse(periodResult.getStart() + " 00:00:00", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); | 146 | entity.setBeginTime(LocalDateTime.parse(periodResult.getStart() + " 00:00:00", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| 146 | entity.setEndTime(LocalDateTime.parse(periodResult.getEnd() + " 23:59:59", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); | 147 | entity.setEndTime(LocalDateTime.parse(periodResult.getEnd() + " 23:59:59", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| 147 | detailDOList.add(entity); | 148 | detailDOList.add(entity); |
| 149 | + index++; | ||
| 148 | } | 150 | } |
| 149 | }); | 151 | }); |
| 150 | 152 |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/maintainplan/MaintainPlanServiceImpl.java
| @@ -93,7 +93,7 @@ public class MaintainPlanServiceImpl implements MaintainPlanService { | @@ -93,7 +93,7 @@ public class MaintainPlanServiceImpl implements MaintainPlanService { | ||
| 93 | return CommonResult.error(INSPECTION_CYCLE_ERROR); | 93 | return CommonResult.error(INSPECTION_CYCLE_ERROR); |
| 94 | } | 94 | } |
| 95 | //计算计划次数 | 95 | //计算计划次数 |
| 96 | - Integer planNum = calculate.size(); | 96 | + int planNum = calculate.stream().mapToInt(PeriodResult::getCount).sum(); |
| 97 | //巡检计划list | 97 | //巡检计划list |
| 98 | List<MaintainPlanDO> maintainPlanList = new ArrayList<>(); | 98 | List<MaintainPlanDO> maintainPlanList = new ArrayList<>(); |
| 99 | //角色列表 | 99 | //角色列表 |
| @@ -138,13 +138,16 @@ public class MaintainPlanServiceImpl implements MaintainPlanService { | @@ -138,13 +138,16 @@ public class MaintainPlanServiceImpl implements MaintainPlanService { | ||
| 138 | roleList.add(maintainPlanRoleDO); | 138 | roleList.add(maintainPlanRoleDO); |
| 139 | }); | 139 | }); |
| 140 | /*3.插入巡查计划明细*/ | 140 | /*3.插入巡查计划明细*/ |
| 141 | + int index =1; | ||
| 141 | for (PeriodResult periodResult : calculate) { | 142 | for (PeriodResult periodResult : calculate) { |
| 142 | MaintainPlanDetailDO entity = getMaintainPlanDetailDO(batchNo, createReqVO, roadReqVO, now); | 143 | MaintainPlanDetailDO entity = getMaintainPlanDetailDO(batchNo, createReqVO, roadReqVO, now); |
| 143 | ThreadUtil.sleep(2); | 144 | ThreadUtil.sleep(2); |
| 144 | - entity.setSortNum(periodResult.getCount()); | 145 | + entity.setSortNum(index); |
| 146 | + entity.setPlanNum(periodResult.getCount()); | ||
| 145 | entity.setBeginTime(LocalDateTime.parse(periodResult.getStart() + " 00:00:00", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); | 147 | entity.setBeginTime(LocalDateTime.parse(periodResult.getStart() + " 00:00:00", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| 146 | entity.setEndTime(LocalDateTime.parse(periodResult.getEnd() + " 23:59:59", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); | 148 | entity.setEndTime(LocalDateTime.parse(periodResult.getEnd() + " 23:59:59", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| 147 | detailDOList.add(entity); | 149 | detailDOList.add(entity); |
| 150 | + index++; | ||
| 148 | } | 151 | } |
| 149 | }); | 152 | }); |
| 150 | 153 |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/util/timeinterval/TimeIntervalFrequencyUtil.java
| @@ -11,7 +11,7 @@ import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.INSPECT | @@ -11,7 +11,7 @@ import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.INSPECT | ||
| 11 | 11 | ||
| 12 | /** | 12 | /** |
| 13 | * 时间区间拆分+频次计算工具类 | 13 | * 时间区间拆分+频次计算工具类 |
| 14 | - * 支持:按日/周/月/年拆分,区间临界点重叠,动态计算每个区间的执行频次 | 14 | + * 支持:按日/周/月/年拆分,基于固定天数换算(周=7天,月=30天,年=365天) |
| 15 | */ | 15 | */ |
| 16 | public class TimeIntervalFrequencyUtil { | 16 | public class TimeIntervalFrequencyUtil { |
| 17 | 17 | ||
| @@ -42,12 +42,12 @@ public class TimeIntervalFrequencyUtil { | @@ -42,12 +42,12 @@ public class TimeIntervalFrequencyUtil { | ||
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | /** | 44 | /** |
| 45 | - * 计算时间段划分结果 | 45 | + * 计算时间段划分结果(基于固定天数换算) |
| 46 | * | 46 | * |
| 47 | * @param startStr 开始日期 (yyyy-MM-dd) | 47 | * @param startStr 开始日期 (yyyy-MM-dd) |
| 48 | * @param endStr 结束日期 (yyyy-MM-dd) | 48 | * @param endStr 结束日期 (yyyy-MM-dd) |
| 49 | * @param freq 频次值,格式 "x/y" | 49 | * @param freq 频次值,格式 "x/y" |
| 50 | - * @param cycleId cycleId 1:日/次;2:周/次;3:月/次;4:年/次 | 50 | + * @param cycleId 1:日/次;2:周/次;3:月/次;4:年/次 |
| 51 | * @return 划分结果列表 | 51 | * @return 划分结果列表 |
| 52 | */ | 52 | */ |
| 53 | public static List<PeriodResult> calculate(String startStr, String endStr, String freq, Integer cycleId) { | 53 | public static List<PeriodResult> calculate(String startStr, String endStr, String freq, Integer cycleId) { |
| @@ -62,31 +62,29 @@ public class TimeIntervalFrequencyUtil { | @@ -62,31 +62,29 @@ public class TimeIntervalFrequencyUtil { | ||
| 62 | if (parts.length != 2) { | 62 | if (parts.length != 2) { |
| 63 | throw new IllegalArgumentException("频次值格式错误,应为 'x/y': " + freq); | 63 | throw new IllegalArgumentException("频次值格式错误,应为 'x/y': " + freq); |
| 64 | } | 64 | } |
| 65 | - int x = Integer.parseInt(parts[0]); | ||
| 66 | - int y = Integer.parseInt(parts[1]); | 65 | + int x = Integer.parseInt(parts[0]); // 每周期次数 |
| 66 | + int y = Integer.parseInt(parts[1]); // 周期数量 | ||
| 67 | 67 | ||
| 68 | IntervalUnit unit = getIntervalUnit(cycleId); | 68 | IntervalUnit unit = getIntervalUnit(cycleId); |
| 69 | + long periodDays = convertToDays(y, unit); // 转为固定天数 | ||
| 69 | 70 | ||
| 70 | List<PeriodResult> results = new ArrayList<>(); | 71 | List<PeriodResult> results = new ArrayList<>(); |
| 71 | LocalDate currentStart = start; | 72 | LocalDate currentStart = start; |
| 72 | 73 | ||
| 73 | while (!currentStart.isAfter(end)) { | 74 | while (!currentStart.isAfter(end)) { |
| 74 | - // 计算当前周期的理论结束日期(包含 y 个单位) | ||
| 75 | - LocalDate periodEnd = calculatePeriodEnd(currentStart, y, unit); | ||
| 76 | - | ||
| 77 | - // 实际段结束 = min(periodEnd, end) | ||
| 78 | - LocalDate segEnd = periodEnd.isAfter(end) ? end : periodEnd; | 75 | + // 当前段理论结束 = currentStart + periodDays - 1 |
| 76 | + LocalDate currentEnd = safePlusDays(currentStart, periodDays - 1); | ||
| 77 | + if (currentEnd.isAfter(end)) { | ||
| 78 | + currentEnd = end; // 截断 | ||
| 79 | + } | ||
| 79 | 80 | ||
| 80 | - results.add(new PeriodResult(currentStart, segEnd, x)); | 81 | + results.add(new PeriodResult(currentStart, currentEnd, x)); |
| 81 | 82 | ||
| 82 | // 下一段从当前段结束的第二天开始 | 83 | // 下一段从当前段结束的第二天开始 |
| 83 | - LocalDate nextStart = segEnd.plusDays(1); | ||
| 84 | - | ||
| 85 | - // 如果已经超过总结束时间,则终止 | 84 | + LocalDate nextStart = currentEnd.plusDays(1); |
| 86 | if (nextStart.isAfter(end)) { | 85 | if (nextStart.isAfter(end)) { |
| 87 | break; | 86 | break; |
| 88 | } | 87 | } |
| 89 | - | ||
| 90 | currentStart = nextStart; | 88 | currentStart = nextStart; |
| 91 | } | 89 | } |
| 92 | 90 | ||
| @@ -94,62 +92,70 @@ public class TimeIntervalFrequencyUtil { | @@ -94,62 +92,70 @@ public class TimeIntervalFrequencyUtil { | ||
| 94 | } | 92 | } |
| 95 | 93 | ||
| 96 | /** | 94 | /** |
| 97 | - * 计算从 start 开始,经过 y 个单位周期后的结束日期(包含) | 95 | + * 将 y 个单位转换为固定天数 |
| 98 | */ | 96 | */ |
| 99 | - private static LocalDate calculatePeriodEnd(LocalDate start, int y, IntervalUnit unit) { | 97 | + private static long convertToDays(int y, IntervalUnit unit) { |
| 100 | switch (unit) { | 98 | switch (unit) { |
| 101 | case DAY: | 99 | case DAY: |
| 102 | - return start.plusDays(y - 1); // 包含 y 天:start 到 start+y-1 | 100 | + return y; |
| 103 | case WEEK: | 101 | case WEEK: |
| 104 | - return start.plusDays((long) y * 7 - 1); // y周 = y*7天,减1得包含结束 | 102 | + return (long) y * 7; |
| 105 | case MONTH: | 103 | case MONTH: |
| 106 | - return addMonthsSafely(start, y).minusDays(1); | 104 | + return (long) y * 30; |
| 107 | case YEAR: | 105 | case YEAR: |
| 108 | - return start.plusYears(y).minusDays(1); | 106 | + return (long) y * 365; |
| 109 | default: | 107 | default: |
| 110 | - throw new UnsupportedOperationException("未支持的单位: " + unit); | 108 | + throw new UnsupportedOperationException("不支持的单位: " + unit); |
| 111 | } | 109 | } |
| 112 | } | 110 | } |
| 113 | 111 | ||
| 114 | - | ||
| 115 | - | ||
| 116 | /** | 112 | /** |
| 117 | - * 安全地加上 y 个月(避免3月31日+1月变成异常) | ||
| 118 | - * 这里使用 Java 8+ 的 plusMonths 自动调整规则 | 113 | + * 安全地加天数(防止溢出) |
| 119 | */ | 114 | */ |
| 120 | - private static LocalDate addMonthsSafely(LocalDate date, int months) { | ||
| 121 | - return date.plusMonths(months); | ||
| 122 | - // Java 会自动处理:如 1月31日 +1月 → 2月28/29日(不会抛异常) | 115 | + private static LocalDate safePlusDays(LocalDate date, long days) { |
| 116 | + if (days == 0) return date; | ||
| 117 | + try { | ||
| 118 | + return date.plusDays(days); | ||
| 119 | + } catch (ArithmeticException e) { | ||
| 120 | + return days > 0 ? LocalDate.MAX : LocalDate.MIN; | ||
| 121 | + } | ||
| 123 | } | 122 | } |
| 124 | 123 | ||
| 125 | - | ||
| 126 | - | ||
| 127 | - | ||
| 128 | // ====================== 测试用例 ====================== | 124 | // ====================== 测试用例 ====================== |
| 129 | - //cycleId 1:日/次;2:周/次;3:月/次;4:年/次 | ||
| 130 | public static void main(String[] args) { | 125 | public static void main(String[] args) { |
| 131 | - System.out.println("=== 示例1:每3天一次,按日 ==="); | ||
| 132 | - List<PeriodResult> r1 = calculate("2025-01-01", "2025-01-07", "1/3", 1); | 126 | + //1:日/次;2:周/次;3:月/次;4:年/次 |
| 127 | + System.out.println("=== 示例1:每2天3次(即:3/2),按日 ===2025-12-01 2025-12-31"); | ||
| 128 | + List<PeriodResult> r1 = calculate("2025-12-01", "2025-12-31", "3/2", 1); | ||
| 133 | r1.forEach(System.out::println); | 129 | r1.forEach(System.out::println); |
| 134 | - | ||
| 135 | - System.out.println("\n=== 示例2:每3周一次(21天),按周 ==="); | ||
| 136 | - List<PeriodResult> r2 = calculate("2025-01-01", "2025-02-08", "1/2", 2); | 130 | + // 输出: |
| 131 | + // 2025-01-01 2025-01-03 1次 | ||
| 132 | + // 2025-01-04 2025-01-06 1次 | ||
| 133 | + // 2025-01-07 2025-01-07 1次 | ||
| 134 | + System.out.println("\n=== 示例2:每2周3次(即:3/2)(14天),按周 ===2025-12-01 2025-12-10"); | ||
| 135 | + List<PeriodResult> r2 = calculate("2025-12-01", "2025-12-10", "3/2", 2); | ||
| 137 | r2.forEach(System.out::println); | 136 | r2.forEach(System.out::println); |
| 138 | - | ||
| 139 | - System.out.println("\n=== 示例3:每5个月一次,按月 ==="); | ||
| 140 | - List<PeriodResult> r3 = calculate("2025-11-01", "2025-12-31", "5/1", 3); | 137 | + // 每2周 = 14天 |
| 138 | + // 2025-01-01 ~ 2025-01-14 | ||
| 139 | + // 2025-01-15 ~ 2025-01-28 | ||
| 140 | + // 2025-01-29 ~ 2025-02-08(剩余11天) | ||
| 141 | + System.out.println("\n=== 示例3:每2个月4次(即:4/2)(30天),按月 === 2025-09-15 2025-12-31"); | ||
| 142 | + List<PeriodResult> r3 = calculate("2025-09-15", "2025-12-31", "4/2", 3); | ||
| 141 | r3.forEach(System.out::println); | 143 | r3.forEach(System.out::println); |
| 144 | + // 每1月 = 30天 | ||
| 145 | + // 2025-01-01 ~ 2025-01-30 | ||
| 146 | + // 2025-01-31 ~ 2025-02-28(30天?→ 实际是29天,但按30天算) | ||
| 147 | + // 2025-03-01 ~ 2025-03-15(不足) | ||
| 142 | 148 | ||
| 143 | - System.out.println("\n=== 示例4:每3年一次,按年 ==="); | ||
| 144 | - List<PeriodResult> r4 = calculate("2025-01-01", "2035-06-01", "1/3", 3); | 149 | + System.out.println("\n=== 示例4:每2年1次(即:1/2)(730天),按年 ===2025-01-01 2030-01-01"); |
| 150 | + List<PeriodResult> r4 = calculate("2025-01-01", "2030-01-01", "1/2", 4); | ||
| 145 | r4.forEach(System.out::println); | 151 | r4.forEach(System.out::println); |
| 146 | - | ||
| 147 | - System.out.println("\n=== 示例5:每2天2次,按日 ==="); | ||
| 148 | - List<PeriodResult> r5 = calculate("2025-01-01", "2025-01-05", "2/2", 1); | 152 | + // 每2年 = 730天 |
| 153 | + // 2025-01-01 ~ 2025-12-26(+729d) | ||
| 154 | + // 2025-12-27 ~ 2027-12-21 | ||
| 155 | + // 2027-12-22 ~ 2029-12-16 | ||
| 156 | + // 2029-12-17 ~ 2030-01-01(最后一段) | ||
| 157 | + System.out.println("\n=== 示例5:每1年4次(即:4/1),按年(测试)=== 2023-09-15 2025-01-31"); | ||
| 158 | + List<PeriodResult> r5 = calculate("2023-09-15", "2025-01-31", "4/1", 4); | ||
| 149 | r5.forEach(System.out::println); | 159 | r5.forEach(System.out::println); |
| 150 | - | ||
| 151 | - System.out.println("\n=== 示例5:每2年1次,按年 ==="); | ||
| 152 | - List<PeriodResult> r6 = calculate("2025-01-01", "2028-01-05", "1/2", 4); | ||
| 153 | - r6.forEach(System.out::println); | ||
| 154 | } | 160 | } |
| 155 | -} | ||
| 156 | \ No newline at end of file | 161 | \ No newline at end of file |
| 162 | +} |
urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/api/constant/BpmCommonConstant.java
| @@ -8,6 +8,10 @@ package com.zteits.urbanops.module.workorder.api.constant; | @@ -8,6 +8,10 @@ package com.zteits.urbanops.module.workorder.api.constant; | ||
| 8 | */ | 8 | */ |
| 9 | public class BpmCommonConstant { | 9 | public class BpmCommonConstant { |
| 10 | /** | 10 | /** |
| 11 | + * 通用快速流程 | ||
| 12 | + */ | ||
| 13 | + public static final String COMMON_QUICK_PROCESS = "common_quick_process"; | ||
| 14 | + /** | ||
| 11 | * 园林巡检工单 流程业务key | 15 | * 园林巡检工单 流程业务key |
| 12 | */ | 16 | */ |
| 13 | public static final String BPM_GARDEN_INSPECT_WO = "garden_inspect_wo"; | 17 | public static final String BPM_GARDEN_INSPECT_WO = "garden_inspect_wo"; |
| @@ -31,5 +35,13 @@ public class BpmCommonConstant { | @@ -31,5 +35,13 @@ public class BpmCommonConstant { | ||
| 31 | * 园林远景图片类型 | 35 | * 园林远景图片类型 |
| 32 | */ | 36 | */ |
| 33 | public static final String GARDEN_INSPECT_WO_ATTACH3 = "03"; | 37 | public static final String GARDEN_INSPECT_WO_ATTACH3 = "03"; |
| 38 | + /** | ||
| 39 | + * 园林工单编号前缀 | ||
| 40 | + */ | ||
| 41 | + public static final String WORK_ORDER_PREFFIX_GARDEN = "GWO"; | ||
| 42 | + /** | ||
| 43 | + * 快速工单编号前缀 | ||
| 44 | + */ | ||
| 45 | + public static final String WORK_ORDER_PREFFIX_QUICK = "QWO"; | ||
| 34 | 46 | ||
| 35 | } | 47 | } |
urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/api/workorder/WorkOrderApi.java
0 → 100644
urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/api/workorder/WorkOrderApiImpl.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.workorder.api.workorder; | ||
| 2 | + | ||
| 3 | +import com.zteits.urbanops.module.workorder.api.constant.BpmCommonConstant; | ||
| 4 | +import org.springframework.stereotype.Service; | ||
| 5 | +import org.springframework.util.ObjectUtils; | ||
| 6 | + | ||
| 7 | +import java.time.LocalDateTime; | ||
| 8 | +import java.time.format.DateTimeFormatter; | ||
| 9 | +import java.util.concurrent.atomic.AtomicInteger; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * @author yanhuiqing | ||
| 13 | + * @version 1.0 | ||
| 14 | + * @description: 工单对外api | ||
| 15 | + * @date 2025/12/5 17:21 | ||
| 16 | + */ | ||
| 17 | +@Service | ||
| 18 | +public class WorkOrderApiImpl implements WorkOrderApi{ | ||
| 19 | + | ||
| 20 | + private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); | ||
| 21 | + private static final AtomicInteger counter = new AtomicInteger(1); | ||
| 22 | + | ||
| 23 | + @Override | ||
| 24 | + public String generateWONum(String prefix) { | ||
| 25 | + if (ObjectUtils.isEmpty(prefix)) { | ||
| 26 | + prefix = BpmCommonConstant.WORK_ORDER_PREFFIX_GARDEN; | ||
| 27 | + } | ||
| 28 | + String dateStr = LocalDateTime.now().format(DATE_FORMAT); | ||
| 29 | + int seqNum = counter.getAndIncrement(); | ||
| 30 | + if(seqNum>999){ | ||
| 31 | + synchronized (counter) { | ||
| 32 | + if (counter.intValue() > 999) { | ||
| 33 | + counter.set(1); | ||
| 34 | + } | ||
| 35 | + seqNum = counter.getAndIncrement(); | ||
| 36 | + } | ||
| 37 | + } | ||
| 38 | + return String.format("%s%03d_%s", prefix, seqNum,dateStr); | ||
| 39 | + } | ||
| 40 | +} |
urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/controller/app/garden/AppGardenWorkOrderController.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.workorder.controller.app.garden; | ||
| 2 | + | ||
| 3 | +import com.zteits.urbanops.framework.common.pojo.CommonResult; | ||
| 4 | +import com.zteits.urbanops.framework.common.pojo.PageResult; | ||
| 5 | +import com.zteits.urbanops.framework.common.util.object.BeanUtils; | ||
| 6 | +import com.zteits.urbanops.module.workorder.controller.admin.garden.vo.BpmGardenWorkOrderPageReqVO; | ||
| 7 | +import com.zteits.urbanops.module.workorder.controller.admin.garden.vo.BpmGardenWorkOrderRespVO; | ||
| 8 | +import com.zteits.urbanops.module.workorder.controller.app.garden.vo.AppGardenWorkOrderReqVO; | ||
| 9 | +import com.zteits.urbanops.module.workorder.dal.dataobject.garden.BpmGardenWorkOrderDO; | ||
| 10 | +import com.zteits.urbanops.module.workorder.service.garden.BpmGardenService; | ||
| 11 | +import io.swagger.v3.oas.annotations.Operation; | ||
| 12 | +import io.swagger.v3.oas.annotations.Parameter; | ||
| 13 | +import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 14 | +import jakarta.annotation.Resource; | ||
| 15 | +import jakarta.validation.Valid; | ||
| 16 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 17 | +import org.springframework.web.bind.annotation.*; | ||
| 18 | + | ||
| 19 | +import static com.zteits.urbanops.framework.common.pojo.CommonResult.success; | ||
| 20 | +import static com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | ||
| 21 | + | ||
| 22 | +/** | ||
| 23 | + * @author yanhuiqing | ||
| 24 | + * @version 1.0 | ||
| 25 | + * @description: app端 园林工单请求入口 | ||
| 26 | + * @date 2025/12/6 10:07 | ||
| 27 | + */ | ||
| 28 | +@Tag(name = "APP - 园林工单bpm") | ||
| 29 | +@RestController | ||
| 30 | +@RequestMapping("/app/garden/workorder") | ||
| 31 | +public class AppGardenWorkOrderController { | ||
| 32 | + @Resource | ||
| 33 | + private BpmGardenService gardenService; | ||
| 34 | + | ||
| 35 | + @PostMapping("/create") | ||
| 36 | + @Operation(summary = "app-创建工单信息") | ||
| 37 | + public CommonResult<Long> createMainInfo(@Valid @RequestBody AppGardenWorkOrderReqVO createReqVO) { | ||
| 38 | + return success(gardenService.createWorkOrder(createReqVO)); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + @PostMapping("/createQuick") | ||
| 42 | + @Operation(summary = "app-创建快速工单信息") | ||
| 43 | + public CommonResult<Long> createMainInfoQuick(@Valid @RequestBody AppGardenWorkOrderReqVO createReqVO) { | ||
| 44 | + return success(gardenService.createWorkOrderQuick(createReqVO)); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + @GetMapping("/get") | ||
| 48 | + @Operation(summary = "app-获得工单详情") | ||
| 49 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||
| 50 | + public CommonResult<BpmGardenWorkOrderRespVO> getGardenInspection(@RequestParam("id") Long id) { | ||
| 51 | + BpmGardenWorkOrderDO gardenInspection = gardenService.getWorkOrder(id); | ||
| 52 | + return success(BeanUtils.toBean(gardenInspection, BpmGardenWorkOrderRespVO.class)); | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + @GetMapping("/page") | ||
| 56 | + @Operation(summary = "app-获得园林巡检工单申请分页") | ||
| 57 | + public CommonResult<PageResult<BpmGardenWorkOrderRespVO>> getGardenInspectionPage(@Valid BpmGardenWorkOrderPageReqVO pageVO) { | ||
| 58 | + PageResult<BpmGardenWorkOrderDO> pageResult = gardenService.getGardenInspectionPage(getLoginUserId(), pageVO); | ||
| 59 | + return success(BeanUtils.toBean(pageResult, BpmGardenWorkOrderRespVO.class)); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | +} |
urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/controller/app/garden/vo/AppGardenWorkOrderReqVO.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.workorder.controller.app.garden.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import jakarta.validation.constraints.NotEmpty; | ||
| 5 | +import jakarta.validation.constraints.NotNull; | ||
| 6 | +import lombok.Data; | ||
| 7 | +import org.hibernate.validator.constraints.Length; | ||
| 8 | + | ||
| 9 | +import java.math.BigDecimal; | ||
| 10 | +import java.util.List; | ||
| 11 | +import java.util.Map; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * @author yanhuiqing | ||
| 15 | + * @version 1.0 | ||
| 16 | + * @description: app端请求参数 | ||
| 17 | + * @date 2025/12/6 10:17 | ||
| 18 | + */ | ||
| 19 | +@Schema(description = "APP-园林工单请求创建 Request VO") | ||
| 20 | +@Data | ||
| 21 | +public class AppGardenWorkOrderReqVO { | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + @Schema(description = "道路ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "21128") | ||
| 25 | + @NotNull(message = "道路ID不能为空") | ||
| 26 | + private Long roadId; | ||
| 27 | + | ||
| 28 | + @Schema(description = "问题图片", example = "9184") | ||
| 29 | + private List<String> imgs; | ||
| 30 | + | ||
| 31 | + @Schema(description = "处理完成照片", example = "9184") | ||
| 32 | + private List<String> longRangeImgList; | ||
| 33 | + | ||
| 34 | + @Schema(description = "工单描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "你说的对") | ||
| 35 | + @NotEmpty(message = "工单描述不能为空") | ||
| 36 | + @Length(max = 500) | ||
| 37 | + private String remark; | ||
| 38 | + | ||
| 39 | + @NotEmpty(message = "经纬度类型") | ||
| 40 | + @Schema(description = "经纬度类型: 1:国标; 2:百度;3:高德;4:腾讯", example = "2") | ||
| 41 | + private Integer latLonType; | ||
| 42 | + | ||
| 43 | + @Schema(description = "经度", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 44 | + @NotNull(message = "经度不能为空") | ||
| 45 | + private BigDecimal lat; | ||
| 46 | + | ||
| 47 | + @Schema(description = "维度", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 48 | + @NotNull(message = "维度不能为空") | ||
| 49 | + private BigDecimal lon; | ||
| 50 | + | ||
| 51 | + @Schema(description = "经纬度地址", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 52 | + @NotEmpty(message = "经纬度地址不能为空") | ||
| 53 | + private String lonLatAddress; | ||
| 54 | + | ||
| 55 | + @Schema(description = "紧急程度:1:特急;2:紧急;3:一般", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | ||
| 56 | + @NotNull(message = "紧急程度:1:特急;2:紧急;3:一般不能为空") | ||
| 57 | + private Integer pressingType; | ||
| 58 | + | ||
| 59 | + @Schema(description = "工单名称", example = "绿地卫生") | ||
| 60 | + private String orderName; | ||
| 61 | + | ||
| 62 | + @Schema(description = "来源ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 63 | + //@NotNull(message = "来源ID不能为空") | ||
| 64 | + private Integer sourceId; | ||
| 65 | + | ||
| 66 | + @Schema(description = "来源名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "园林") | ||
| 67 | + //@NotEmpty(message = "来源名称不能为空") | ||
| 68 | + private String sourceName; | ||
| 69 | + | ||
| 70 | + @Schema(description = "三方工单ID") | ||
| 71 | + private String thirdWorkNo; | ||
| 72 | + | ||
| 73 | + /* @Schema(description = "发起人自选审批人 Map", example = "{taskKey1: [1, 2]}") | ||
| 74 | + private Map<String, List<Long>> startUserSelectAssignees; | ||
| 75 | + | ||
| 76 | + @Schema(description = "是否需要养护人员修复,'0' 是,'1' 否") | ||
| 77 | + private String isYesOrNo;*/ | ||
| 78 | + | ||
| 79 | + | ||
| 80 | +} |
urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/service/garden/BpmGardenService.java
| @@ -3,6 +3,7 @@ package com.zteits.urbanops.module.workorder.service.garden; | @@ -3,6 +3,7 @@ package com.zteits.urbanops.module.workorder.service.garden; | ||
| 3 | import com.zteits.urbanops.framework.common.pojo.PageResult; | 3 | import com.zteits.urbanops.framework.common.pojo.PageResult; |
| 4 | import com.zteits.urbanops.module.workorder.controller.admin.garden.vo.BpmGardenWorkOrderCreateReqVo; | 4 | import com.zteits.urbanops.module.workorder.controller.admin.garden.vo.BpmGardenWorkOrderCreateReqVo; |
| 5 | import com.zteits.urbanops.module.workorder.controller.admin.garden.vo.BpmGardenWorkOrderPageReqVO; | 5 | import com.zteits.urbanops.module.workorder.controller.admin.garden.vo.BpmGardenWorkOrderPageReqVO; |
| 6 | +import com.zteits.urbanops.module.workorder.controller.app.garden.vo.AppGardenWorkOrderReqVO; | ||
| 6 | import com.zteits.urbanops.module.workorder.dal.dataobject.garden.BpmGardenWorkOrderDO; | 7 | import com.zteits.urbanops.module.workorder.dal.dataobject.garden.BpmGardenWorkOrderDO; |
| 7 | import jakarta.validation.Valid; | 8 | import jakarta.validation.Valid; |
| 8 | /** | 9 | /** |
| @@ -13,6 +14,12 @@ import jakarta.validation.Valid; | @@ -13,6 +14,12 @@ import jakarta.validation.Valid; | ||
| 13 | */ | 14 | */ |
| 14 | public interface BpmGardenService { | 15 | public interface BpmGardenService { |
| 15 | /** | 16 | /** |
| 17 | + * 园林工单申请 app service 接口 | ||
| 18 | + * @param createRequestVo | ||
| 19 | + * @return | ||
| 20 | + */ | ||
| 21 | + Long createWorkOrder(@Valid AppGardenWorkOrderReqVO createRequestVo); | ||
| 22 | + /** | ||
| 16 | * 园林工单申请 Service 接口 | 23 | * 园林工单申请 Service 接口 |
| 17 | * @param userId | 24 | * @param userId |
| 18 | * @param createRequestVo | 25 | * @param createRequestVo |
| @@ -43,4 +50,11 @@ public interface BpmGardenService { | @@ -43,4 +50,11 @@ public interface BpmGardenService { | ||
| 43 | * @return | 50 | * @return |
| 44 | */ | 51 | */ |
| 45 | PageResult<BpmGardenWorkOrderDO> getGardenInspectionPage(Long loginUserId, BpmGardenWorkOrderPageReqVO pageVO); | 52 | PageResult<BpmGardenWorkOrderDO> getGardenInspectionPage(Long loginUserId, BpmGardenWorkOrderPageReqVO pageVO); |
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * 快速流程 | ||
| 56 | + * @param createReqVO | ||
| 57 | + * @return | ||
| 58 | + */ | ||
| 59 | + Long createWorkOrderQuick(@Valid AppGardenWorkOrderReqVO createReqVO); | ||
| 46 | } | 60 | } |
urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/service/garden/BpmGardenServiceImpl.java
| @@ -4,13 +4,17 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | @@ -4,13 +4,17 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||
| 4 | import com.zteits.urbanops.framework.common.pojo.PageResult; | 4 | import com.zteits.urbanops.framework.common.pojo.PageResult; |
| 5 | import com.zteits.urbanops.framework.common.util.object.BeanUtils; | 5 | import com.zteits.urbanops.framework.common.util.object.BeanUtils; |
| 6 | import com.zteits.urbanops.framework.common.util.object.ObjectUtils; | 6 | import com.zteits.urbanops.framework.common.util.object.ObjectUtils; |
| 7 | +import com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils; | ||
| 7 | import com.zteits.urbanops.module.bpm.api.task.BpmProcessInstanceApi; | 8 | import com.zteits.urbanops.module.bpm.api.task.BpmProcessInstanceApi; |
| 8 | import com.zteits.urbanops.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; | 9 | import com.zteits.urbanops.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; |
| 9 | import com.zteits.urbanops.module.bpm.enums.task.BpmTaskStatusEnum; | 10 | import com.zteits.urbanops.module.bpm.enums.task.BpmTaskStatusEnum; |
| 11 | +import com.zteits.urbanops.module.bpm.service.task.BpmProcessInstanceService; | ||
| 10 | import com.zteits.urbanops.module.workorder.api.constant.BpmCommonConstant; | 12 | import com.zteits.urbanops.module.workorder.api.constant.BpmCommonConstant; |
| 13 | +import com.zteits.urbanops.module.workorder.api.workorder.WorkOrderApi; | ||
| 11 | import com.zteits.urbanops.module.workorder.controller.admin.garden.vo.BpmGardenWorkOrderCreateReqVo; | 14 | import com.zteits.urbanops.module.workorder.controller.admin.garden.vo.BpmGardenWorkOrderCreateReqVo; |
| 12 | import com.zteits.urbanops.module.workorder.controller.admin.garden.vo.BpmGardenWorkOrderPageReqVO; | 15 | import com.zteits.urbanops.module.workorder.controller.admin.garden.vo.BpmGardenWorkOrderPageReqVO; |
| 13 | import com.zteits.urbanops.module.workorder.controller.admin.maininfo.vo.MainInfoPageReqVO; | 16 | import com.zteits.urbanops.module.workorder.controller.admin.maininfo.vo.MainInfoPageReqVO; |
| 17 | +import com.zteits.urbanops.module.workorder.controller.app.garden.vo.AppGardenWorkOrderReqVO; | ||
| 14 | import com.zteits.urbanops.module.workorder.dal.dataobject.attachment.AttachmentDO; | 18 | import com.zteits.urbanops.module.workorder.dal.dataobject.attachment.AttachmentDO; |
| 15 | import com.zteits.urbanops.module.workorder.dal.dataobject.garden.BpmGardenWorkOrderDO; | 19 | import com.zteits.urbanops.module.workorder.dal.dataobject.garden.BpmGardenWorkOrderDO; |
| 16 | import com.zteits.urbanops.module.workorder.dal.dataobject.maininfo.MainInfoDO; | 20 | import com.zteits.urbanops.module.workorder.dal.dataobject.maininfo.MainInfoDO; |
| @@ -45,6 +49,74 @@ public class BpmGardenServiceImpl implements BpmGardenService{ | @@ -45,6 +49,74 @@ public class BpmGardenServiceImpl implements BpmGardenService{ | ||
| 45 | private MainInfoMapper workOrderMapper; | 49 | private MainInfoMapper workOrderMapper; |
| 46 | @Resource | 50 | @Resource |
| 47 | private BpmProcessInstanceApi processInstanceApi; | 51 | private BpmProcessInstanceApi processInstanceApi; |
| 52 | + @Resource | ||
| 53 | + private WorkOrderApi workOrderApi; | ||
| 54 | + | ||
| 55 | + @Override | ||
| 56 | + @Transactional(rollbackFor = Exception.class) | ||
| 57 | + public Long createWorkOrderQuick(AppGardenWorkOrderReqVO createRequestVo) { | ||
| 58 | + | ||
| 59 | + List<String> imgList = createRequestVo.getImgs(); | ||
| 60 | + //List<String> streetImgList = createRequestVo.getStreetImgList(); | ||
| 61 | + List<String> longRangeImgList = createRequestVo.getLongRangeImgList(); | ||
| 62 | + // 插入 工单 | ||
| 63 | + MainInfoDO workOrder = BeanUtils.toBean(createRequestVo, MainInfoDO.class) | ||
| 64 | + .setStatus(BpmTaskStatusEnum.RUNNING.getStatus()); | ||
| 65 | + //TODO 设置其它值 需从道路表获取 | ||
| 66 | + workOrder.setStreetId("test"); | ||
| 67 | + workOrder.setBuzStatus("t1");//需给出映射关系 | ||
| 68 | + workOrder.setCommitDate(LocalDateTime.now()); | ||
| 69 | + String workOrderNum = workOrderApi.generateWONum(BpmCommonConstant.WORK_ORDER_PREFFIX_QUICK); | ||
| 70 | + workOrder.setOrderNo(workOrderNum); | ||
| 71 | + workOrder.setOrderName("园林工单"); | ||
| 72 | + workOrder.setCompanyId(SecurityFrameworkUtils.getCompanyId()); | ||
| 73 | + workOrder.setBusiLine(SecurityFrameworkUtils.getBusiLine()); | ||
| 74 | + workOrderMapper.insert(workOrder); | ||
| 75 | + | ||
| 76 | + //附件插入 | ||
| 77 | + attachmentApend(imgList,null,longRangeImgList,workOrder); | ||
| 78 | + // 发起 BPM 流程 | ||
| 79 | + Map<String, Object> processInstanceVariables = new HashMap<>(); | ||
| 80 | + processInstanceVariables.put("workOrder", workOrder); | ||
| 81 | + processInstanceVariables.put("imgList", imgList); | ||
| 82 | + processInstanceVariables.put("longRangeImgList", longRangeImgList); | ||
| 83 | + String processInstanceId = processInstanceApi.createProcessInstance(SecurityFrameworkUtils.getLoginUserId(), | ||
| 84 | + new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(BpmCommonConstant.COMMON_QUICK_PROCESS) | ||
| 85 | + .setVariables(processInstanceVariables).setBusinessKey(String.valueOf(workOrder.getId()))); | ||
| 86 | + | ||
| 87 | + // 将工作流的编号,更新到 工单中 | ||
| 88 | + workOrderMapper.updateById(new MainInfoDO().setId(workOrder.getId()).setProcessInstanceId(processInstanceId)); | ||
| 89 | + return workOrder.getId(); | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + @Override | ||
| 93 | + @Transactional(rollbackFor = Exception.class) | ||
| 94 | + public Long createWorkOrder(AppGardenWorkOrderReqVO createRequestVo) { | ||
| 95 | + List<String> imgList = createRequestVo.getImgs(); | ||
| 96 | + //List<String> streetImgList = createRequestVo.getStreetImgList(); | ||
| 97 | + List<String> longRangeImgList = createRequestVo.getLongRangeImgList(); | ||
| 98 | + | ||
| 99 | + MainInfoDO workOrder = BeanUtils.toBean(createRequestVo, MainInfoDO.class) | ||
| 100 | + .setStatus(BpmTaskStatusEnum.NOT_START.getStatus()); | ||
| 101 | + //TODO 设置其它值 需从道路表获取 | ||
| 102 | + workOrder.setStreetId("test"); | ||
| 103 | + //workOrder.setBuzStatus("t1");//需给出映射关系 | ||
| 104 | + //workOrder.setCommitDate(LocalDateTime.now()); | ||
| 105 | + workOrder.setCompanyId(SecurityFrameworkUtils.getCompanyId()); | ||
| 106 | + workOrder.setBusiLine(SecurityFrameworkUtils.getBusiLine()); | ||
| 107 | + String workOrderNum = workOrderApi.generateWONum(BpmCommonConstant.WORK_ORDER_PREFFIX_GARDEN); | ||
| 108 | + workOrder.setOrderNo(workOrderNum); | ||
| 109 | + //workOrder.setOrderName("园林工单"); | ||
| 110 | + Long userId = com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId(); | ||
| 111 | + String nickname = com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils.getLoginUserNickname(); | ||
| 112 | + workOrder.setUserId(userId); | ||
| 113 | + workOrder.setUserName(nickname); | ||
| 114 | + workOrderMapper.insert(workOrder); | ||
| 115 | + //附件插入 | ||
| 116 | + attachmentApend(imgList,null,longRangeImgList,workOrder); | ||
| 117 | + return workOrder.getId(); | ||
| 118 | + } | ||
| 119 | + | ||
| 48 | @Override | 120 | @Override |
| 49 | @Transactional(rollbackFor = Exception.class) | 121 | @Transactional(rollbackFor = Exception.class) |
| 50 | public Long createWorkOrder(Long userId, BpmGardenWorkOrderCreateReqVo createRequestVo) { | 122 | public Long createWorkOrder(Long userId, BpmGardenWorkOrderCreateReqVo createRequestVo) { |
| @@ -59,6 +131,11 @@ public class BpmGardenServiceImpl implements BpmGardenService{ | @@ -59,6 +131,11 @@ public class BpmGardenServiceImpl implements BpmGardenService{ | ||
| 59 | workOrder.setStreetId("test"); | 131 | workOrder.setStreetId("test"); |
| 60 | workOrder.setBuzStatus("t1");//需给出映射关系 | 132 | workOrder.setBuzStatus("t1");//需给出映射关系 |
| 61 | workOrder.setCommitDate(LocalDateTime.now()); | 133 | workOrder.setCommitDate(LocalDateTime.now()); |
| 134 | + String workOrderNum = workOrderApi.generateWONum(BpmCommonConstant.WORK_ORDER_PREFFIX_GARDEN); | ||
| 135 | + workOrder.setOrderNo(workOrderNum); | ||
| 136 | + workOrder.setOrderName("园林工单"); | ||
| 137 | + workOrder.setCompanyId(SecurityFrameworkUtils.getCompanyId()); | ||
| 138 | + workOrder.setBusiLine(SecurityFrameworkUtils.getBusiLine()); | ||
| 62 | workOrderMapper.insert(workOrder); | 139 | workOrderMapper.insert(workOrder); |
| 63 | 140 | ||
| 64 | //附件插入 | 141 | //附件插入 |
| @@ -160,4 +237,6 @@ public class BpmGardenServiceImpl implements BpmGardenService{ | @@ -160,4 +237,6 @@ public class BpmGardenServiceImpl implements BpmGardenService{ | ||
| 160 | PageResult<BpmGardenWorkOrderDO> targetList = BeanUtils.toBean(pageList,BpmGardenWorkOrderDO.class); | 237 | PageResult<BpmGardenWorkOrderDO> targetList = BeanUtils.toBean(pageList,BpmGardenWorkOrderDO.class); |
| 161 | return targetList; | 238 | return targetList; |
| 162 | } | 239 | } |
| 240 | + | ||
| 241 | + | ||
| 163 | } | 242 | } |
urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/service/garden/listener/BomGardenWorkOrderStatusListener.java renamed to urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/service/garden/listener/BpmGardenWorkOrderStatusListener.java
| @@ -2,6 +2,7 @@ package com.zteits.urbanops.module.workorder.service.garden.listener; | @@ -2,6 +2,7 @@ package com.zteits.urbanops.module.workorder.service.garden.listener; | ||
| 2 | 2 | ||
| 3 | import com.zteits.urbanops.module.bpm.api.event.BpmProcessInstanceStatusEvent; | 3 | import com.zteits.urbanops.module.bpm.api.event.BpmProcessInstanceStatusEvent; |
| 4 | import com.zteits.urbanops.module.bpm.api.event.BpmProcessInstanceStatusEventListener; | 4 | import com.zteits.urbanops.module.bpm.api.event.BpmProcessInstanceStatusEventListener; |
| 5 | +import com.zteits.urbanops.module.workorder.api.constant.BpmCommonConstant; | ||
| 5 | import com.zteits.urbanops.module.workorder.service.garden.BpmGardenService; | 6 | import com.zteits.urbanops.module.workorder.service.garden.BpmGardenService; |
| 6 | import jakarta.annotation.Resource; | 7 | import jakarta.annotation.Resource; |
| 7 | import org.springframework.stereotype.Component; | 8 | import org.springframework.stereotype.Component; |
| @@ -13,13 +14,13 @@ import org.springframework.stereotype.Component; | @@ -13,13 +14,13 @@ import org.springframework.stereotype.Component; | ||
| 13 | * @date 2025/12/1 11:45 | 14 | * @date 2025/12/1 11:45 |
| 14 | */ | 15 | */ |
| 15 | @Component | 16 | @Component |
| 16 | -public class BomGardenWorkOrderStatusListener extends BpmProcessInstanceStatusEventListener { | 17 | +public class BpmGardenWorkOrderStatusListener extends BpmProcessInstanceStatusEventListener { |
| 17 | @Resource | 18 | @Resource |
| 18 | private BpmGardenService gardenService; | 19 | private BpmGardenService gardenService; |
| 19 | @Override | 20 | @Override |
| 20 | protected String getProcessDefinitionKey() { | 21 | protected String getProcessDefinitionKey() { |
| 21 | 22 | ||
| 22 | - return null; | 23 | + return BpmCommonConstant.BPM_GARDEN_INSPECT_WO; |
| 23 | } | 24 | } |
| 24 | 25 | ||
| 25 | @Override | 26 | @Override |
urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/service/garden/listener/BpmQuickProcessTaskAutoCompleteListener.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.workorder.service.garden.listener; | ||
| 2 | + | ||
| 3 | +import com.zteits.urbanops.module.bpm.api.event.BpmProcessInstanceStatusEvent; | ||
| 4 | +import com.zteits.urbanops.module.bpm.api.event.BpmProcessInstanceStatusEventListener; | ||
| 5 | +import com.zteits.urbanops.module.workorder.api.constant.BpmCommonConstant; | ||
| 6 | +import com.zteits.urbanops.module.workorder.service.garden.BpmGardenService; | ||
| 7 | +import jakarta.annotation.Resource; | ||
| 8 | +import org.flowable.common.engine.api.delegate.event.FlowableEngineEntityEvent; | ||
| 9 | +import org.springframework.stereotype.Component; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * @author yanhuiqing | ||
| 13 | + * @version 1.0 | ||
| 14 | + * @description: 快速处理流程的任务自动完成监听器 | ||
| 15 | + * @date 2025/12/6 14:00 | ||
| 16 | + */ | ||
| 17 | +@Component | ||
| 18 | +public class BpmQuickProcessTaskAutoCompleteListener extends BpmProcessInstanceStatusEventListener { | ||
| 19 | + @Resource | ||
| 20 | + private BpmGardenService gardenService; | ||
| 21 | + @Override | ||
| 22 | + protected String getProcessDefinitionKey() { | ||
| 23 | + return BpmCommonConstant.COMMON_QUICK_PROCESS; | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + @Override | ||
| 27 | + protected void onEvent(BpmProcessInstanceStatusEvent event) { | ||
| 28 | + gardenService.updateWorkOrderStatus(Long.parseLong(event.getBusinessKey()), event.getStatus()); | ||
| 29 | + | ||
| 30 | + } | ||
| 31 | +} |