Commit 487e54c6e58ce4534b8b4072f31cfa8c30739089
1 parent
ef51d789
增加单位积分查询功能
1、上报积分增加 2、退回积分扣减 3、查询列表增加当前派单任务积分字段
Showing
37 changed files
with
2373 additions
and
64 deletions
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/assigntasks/AssignTasksController.java
| 1 | package com.zteits.urbanops.module.garden.controller.admin.assigntasks; | 1 | package com.zteits.urbanops.module.garden.controller.admin.assigntasks; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollectionUtil; | 3 | import cn.hutool.core.collection.CollectionUtil; |
| 4 | -import cn.hutool.core.util.StrUtil; | ||
| 5 | import com.zteits.urbanops.framework.apilog.core.annotation.ApiAccessLog; | 4 | import com.zteits.urbanops.framework.apilog.core.annotation.ApiAccessLog; |
| 6 | import com.zteits.urbanops.framework.common.pojo.CommonResult; | 5 | import com.zteits.urbanops.framework.common.pojo.CommonResult; |
| 7 | import com.zteits.urbanops.framework.common.pojo.PageParam; | 6 | import com.zteits.urbanops.framework.common.pojo.PageParam; |
| 8 | import com.zteits.urbanops.framework.common.pojo.PageResult; | 7 | import com.zteits.urbanops.framework.common.pojo.PageResult; |
| 9 | import com.zteits.urbanops.framework.common.util.object.BeanUtils; | 8 | import com.zteits.urbanops.framework.common.util.object.BeanUtils; |
| 10 | import com.zteits.urbanops.framework.excel.core.util.ExcelUtils; | 9 | import com.zteits.urbanops.framework.excel.core.util.ExcelUtils; |
| 11 | -import com.zteits.urbanops.framework.translate.core.TranslateUtils; | ||
| 12 | import com.zteits.urbanops.module.garden.controller.admin.assigntasks.vo.AssignTasksPageReqVO; | 10 | import com.zteits.urbanops.module.garden.controller.admin.assigntasks.vo.AssignTasksPageReqVO; |
| 13 | import com.zteits.urbanops.module.garden.controller.admin.assigntasks.vo.AssignTasksRespVO; | 11 | import com.zteits.urbanops.module.garden.controller.admin.assigntasks.vo.AssignTasksRespVO; |
| 14 | import com.zteits.urbanops.module.garden.controller.admin.assigntasks.vo.AssignTasksSaveReqVO; | 12 | import com.zteits.urbanops.module.garden.controller.admin.assigntasks.vo.AssignTasksSaveReqVO; |
| 13 | +import com.zteits.urbanops.module.garden.controller.admin.unitintegraltotal.vo.UnitIntegralRespVO; | ||
| 14 | +import com.zteits.urbanops.module.garden.convert.AssignTaskConvert; | ||
| 15 | import com.zteits.urbanops.module.garden.dal.dataobject.assigntasks.AssignTasksDO; | 15 | import com.zteits.urbanops.module.garden.dal.dataobject.assigntasks.AssignTasksDO; |
| 16 | import com.zteits.urbanops.module.garden.dal.dataobject.assigntasksinfo.AssignTasksInfoDO; | 16 | import com.zteits.urbanops.module.garden.dal.dataobject.assigntasksinfo.AssignTasksInfoDO; |
| 17 | import com.zteits.urbanops.module.garden.service.assigntasks.AssignTasksService; | 17 | import com.zteits.urbanops.module.garden.service.assigntasks.AssignTasksService; |
| 18 | import com.zteits.urbanops.module.garden.service.assigntasksinfo.AssignTasksInfoService; | 18 | import com.zteits.urbanops.module.garden.service.assigntasksinfo.AssignTasksInfoService; |
| 19 | +import com.zteits.urbanops.module.garden.service.unitintegraltotal.UnitIntegralService; | ||
| 19 | import io.swagger.v3.oas.annotations.Operation; | 20 | import io.swagger.v3.oas.annotations.Operation; |
| 20 | import io.swagger.v3.oas.annotations.Parameter; | 21 | import io.swagger.v3.oas.annotations.Parameter; |
| 21 | import io.swagger.v3.oas.annotations.tags.Tag; | 22 | import io.swagger.v3.oas.annotations.tags.Tag; |
| @@ -46,6 +47,9 @@ public class AssignTasksController { | @@ -46,6 +47,9 @@ public class AssignTasksController { | ||
| 46 | @Resource | 47 | @Resource |
| 47 | private AssignTasksInfoService asignTasksInfoService; | 48 | private AssignTasksInfoService asignTasksInfoService; |
| 48 | 49 | ||
| 50 | + @Resource | ||
| 51 | + private UnitIntegralService unitIntegralService; | ||
| 52 | + | ||
| 49 | @PostMapping("/create") | 53 | @PostMapping("/create") |
| 50 | @Operation(summary = "创建派单任务主表(记录派单任务基本信息)") | 54 | @Operation(summary = "创建派单任务主表(记录派单任务基本信息)") |
| 51 | @PreAuthorize("@ss.hasPermission('garden:assign-tasks:create')") | 55 | @PreAuthorize("@ss.hasPermission('garden:assign-tasks:create')") |
| @@ -90,7 +94,13 @@ public class AssignTasksController { | @@ -90,7 +94,13 @@ public class AssignTasksController { | ||
| 90 | } | 94 | } |
| 91 | AssignTasksRespVO assignTasksRespVO = BeanUtils.toBean(assignTasks, AssignTasksRespVO.class); | 95 | AssignTasksRespVO assignTasksRespVO = BeanUtils.toBean(assignTasks, AssignTasksRespVO.class); |
| 92 | List<AssignTasksInfoDO> assignTaskInfoList = asignTasksInfoService.getAssignTasksInfos(assignTasks.getId()); | 96 | List<AssignTasksInfoDO> assignTaskInfoList = asignTasksInfoService.getAssignTasksInfos(assignTasks.getId()); |
| 93 | - assignTasksRespVO.setAssignTaskInfoList(assignTaskInfoList); | 97 | + //add by 20260307 convert 转换获取任务积分 |
| 98 | + List<Long> taskIds = assignTaskInfoList.stream() | ||
| 99 | + .map(AssignTasksInfoDO::getId) | ||
| 100 | + .distinct() // 去重重复的taskId | ||
| 101 | + .collect(Collectors.toList()); | ||
| 102 | + List<UnitIntegralRespVO> unitIntegralList = unitIntegralService.queryIntegralByRelatedTaskIds(taskIds); | ||
| 103 | + assignTasksRespVO.setAssignTaskInfoList(AssignTaskConvert.INSTANCE.buildTaskInfo(assignTaskInfoList, unitIntegralList)); | ||
| 94 | //获取单位集合 | 104 | //获取单位集合 |
| 95 | List<Long> companyIds = CollectionUtil.isEmpty(assignTaskInfoList) | 105 | List<Long> companyIds = CollectionUtil.isEmpty(assignTaskInfoList) |
| 96 | ? Collections.emptyList() | 106 | ? Collections.emptyList() |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/assigntasks/vo/AssignTasksRespVO.java
| @@ -3,8 +3,7 @@ package com.zteits.urbanops.module.garden.controller.admin.assigntasks.vo; | @@ -3,8 +3,7 @@ package com.zteits.urbanops.module.garden.controller.admin.assigntasks.vo; | ||
| 3 | import cn.idev.excel.annotation.ExcelIgnoreUnannotated; | 3 | import cn.idev.excel.annotation.ExcelIgnoreUnannotated; |
| 4 | import cn.idev.excel.annotation.ExcelProperty; | 4 | import cn.idev.excel.annotation.ExcelProperty; |
| 5 | import com.fasterxml.jackson.annotation.JsonFormat; | 5 | import com.fasterxml.jackson.annotation.JsonFormat; |
| 6 | -import com.fhs.core.trans.vo.VO; | ||
| 7 | -import com.zteits.urbanops.module.garden.dal.dataobject.assigntasksinfo.AssignTasksInfoDO; | 6 | +import com.zteits.urbanops.module.garden.controller.admin.assigntasksinfo.vo.AssignTasksInfoRespVO; |
| 8 | import io.swagger.v3.oas.annotations.media.Schema; | 7 | import io.swagger.v3.oas.annotations.media.Schema; |
| 9 | import lombok.Data; | 8 | import lombok.Data; |
| 10 | 9 | ||
| @@ -64,7 +63,7 @@ public class AssignTasksRespVO { | @@ -64,7 +63,7 @@ public class AssignTasksRespVO { | ||
| 64 | private String updater; | 63 | private String updater; |
| 65 | 64 | ||
| 66 | private List<Long> companyIds; | 65 | private List<Long> companyIds; |
| 67 | - private List<AssignTasksInfoDO> assignTaskInfoList; | 66 | + private List<AssignTasksInfoRespVO> assignTaskInfoList; |
| 68 | 67 | ||
| 69 | public void setParentFinish(Integer parentFinish) { | 68 | public void setParentFinish(Integer parentFinish) { |
| 70 | this.parentFinish = parentFinish; | 69 | this.parentFinish = parentFinish; |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/assigntasksinfo/AssignTasksInfoController.java
| @@ -10,11 +10,13 @@ import com.zteits.urbanops.module.garden.controller.admin.assigntasksinfo.vo.Ass | @@ -10,11 +10,13 @@ import com.zteits.urbanops.module.garden.controller.admin.assigntasksinfo.vo.Ass | ||
| 10 | import com.zteits.urbanops.module.garden.controller.admin.assigntasksinfo.vo.AssignTasksInfoRespVO; | 10 | import com.zteits.urbanops.module.garden.controller.admin.assigntasksinfo.vo.AssignTasksInfoRespVO; |
| 11 | import com.zteits.urbanops.module.garden.controller.admin.assigntasksinfo.vo.AssignTasksInfoSaveReqVO; | 11 | import com.zteits.urbanops.module.garden.controller.admin.assigntasksinfo.vo.AssignTasksInfoSaveReqVO; |
| 12 | import com.zteits.urbanops.module.garden.controller.admin.assigntasksinfo.vo.AssignTasksInfoUpdReqVO; | 12 | import com.zteits.urbanops.module.garden.controller.admin.assigntasksinfo.vo.AssignTasksInfoUpdReqVO; |
| 13 | +import com.zteits.urbanops.module.garden.controller.admin.unitintegraltotal.vo.UnitIntegralRespVO; | ||
| 13 | import com.zteits.urbanops.module.garden.convert.AssignTaskConvert; | 14 | import com.zteits.urbanops.module.garden.convert.AssignTaskConvert; |
| 14 | import com.zteits.urbanops.module.garden.dal.dataobject.assigntasks.AssignTasksDO; | 15 | import com.zteits.urbanops.module.garden.dal.dataobject.assigntasks.AssignTasksDO; |
| 15 | import com.zteits.urbanops.module.garden.dal.dataobject.assigntasksinfo.AssignTasksInfoDO; | 16 | import com.zteits.urbanops.module.garden.dal.dataobject.assigntasksinfo.AssignTasksInfoDO; |
| 16 | import com.zteits.urbanops.module.garden.service.assigntasks.AssignTasksService; | 17 | import com.zteits.urbanops.module.garden.service.assigntasks.AssignTasksService; |
| 17 | import com.zteits.urbanops.module.garden.service.assigntasksinfo.AssignTasksInfoService; | 18 | import com.zteits.urbanops.module.garden.service.assigntasksinfo.AssignTasksInfoService; |
| 19 | +import com.zteits.urbanops.module.garden.service.unitintegraltotal.UnitIntegralService; | ||
| 18 | import io.swagger.v3.oas.annotations.Operation; | 20 | import io.swagger.v3.oas.annotations.Operation; |
| 19 | import io.swagger.v3.oas.annotations.Parameter; | 21 | import io.swagger.v3.oas.annotations.Parameter; |
| 20 | import io.swagger.v3.oas.annotations.tags.Tag; | 22 | import io.swagger.v3.oas.annotations.tags.Tag; |
| @@ -26,7 +28,9 @@ import org.springframework.validation.annotation.Validated; | @@ -26,7 +28,9 @@ import org.springframework.validation.annotation.Validated; | ||
| 26 | import org.springframework.web.bind.annotation.*; | 28 | import org.springframework.web.bind.annotation.*; |
| 27 | 29 | ||
| 28 | import java.io.IOException; | 30 | import java.io.IOException; |
| 31 | +import java.util.ArrayList; | ||
| 29 | import java.util.List; | 32 | import java.util.List; |
| 33 | +import java.util.stream.Collectors; | ||
| 30 | 34 | ||
| 31 | import static com.zteits.urbanops.framework.apilog.core.enums.OperateTypeEnum.EXPORT; | 35 | import static com.zteits.urbanops.framework.apilog.core.enums.OperateTypeEnum.EXPORT; |
| 32 | import static com.zteits.urbanops.framework.common.pojo.CommonResult.success; | 36 | import static com.zteits.urbanops.framework.common.pojo.CommonResult.success; |
| @@ -42,6 +46,8 @@ public class AssignTasksInfoController { | @@ -42,6 +46,8 @@ public class AssignTasksInfoController { | ||
| 42 | private AssignTasksInfoService assignTasksInfoService; | 46 | private AssignTasksInfoService assignTasksInfoService; |
| 43 | @Resource | 47 | @Resource |
| 44 | private AssignTasksService assignTasksService; | 48 | private AssignTasksService assignTasksService; |
| 49 | + @Resource | ||
| 50 | + private UnitIntegralService unitIntegralService; | ||
| 45 | 51 | ||
| 46 | @PostMapping("/create") | 52 | @PostMapping("/create") |
| 47 | @Operation(summary = "创建派单任务-单位关联表(记录单位接收派单后的执行详情)") | 53 | @Operation(summary = "创建派单任务-单位关联表(记录单位接收派单后的执行详情)") |
| @@ -83,7 +89,11 @@ public class AssignTasksInfoController { | @@ -83,7 +89,11 @@ public class AssignTasksInfoController { | ||
| 83 | public CommonResult<AssignTasksInfoRespVO> getAssignTasksInfo(@RequestParam("id") Long id) { | 89 | public CommonResult<AssignTasksInfoRespVO> getAssignTasksInfo(@RequestParam("id") Long id) { |
| 84 | AssignTasksInfoDO assignTasksInfo = assignTasksInfoService.getAssignTasksInfo(id); | 90 | AssignTasksInfoDO assignTasksInfo = assignTasksInfoService.getAssignTasksInfo(id); |
| 85 | AssignTasksDO tasksDO = assignTasksService.getAssignTasks(assignTasksInfo.getTaskId()); | 91 | AssignTasksDO tasksDO = assignTasksService.getAssignTasks(assignTasksInfo.getTaskId()); |
| 86 | - return success(AssignTaskConvert.INSTANCE.buildTask(assignTasksInfo, tasksDO)); | 92 | + //add by 20260307 convert 转换获取任务积分 |
| 93 | + List<Long> taskIds = new ArrayList<>(); | ||
| 94 | + taskIds.add(assignTasksInfo.getId()); | ||
| 95 | + List<UnitIntegralRespVO> unitIntegralList = unitIntegralService.queryIntegralByRelatedTaskIds(taskIds); | ||
| 96 | + return success(AssignTaskConvert.INSTANCE.buildTask(assignTasksInfo, tasksDO, unitIntegralList)); | ||
| 87 | //return success(BeanUtils.toBean(assignTasksInfo, AssignTasksInfoRespVO.class)); | 97 | //return success(BeanUtils.toBean(assignTasksInfo, AssignTasksInfoRespVO.class)); |
| 88 | } | 98 | } |
| 89 | 99 | ||
| @@ -93,26 +103,16 @@ public class AssignTasksInfoController { | @@ -93,26 +103,16 @@ public class AssignTasksInfoController { | ||
| 93 | public CommonResult<PageResult<AssignTasksInfoRespVO>> getAssignTasksInfoPage(@Valid AssignTasksInfoPageReqVO pageReqVO) { | 103 | public CommonResult<PageResult<AssignTasksInfoRespVO>> getAssignTasksInfoPage(@Valid AssignTasksInfoPageReqVO pageReqVO) { |
| 94 | pageReqVO.setCompanyId(getCompanyId()); | 104 | pageReqVO.setCompanyId(getCompanyId()); |
| 95 | PageResult<AssignTasksInfoDO> pageResult = assignTasksInfoService.getAssignTasksInfoPage(pageReqVO); | 105 | PageResult<AssignTasksInfoDO> pageResult = assignTasksInfoService.getAssignTasksInfoPage(pageReqVO); |
| 96 | -// if (pageResult == null || pageResult.getList() == null || pageResult.getList().isEmpty()) { | ||
| 97 | -// return success(BeanUtils.toBean(pageResult, AssignTasksInfoRespVO.class)); | ||
| 98 | -// } | ||
| 99 | -// List<Long> assignIds = pageResult.getList().stream() | ||
| 100 | -// .map(AssignTasksInfoDO::getTaskId) | ||
| 101 | -// .distinct() | ||
| 102 | -// .collect(Collectors.toList()); | ||
| 103 | -// List<AssignTasksDO> taskList = assignTasksService.getAssignTasksList(assignIds); | ||
| 104 | -// if (CollectionUtils.isNotEmpty(taskList)) { | ||
| 105 | -// Map<Long, AssignTasksDO> taskMap = taskList.stream() | ||
| 106 | -// .collect(Collectors.toMap( | ||
| 107 | -// AssignTasksDO::getId, // Key:任务ID | ||
| 108 | -// task -> task, | ||
| 109 | -// (existing, replacement) -> replacement | ||
| 110 | -// )); | ||
| 111 | -// return success(AssignTaskConvert.INSTANCE.buildTaskPage(pageResult, taskMap)); | ||
| 112 | -// } else { | ||
| 113 | -// return CommonResult.error(BAD_REQUEST.getCode(), "派单数据异常"); | ||
| 114 | -// } | ||
| 115 | - return success(BeanUtils.toBean(pageResult, AssignTasksInfoRespVO.class)); | 106 | + if (pageResult == null || pageResult.getList() == null || pageResult.getList().isEmpty()) { |
| 107 | + return success(BeanUtils.toBean(pageResult, AssignTasksInfoRespVO.class)); | ||
| 108 | + } | ||
| 109 | + //add by 20260307 convert 转换获取任务积分 | ||
| 110 | + List<Long> taskIds = pageResult.getList().stream() | ||
| 111 | + .map(AssignTasksInfoDO::getId) | ||
| 112 | + .distinct() // 去重重复的taskId | ||
| 113 | + .collect(Collectors.toList()); | ||
| 114 | + List<UnitIntegralRespVO> unitIntegralList = unitIntegralService.queryIntegralByRelatedTaskIds(taskIds); | ||
| 115 | + return success(AssignTaskConvert.INSTANCE.buildTaskPage(pageResult, unitIntegralList)); | ||
| 116 | } | 116 | } |
| 117 | @GetMapping("/list") | 117 | @GetMapping("/list") |
| 118 | @Operation(summary = "获得派单任务-单位关联表(记录单位接收派单后的执行详情)分页") | 118 | @Operation(summary = "获得派单任务-单位关联表(记录单位接收派单后的执行详情)分页") |
| @@ -120,26 +120,13 @@ public class AssignTasksInfoController { | @@ -120,26 +120,13 @@ public class AssignTasksInfoController { | ||
| 120 | public CommonResult<PageResult<AssignTasksInfoRespVO>> list(@Valid AssignTasksInfoPageReqVO pageReqVO) { | 120 | public CommonResult<PageResult<AssignTasksInfoRespVO>> list(@Valid AssignTasksInfoPageReqVO pageReqVO) { |
| 121 | pageReqVO.setCompanyId(getCompanyId()); | 121 | pageReqVO.setCompanyId(getCompanyId()); |
| 122 | PageResult<AssignTasksInfoDO> pageResult = assignTasksInfoService.getAssignTasksInfoPage(pageReqVO); | 122 | PageResult<AssignTasksInfoDO> pageResult = assignTasksInfoService.getAssignTasksInfoPage(pageReqVO); |
| 123 | -// if (pageResult == null || pageResult.getList() == null || pageResult.getList().isEmpty()) { | ||
| 124 | -// return success(BeanUtils.toBean(pageResult, AssignTasksInfoRespVO.class)); | ||
| 125 | -// } | ||
| 126 | -// List<Long> assignIds = pageResult.getList().stream() | ||
| 127 | -// .map(AssignTasksInfoDO::getTaskId) | ||
| 128 | -// .distinct() | ||
| 129 | -// .collect(Collectors.toList()); | ||
| 130 | -// List<AssignTasksDO> taskList = assignTasksService.getAssignTasksList(assignIds); | ||
| 131 | -// if (CollectionUtils.isNotEmpty(taskList)) { | ||
| 132 | -// Map<Long, AssignTasksDO> taskMap = taskList.stream() | ||
| 133 | -// .collect(Collectors.toMap( | ||
| 134 | -// AssignTasksDO::getId, // Key:任务ID | ||
| 135 | -// task -> task, | ||
| 136 | -// (existing, replacement) -> replacement | ||
| 137 | -// )); | ||
| 138 | -// return success(AssignTaskConvert.INSTANCE.buildTaskPage(pageResult, taskMap)); | ||
| 139 | -// } else { | ||
| 140 | -// return CommonResult.error(BAD_REQUEST.getCode(), "派单数据异常"); | ||
| 141 | -// } | ||
| 142 | - return success(BeanUtils.toBean(pageResult, AssignTasksInfoRespVO.class)); | 123 | + //add by 20260307 convert 转换获取任务积分 |
| 124 | + List<Long> taskIds = pageResult.getList().stream() | ||
| 125 | + .map(AssignTasksInfoDO::getId) | ||
| 126 | + .distinct() // 去重重复的taskId | ||
| 127 | + .collect(Collectors.toList()); | ||
| 128 | + List<UnitIntegralRespVO> unitIntegralList = unitIntegralService.queryIntegralByRelatedTaskIds(taskIds); | ||
| 129 | + return success(AssignTaskConvert.INSTANCE.buildTaskPage(pageResult, unitIntegralList)); | ||
| 143 | } | 130 | } |
| 144 | @GetMapping("/export-excel") | 131 | @GetMapping("/export-excel") |
| 145 | @Operation(summary = "导出派单任务-单位关联表(记录单位接收派单后的执行详情) Excel") | 132 | @Operation(summary = "导出派单任务-单位关联表(记录单位接收派单后的执行详情) Excel") |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/assigntasksinfo/vo/AssignTasksInfoRespVO.java
| @@ -139,4 +139,9 @@ public class AssignTasksInfoRespVO { | @@ -139,4 +139,9 @@ public class AssignTasksInfoRespVO { | ||
| 139 | @TableField(typeHandler = JacksonTypeHandler.class) | 139 | @TableField(typeHandler = JacksonTypeHandler.class) |
| 140 | private List templateFile; | 140 | private List templateFile; |
| 141 | 141 | ||
| 142 | + | ||
| 143 | + /*当前积分*/ | ||
| 144 | + private Integer totalIntegral; | ||
| 145 | + | ||
| 146 | + | ||
| 142 | } | 147 | } |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/unitintegraladd/UnitIntegralAddController.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.unitintegraladd; | ||
| 2 | + | ||
| 3 | +import org.springframework.web.bind.annotation.*; | ||
| 4 | +import jakarta.annotation.Resource; | ||
| 5 | +import org.springframework.validation.annotation.Validated; | ||
| 6 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 7 | +import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 8 | +import io.swagger.v3.oas.annotations.Parameter; | ||
| 9 | +import io.swagger.v3.oas.annotations.Operation; | ||
| 10 | + | ||
| 11 | +import jakarta.validation.constraints.*; | ||
| 12 | +import jakarta.validation.*; | ||
| 13 | +import jakarta.servlet.http.*; | ||
| 14 | +import java.util.*; | ||
| 15 | +import java.io.IOException; | ||
| 16 | + | ||
| 17 | +import com.zteits.urbanops.framework.common.pojo.PageParam; | ||
| 18 | +import com.zteits.urbanops.framework.common.pojo.PageResult; | ||
| 19 | +import com.zteits.urbanops.framework.common.pojo.CommonResult; | ||
| 20 | +import com.zteits.urbanops.framework.common.util.object.BeanUtils; | ||
| 21 | +import static com.zteits.urbanops.framework.common.pojo.CommonResult.success; | ||
| 22 | + | ||
| 23 | +import com.zteits.urbanops.framework.excel.core.util.ExcelUtils; | ||
| 24 | + | ||
| 25 | +import com.zteits.urbanops.framework.apilog.core.annotation.ApiAccessLog; | ||
| 26 | +import static com.zteits.urbanops.framework.apilog.core.enums.OperateTypeEnum.*; | ||
| 27 | + | ||
| 28 | +import com.zteits.urbanops.module.garden.controller.admin.unitintegraladd.vo.*; | ||
| 29 | +import com.zteits.urbanops.module.garden.dal.dataobject.unitintegraladd.UnitIntegralAddDO; | ||
| 30 | +import com.zteits.urbanops.module.garden.service.unitintegraladd.UnitIntegralAddService; | ||
| 31 | + | ||
| 32 | +@Tag(name = "管理后台 - 积分增加记录") | ||
| 33 | +@RestController | ||
| 34 | +@RequestMapping("/garden/unit-integral-add") | ||
| 35 | +@Validated | ||
| 36 | +public class UnitIntegralAddController { | ||
| 37 | + | ||
| 38 | + @Resource | ||
| 39 | + private UnitIntegralAddService unitIntegralAddService; | ||
| 40 | + | ||
| 41 | + @PostMapping("/create") | ||
| 42 | + @Operation(summary = "创建积分增加记录") | ||
| 43 | + @PreAuthorize("@ss.hasPermission('garden:unit-integral-add:create')") | ||
| 44 | + public CommonResult<Long> createUnitIntegralAdd(@Valid @RequestBody UnitIntegralAddSaveReqVO createReqVO) { | ||
| 45 | + return success(unitIntegralAddService.createUnitIntegralAdd(createReqVO)); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + @PutMapping("/update") | ||
| 49 | + @Operation(summary = "更新积分增加记录") | ||
| 50 | + @PreAuthorize("@ss.hasPermission('garden:unit-integral-add:update')") | ||
| 51 | + public CommonResult<Boolean> updateUnitIntegralAdd(@Valid @RequestBody UnitIntegralAddSaveReqVO updateReqVO) { | ||
| 52 | + unitIntegralAddService.updateUnitIntegralAdd(updateReqVO); | ||
| 53 | + return success(true); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + @DeleteMapping("/delete") | ||
| 57 | + @Operation(summary = "删除积分增加记录") | ||
| 58 | + @Parameter(name = "id", description = "编号", required = true) | ||
| 59 | + @PreAuthorize("@ss.hasPermission('garden:unit-integral-add:delete')") | ||
| 60 | + public CommonResult<Boolean> deleteUnitIntegralAdd(@RequestParam("id") Long id) { | ||
| 61 | + unitIntegralAddService.deleteUnitIntegralAdd(id); | ||
| 62 | + return success(true); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + @DeleteMapping("/delete-list") | ||
| 66 | + @Parameter(name = "ids", description = "编号", required = true) | ||
| 67 | + @Operation(summary = "批量删除积分增加记录") | ||
| 68 | + @PreAuthorize("@ss.hasPermission('garden:unit-integral-add:delete')") | ||
| 69 | + public CommonResult<Boolean> deleteUnitIntegralAddList(@RequestParam("ids") List<Long> ids) { | ||
| 70 | + unitIntegralAddService.deleteUnitIntegralAddListByIds(ids); | ||
| 71 | + return success(true); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + @GetMapping("/get") | ||
| 75 | + @Operation(summary = "获得积分增加记录") | ||
| 76 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||
| 77 | + @PreAuthorize("@ss.hasPermission('garden:unit-integral-add:query')") | ||
| 78 | + public CommonResult<UnitIntegralAddRespVO> getUnitIntegralAdd(@RequestParam("id") Long id) { | ||
| 79 | + UnitIntegralAddDO unitIntegralAdd = unitIntegralAddService.getUnitIntegralAdd(id); | ||
| 80 | + return success(BeanUtils.toBean(unitIntegralAdd, UnitIntegralAddRespVO.class)); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + @GetMapping("/page") | ||
| 84 | + @Operation(summary = "获得积分增加记录分页") | ||
| 85 | + @PreAuthorize("@ss.hasPermission('garden:unit-integral-add:query')") | ||
| 86 | + public CommonResult<PageResult<UnitIntegralAddRespVO>> getUnitIntegralAddPage(@Valid UnitIntegralAddPageReqVO pageReqVO) { | ||
| 87 | + PageResult<UnitIntegralAddDO> pageResult = unitIntegralAddService.getUnitIntegralAddPage(pageReqVO); | ||
| 88 | + return success(BeanUtils.toBean(pageResult, UnitIntegralAddRespVO.class)); | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + @GetMapping("/export-excel") | ||
| 92 | + @Operation(summary = "导出积分增加记录 Excel") | ||
| 93 | + @PreAuthorize("@ss.hasPermission('garden:unit-integral-add:export')") | ||
| 94 | + @ApiAccessLog(operateType = EXPORT) | ||
| 95 | + public void exportUnitIntegralAddExcel(@Valid UnitIntegralAddPageReqVO pageReqVO, | ||
| 96 | + HttpServletResponse response) throws IOException { | ||
| 97 | + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | ||
| 98 | + List<UnitIntegralAddDO> list = unitIntegralAddService.getUnitIntegralAddPage(pageReqVO).getList(); | ||
| 99 | + // 导出 Excel | ||
| 100 | + ExcelUtils.write(response, "积分增加记录.xls", "数据", UnitIntegralAddRespVO.class, | ||
| 101 | + BeanUtils.toBean(list, UnitIntegralAddRespVO.class)); | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | +} | ||
| 0 | \ No newline at end of file | 105 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/unitintegraladd/vo/UnitIntegralAddPageReqVO.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.unitintegraladd.vo; | ||
| 2 | + | ||
| 3 | +import lombok.*; | ||
| 4 | +import java.util.*; | ||
| 5 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 6 | +import com.zteits.urbanops.framework.common.pojo.PageParam; | ||
| 7 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 8 | +import java.time.LocalDateTime; | ||
| 9 | + | ||
| 10 | +import static com.zteits.urbanops.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 11 | + | ||
| 12 | +@Schema(description = "管理后台 - 积分增加记录分页 Request VO") | ||
| 13 | +@Data | ||
| 14 | +public class UnitIntegralAddPageReqVO extends PageParam { | ||
| 15 | + | ||
| 16 | + @Schema(description = "来源类型 01:派单", example = "1") | ||
| 17 | + private String sourceType; | ||
| 18 | + | ||
| 19 | + @Schema(description = "单位类型:01:公司 02:班组 03:个人", example = "1") | ||
| 20 | + private String unitType; | ||
| 21 | + | ||
| 22 | + @Schema(description = "单位ID(部门表 id)", example = "26490") | ||
| 23 | + private String unitId; | ||
| 24 | + | ||
| 25 | + @Schema(description = "单位名称(冗余,避免联表查询)", example = "芋艿") | ||
| 26 | + private String unitName; | ||
| 27 | + | ||
| 28 | + @Schema(description = "关联ID(关联业务表主键)", example = "24947") | ||
| 29 | + private Long relatedTaskId; | ||
| 30 | + | ||
| 31 | + @Schema(description = "业务名称(冗余)", example = "张三") | ||
| 32 | + private String relatedTaskName; | ||
| 33 | + | ||
| 34 | + @Schema(description = "本次增加积分(正数)") | ||
| 35 | + private Integer addIntegral; | ||
| 36 | + | ||
| 37 | + @Schema(description = "增加原因(如:到期前上报奖励、到期后上报奖励等)", example = "不好") | ||
| 38 | + private String addReason; | ||
| 39 | + | ||
| 40 | + @Schema(description = "增加前总积分(对账用)") | ||
| 41 | + private Integer beforeIntegral; | ||
| 42 | + | ||
| 43 | + @Schema(description = "增加后总积分(对账用)") | ||
| 44 | + private Integer afterIntegral; | ||
| 45 | + | ||
| 46 | + @Schema(description = "工单号") | ||
| 47 | + private String workNo; | ||
| 48 | + | ||
| 49 | + @Schema(description = "备注(补充积分增加的特殊说明)", example = "你说的对") | ||
| 50 | + private String remark; | ||
| 51 | + | ||
| 52 | + @Schema(description = "积分增加操作时间") | ||
| 53 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 54 | + private LocalDateTime[] createTime; | ||
| 55 | + | ||
| 56 | +} | ||
| 0 | \ No newline at end of file | 57 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/unitintegraladd/vo/UnitIntegralAddRespVO.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.unitintegraladd.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.*; | ||
| 5 | +import java.util.*; | ||
| 6 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 7 | +import java.time.LocalDateTime; | ||
| 8 | +import cn.idev.excel.annotation.*; | ||
| 9 | + | ||
| 10 | +@Schema(description = "管理后台 - 积分增加记录 Response VO") | ||
| 11 | +@Data | ||
| 12 | +@ExcelIgnoreUnannotated | ||
| 13 | +public class UnitIntegralAddRespVO { | ||
| 14 | + | ||
| 15 | + @Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "12471") | ||
| 16 | + @ExcelProperty("主键ID") | ||
| 17 | + private Long id; | ||
| 18 | + | ||
| 19 | + @Schema(description = "来源类型 01:派单", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 20 | + @ExcelProperty("来源类型 01:派单") | ||
| 21 | + private String sourceType; | ||
| 22 | + | ||
| 23 | + @Schema(description = "单位类型:01:公司 02:班组 03:个人", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 24 | + @ExcelProperty("单位类型:01:公司 02:班组 03:个人") | ||
| 25 | + private String unitType; | ||
| 26 | + | ||
| 27 | + @Schema(description = "单位ID(部门表 id)", requiredMode = Schema.RequiredMode.REQUIRED, example = "26490") | ||
| 28 | + @ExcelProperty("单位ID(部门表 id)") | ||
| 29 | + private String unitId; | ||
| 30 | + | ||
| 31 | + @Schema(description = "单位名称(冗余,避免联表查询)", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | ||
| 32 | + @ExcelProperty("单位名称(冗余,避免联表查询)") | ||
| 33 | + private String unitName; | ||
| 34 | + | ||
| 35 | + @Schema(description = "关联ID(关联业务表主键)", requiredMode = Schema.RequiredMode.REQUIRED, example = "24947") | ||
| 36 | + @ExcelProperty("关联ID(关联业务表主键)") | ||
| 37 | + private Long relatedTaskId; | ||
| 38 | + | ||
| 39 | + @Schema(description = "业务名称(冗余)", example = "张三") | ||
| 40 | + @ExcelProperty("业务名称(冗余)") | ||
| 41 | + private String relatedTaskName; | ||
| 42 | + | ||
| 43 | + @Schema(description = "本次增加积分(正数)", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 44 | + @ExcelProperty("本次增加积分(正数)") | ||
| 45 | + private Integer addIntegral; | ||
| 46 | + | ||
| 47 | + @Schema(description = "增加原因(如:到期前上报奖励、到期后上报奖励等)", requiredMode = Schema.RequiredMode.REQUIRED, example = "不好") | ||
| 48 | + @ExcelProperty("增加原因(如:到期前上报奖励、到期后上报奖励等)") | ||
| 49 | + private String addReason; | ||
| 50 | + | ||
| 51 | + @Schema(description = "增加前总积分(对账用)") | ||
| 52 | + @ExcelProperty("增加前总积分(对账用)") | ||
| 53 | + private Integer beforeIntegral; | ||
| 54 | + | ||
| 55 | + @Schema(description = "增加后总积分(对账用)") | ||
| 56 | + @ExcelProperty("增加后总积分(对账用)") | ||
| 57 | + private Integer afterIntegral; | ||
| 58 | + | ||
| 59 | + @Schema(description = "工单号") | ||
| 60 | + @ExcelProperty("工单号") | ||
| 61 | + private String workNo; | ||
| 62 | + | ||
| 63 | + @Schema(description = "备注(补充积分增加的特殊说明)", example = "你说的对") | ||
| 64 | + @ExcelProperty("备注(补充积分增加的特殊说明)") | ||
| 65 | + private String remark; | ||
| 66 | + | ||
| 67 | + @Schema(description = "积分增加操作时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 68 | + @ExcelProperty("积分增加操作时间") | ||
| 69 | + private LocalDateTime createTime; | ||
| 70 | + | ||
| 71 | +} | ||
| 0 | \ No newline at end of file | 72 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/unitintegraladd/vo/UnitIntegralAddSaveReqVO.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.unitintegraladd.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.*; | ||
| 5 | +import java.util.*; | ||
| 6 | +import jakarta.validation.constraints.*; | ||
| 7 | + | ||
| 8 | +@Schema(description = "管理后台 - 积分增加记录新增/修改 Request VO") | ||
| 9 | +@Data | ||
| 10 | +public class UnitIntegralAddSaveReqVO { | ||
| 11 | + | ||
| 12 | + @Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "12471") | ||
| 13 | + private Long id; | ||
| 14 | + | ||
| 15 | + @Schema(description = "来源类型 01:派单", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 16 | + @NotEmpty(message = "来源类型 01:派单不能为空") | ||
| 17 | + private String sourceType; | ||
| 18 | + | ||
| 19 | + @Schema(description = "单位类型:01:公司 02:班组 03:个人", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 20 | + @NotEmpty(message = "单位类型:01:公司 02:班组 03:个人不能为空") | ||
| 21 | + private String unitType; | ||
| 22 | + | ||
| 23 | + @Schema(description = "单位ID(部门表 id)", requiredMode = Schema.RequiredMode.REQUIRED, example = "26490") | ||
| 24 | + @NotEmpty(message = "单位ID(部门表 id)不能为空") | ||
| 25 | + private String unitId; | ||
| 26 | + | ||
| 27 | + @Schema(description = "单位名称(冗余,避免联表查询)", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | ||
| 28 | + @NotEmpty(message = "单位名称(冗余,避免联表查询)不能为空") | ||
| 29 | + private String unitName; | ||
| 30 | + | ||
| 31 | + @Schema(description = "关联ID(关联业务表主键)", requiredMode = Schema.RequiredMode.REQUIRED, example = "24947") | ||
| 32 | + @NotNull(message = "关联ID(关联业务表主键)不能为空") | ||
| 33 | + private Long relatedTaskId; | ||
| 34 | + | ||
| 35 | + @Schema(description = "业务名称(冗余)", example = "张三") | ||
| 36 | + private String relatedTaskName; | ||
| 37 | + | ||
| 38 | + @Schema(description = "本次增加积分(正数)", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 39 | + @NotNull(message = "本次增加积分(正数)不能为空") | ||
| 40 | + private Integer addIntegral; | ||
| 41 | + | ||
| 42 | + @Schema(description = "增加原因(如:到期前上报奖励、到期后上报奖励等)", requiredMode = Schema.RequiredMode.REQUIRED, example = "不好") | ||
| 43 | + @NotEmpty(message = "增加原因(如:到期前上报奖励、到期后上报奖励等)不能为空") | ||
| 44 | + private String addReason; | ||
| 45 | + | ||
| 46 | + @Schema(description = "增加前总积分(对账用)") | ||
| 47 | + private Integer beforeIntegral; | ||
| 48 | + | ||
| 49 | + @Schema(description = "增加后总积分(对账用)") | ||
| 50 | + private Integer afterIntegral; | ||
| 51 | + | ||
| 52 | + @Schema(description = "工单号") | ||
| 53 | + private String workNo; | ||
| 54 | + | ||
| 55 | + @Schema(description = "备注(补充积分增加的特殊说明)", example = "你说的对") | ||
| 56 | + private String remark; | ||
| 57 | + | ||
| 58 | +} | ||
| 0 | \ No newline at end of file | 59 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/unitintegralsub/UnitIntegralSubController.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.unitintegralsub; | ||
| 2 | + | ||
| 3 | +import org.springframework.web.bind.annotation.*; | ||
| 4 | +import jakarta.annotation.Resource; | ||
| 5 | +import org.springframework.validation.annotation.Validated; | ||
| 6 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 7 | +import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 8 | +import io.swagger.v3.oas.annotations.Parameter; | ||
| 9 | +import io.swagger.v3.oas.annotations.Operation; | ||
| 10 | + | ||
| 11 | +import jakarta.validation.constraints.*; | ||
| 12 | +import jakarta.validation.*; | ||
| 13 | +import jakarta.servlet.http.*; | ||
| 14 | +import java.util.*; | ||
| 15 | +import java.io.IOException; | ||
| 16 | + | ||
| 17 | +import com.zteits.urbanops.framework.common.pojo.PageParam; | ||
| 18 | +import com.zteits.urbanops.framework.common.pojo.PageResult; | ||
| 19 | +import com.zteits.urbanops.framework.common.pojo.CommonResult; | ||
| 20 | +import com.zteits.urbanops.framework.common.util.object.BeanUtils; | ||
| 21 | +import static com.zteits.urbanops.framework.common.pojo.CommonResult.success; | ||
| 22 | + | ||
| 23 | +import com.zteits.urbanops.framework.excel.core.util.ExcelUtils; | ||
| 24 | + | ||
| 25 | +import com.zteits.urbanops.framework.apilog.core.annotation.ApiAccessLog; | ||
| 26 | +import static com.zteits.urbanops.framework.apilog.core.enums.OperateTypeEnum.*; | ||
| 27 | + | ||
| 28 | +import com.zteits.urbanops.module.garden.controller.admin.unitintegralsub.vo.*; | ||
| 29 | +import com.zteits.urbanops.module.garden.dal.dataobject.unitintegralsub.UnitIntegralSubDO; | ||
| 30 | +import com.zteits.urbanops.module.garden.service.unitintegralsub.UnitIntegralSubService; | ||
| 31 | + | ||
| 32 | +@Tag(name = "管理后台 - 积分扣减记录") | ||
| 33 | +@RestController | ||
| 34 | +@RequestMapping("/garden/unit-integral-sub") | ||
| 35 | +@Validated | ||
| 36 | +public class UnitIntegralSubController { | ||
| 37 | + | ||
| 38 | + @Resource | ||
| 39 | + private UnitIntegralSubService unitIntegralSubService; | ||
| 40 | + | ||
| 41 | + @PostMapping("/create") | ||
| 42 | + @Operation(summary = "创建积分扣减记录") | ||
| 43 | + @PreAuthorize("@ss.hasPermission('garden:unit-integral-sub:create')") | ||
| 44 | + public CommonResult<Long> createUnitIntegralSub(@Valid @RequestBody UnitIntegralSubSaveReqVO createReqVO) { | ||
| 45 | + return success(unitIntegralSubService.createUnitIntegralSub(createReqVO)); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + @PutMapping("/update") | ||
| 49 | + @Operation(summary = "更新积分扣减记录") | ||
| 50 | + @PreAuthorize("@ss.hasPermission('garden:unit-integral-sub:update')") | ||
| 51 | + public CommonResult<Boolean> updateUnitIntegralSub(@Valid @RequestBody UnitIntegralSubSaveReqVO updateReqVO) { | ||
| 52 | + unitIntegralSubService.updateUnitIntegralSub(updateReqVO); | ||
| 53 | + return success(true); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + @DeleteMapping("/delete") | ||
| 57 | + @Operation(summary = "删除积分扣减记录") | ||
| 58 | + @Parameter(name = "id", description = "编号", required = true) | ||
| 59 | + @PreAuthorize("@ss.hasPermission('garden:unit-integral-sub:delete')") | ||
| 60 | + public CommonResult<Boolean> deleteUnitIntegralSub(@RequestParam("id") Long id) { | ||
| 61 | + unitIntegralSubService.deleteUnitIntegralSub(id); | ||
| 62 | + return success(true); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + @DeleteMapping("/delete-list") | ||
| 66 | + @Parameter(name = "ids", description = "编号", required = true) | ||
| 67 | + @Operation(summary = "批量删除积分扣减记录") | ||
| 68 | + @PreAuthorize("@ss.hasPermission('garden:unit-integral-sub:delete')") | ||
| 69 | + public CommonResult<Boolean> deleteUnitIntegralSubList(@RequestParam("ids") List<Long> ids) { | ||
| 70 | + unitIntegralSubService.deleteUnitIntegralSubListByIds(ids); | ||
| 71 | + return success(true); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + @GetMapping("/get") | ||
| 75 | + @Operation(summary = "获得积分扣减记录") | ||
| 76 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||
| 77 | + @PreAuthorize("@ss.hasPermission('garden:unit-integral-sub:query')") | ||
| 78 | + public CommonResult<UnitIntegralSubRespVO> getUnitIntegralSub(@RequestParam("id") Long id) { | ||
| 79 | + UnitIntegralSubDO unitIntegralSub = unitIntegralSubService.getUnitIntegralSub(id); | ||
| 80 | + return success(BeanUtils.toBean(unitIntegralSub, UnitIntegralSubRespVO.class)); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + @GetMapping("/page") | ||
| 84 | + @Operation(summary = "获得积分扣减记录分页") | ||
| 85 | + @PreAuthorize("@ss.hasPermission('garden:unit-integral-sub:query')") | ||
| 86 | + public CommonResult<PageResult<UnitIntegralSubRespVO>> getUnitIntegralSubPage(@Valid UnitIntegralSubPageReqVO pageReqVO) { | ||
| 87 | + PageResult<UnitIntegralSubDO> pageResult = unitIntegralSubService.getUnitIntegralSubPage(pageReqVO); | ||
| 88 | + return success(BeanUtils.toBean(pageResult, UnitIntegralSubRespVO.class)); | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + @GetMapping("/export-excel") | ||
| 92 | + @Operation(summary = "导出积分扣减记录 Excel") | ||
| 93 | + @PreAuthorize("@ss.hasPermission('garden:unit-integral-sub:export')") | ||
| 94 | + @ApiAccessLog(operateType = EXPORT) | ||
| 95 | + public void exportUnitIntegralSubExcel(@Valid UnitIntegralSubPageReqVO pageReqVO, | ||
| 96 | + HttpServletResponse response) throws IOException { | ||
| 97 | + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | ||
| 98 | + List<UnitIntegralSubDO> list = unitIntegralSubService.getUnitIntegralSubPage(pageReqVO).getList(); | ||
| 99 | + // 导出 Excel | ||
| 100 | + ExcelUtils.write(response, "积分扣减记录.xls", "数据", UnitIntegralSubRespVO.class, | ||
| 101 | + BeanUtils.toBean(list, UnitIntegralSubRespVO.class)); | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | +} | ||
| 0 | \ No newline at end of file | 105 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/unitintegralsub/vo/UnitIntegralSubPageReqVO.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.unitintegralsub.vo; | ||
| 2 | + | ||
| 3 | +import lombok.*; | ||
| 4 | +import java.util.*; | ||
| 5 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 6 | +import com.zteits.urbanops.framework.common.pojo.PageParam; | ||
| 7 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 8 | +import java.time.LocalDateTime; | ||
| 9 | + | ||
| 10 | +import static com.zteits.urbanops.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 11 | + | ||
| 12 | +@Schema(description = "管理后台 - 积分扣减记录分页 Request VO") | ||
| 13 | +@Data | ||
| 14 | +public class UnitIntegralSubPageReqVO extends PageParam { | ||
| 15 | + | ||
| 16 | + @Schema(description = "来源类型 01:派单", example = "1") | ||
| 17 | + private String sourceType; | ||
| 18 | + | ||
| 19 | + @Schema(description = "单位类型:01:公司 02:班组 03:个人", example = "1") | ||
| 20 | + private String unitType; | ||
| 21 | + | ||
| 22 | + @Schema(description = "单位ID(部门表 id)", example = "13254") | ||
| 23 | + private String unitId; | ||
| 24 | + | ||
| 25 | + @Schema(description = "单位名称(冗余,避免联表查询)", example = "芋艿") | ||
| 26 | + private String unitName; | ||
| 27 | + | ||
| 28 | + @Schema(description = "关联任务ID(外键,关联业务表主键)", example = "21804") | ||
| 29 | + private Long relatedTaskId; | ||
| 30 | + | ||
| 31 | + @Schema(description = "业务名称(冗余)", example = "芋艿") | ||
| 32 | + private String relatedTaskName; | ||
| 33 | + | ||
| 34 | + @Schema(description = "本次扣减积分(正数,存储扣减数值)") | ||
| 35 | + private Integer subIntegral; | ||
| 36 | + | ||
| 37 | + @Schema(description = "扣减原因(如:任务打回等)", example = "不香") | ||
| 38 | + private String subReason; | ||
| 39 | + | ||
| 40 | + @Schema(description = "扣减前总积分(对账用)") | ||
| 41 | + private Integer beforeIntegral; | ||
| 42 | + | ||
| 43 | + @Schema(description = "扣减后总积分(对账用)") | ||
| 44 | + private Integer afterIntegral; | ||
| 45 | + | ||
| 46 | + @Schema(description = "工单号") | ||
| 47 | + private String workNo; | ||
| 48 | + | ||
| 49 | + @Schema(description = "备注(补充扣减的特殊说明)", example = "随便") | ||
| 50 | + private String remark; | ||
| 51 | + | ||
| 52 | + @Schema(description = "积分扣减操作时间") | ||
| 53 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 54 | + private LocalDateTime[] createTime; | ||
| 55 | + | ||
| 56 | +} | ||
| 0 | \ No newline at end of file | 57 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/unitintegralsub/vo/UnitIntegralSubRespVO.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.unitintegralsub.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.*; | ||
| 5 | +import java.util.*; | ||
| 6 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 7 | +import java.time.LocalDateTime; | ||
| 8 | +import cn.idev.excel.annotation.*; | ||
| 9 | + | ||
| 10 | +@Schema(description = "管理后台 - 积分扣减记录 Response VO") | ||
| 11 | +@Data | ||
| 12 | +@ExcelIgnoreUnannotated | ||
| 13 | +public class UnitIntegralSubRespVO { | ||
| 14 | + | ||
| 15 | + @Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "499") | ||
| 16 | + @ExcelProperty("主键ID") | ||
| 17 | + private Long id; | ||
| 18 | + | ||
| 19 | + @Schema(description = "来源类型 01:派单", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 20 | + @ExcelProperty("来源类型 01:派单") | ||
| 21 | + private String sourceType; | ||
| 22 | + | ||
| 23 | + @Schema(description = "单位类型:01:公司 02:班组 03:个人", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 24 | + @ExcelProperty("单位类型:01:公司 02:班组 03:个人") | ||
| 25 | + private String unitType; | ||
| 26 | + | ||
| 27 | + @Schema(description = "单位ID(部门表 id)", requiredMode = Schema.RequiredMode.REQUIRED, example = "13254") | ||
| 28 | + @ExcelProperty("单位ID(部门表 id)") | ||
| 29 | + private String unitId; | ||
| 30 | + | ||
| 31 | + @Schema(description = "单位名称(冗余,避免联表查询)", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | ||
| 32 | + @ExcelProperty("单位名称(冗余,避免联表查询)") | ||
| 33 | + private String unitName; | ||
| 34 | + | ||
| 35 | + @Schema(description = "关联任务ID(外键,关联业务表主键)", requiredMode = Schema.RequiredMode.REQUIRED, example = "21804") | ||
| 36 | + @ExcelProperty("关联任务ID(外键,关联业务表主键)") | ||
| 37 | + private Long relatedTaskId; | ||
| 38 | + | ||
| 39 | + @Schema(description = "业务名称(冗余)", example = "芋艿") | ||
| 40 | + @ExcelProperty("业务名称(冗余)") | ||
| 41 | + private String relatedTaskName; | ||
| 42 | + | ||
| 43 | + @Schema(description = "本次扣减积分(正数,存储扣减数值)", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 44 | + @ExcelProperty("本次扣减积分(正数,存储扣减数值)") | ||
| 45 | + private Integer subIntegral; | ||
| 46 | + | ||
| 47 | + @Schema(description = "扣减原因(如:任务打回等)", requiredMode = Schema.RequiredMode.REQUIRED, example = "不香") | ||
| 48 | + @ExcelProperty("扣减原因(如:任务打回等)") | ||
| 49 | + private String subReason; | ||
| 50 | + | ||
| 51 | + @Schema(description = "扣减前总积分(对账用)") | ||
| 52 | + @ExcelProperty("扣减前总积分(对账用)") | ||
| 53 | + private Integer beforeIntegral; | ||
| 54 | + | ||
| 55 | + @Schema(description = "扣减后总积分(对账用)") | ||
| 56 | + @ExcelProperty("扣减后总积分(对账用)") | ||
| 57 | + private Integer afterIntegral; | ||
| 58 | + | ||
| 59 | + @Schema(description = "工单号") | ||
| 60 | + @ExcelProperty("工单号") | ||
| 61 | + private String workNo; | ||
| 62 | + | ||
| 63 | + @Schema(description = "备注(补充扣减的特殊说明)", example = "随便") | ||
| 64 | + @ExcelProperty("备注(补充扣减的特殊说明)") | ||
| 65 | + private String remark; | ||
| 66 | + | ||
| 67 | + @Schema(description = "积分扣减操作时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 68 | + @ExcelProperty("积分扣减操作时间") | ||
| 69 | + private LocalDateTime createTime; | ||
| 70 | + | ||
| 71 | +} | ||
| 0 | \ No newline at end of file | 72 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/unitintegralsub/vo/UnitIntegralSubSaveReqVO.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.unitintegralsub.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.*; | ||
| 5 | +import java.util.*; | ||
| 6 | +import jakarta.validation.constraints.*; | ||
| 7 | + | ||
| 8 | +@Schema(description = "管理后台 - 积分扣减记录新增/修改 Request VO") | ||
| 9 | +@Data | ||
| 10 | +public class UnitIntegralSubSaveReqVO { | ||
| 11 | + | ||
| 12 | + @Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "499") | ||
| 13 | + private Long id; | ||
| 14 | + | ||
| 15 | + @Schema(description = "来源类型 01:派单", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 16 | + @NotEmpty(message = "来源类型 01:派单不能为空") | ||
| 17 | + private String sourceType; | ||
| 18 | + | ||
| 19 | + @Schema(description = "单位类型:01:公司 02:班组 03:个人", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 20 | + @NotEmpty(message = "单位类型:01:公司 02:班组 03:个人不能为空") | ||
| 21 | + private String unitType; | ||
| 22 | + | ||
| 23 | + @Schema(description = "单位ID(部门表 id)", requiredMode = Schema.RequiredMode.REQUIRED, example = "13254") | ||
| 24 | + @NotEmpty(message = "单位ID(部门表 id)不能为空") | ||
| 25 | + private String unitId; | ||
| 26 | + | ||
| 27 | + @Schema(description = "单位名称(冗余,避免联表查询)", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | ||
| 28 | + @NotEmpty(message = "单位名称(冗余,避免联表查询)不能为空") | ||
| 29 | + private String unitName; | ||
| 30 | + | ||
| 31 | + @Schema(description = "关联任务ID(外键,关联业务表主键)", requiredMode = Schema.RequiredMode.REQUIRED, example = "21804") | ||
| 32 | + @NotNull(message = "关联任务ID(外键,关联业务表主键)不能为空") | ||
| 33 | + private Long relatedTaskId; | ||
| 34 | + | ||
| 35 | + @Schema(description = "业务名称(冗余)", example = "芋艿") | ||
| 36 | + private String relatedTaskName; | ||
| 37 | + | ||
| 38 | + @Schema(description = "本次扣减积分(正数,存储扣减数值)", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 39 | + @NotNull(message = "本次扣减积分(正数,存储扣减数值)不能为空") | ||
| 40 | + private Integer subIntegral; | ||
| 41 | + | ||
| 42 | + @Schema(description = "扣减原因(如:任务打回等)", requiredMode = Schema.RequiredMode.REQUIRED, example = "不香") | ||
| 43 | + @NotEmpty(message = "扣减原因(如:任务打回等)不能为空") | ||
| 44 | + private String subReason; | ||
| 45 | + | ||
| 46 | + @Schema(description = "扣减前总积分(对账用)") | ||
| 47 | + private Integer beforeIntegral; | ||
| 48 | + | ||
| 49 | + @Schema(description = "扣减后总积分(对账用)") | ||
| 50 | + private Integer afterIntegral; | ||
| 51 | + | ||
| 52 | + @Schema(description = "工单号") | ||
| 53 | + private String workNo; | ||
| 54 | + | ||
| 55 | + @Schema(description = "备注(补充扣减的特殊说明)", example = "随便") | ||
| 56 | + private String remark; | ||
| 57 | + | ||
| 58 | +} | ||
| 0 | \ No newline at end of file | 59 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/unitintegraltotal/UnitIntegralTotalController.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.unitintegraltotal; | ||
| 2 | + | ||
| 3 | +import com.zteits.urbanops.module.garden.service.unitintegraltotal.UnitIntegralService; | ||
| 4 | +import org.springframework.web.bind.annotation.*; | ||
| 5 | +import jakarta.annotation.Resource; | ||
| 6 | +import org.springframework.validation.annotation.Validated; | ||
| 7 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 8 | +import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 9 | +import io.swagger.v3.oas.annotations.Parameter; | ||
| 10 | +import io.swagger.v3.oas.annotations.Operation; | ||
| 11 | + | ||
| 12 | +import jakarta.validation.constraints.*; | ||
| 13 | +import jakarta.validation.*; | ||
| 14 | +import jakarta.servlet.http.*; | ||
| 15 | +import java.util.*; | ||
| 16 | +import java.io.IOException; | ||
| 17 | + | ||
| 18 | +import com.zteits.urbanops.framework.common.pojo.PageParam; | ||
| 19 | +import com.zteits.urbanops.framework.common.pojo.PageResult; | ||
| 20 | +import com.zteits.urbanops.framework.common.pojo.CommonResult; | ||
| 21 | +import com.zteits.urbanops.framework.common.util.object.BeanUtils; | ||
| 22 | +import static com.zteits.urbanops.framework.common.pojo.CommonResult.success; | ||
| 23 | + | ||
| 24 | +import com.zteits.urbanops.framework.excel.core.util.ExcelUtils; | ||
| 25 | + | ||
| 26 | +import com.zteits.urbanops.framework.apilog.core.annotation.ApiAccessLog; | ||
| 27 | +import static com.zteits.urbanops.framework.apilog.core.enums.OperateTypeEnum.*; | ||
| 28 | + | ||
| 29 | +import com.zteits.urbanops.module.garden.controller.admin.unitintegraltotal.vo.*; | ||
| 30 | +import com.zteits.urbanops.module.garden.dal.dataobject.unitintegraltotal.UnitIntegralTotalDO; | ||
| 31 | +import com.zteits.urbanops.module.garden.service.unitintegraltotal.UnitIntegralTotalService; | ||
| 32 | + | ||
| 33 | +@Tag(name = "管理后台 - 单位积分累计") | ||
| 34 | +@RestController | ||
| 35 | +@RequestMapping("/garden/unit-integral-total") | ||
| 36 | +@Validated | ||
| 37 | +public class UnitIntegralTotalController { | ||
| 38 | + | ||
| 39 | + @Resource | ||
| 40 | + private UnitIntegralTotalService unitIntegralTotalService; | ||
| 41 | + | ||
| 42 | + @Resource | ||
| 43 | + private UnitIntegralService unitIntegralService; | ||
| 44 | + | ||
| 45 | + @PostMapping("/create") | ||
| 46 | + @Operation(summary = "创建单位积分累计") | ||
| 47 | + @PreAuthorize("@ss.hasPermission('garden:unit-integral-total:create')") | ||
| 48 | + public CommonResult<Long> createUnitIntegralTotal(@Valid @RequestBody UnitIntegralTotalSaveReqVO createReqVO) { | ||
| 49 | + return success(unitIntegralTotalService.createUnitIntegralTotal(createReqVO)); | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + @PutMapping("/update") | ||
| 53 | + @Operation(summary = "更新单位积分累计") | ||
| 54 | + @PreAuthorize("@ss.hasPermission('garden:unit-integral-total:update')") | ||
| 55 | + public CommonResult<Boolean> updateUnitIntegralTotal(@Valid @RequestBody UnitIntegralTotalSaveReqVO updateReqVO) { | ||
| 56 | + unitIntegralTotalService.updateUnitIntegralTotal(updateReqVO); | ||
| 57 | + return success(true); | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + @DeleteMapping("/delete") | ||
| 61 | + @Operation(summary = "删除单位积分累计") | ||
| 62 | + @Parameter(name = "id", description = "编号", required = true) | ||
| 63 | + @PreAuthorize("@ss.hasPermission('garden:unit-integral-total:delete')") | ||
| 64 | + public CommonResult<Boolean> deleteUnitIntegralTotal(@RequestParam("id") Long id) { | ||
| 65 | + unitIntegralTotalService.deleteUnitIntegralTotal(id); | ||
| 66 | + return success(true); | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + @DeleteMapping("/delete-list") | ||
| 70 | + @Parameter(name = "ids", description = "编号", required = true) | ||
| 71 | + @Operation(summary = "批量删除单位积分累计") | ||
| 72 | + @PreAuthorize("@ss.hasPermission('garden:unit-integral-total:delete')") | ||
| 73 | + public CommonResult<Boolean> deleteUnitIntegralTotalList(@RequestParam("ids") List<Long> ids) { | ||
| 74 | + unitIntegralTotalService.deleteUnitIntegralTotalListByIds(ids); | ||
| 75 | + return success(true); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + @GetMapping("/get") | ||
| 79 | + @Operation(summary = "获得单位积分累计") | ||
| 80 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||
| 81 | + @PreAuthorize("@ss.hasPermission('garden:unit-integral-total:query')") | ||
| 82 | + public CommonResult<UnitIntegralTotalRespVO> getUnitIntegralTotal(@RequestParam("id") Long id) { | ||
| 83 | + UnitIntegralTotalDO unitIntegralTotal = unitIntegralTotalService.getUnitIntegralTotal(id); | ||
| 84 | + return success(BeanUtils.toBean(unitIntegralTotal, UnitIntegralTotalRespVO.class)); | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + @GetMapping("/page") | ||
| 88 | + @Operation(summary = "获得单位积分累计分页") | ||
| 89 | + @PreAuthorize("@ss.hasPermission('garden:unit-integral-total:query')") | ||
| 90 | + public CommonResult<PageResult<UnitIntegralTotalRespVO>> getUnitIntegralTotalPage(@Valid UnitIntegralTotalPageReqVO pageReqVO) { | ||
| 91 | + PageResult<UnitIntegralTotalDO> pageResult = unitIntegralTotalService.getUnitIntegralTotalPage(pageReqVO); | ||
| 92 | + return success(BeanUtils.toBean(pageResult, UnitIntegralTotalRespVO.class)); | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + @GetMapping("/export-excel") | ||
| 96 | + @Operation(summary = "导出单位积分累计 Excel") | ||
| 97 | + @PreAuthorize("@ss.hasPermission('garden:unit-integral-total:export')") | ||
| 98 | + @ApiAccessLog(operateType = EXPORT) | ||
| 99 | + public void exportUnitIntegralTotalExcel(@Valid UnitIntegralTotalPageReqVO pageReqVO, | ||
| 100 | + HttpServletResponse response) throws IOException { | ||
| 101 | + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | ||
| 102 | + List<UnitIntegralTotalDO> list = unitIntegralTotalService.getUnitIntegralTotalPage(pageReqVO).getList(); | ||
| 103 | + // 导出 Excel | ||
| 104 | + ExcelUtils.write(response, "单位积分累计.xls", "数据", UnitIntegralTotalRespVO.class, | ||
| 105 | + BeanUtils.toBean(list, UnitIntegralTotalRespVO.class)); | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + @PostMapping ("/unitIntegralCreate") | ||
| 109 | + public void testCreate() { | ||
| 110 | + unitIntegralService.createUnitIntegral("01", "200", "测试"); | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + @PostMapping ("/unitIntegralAdd") | ||
| 114 | + public void testAdd() { | ||
| 115 | + UnitIntegralSaveReqVO updateReqVO = new UnitIntegralSaveReqVO(); | ||
| 116 | + updateReqVO.setTotalIntegral(100); | ||
| 117 | + updateReqVO.setUnitType("01"); | ||
| 118 | + updateReqVO.setUnitId("100"); | ||
| 119 | + updateReqVO.setUnitName("西城园林"); | ||
| 120 | + updateReqVO.setSourceType("01"); | ||
| 121 | + updateReqVO.setReason("测试"); | ||
| 122 | + updateReqVO.setRelatedTaskId(11111111111L); | ||
| 123 | + updateReqVO.setRelatedTaskName("任务派发"); | ||
| 124 | + | ||
| 125 | + unitIntegralService.addUnitIntegral(updateReqVO); | ||
| 126 | + } | ||
| 127 | + @PostMapping ("/unitIntegralSub") | ||
| 128 | + public void testSub() { | ||
| 129 | + UnitIntegralSaveReqVO updateReqVO = new UnitIntegralSaveReqVO(); | ||
| 130 | + updateReqVO.setTotalIntegral(100); | ||
| 131 | + updateReqVO.setUnitType("01"); | ||
| 132 | + updateReqVO.setUnitId("100"); | ||
| 133 | + updateReqVO.setUnitName("西城园林"); | ||
| 134 | + updateReqVO.setSourceType("01"); | ||
| 135 | + updateReqVO.setReason("测试"); | ||
| 136 | + updateReqVO.setRelatedTaskId(11111111112L); | ||
| 137 | + updateReqVO.setRelatedTaskName("任务派发"); | ||
| 138 | + | ||
| 139 | + unitIntegralService.subUnitIntegral(updateReqVO); | ||
| 140 | + } | ||
| 141 | +} |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/unitintegraltotal/vo/UnitIntegralRespVO.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.unitintegraltotal.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.Data; | ||
| 5 | + | ||
| 6 | +@Schema(description = "管理后台 - 单位积分累计新增/修改 Request VO") | ||
| 7 | +@Data | ||
| 8 | +public class UnitIntegralRespVO { | ||
| 9 | + @Schema(description = "来源类型 01:派单", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 10 | + private String sourceType; | ||
| 11 | + | ||
| 12 | + @Schema(description = "关联ID(关联业务表主键)", requiredMode = Schema.RequiredMode.REQUIRED, example = "24947") | ||
| 13 | + private Long relatedTaskId; | ||
| 14 | + | ||
| 15 | + @Schema(description = "当前总积分") | ||
| 16 | + private Integer totalIntegral; | ||
| 17 | + | ||
| 18 | + | ||
| 19 | +} |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/unitintegraltotal/vo/UnitIntegralSaveReqVO.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.unitintegraltotal.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.apache.commons.lang3.StringUtils; | ||
| 8 | + | ||
| 9 | +import java.time.LocalDate; | ||
| 10 | +import java.time.format.DateTimeFormatter; | ||
| 11 | + | ||
| 12 | +@Schema(description = "管理后台 - 单位积分累计新增/修改 Request VO") | ||
| 13 | +@Data | ||
| 14 | +public class UnitIntegralSaveReqVO { | ||
| 15 | + @Schema(description = "查询日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "yyyy") | ||
| 16 | + private String statDate; | ||
| 17 | + | ||
| 18 | + @Schema(description = "单位类型:01:公司 02:班组 03:个人", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 19 | + @NotEmpty(message = "单位类型:01:公司 02:班组 03:个人不能为空") | ||
| 20 | + private String unitType; | ||
| 21 | + | ||
| 22 | + @Schema(description = "单位ID(部门表 id)", requiredMode = Schema.RequiredMode.REQUIRED, example = "22785") | ||
| 23 | + @NotEmpty(message = "单位ID(部门表 id)不能为空") | ||
| 24 | + private String unitId; | ||
| 25 | + | ||
| 26 | + @Schema(description = "单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "西城") | ||
| 27 | + @NotEmpty(message = "单位名称不能为空") | ||
| 28 | + private String unitName; | ||
| 29 | + | ||
| 30 | + @Schema(description = "当前总积分") | ||
| 31 | + private Integer totalIntegral; | ||
| 32 | + | ||
| 33 | + @Schema(description = "来源类型 01:派单", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 34 | + @NotEmpty(message = "来源类型 01:派单不能为空") | ||
| 35 | + private String sourceType; | ||
| 36 | + | ||
| 37 | + @Schema(description = "关联ID(关联业务表主键)", requiredMode = Schema.RequiredMode.REQUIRED, example = "24947") | ||
| 38 | + @NotNull(message = "关联ID(关联业务表主键)不能为空") | ||
| 39 | + private Long relatedTaskId; | ||
| 40 | + | ||
| 41 | + @Schema(description = "业务名称(冗余)", example = "张三") | ||
| 42 | + private String relatedTaskName; | ||
| 43 | + | ||
| 44 | + @Schema(description = "原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "不好") | ||
| 45 | + private String reason; | ||
| 46 | + | ||
| 47 | + @Schema(description = "工单号") | ||
| 48 | + private String workNo; | ||
| 49 | + | ||
| 50 | + public String getStatDate() { | ||
| 51 | + if (StringUtils.isBlank(statDate)) { | ||
| 52 | + // 获取当前年份,转为字符串(如 2026) | ||
| 53 | + return LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy")); | ||
| 54 | + } | ||
| 55 | + // 2. 若有值,直接返回(兼容传入的年份) | ||
| 56 | + return statDate; | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + public void setStatDate(String statDate) { | ||
| 60 | + this.statDate = statDate; | ||
| 61 | + } | ||
| 62 | +} |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/unitintegraltotal/vo/UnitIntegralTotalPageReqVO.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.unitintegraltotal.vo; | ||
| 2 | + | ||
| 3 | +import lombok.*; | ||
| 4 | +import java.util.*; | ||
| 5 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 6 | +import com.zteits.urbanops.framework.common.pojo.PageParam; | ||
| 7 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 8 | +import java.time.LocalDateTime; | ||
| 9 | + | ||
| 10 | +import static com.zteits.urbanops.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 11 | + | ||
| 12 | +@Schema(description = "管理后台 - 单位积分累计分页 Request VO") | ||
| 13 | +@Data | ||
| 14 | +public class UnitIntegralTotalPageReqVO extends PageParam { | ||
| 15 | + | ||
| 16 | + @Schema(description = "积分汇总的统计日期(格式:YYYY)") | ||
| 17 | + private String statDate; | ||
| 18 | + | ||
| 19 | + @Schema(description = "单位类型:01:公司 02:班组 03:个人", example = "1") | ||
| 20 | + private String unitType; | ||
| 21 | + | ||
| 22 | + @Schema(description = "单位ID(部门表 id)", example = "22785") | ||
| 23 | + private String unitId; | ||
| 24 | + | ||
| 25 | + @Schema(description = "单位名称", example = "王五") | ||
| 26 | + private String unitName; | ||
| 27 | + | ||
| 28 | + @Schema(description = "当前总积分(累计增加-累计扣减)") | ||
| 29 | + private Integer totalIntegral; | ||
| 30 | + | ||
| 31 | + @Schema(description = "累计增加积分") | ||
| 32 | + private Integer totalAdd; | ||
| 33 | + | ||
| 34 | + @Schema(description = "累计扣减积分") | ||
| 35 | + private Integer totalSub; | ||
| 36 | + | ||
| 37 | + @Schema(description = "备注", example = "你猜") | ||
| 38 | + private String remark; | ||
| 39 | + | ||
| 40 | + @Schema(description = "关联记录创建时间(派单给单位的时间)") | ||
| 41 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 42 | + private LocalDateTime[] createTime; | ||
| 43 | + | ||
| 44 | +} |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/unitintegraltotal/vo/UnitIntegralTotalRespVO.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.unitintegraltotal.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.*; | ||
| 5 | +import java.util.*; | ||
| 6 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 7 | +import java.time.LocalDateTime; | ||
| 8 | +import cn.idev.excel.annotation.*; | ||
| 9 | + | ||
| 10 | +@Schema(description = "管理后台 - 单位积分累计 Response VO") | ||
| 11 | +@Data | ||
| 12 | +@ExcelIgnoreUnannotated | ||
| 13 | +public class UnitIntegralTotalRespVO { | ||
| 14 | + | ||
| 15 | + @Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "640") | ||
| 16 | + @ExcelProperty("主键ID") | ||
| 17 | + private Long id; | ||
| 18 | + | ||
| 19 | + @Schema(description = "积分汇总的统计日期(格式:YYYY)", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 20 | + @ExcelProperty("积分汇总的统计日期(格式:YYYY)") | ||
| 21 | + private String statDate; | ||
| 22 | + | ||
| 23 | + @Schema(description = "单位类型:01:公司 02:班组 03:个人", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 24 | + @ExcelProperty("单位类型:01:公司 02:班组 03:个人") | ||
| 25 | + private String unitType; | ||
| 26 | + | ||
| 27 | + @Schema(description = "单位ID(部门表 id)", requiredMode = Schema.RequiredMode.REQUIRED, example = "22785") | ||
| 28 | + @ExcelProperty("单位ID(部门表 id)") | ||
| 29 | + private String unitId; | ||
| 30 | + | ||
| 31 | + @Schema(description = "单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") | ||
| 32 | + @ExcelProperty("单位名称") | ||
| 33 | + private String unitName; | ||
| 34 | + | ||
| 35 | + @Schema(description = "当前总积分(累计增加-累计扣减)") | ||
| 36 | + @ExcelProperty("当前总积分(累计增加-累计扣减)") | ||
| 37 | + private Integer totalIntegral; | ||
| 38 | + | ||
| 39 | + @Schema(description = "累计增加积分") | ||
| 40 | + @ExcelProperty("累计增加积分") | ||
| 41 | + private Integer totalAdd; | ||
| 42 | + | ||
| 43 | + @Schema(description = "累计扣减积分") | ||
| 44 | + @ExcelProperty("累计扣减积分") | ||
| 45 | + private Integer totalSub; | ||
| 46 | + | ||
| 47 | + @Schema(description = "备注", example = "你猜") | ||
| 48 | + @ExcelProperty("备注") | ||
| 49 | + private String remark; | ||
| 50 | + | ||
| 51 | + @Schema(description = "关联记录创建时间(派单给单位的时间)", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 52 | + @ExcelProperty("关联记录创建时间(派单给单位的时间)") | ||
| 53 | + private LocalDateTime createTime; | ||
| 54 | + | ||
| 55 | +} | ||
| 0 | \ No newline at end of file | 56 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/unitintegraltotal/vo/UnitIntegralTotalSaveReqVO.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.controller.admin.unitintegraltotal.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.*; | ||
| 5 | +import java.util.*; | ||
| 6 | +import jakarta.validation.constraints.*; | ||
| 7 | + | ||
| 8 | +@Schema(description = "管理后台 - 单位积分累计新增/修改 Request VO") | ||
| 9 | +@Data | ||
| 10 | +public class UnitIntegralTotalSaveReqVO { | ||
| 11 | + | ||
| 12 | + @Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "640") | ||
| 13 | + private Long id; | ||
| 14 | + | ||
| 15 | + @Schema(description = "积分汇总的统计日期(格式:YYYY)", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 16 | + @NotEmpty(message = "积分汇总的统计日期(格式:YYYY)不能为空") | ||
| 17 | + private String statDate; | ||
| 18 | + | ||
| 19 | + @Schema(description = "单位类型:01:公司 02:班组 03:个人", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 20 | + @NotEmpty(message = "单位类型:01:公司 02:班组 03:个人不能为空") | ||
| 21 | + private String unitType; | ||
| 22 | + | ||
| 23 | + @Schema(description = "单位ID(部门表 id)", requiredMode = Schema.RequiredMode.REQUIRED, example = "22785") | ||
| 24 | + @NotEmpty(message = "单位ID(部门表 id)不能为空") | ||
| 25 | + private String unitId; | ||
| 26 | + | ||
| 27 | + @Schema(description = "单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") | ||
| 28 | + @NotEmpty(message = "单位名称不能为空") | ||
| 29 | + private String unitName; | ||
| 30 | + | ||
| 31 | + @Schema(description = "当前总积分(累计增加-累计扣减)") | ||
| 32 | + private Integer totalIntegral; | ||
| 33 | + | ||
| 34 | + @Schema(description = "累计增加积分") | ||
| 35 | + private Integer totalAdd; | ||
| 36 | + | ||
| 37 | + @Schema(description = "累计扣减积分") | ||
| 38 | + private Integer totalSub; | ||
| 39 | + | ||
| 40 | + @Schema(description = "备注", example = "你猜") | ||
| 41 | + private String remark; | ||
| 42 | + | ||
| 43 | +} | ||
| 0 | \ No newline at end of file | 44 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/convert/AssignTaskConvert.java
| @@ -2,16 +2,18 @@ package com.zteits.urbanops.module.garden.convert; | @@ -2,16 +2,18 @@ package com.zteits.urbanops.module.garden.convert; | ||
| 2 | 2 | ||
| 3 | 3 | ||
| 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.collection.CollectionUtils; | ||
| 6 | import com.zteits.urbanops.framework.common.util.object.BeanUtils; | 5 | import com.zteits.urbanops.framework.common.util.object.BeanUtils; |
| 7 | import com.zteits.urbanops.module.garden.controller.admin.assigntasksinfo.vo.AssignTasksInfoRespVO; | 6 | import com.zteits.urbanops.module.garden.controller.admin.assigntasksinfo.vo.AssignTasksInfoRespVO; |
| 7 | +import com.zteits.urbanops.module.garden.controller.admin.unitintegraltotal.vo.UnitIntegralRespVO; | ||
| 8 | import com.zteits.urbanops.module.garden.dal.dataobject.assigntasks.AssignTasksDO; | 8 | import com.zteits.urbanops.module.garden.dal.dataobject.assigntasks.AssignTasksDO; |
| 9 | import com.zteits.urbanops.module.garden.dal.dataobject.assigntasksinfo.AssignTasksInfoDO; | 9 | import com.zteits.urbanops.module.garden.dal.dataobject.assigntasksinfo.AssignTasksInfoDO; |
| 10 | import org.mapstruct.Mapper; | 10 | import org.mapstruct.Mapper; |
| 11 | import org.mapstruct.factory.Mappers; | 11 | import org.mapstruct.factory.Mappers; |
| 12 | 12 | ||
| 13 | +import java.util.Collections; | ||
| 13 | import java.util.List; | 14 | import java.util.List; |
| 14 | import java.util.Map; | 15 | import java.util.Map; |
| 16 | +import java.util.stream.Collectors; | ||
| 15 | 17 | ||
| 16 | /** | 18 | /** |
| 17 | * @Classname AssignTaskConvert | 19 | * @Classname AssignTaskConvert |
| @@ -23,25 +25,94 @@ import java.util.Map; | @@ -23,25 +25,94 @@ import java.util.Map; | ||
| 23 | public interface AssignTaskConvert { | 25 | public interface AssignTaskConvert { |
| 24 | AssignTaskConvert INSTANCE = Mappers.getMapper(AssignTaskConvert.class); | 26 | AssignTaskConvert INSTANCE = Mappers.getMapper(AssignTaskConvert.class); |
| 25 | 27 | ||
| 26 | - default PageResult<AssignTasksInfoRespVO> buildTaskPage(PageResult<AssignTasksInfoDO> pageResult, Map<Long, AssignTasksDO> taskMap) { | ||
| 27 | - List<AssignTasksInfoRespVO> taskVOList = CollectionUtils.convertList(pageResult.getList(), task -> { | ||
| 28 | - AssignTasksInfoRespVO taskVO = BeanUtils.toBean(task, AssignTasksInfoRespVO.class); | ||
| 29 | - AssignTasksDO tasksDO = taskMap.get(taskVO.getTaskId()); | ||
| 30 | - if (tasksDO != null) { | ||
| 31 | - taskVO.setTaskName(tasksDO.getTaskName()); | ||
| 32 | - taskVO.setTaskType(tasksDO.getTaskType()); | ||
| 33 | - taskVO.setDeadline(tasksDO.getDeadline()); | ||
| 34 | - } | ||
| 35 | - return taskVO; | ||
| 36 | - }); | 28 | + default PageResult<AssignTasksInfoRespVO> buildTaskPage(PageResult<AssignTasksInfoDO> pageResult, List<UnitIntegralRespVO> unitIntegralList) { |
| 29 | + //1.源列表为空直接返回空列表 | ||
| 30 | + if (org.apache.commons.collections4.CollectionUtils.isEmpty(pageResult.getList())) { | ||
| 31 | + return new PageResult<>(Collections.emptyList(), pageResult.getTotal()); | ||
| 32 | + } | ||
| 33 | + //2、构建积分Map:Key为String类型的任务ID(匹配relatedTaskId的类型),避免类型不匹配 | ||
| 34 | + Map<Long, UnitIntegralRespVO> integralMap = org.apache.commons.collections4.CollectionUtils.isEmpty(pageResult.getList()) | ||
| 35 | + ? Collections.emptyMap() : unitIntegralList.stream() | ||
| 36 | + .collect( | ||
| 37 | + Collectors.toMap(UnitIntegralRespVO::getRelatedTaskId, | ||
| 38 | + integral -> integral, | ||
| 39 | + (existing, replacement) -> replacement | ||
| 40 | + ) | ||
| 41 | + ); | ||
| 42 | + // 3. 转换任务DO为VO,并绑定积分 | ||
| 43 | + List<AssignTasksInfoRespVO> taskVOList = pageResult.getList().stream() | ||
| 44 | + .map(taskDO -> { | ||
| 45 | + // 转换DO到VO | ||
| 46 | + AssignTasksInfoRespVO taskVO = new AssignTasksInfoRespVO(); | ||
| 47 | + BeanUtils.copyProperties(taskDO, taskVO); | ||
| 48 | + | ||
| 49 | + // 4. 匹配积分:将Long类型的taskId转为String,匹配Map的Key | ||
| 50 | + Long taskIdStr = taskDO.getId() == null ? null : taskDO.getId(); | ||
| 51 | + UnitIntegralRespVO integralVO = integralMap.get(taskIdStr); | ||
| 52 | + | ||
| 53 | + // 5. 积分赋值:无积分则设为0 | ||
| 54 | + taskVO.setTotalIntegral(integralVO != null ? integralVO.getTotalIntegral() : 0); | ||
| 55 | + | ||
| 56 | + return taskVO; | ||
| 57 | + }) | ||
| 58 | + .collect(Collectors.toList()); | ||
| 59 | + | ||
| 37 | return new PageResult<>(taskVOList, pageResult.getTotal()); | 60 | return new PageResult<>(taskVOList, pageResult.getTotal()); |
| 38 | } | 61 | } |
| 39 | - default AssignTasksInfoRespVO buildTask(AssignTasksInfoDO tasksInfoDO, AssignTasksDO tasksDO) { | 62 | + default AssignTasksInfoRespVO buildTask(AssignTasksInfoDO tasksInfoDO, AssignTasksDO tasksDO, List<UnitIntegralRespVO> unitIntegralList) { |
| 40 | AssignTasksInfoRespVO taskVO = BeanUtils.toBean(tasksInfoDO, AssignTasksInfoRespVO.class); | 63 | AssignTasksInfoRespVO taskVO = BeanUtils.toBean(tasksInfoDO, AssignTasksInfoRespVO.class); |
| 41 | if (tasksDO != null) { | 64 | if (tasksDO != null) { |
| 42 | taskVO.setTemplateFile(tasksDO.getTemplateFile()); | 65 | taskVO.setTemplateFile(tasksDO.getTemplateFile()); |
| 43 | } | 66 | } |
| 67 | + //2、构建积分Map:Key为String类型的任务ID(匹配relatedTaskId的类型),避免类型不匹配 | ||
| 68 | + Map<Long, UnitIntegralRespVO> integralMap = org.apache.commons.collections4.CollectionUtils.isEmpty(unitIntegralList) | ||
| 69 | + ? Collections.emptyMap() : unitIntegralList.stream() | ||
| 70 | + .collect( | ||
| 71 | + Collectors.toMap(UnitIntegralRespVO::getRelatedTaskId, | ||
| 72 | + integral -> integral, | ||
| 73 | + (existing, replacement) -> replacement | ||
| 74 | + ) | ||
| 75 | + ); | ||
| 76 | + // 4. 匹配积分:将Long类型的taskId转为String,匹配Map的Key | ||
| 77 | + Long taskIdStr = tasksInfoDO.getId() == null ? null : tasksInfoDO.getId(); | ||
| 78 | + UnitIntegralRespVO integralVO = integralMap.get(taskIdStr); | ||
| 79 | + // 5. 积分赋值:无积分则设为0 | ||
| 80 | + taskVO.setTotalIntegral(integralVO != null ? integralVO.getTotalIntegral() : 0); | ||
| 44 | return taskVO; | 81 | return taskVO; |
| 45 | } | 82 | } |
| 46 | 83 | ||
| 84 | + default List<AssignTasksInfoRespVO> buildTaskInfo(List<AssignTasksInfoDO> assignTaskInfoList, List<UnitIntegralRespVO> unitIntegralList) { | ||
| 85 | + //1.源列表为空直接返回空列表 | ||
| 86 | + if (org.apache.commons.collections4.CollectionUtils.isEmpty(assignTaskInfoList)) { | ||
| 87 | + return Collections.emptyList(); | ||
| 88 | + } | ||
| 89 | + //2、构建积分Map:Key为String类型的任务ID(匹配relatedTaskId的类型),避免类型不匹配 | ||
| 90 | + Map<Long, UnitIntegralRespVO> integralMap = org.apache.commons.collections4.CollectionUtils.isEmpty(unitIntegralList) | ||
| 91 | + ? Collections.emptyMap() : unitIntegralList.stream() | ||
| 92 | + .collect( | ||
| 93 | + Collectors.toMap(UnitIntegralRespVO::getRelatedTaskId, | ||
| 94 | + integral -> integral, | ||
| 95 | + (existing, replacement) -> replacement | ||
| 96 | + ) | ||
| 97 | + ); | ||
| 98 | + // 3. 转换任务DO为VO,并绑定积分 | ||
| 99 | + List<AssignTasksInfoRespVO> taskVOList = assignTaskInfoList.stream() | ||
| 100 | + .map(taskDO -> { | ||
| 101 | + // 转换DO到VO | ||
| 102 | + AssignTasksInfoRespVO taskVO = new AssignTasksInfoRespVO(); | ||
| 103 | + BeanUtils.copyProperties(taskDO, taskVO); | ||
| 104 | + | ||
| 105 | + // 4. 匹配积分:将Long类型的taskId转为String,匹配Map的Key | ||
| 106 | + Long taskIdStr = taskDO.getId() == null ? null : taskDO.getId(); | ||
| 107 | + UnitIntegralRespVO integralVO = integralMap.get(taskIdStr); | ||
| 108 | + | ||
| 109 | + // 5. 积分赋值:无积分则设为0 | ||
| 110 | + taskVO.setTotalIntegral(integralVO != null ? integralVO.getTotalIntegral() : 0); | ||
| 111 | + | ||
| 112 | + return taskVO; | ||
| 113 | + }) | ||
| 114 | + .collect(Collectors.toList()); | ||
| 115 | + | ||
| 116 | + return taskVOList; | ||
| 117 | + } | ||
| 47 | } | 118 | } |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/dataobject/unitintegraladd/UnitIntegralAddDO.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.dal.dataobject.unitintegraladd; | ||
| 2 | + | ||
| 3 | +import lombok.*; | ||
| 4 | +import java.util.*; | ||
| 5 | +import java.time.LocalDateTime; | ||
| 6 | +import java.time.LocalDateTime; | ||
| 7 | +import com.baomidou.mybatisplus.annotation.*; | ||
| 8 | +import com.zteits.urbanops.framework.mybatis.core.dataobject.BaseDO; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 积分增加记录 DO | ||
| 12 | + * | ||
| 13 | + * @author 超级管理员 | ||
| 14 | + */ | ||
| 15 | +@TableName("garden_unit_integral_add") | ||
| 16 | +@KeySequence("garden_unit_integral_add_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||
| 17 | +@Data | ||
| 18 | +@EqualsAndHashCode(callSuper = true) | ||
| 19 | +@ToString(callSuper = true) | ||
| 20 | +@Builder | ||
| 21 | +@NoArgsConstructor | ||
| 22 | +@AllArgsConstructor | ||
| 23 | +public class UnitIntegralAddDO extends BaseDO { | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 主键ID | ||
| 27 | + */ | ||
| 28 | + @TableId | ||
| 29 | + private Long id; | ||
| 30 | + /** | ||
| 31 | + * 来源类型 01:派单 | ||
| 32 | + */ | ||
| 33 | + private String sourceType; | ||
| 34 | + /** | ||
| 35 | + * 单位类型:01:公司 02:班组 03:个人 | ||
| 36 | + */ | ||
| 37 | + private String unitType; | ||
| 38 | + /** | ||
| 39 | + * 单位ID(部门表 id) | ||
| 40 | + */ | ||
| 41 | + private String unitId; | ||
| 42 | + /** | ||
| 43 | + * 单位名称(冗余,避免联表查询) | ||
| 44 | + */ | ||
| 45 | + private String unitName; | ||
| 46 | + /** | ||
| 47 | + * 关联ID(关联业务表主键) | ||
| 48 | + */ | ||
| 49 | + private Long relatedTaskId; | ||
| 50 | + /** | ||
| 51 | + * 业务名称(冗余) | ||
| 52 | + */ | ||
| 53 | + private String relatedTaskName; | ||
| 54 | + /** | ||
| 55 | + * 本次增加积分(正数) | ||
| 56 | + */ | ||
| 57 | + private Integer addIntegral; | ||
| 58 | + /** | ||
| 59 | + * 增加原因(如:到期前上报奖励、到期后上报奖励等) | ||
| 60 | + */ | ||
| 61 | + private String addReason; | ||
| 62 | + /** | ||
| 63 | + * 增加前总积分(对账用) | ||
| 64 | + */ | ||
| 65 | + private Integer beforeIntegral; | ||
| 66 | + /** | ||
| 67 | + * 增加后总积分(对账用) | ||
| 68 | + */ | ||
| 69 | + private Integer afterIntegral; | ||
| 70 | + /** | ||
| 71 | + * 工单号 | ||
| 72 | + */ | ||
| 73 | + private String workNo; | ||
| 74 | + /** | ||
| 75 | + * 备注(补充积分增加的特殊说明) | ||
| 76 | + */ | ||
| 77 | + private String remark; | ||
| 78 | + | ||
| 79 | + | ||
| 80 | +} | ||
| 0 | \ No newline at end of file | 81 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/dataobject/unitintegralsub/UnitIntegralSubDO.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.dal.dataobject.unitintegralsub; | ||
| 2 | + | ||
| 3 | +import lombok.*; | ||
| 4 | +import java.util.*; | ||
| 5 | +import java.time.LocalDateTime; | ||
| 6 | +import java.time.LocalDateTime; | ||
| 7 | +import com.baomidou.mybatisplus.annotation.*; | ||
| 8 | +import com.zteits.urbanops.framework.mybatis.core.dataobject.BaseDO; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 积分扣减记录 DO | ||
| 12 | + * | ||
| 13 | + * @author 超级管理员 | ||
| 14 | + */ | ||
| 15 | +@TableName("garden_unit_integral_sub") | ||
| 16 | +@KeySequence("garden_unit_integral_sub_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||
| 17 | +@Data | ||
| 18 | +@EqualsAndHashCode(callSuper = true) | ||
| 19 | +@ToString(callSuper = true) | ||
| 20 | +@Builder | ||
| 21 | +@NoArgsConstructor | ||
| 22 | +@AllArgsConstructor | ||
| 23 | +public class UnitIntegralSubDO extends BaseDO { | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 主键ID | ||
| 27 | + */ | ||
| 28 | + @TableId | ||
| 29 | + private Long id; | ||
| 30 | + /** | ||
| 31 | + * 来源类型 01:派单 | ||
| 32 | + */ | ||
| 33 | + private String sourceType; | ||
| 34 | + /** | ||
| 35 | + * 单位类型:01:公司 02:班组 03:个人 | ||
| 36 | + */ | ||
| 37 | + private String unitType; | ||
| 38 | + /** | ||
| 39 | + * 单位ID(部门表 id) | ||
| 40 | + */ | ||
| 41 | + private String unitId; | ||
| 42 | + /** | ||
| 43 | + * 单位名称(冗余,避免联表查询) | ||
| 44 | + */ | ||
| 45 | + private String unitName; | ||
| 46 | + /** | ||
| 47 | + * 关联任务ID(外键,关联业务表主键) | ||
| 48 | + */ | ||
| 49 | + private Long relatedTaskId; | ||
| 50 | + /** | ||
| 51 | + * 业务名称(冗余) | ||
| 52 | + */ | ||
| 53 | + private String relatedTaskName; | ||
| 54 | + /** | ||
| 55 | + * 本次扣减积分(正数,存储扣减数值) | ||
| 56 | + */ | ||
| 57 | + private Integer subIntegral; | ||
| 58 | + /** | ||
| 59 | + * 扣减原因(如:任务打回等) | ||
| 60 | + */ | ||
| 61 | + private String subReason; | ||
| 62 | + /** | ||
| 63 | + * 扣减前总积分(对账用) | ||
| 64 | + */ | ||
| 65 | + private Integer beforeIntegral; | ||
| 66 | + /** | ||
| 67 | + * 扣减后总积分(对账用) | ||
| 68 | + */ | ||
| 69 | + private Integer afterIntegral; | ||
| 70 | + /** | ||
| 71 | + * 工单号 | ||
| 72 | + */ | ||
| 73 | + private String workNo; | ||
| 74 | + /** | ||
| 75 | + * 备注(补充扣减的特殊说明) | ||
| 76 | + */ | ||
| 77 | + private String remark; | ||
| 78 | + | ||
| 79 | + | ||
| 80 | +} | ||
| 0 | \ No newline at end of file | 81 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/dataobject/unitintegraltotal/UnitIntegralTotalDO.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.dal.dataobject.unitintegraltotal; | ||
| 2 | + | ||
| 3 | +import lombok.*; | ||
| 4 | +import java.util.*; | ||
| 5 | +import java.time.LocalDateTime; | ||
| 6 | +import java.time.LocalDateTime; | ||
| 7 | +import com.baomidou.mybatisplus.annotation.*; | ||
| 8 | +import com.zteits.urbanops.framework.mybatis.core.dataobject.BaseDO; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 单位积分累计 DO | ||
| 12 | + * | ||
| 13 | + * @author 超级管理员 | ||
| 14 | + */ | ||
| 15 | +@TableName("garden_unit_integral_total") | ||
| 16 | +@KeySequence("garden_unit_integral_total_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||
| 17 | +@Data | ||
| 18 | +@EqualsAndHashCode(callSuper = true) | ||
| 19 | +@ToString(callSuper = true) | ||
| 20 | +@Builder | ||
| 21 | +@NoArgsConstructor | ||
| 22 | +@AllArgsConstructor | ||
| 23 | +public class UnitIntegralTotalDO extends BaseDO { | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 主键ID | ||
| 27 | + */ | ||
| 28 | + @TableId | ||
| 29 | + private Long id; | ||
| 30 | + /** | ||
| 31 | + * 积分汇总的统计日期(格式:YYYY) | ||
| 32 | + */ | ||
| 33 | + private String statDate; | ||
| 34 | + /** | ||
| 35 | + * 单位类型:01:公司 02:班组 03:个人 | ||
| 36 | + */ | ||
| 37 | + private String unitType; | ||
| 38 | + /** | ||
| 39 | + * 单位ID(部门表 id) | ||
| 40 | + */ | ||
| 41 | + private String unitId; | ||
| 42 | + /** | ||
| 43 | + * 单位名称 | ||
| 44 | + */ | ||
| 45 | + private String unitName; | ||
| 46 | + /** | ||
| 47 | + * 当前总积分(累计增加-累计扣减) | ||
| 48 | + */ | ||
| 49 | + private Integer totalIntegral; | ||
| 50 | + /** | ||
| 51 | + * 累计增加积分 | ||
| 52 | + */ | ||
| 53 | + private Integer totalAdd; | ||
| 54 | + /** | ||
| 55 | + * 累计扣减积分 | ||
| 56 | + */ | ||
| 57 | + private Integer totalSub; | ||
| 58 | + /** | ||
| 59 | + * 备注 | ||
| 60 | + */ | ||
| 61 | + private String remark; | ||
| 62 | + | ||
| 63 | + | ||
| 64 | +} | ||
| 0 | \ No newline at end of file | 65 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/mysql/unitintegraladd/UnitIntegralAddMapper.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.dal.mysql.unitintegraladd; | ||
| 2 | + | ||
| 3 | +import java.util.*; | ||
| 4 | + | ||
| 5 | +import com.zteits.urbanops.framework.common.pojo.PageResult; | ||
| 6 | +import com.zteits.urbanops.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 7 | +import com.zteits.urbanops.framework.mybatis.core.mapper.BaseMapperX; | ||
| 8 | +import com.zteits.urbanops.module.garden.dal.dataobject.unitintegraladd.UnitIntegralAddDO; | ||
| 9 | +import org.apache.ibatis.annotations.Mapper; | ||
| 10 | +import com.zteits.urbanops.module.garden.controller.admin.unitintegraladd.vo.*; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * 积分增加记录 Mapper | ||
| 14 | + * | ||
| 15 | + * @author 超级管理员 | ||
| 16 | + */ | ||
| 17 | +@Mapper | ||
| 18 | +public interface UnitIntegralAddMapper extends BaseMapperX<UnitIntegralAddDO> { | ||
| 19 | + | ||
| 20 | + default PageResult<UnitIntegralAddDO> selectPage(UnitIntegralAddPageReqVO reqVO) { | ||
| 21 | + return selectPage(reqVO, new LambdaQueryWrapperX<UnitIntegralAddDO>() | ||
| 22 | + .eqIfPresent(UnitIntegralAddDO::getSourceType, reqVO.getSourceType()) | ||
| 23 | + .eqIfPresent(UnitIntegralAddDO::getUnitType, reqVO.getUnitType()) | ||
| 24 | + .eqIfPresent(UnitIntegralAddDO::getUnitId, reqVO.getUnitId()) | ||
| 25 | + .likeIfPresent(UnitIntegralAddDO::getUnitName, reqVO.getUnitName()) | ||
| 26 | + .eqIfPresent(UnitIntegralAddDO::getRelatedTaskId, reqVO.getRelatedTaskId()) | ||
| 27 | + .likeIfPresent(UnitIntegralAddDO::getRelatedTaskName, reqVO.getRelatedTaskName()) | ||
| 28 | + .eqIfPresent(UnitIntegralAddDO::getAddIntegral, reqVO.getAddIntegral()) | ||
| 29 | + .eqIfPresent(UnitIntegralAddDO::getAddReason, reqVO.getAddReason()) | ||
| 30 | + .eqIfPresent(UnitIntegralAddDO::getBeforeIntegral, reqVO.getBeforeIntegral()) | ||
| 31 | + .eqIfPresent(UnitIntegralAddDO::getAfterIntegral, reqVO.getAfterIntegral()) | ||
| 32 | + .eqIfPresent(UnitIntegralAddDO::getWorkNo, reqVO.getWorkNo()) | ||
| 33 | + .eqIfPresent(UnitIntegralAddDO::getRemark, reqVO.getRemark()) | ||
| 34 | + .betweenIfPresent(UnitIntegralAddDO::getCreateTime, reqVO.getCreateTime()) | ||
| 35 | + .orderByDesc(UnitIntegralAddDO::getId)); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | +} | ||
| 0 | \ No newline at end of file | 39 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/mysql/unitintegralsub/UnitIntegralSubMapper.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.dal.mysql.unitintegralsub; | ||
| 2 | + | ||
| 3 | +import java.util.*; | ||
| 4 | + | ||
| 5 | +import com.zteits.urbanops.framework.common.pojo.PageResult; | ||
| 6 | +import com.zteits.urbanops.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 7 | +import com.zteits.urbanops.framework.mybatis.core.mapper.BaseMapperX; | ||
| 8 | +import com.zteits.urbanops.module.garden.dal.dataobject.unitintegralsub.UnitIntegralSubDO; | ||
| 9 | +import org.apache.ibatis.annotations.Mapper; | ||
| 10 | +import com.zteits.urbanops.module.garden.controller.admin.unitintegralsub.vo.*; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * 积分扣减记录 Mapper | ||
| 14 | + * | ||
| 15 | + * @author 超级管理员 | ||
| 16 | + */ | ||
| 17 | +@Mapper | ||
| 18 | +public interface UnitIntegralSubMapper extends BaseMapperX<UnitIntegralSubDO> { | ||
| 19 | + | ||
| 20 | + default PageResult<UnitIntegralSubDO> selectPage(UnitIntegralSubPageReqVO reqVO) { | ||
| 21 | + return selectPage(reqVO, new LambdaQueryWrapperX<UnitIntegralSubDO>() | ||
| 22 | + .eqIfPresent(UnitIntegralSubDO::getSourceType, reqVO.getSourceType()) | ||
| 23 | + .eqIfPresent(UnitIntegralSubDO::getUnitType, reqVO.getUnitType()) | ||
| 24 | + .eqIfPresent(UnitIntegralSubDO::getUnitId, reqVO.getUnitId()) | ||
| 25 | + .likeIfPresent(UnitIntegralSubDO::getUnitName, reqVO.getUnitName()) | ||
| 26 | + .eqIfPresent(UnitIntegralSubDO::getRelatedTaskId, reqVO.getRelatedTaskId()) | ||
| 27 | + .likeIfPresent(UnitIntegralSubDO::getRelatedTaskName, reqVO.getRelatedTaskName()) | ||
| 28 | + .eqIfPresent(UnitIntegralSubDO::getSubIntegral, reqVO.getSubIntegral()) | ||
| 29 | + .eqIfPresent(UnitIntegralSubDO::getSubReason, reqVO.getSubReason()) | ||
| 30 | + .eqIfPresent(UnitIntegralSubDO::getBeforeIntegral, reqVO.getBeforeIntegral()) | ||
| 31 | + .eqIfPresent(UnitIntegralSubDO::getAfterIntegral, reqVO.getAfterIntegral()) | ||
| 32 | + .eqIfPresent(UnitIntegralSubDO::getWorkNo, reqVO.getWorkNo()) | ||
| 33 | + .eqIfPresent(UnitIntegralSubDO::getRemark, reqVO.getRemark()) | ||
| 34 | + .betweenIfPresent(UnitIntegralSubDO::getCreateTime, reqVO.getCreateTime()) | ||
| 35 | + .orderByDesc(UnitIntegralSubDO::getId)); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | +} | ||
| 0 | \ No newline at end of file | 39 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/mysql/unitintegraltotal/UnitIntegralTotalMapper.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.dal.mysql.unitintegraltotal; | ||
| 2 | + | ||
| 3 | +import java.util.*; | ||
| 4 | + | ||
| 5 | +import com.zteits.urbanops.framework.common.pojo.PageResult; | ||
| 6 | +import com.zteits.urbanops.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 7 | +import com.zteits.urbanops.framework.mybatis.core.mapper.BaseMapperX; | ||
| 8 | +import com.zteits.urbanops.module.garden.dal.dataobject.unitintegraltotal.UnitIntegralTotalDO; | ||
| 9 | +import org.apache.ibatis.annotations.Mapper; | ||
| 10 | +import com.zteits.urbanops.module.garden.controller.admin.unitintegraltotal.vo.*; | ||
| 11 | +import org.apache.ibatis.annotations.Param; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * 单位积分累计 Mapper | ||
| 15 | + * | ||
| 16 | + * @author 超级管理员 | ||
| 17 | + */ | ||
| 18 | +@Mapper | ||
| 19 | +public interface UnitIntegralTotalMapper extends BaseMapperX<UnitIntegralTotalDO> { | ||
| 20 | + | ||
| 21 | + default PageResult<UnitIntegralTotalDO> selectPage(UnitIntegralTotalPageReqVO reqVO) { | ||
| 22 | + return selectPage(reqVO, new LambdaQueryWrapperX<UnitIntegralTotalDO>() | ||
| 23 | + .eqIfPresent(UnitIntegralTotalDO::getStatDate, reqVO.getStatDate()) | ||
| 24 | + .eqIfPresent(UnitIntegralTotalDO::getUnitType, reqVO.getUnitType()) | ||
| 25 | + .eqIfPresent(UnitIntegralTotalDO::getUnitId, reqVO.getUnitId()) | ||
| 26 | + .likeIfPresent(UnitIntegralTotalDO::getUnitName, reqVO.getUnitName()) | ||
| 27 | + .eqIfPresent(UnitIntegralTotalDO::getTotalIntegral, reqVO.getTotalIntegral()) | ||
| 28 | + .eqIfPresent(UnitIntegralTotalDO::getTotalAdd, reqVO.getTotalAdd()) | ||
| 29 | + .eqIfPresent(UnitIntegralTotalDO::getTotalSub, reqVO.getTotalSub()) | ||
| 30 | + .eqIfPresent(UnitIntegralTotalDO::getRemark, reqVO.getRemark()) | ||
| 31 | + .betweenIfPresent(UnitIntegralTotalDO::getCreateTime, reqVO.getCreateTime()) | ||
| 32 | + .orderByDesc(UnitIntegralTotalDO::getId)); | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * 根据任务ID列表统计总积分 | ||
| 38 | + * @param relatedTaskIds 关联任务ID列表 | ||
| 39 | + * @return 积分统计结果 | ||
| 40 | + */ | ||
| 41 | + List<UnitIntegralRespVO> queryIntegralByRelatedTaskIds(@Param("relatedTaskIds") List<Long> relatedTaskIds); | ||
| 42 | + | ||
| 43 | +} |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/enums/CommonConstants.java
| @@ -14,4 +14,16 @@ public interface CommonConstants { | @@ -14,4 +14,16 @@ public interface CommonConstants { | ||
| 14 | 14 | ||
| 15 | public static final String QUERY_TYPE_SOURCE_ID = "source_id"; | 15 | public static final String QUERY_TYPE_SOURCE_ID = "source_id"; |
| 16 | 16 | ||
| 17 | + /*单位*/ | ||
| 18 | + public static final String UNIT_INTEGRAL_UNIT_TYPE_01 = "01"; | ||
| 19 | + | ||
| 20 | + /*班组*/ | ||
| 21 | + public static final String UNIT_INTEGRAL_UNIT_TYPE_02 = "02"; | ||
| 22 | + | ||
| 23 | + /*个人*/ | ||
| 24 | + public static final String UNIT_INTEGRAL_UNIT_TYPE_03 = "03"; | ||
| 25 | + | ||
| 26 | + | ||
| 27 | + /*积分来源 01:任务反馈*/ | ||
| 28 | + public static final String UNIT_INTEGRAL_SOURCE_TYPE_01 = "01"; | ||
| 17 | } | 29 | } |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/enums/ErrorCodeConstants.java
| @@ -137,6 +137,9 @@ public interface ErrorCodeConstants { | @@ -137,6 +137,9 @@ public interface ErrorCodeConstants { | ||
| 137 | 137 | ||
| 138 | ErrorCode ROAD_MANAGER_NOT_EXISTS = new ErrorCode(1-100-006-001, "道路管理不存在"); | 138 | ErrorCode ROAD_MANAGER_NOT_EXISTS = new ErrorCode(1-100-006-001, "道路管理不存在"); |
| 139 | 139 | ||
| 140 | + ErrorCode DEVICE_CLOCK_RECORD_NOT_EXISTS = new ErrorCode(1-100-011-001, ""); | ||
| 141 | + ErrorCode UNIT_INTEGRAL_TOTAL_NOT_EXISTS = new ErrorCode(1-100-012-001, "单位积分累计不存在"); | ||
| 142 | + ErrorCode UNIT_INTEGRAL_ADD_NOT_EXISTS = new ErrorCode(1-100-012-002, "积分增加记录不存在"); | ||
| 140 | 143 | ||
| 141 | - | 144 | + ErrorCode UNIT_INTEGRAL_SUB_NOT_EXISTS = new ErrorCode(1-100-012-003, "积分扣减记录不存在"); |
| 142 | } | 145 | } |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/assigntasksinfo/AssignTasksInfoServiceImpl.java
| @@ -7,11 +7,14 @@ import com.zteits.urbanops.framework.common.util.object.BeanUtils; | @@ -7,11 +7,14 @@ import com.zteits.urbanops.framework.common.util.object.BeanUtils; | ||
| 7 | import com.zteits.urbanops.module.garden.controller.admin.assigntasksinfo.vo.AssignTasksInfoPageReqVO; | 7 | import com.zteits.urbanops.module.garden.controller.admin.assigntasksinfo.vo.AssignTasksInfoPageReqVO; |
| 8 | import com.zteits.urbanops.module.garden.controller.admin.assigntasksinfo.vo.AssignTasksInfoSaveReqVO; | 8 | import com.zteits.urbanops.module.garden.controller.admin.assigntasksinfo.vo.AssignTasksInfoSaveReqVO; |
| 9 | import com.zteits.urbanops.module.garden.controller.admin.assigntasksinfo.vo.AssignTasksInfoUpdReqVO; | 9 | import com.zteits.urbanops.module.garden.controller.admin.assigntasksinfo.vo.AssignTasksInfoUpdReqVO; |
| 10 | +import com.zteits.urbanops.module.garden.controller.admin.unitintegraltotal.vo.UnitIntegralSaveReqVO; | ||
| 10 | import com.zteits.urbanops.module.garden.dal.dataobject.assigntasks.AssignTasksDO; | 11 | import com.zteits.urbanops.module.garden.dal.dataobject.assigntasks.AssignTasksDO; |
| 11 | import com.zteits.urbanops.module.garden.dal.dataobject.assigntasksinfo.AssignTasksInfoDO; | 12 | import com.zteits.urbanops.module.garden.dal.dataobject.assigntasksinfo.AssignTasksInfoDO; |
| 12 | import com.zteits.urbanops.module.garden.dal.mysql.assigntasks.AssignTasksMapper; | 13 | import com.zteits.urbanops.module.garden.dal.mysql.assigntasks.AssignTasksMapper; |
| 13 | import com.zteits.urbanops.module.garden.dal.mysql.assigntasksinfo.AssignTasksInfoMapper; | 14 | import com.zteits.urbanops.module.garden.dal.mysql.assigntasksinfo.AssignTasksInfoMapper; |
| 14 | import com.zteits.urbanops.module.garden.enums.AssignTasksConstants; | 15 | import com.zteits.urbanops.module.garden.enums.AssignTasksConstants; |
| 16 | +import com.zteits.urbanops.module.garden.enums.CommonConstants; | ||
| 17 | +import com.zteits.urbanops.module.garden.service.unitintegraltotal.UnitIntegralService; | ||
| 15 | import com.zteits.urbanops.module.system.api.dept.DeptApi; | 18 | import com.zteits.urbanops.module.system.api.dept.DeptApi; |
| 16 | import com.zteits.urbanops.module.system.api.dept.dto.DeptRespDTO; | 19 | import com.zteits.urbanops.module.system.api.dept.dto.DeptRespDTO; |
| 17 | import com.zteits.urbanops.module.system.api.permission.RoleApi; | 20 | import com.zteits.urbanops.module.system.api.permission.RoleApi; |
| @@ -19,24 +22,29 @@ import com.zteits.urbanops.module.system.api.sms.SmsCodeApi; | @@ -19,24 +22,29 @@ import com.zteits.urbanops.module.system.api.sms.SmsCodeApi; | ||
| 19 | import com.zteits.urbanops.module.system.api.sms.dto.code.SmsCodeSendReqDTO; | 22 | import com.zteits.urbanops.module.system.api.sms.dto.code.SmsCodeSendReqDTO; |
| 20 | import com.zteits.urbanops.module.system.api.user.AdminUserApi; | 23 | import com.zteits.urbanops.module.system.api.user.AdminUserApi; |
| 21 | import com.zteits.urbanops.module.system.api.user.dto.AdminUserRespDTO; | 24 | import com.zteits.urbanops.module.system.api.user.dto.AdminUserRespDTO; |
| 22 | -import com.zteits.urbanops.module.system.dal.dataobject.permission.RoleDO; | ||
| 23 | import jakarta.annotation.Resource; | 25 | import jakarta.annotation.Resource; |
| 24 | import lombok.extern.slf4j.Slf4j; | 26 | import lombok.extern.slf4j.Slf4j; |
| 25 | import org.apache.commons.collections4.CollectionUtils; | 27 | import org.apache.commons.collections4.CollectionUtils; |
| 26 | import org.springframework.stereotype.Service; | 28 | import org.springframework.stereotype.Service; |
| 29 | +import org.springframework.transaction.annotation.Transactional; | ||
| 27 | import org.springframework.validation.annotation.Validated; | 30 | import org.springframework.validation.annotation.Validated; |
| 28 | 31 | ||
| 29 | import java.time.LocalDateTime; | 32 | import java.time.LocalDateTime; |
| 30 | import java.time.ZoneId; | 33 | import java.time.ZoneId; |
| 31 | import java.time.format.DateTimeFormatter; | 34 | import java.time.format.DateTimeFormatter; |
| 32 | -import java.util.*; | 35 | +import java.time.temporal.ChronoUnit; |
| 36 | +import java.util.HashMap; | ||
| 37 | +import java.util.List; | ||
| 38 | +import java.util.Map; | ||
| 39 | +import java.util.Objects; | ||
| 33 | import java.util.stream.Collectors; | 40 | import java.util.stream.Collectors; |
| 34 | 41 | ||
| 35 | import static com.zteits.urbanops.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST; | 42 | import static com.zteits.urbanops.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST; |
| 36 | import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception; | 43 | import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 37 | import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception0; | 44 | import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception0; |
| 38 | import static com.zteits.urbanops.framework.common.util.servlet.ServletUtils.getClientIP; | 45 | import static com.zteits.urbanops.framework.common.util.servlet.ServletUtils.getClientIP; |
| 39 | -import static com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils.*; | 46 | +import static com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
| 47 | +import static com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils.getLoginUserNickname; | ||
| 40 | import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.*; | 48 | import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.*; |
| 41 | 49 | ||
| 42 | /** | 50 | /** |
| @@ -65,6 +73,9 @@ public class AssignTasksInfoServiceImpl implements AssignTasksInfoService { | @@ -65,6 +73,9 @@ public class AssignTasksInfoServiceImpl implements AssignTasksInfoService { | ||
| 65 | @Resource | 73 | @Resource |
| 66 | private SmsCodeApi smsCodeApi; | 74 | private SmsCodeApi smsCodeApi; |
| 67 | 75 | ||
| 76 | + @Resource | ||
| 77 | + private UnitIntegralService unitIntegralService; | ||
| 78 | + | ||
| 68 | // 时间格式常量(与之前保持一致) | 79 | // 时间格式常量(与之前保持一致) |
| 69 | public static final String FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND = "yyyy-MM-dd HH:mm:ss"; | 80 | public static final String FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND = "yyyy-MM-dd HH:mm:ss"; |
| 70 | 81 | ||
| @@ -156,6 +167,8 @@ public class AssignTasksInfoServiceImpl implements AssignTasksInfoService { | @@ -156,6 +167,8 @@ public class AssignTasksInfoServiceImpl implements AssignTasksInfoService { | ||
| 156 | assignTaskInfo.setTaskType(assignTasks.getTaskType()); | 167 | assignTaskInfo.setTaskType(assignTasks.getTaskType()); |
| 157 | assignTaskInfo.setDeadline(assignTasks.getDeadline()); | 168 | assignTaskInfo.setDeadline(assignTasks.getDeadline()); |
| 158 | assignTasksInfoMapper.insert(assignTaskInfo); | 169 | assignTasksInfoMapper.insert(assignTaskInfo); |
| 170 | + // add by 20260307 初始化单位积分 | ||
| 171 | + unitIntegralService.createUnitIntegral(CommonConstants.UNIT_INTEGRAL_UNIT_TYPE_01, String.valueOf(companyId), assignTaskInfo.getCompanyName()); | ||
| 159 | } | 172 | } |
| 160 | } | 173 | } |
| 161 | } | 174 | } |
| @@ -170,6 +183,7 @@ public class AssignTasksInfoServiceImpl implements AssignTasksInfoService { | @@ -170,6 +183,7 @@ public class AssignTasksInfoServiceImpl implements AssignTasksInfoService { | ||
| 170 | 183 | ||
| 171 | //派单驳回 | 184 | //派单驳回 |
| 172 | @Override | 185 | @Override |
| 186 | + @Transactional | ||
| 173 | public int rejectAssignTaskCompany(AssignTasksInfoUpdReqVO tdAssignTaskCompany) { | 187 | public int rejectAssignTaskCompany(AssignTasksInfoUpdReqVO tdAssignTaskCompany) { |
| 174 | AssignTasksInfoDO assignTaskInfo = assignTasksInfoMapper.selectById(tdAssignTaskCompany.getId()); | 188 | AssignTasksInfoDO assignTaskInfo = assignTasksInfoMapper.selectById(tdAssignTaskCompany.getId()); |
| 175 | //单位任务完成状态(0:未完成,1:已完成) | 189 | //单位任务完成状态(0:未完成,1:已完成) |
| @@ -181,6 +195,19 @@ public class AssignTasksInfoServiceImpl implements AssignTasksInfoService { | @@ -181,6 +195,19 @@ public class AssignTasksInfoServiceImpl implements AssignTasksInfoService { | ||
| 181 | updateAssignTaskInfo.setIsReject(AssignTasksConstants.ASSIGN_TASK_REJECT_1); | 195 | updateAssignTaskInfo.setIsReject(AssignTasksConstants.ASSIGN_TASK_REJECT_1); |
| 182 | updateAssignTaskInfo.setRejectRemark(tdAssignTaskCompany.getRejectRemark()); | 196 | updateAssignTaskInfo.setRejectRemark(tdAssignTaskCompany.getRejectRemark()); |
| 183 | updateAssignTaskInfo.setNewFlag(AssignTasksConstants.ASSIGN_TASK_NEWFLAG_0); | 197 | updateAssignTaskInfo.setNewFlag(AssignTasksConstants.ASSIGN_TASK_NEWFLAG_0); |
| 198 | + | ||
| 199 | + //add bt 20260307 驳回积分扣减 | ||
| 200 | + UnitIntegralSaveReqVO updateReqVO = new UnitIntegralSaveReqVO(); | ||
| 201 | + updateReqVO.setUnitType(CommonConstants.UNIT_INTEGRAL_UNIT_TYPE_01); | ||
| 202 | + updateReqVO.setUnitId(String.valueOf(updateAssignTaskInfo.getCompanyId())); | ||
| 203 | + updateReqVO.setUnitName(updateAssignTaskInfo.getCompanyName()); | ||
| 204 | + updateReqVO.setSourceType(CommonConstants.UNIT_INTEGRAL_SOURCE_TYPE_01); | ||
| 205 | + updateReqVO.setRelatedTaskId(assignTaskInfo.getId()); | ||
| 206 | + updateReqVO.setRelatedTaskName(updateAssignTaskInfo.getTaskName()); | ||
| 207 | + updateReqVO.setTotalIntegral(getUnitCurIngeral(assignTaskInfo.getDeadline())); | ||
| 208 | + updateReqVO.setReason("任务上报驳回积分扣减"); | ||
| 209 | + unitIntegralService.subUnitIntegral(updateReqVO); | ||
| 210 | + | ||
| 184 | return assignTasksInfoMapper.updateById(updateAssignTaskInfo); | 211 | return assignTasksInfoMapper.updateById(updateAssignTaskInfo); |
| 185 | } else { | 212 | } else { |
| 186 | throw exception(ASSIGN_TASKS_INFO_TASKID_REJECT); | 213 | throw exception(ASSIGN_TASKS_INFO_TASKID_REJECT); |
| @@ -266,6 +293,7 @@ public class AssignTasksInfoServiceImpl implements AssignTasksInfoService { | @@ -266,6 +293,7 @@ public class AssignTasksInfoServiceImpl implements AssignTasksInfoService { | ||
| 266 | } | 293 | } |
| 267 | 294 | ||
| 268 | @Override | 295 | @Override |
| 296 | + @Transactional | ||
| 269 | public int feedbackAssignTaskCompany(AssignTasksInfoUpdReqVO tdAssignTaskCompany) { | 297 | public int feedbackAssignTaskCompany(AssignTasksInfoUpdReqVO tdAssignTaskCompany) { |
| 270 | AssignTasksInfoDO assignTaskInfo = assignTasksInfoMapper.selectById(tdAssignTaskCompany.getId()); | 298 | AssignTasksInfoDO assignTaskInfo = assignTasksInfoMapper.selectById(tdAssignTaskCompany.getId()); |
| 271 | if (assignTaskInfo != null) { | 299 | if (assignTaskInfo != null) { |
| @@ -280,9 +308,55 @@ public class AssignTasksInfoServiceImpl implements AssignTasksInfoService { | @@ -280,9 +308,55 @@ public class AssignTasksInfoServiceImpl implements AssignTasksInfoService { | ||
| 280 | updateAssignTaskInfo.setWritePersonId(String.valueOf(user.getId())); | 308 | updateAssignTaskInfo.setWritePersonId(String.valueOf(user.getId())); |
| 281 | updateAssignTaskInfo.setWritePerson(getLoginUserNickname()); | 309 | updateAssignTaskInfo.setWritePerson(getLoginUserNickname()); |
| 282 | updateAssignTaskInfo.setWritePersonPhone(user.getMobile()); | 310 | updateAssignTaskInfo.setWritePersonPhone(user.getMobile()); |
| 311 | + | ||
| 312 | + // add 增加单位积分 | ||
| 313 | + UnitIntegralSaveReqVO updateReqVO = new UnitIntegralSaveReqVO(); | ||
| 314 | + updateReqVO.setUnitType(CommonConstants.UNIT_INTEGRAL_UNIT_TYPE_01); | ||
| 315 | + updateReqVO.setUnitId(String.valueOf(updateAssignTaskInfo.getCompanyId())); | ||
| 316 | + updateReqVO.setUnitName(updateAssignTaskInfo.getCompanyName()); | ||
| 317 | + updateReqVO.setSourceType(CommonConstants.UNIT_INTEGRAL_SOURCE_TYPE_01); | ||
| 318 | + updateReqVO.setRelatedTaskId(assignTaskInfo.getId()); | ||
| 319 | + updateReqVO.setRelatedTaskName(updateAssignTaskInfo.getTaskName()); | ||
| 320 | + | ||
| 321 | + updateReqVO.setTotalIntegral(getUnitCurIngeral(assignTaskInfo.getDeadline())); | ||
| 322 | + if (1 == updateReqVO.getTotalIntegral()) { | ||
| 323 | + updateReqVO.setReason("超时任务上报"); | ||
| 324 | + } | ||
| 325 | + updateReqVO.setReason("任务上报"); | ||
| 326 | + unitIntegralService.addUnitIntegral(updateReqVO); | ||
| 327 | + | ||
| 283 | return assignTasksInfoMapper.updateById(updateAssignTaskInfo); | 328 | return assignTasksInfoMapper.updateById(updateAssignTaskInfo); |
| 284 | } else { | 329 | } else { |
| 285 | throw exception(ASSIGN_TASKS_INFO_NOT_EXISTS); | 330 | throw exception(ASSIGN_TASKS_INFO_NOT_EXISTS); |
| 286 | } | 331 | } |
| 287 | } | 332 | } |
| 333 | + /** | ||
| 334 | + * @Author wangqian | ||
| 335 | + * @Description 获取单位当前积分 | ||
| 336 | + * 1、已填报&未超期 展示3分 | ||
| 337 | + * | ||
| 338 | + * 2、已填报&超期 展示1分 | ||
| 339 | + * | ||
| 340 | + * 3、未填报 展示0分 | ||
| 341 | + * @Date 2026/3/8 13:23 | ||
| 342 | + * @Param | ||
| 343 | + * @Return java.lang.Integer | ||
| 344 | + */ | ||
| 345 | + private Integer getUnitCurIngeral(LocalDateTime deadline){ | ||
| 346 | + if (deadline == null) { | ||
| 347 | + throw exception0(BAD_REQUEST.getCode(), "截止时间为null"); | ||
| 348 | + } | ||
| 349 | + LocalDateTime now = LocalDateTime.now().truncatedTo(ChronoUnit.SECONDS); | ||
| 350 | + boolean isOverdue = deadline.isBefore(now); | ||
| 351 | + log.info("截止时间:{},当前时间:{},超期判定:{},返回积分:{}", | ||
| 352 | + deadline, now, isOverdue, isOverdue ? 1 : 3); | ||
| 353 | + return isOverdue ? 1 : 3; | ||
| 354 | + } | ||
| 355 | + // 测试方法(验证逻辑正确性) | ||
| 356 | + public static void main(String[] args) { | ||
| 357 | + AssignTasksInfoServiceImpl uitl = new AssignTasksInfoServiceImpl(); | ||
| 358 | + // 测试1:未超期(截止时间为1小时后) | ||
| 359 | + LocalDateTime notOverdue = LocalDateTime.now().plusHours(1); | ||
| 360 | + System.out.println(uitl.getUnitCurIngeral(notOverdue)); // 输出3 | ||
| 361 | + } | ||
| 288 | } | 362 | } |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/unitintegraladd/UnitIntegralAddService.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.service.unitintegraladd; | ||
| 2 | + | ||
| 3 | +import java.util.*; | ||
| 4 | +import jakarta.validation.*; | ||
| 5 | +import com.zteits.urbanops.module.garden.controller.admin.unitintegraladd.vo.*; | ||
| 6 | +import com.zteits.urbanops.module.garden.dal.dataobject.unitintegraladd.UnitIntegralAddDO; | ||
| 7 | +import com.zteits.urbanops.framework.common.pojo.PageResult; | ||
| 8 | +import com.zteits.urbanops.framework.common.pojo.PageParam; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 积分增加记录 Service 接口 | ||
| 12 | + * | ||
| 13 | + * @author 超级管理员 | ||
| 14 | + */ | ||
| 15 | +public interface UnitIntegralAddService { | ||
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * 创建积分增加记录 | ||
| 19 | + * | ||
| 20 | + * @param createReqVO 创建信息 | ||
| 21 | + * @return 编号 | ||
| 22 | + */ | ||
| 23 | + Long createUnitIntegralAdd(@Valid UnitIntegralAddSaveReqVO createReqVO); | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 更新积分增加记录 | ||
| 27 | + * | ||
| 28 | + * @param updateReqVO 更新信息 | ||
| 29 | + */ | ||
| 30 | + void updateUnitIntegralAdd(@Valid UnitIntegralAddSaveReqVO updateReqVO); | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * 删除积分增加记录 | ||
| 34 | + * | ||
| 35 | + * @param id 编号 | ||
| 36 | + */ | ||
| 37 | + void deleteUnitIntegralAdd(Long id); | ||
| 38 | + | ||
| 39 | + /** | ||
| 40 | + * 批量删除积分增加记录 | ||
| 41 | + * | ||
| 42 | + * @param ids 编号 | ||
| 43 | + */ | ||
| 44 | + void deleteUnitIntegralAddListByIds(List<Long> ids); | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 获得积分增加记录 | ||
| 48 | + * | ||
| 49 | + * @param id 编号 | ||
| 50 | + * @return 积分增加记录 | ||
| 51 | + */ | ||
| 52 | + UnitIntegralAddDO getUnitIntegralAdd(Long id); | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * 获得积分增加记录分页 | ||
| 56 | + * | ||
| 57 | + * @param pageReqVO 分页查询 | ||
| 58 | + * @return 积分增加记录分页 | ||
| 59 | + */ | ||
| 60 | + PageResult<UnitIntegralAddDO> getUnitIntegralAddPage(UnitIntegralAddPageReqVO pageReqVO); | ||
| 61 | + | ||
| 62 | +} | ||
| 0 | \ No newline at end of file | 63 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/unitintegraladd/UnitIntegralAddServiceImpl.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.service.unitintegraladd; | ||
| 2 | + | ||
| 3 | +import cn.hutool.core.collection.CollUtil; | ||
| 4 | +import org.springframework.stereotype.Service; | ||
| 5 | +import jakarta.annotation.Resource; | ||
| 6 | +import org.springframework.validation.annotation.Validated; | ||
| 7 | +import org.springframework.transaction.annotation.Transactional; | ||
| 8 | + | ||
| 9 | +import java.util.*; | ||
| 10 | +import com.zteits.urbanops.module.garden.controller.admin.unitintegraladd.vo.*; | ||
| 11 | +import com.zteits.urbanops.module.garden.dal.dataobject.unitintegraladd.UnitIntegralAddDO; | ||
| 12 | +import com.zteits.urbanops.framework.common.pojo.PageResult; | ||
| 13 | +import com.zteits.urbanops.framework.common.pojo.PageParam; | ||
| 14 | +import com.zteits.urbanops.framework.common.util.object.BeanUtils; | ||
| 15 | + | ||
| 16 | +import com.zteits.urbanops.module.garden.dal.mysql.unitintegraladd.UnitIntegralAddMapper; | ||
| 17 | + | ||
| 18 | +import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 19 | +import static com.zteits.urbanops.framework.common.util.collection.CollectionUtils.convertList; | ||
| 20 | +import static com.zteits.urbanops.framework.common.util.collection.CollectionUtils.diffList; | ||
| 21 | +import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.*; | ||
| 22 | + | ||
| 23 | +/** | ||
| 24 | + * 积分增加记录 Service 实现类 | ||
| 25 | + * | ||
| 26 | + * @author 超级管理员 | ||
| 27 | + */ | ||
| 28 | +@Service | ||
| 29 | +@Validated | ||
| 30 | +public class UnitIntegralAddServiceImpl implements UnitIntegralAddService { | ||
| 31 | + | ||
| 32 | + @Resource | ||
| 33 | + private UnitIntegralAddMapper unitIntegralAddMapper; | ||
| 34 | + | ||
| 35 | + @Override | ||
| 36 | + public Long createUnitIntegralAdd(UnitIntegralAddSaveReqVO createReqVO) { | ||
| 37 | + // 插入 | ||
| 38 | + UnitIntegralAddDO unitIntegralAdd = BeanUtils.toBean(createReqVO, UnitIntegralAddDO.class); | ||
| 39 | + unitIntegralAddMapper.insert(unitIntegralAdd); | ||
| 40 | + | ||
| 41 | + // 返回 | ||
| 42 | + return unitIntegralAdd.getId(); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + @Override | ||
| 46 | + public void updateUnitIntegralAdd(UnitIntegralAddSaveReqVO updateReqVO) { | ||
| 47 | + // 校验存在 | ||
| 48 | + validateUnitIntegralAddExists(updateReqVO.getId()); | ||
| 49 | + // 更新 | ||
| 50 | + UnitIntegralAddDO updateObj = BeanUtils.toBean(updateReqVO, UnitIntegralAddDO.class); | ||
| 51 | + unitIntegralAddMapper.updateById(updateObj); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + @Override | ||
| 55 | + public void deleteUnitIntegralAdd(Long id) { | ||
| 56 | + // 校验存在 | ||
| 57 | + validateUnitIntegralAddExists(id); | ||
| 58 | + // 删除 | ||
| 59 | + unitIntegralAddMapper.deleteById(id); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + @Override | ||
| 63 | + public void deleteUnitIntegralAddListByIds(List<Long> ids) { | ||
| 64 | + // 删除 | ||
| 65 | + unitIntegralAddMapper.deleteByIds(ids); | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + | ||
| 69 | + private void validateUnitIntegralAddExists(Long id) { | ||
| 70 | + if (unitIntegralAddMapper.selectById(id) == null) { | ||
| 71 | + throw exception(UNIT_INTEGRAL_ADD_NOT_EXISTS); | ||
| 72 | + } | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + @Override | ||
| 76 | + public UnitIntegralAddDO getUnitIntegralAdd(Long id) { | ||
| 77 | + return unitIntegralAddMapper.selectById(id); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + @Override | ||
| 81 | + public PageResult<UnitIntegralAddDO> getUnitIntegralAddPage(UnitIntegralAddPageReqVO pageReqVO) { | ||
| 82 | + return unitIntegralAddMapper.selectPage(pageReqVO); | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | +} | ||
| 0 | \ No newline at end of file | 86 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/unitintegralsub/UnitIntegralSubService.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.service.unitintegralsub; | ||
| 2 | + | ||
| 3 | +import java.util.*; | ||
| 4 | +import jakarta.validation.*; | ||
| 5 | +import com.zteits.urbanops.module.garden.controller.admin.unitintegralsub.vo.*; | ||
| 6 | +import com.zteits.urbanops.module.garden.dal.dataobject.unitintegralsub.UnitIntegralSubDO; | ||
| 7 | +import com.zteits.urbanops.framework.common.pojo.PageResult; | ||
| 8 | +import com.zteits.urbanops.framework.common.pojo.PageParam; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 积分扣减记录 Service 接口 | ||
| 12 | + * | ||
| 13 | + * @author 超级管理员 | ||
| 14 | + */ | ||
| 15 | +public interface UnitIntegralSubService { | ||
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * 创建积分扣减记录 | ||
| 19 | + * | ||
| 20 | + * @param createReqVO 创建信息 | ||
| 21 | + * @return 编号 | ||
| 22 | + */ | ||
| 23 | + Long createUnitIntegralSub(@Valid UnitIntegralSubSaveReqVO createReqVO); | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 更新积分扣减记录 | ||
| 27 | + * | ||
| 28 | + * @param updateReqVO 更新信息 | ||
| 29 | + */ | ||
| 30 | + void updateUnitIntegralSub(@Valid UnitIntegralSubSaveReqVO updateReqVO); | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * 删除积分扣减记录 | ||
| 34 | + * | ||
| 35 | + * @param id 编号 | ||
| 36 | + */ | ||
| 37 | + void deleteUnitIntegralSub(Long id); | ||
| 38 | + | ||
| 39 | + /** | ||
| 40 | + * 批量删除积分扣减记录 | ||
| 41 | + * | ||
| 42 | + * @param ids 编号 | ||
| 43 | + */ | ||
| 44 | + void deleteUnitIntegralSubListByIds(List<Long> ids); | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 获得积分扣减记录 | ||
| 48 | + * | ||
| 49 | + * @param id 编号 | ||
| 50 | + * @return 积分扣减记录 | ||
| 51 | + */ | ||
| 52 | + UnitIntegralSubDO getUnitIntegralSub(Long id); | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * 获得积分扣减记录分页 | ||
| 56 | + * | ||
| 57 | + * @param pageReqVO 分页查询 | ||
| 58 | + * @return 积分扣减记录分页 | ||
| 59 | + */ | ||
| 60 | + PageResult<UnitIntegralSubDO> getUnitIntegralSubPage(UnitIntegralSubPageReqVO pageReqVO); | ||
| 61 | + | ||
| 62 | +} | ||
| 0 | \ No newline at end of file | 63 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/unitintegralsub/UnitIntegralSubServiceImpl.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.service.unitintegralsub; | ||
| 2 | + | ||
| 3 | +import cn.hutool.core.collection.CollUtil; | ||
| 4 | +import org.springframework.stereotype.Service; | ||
| 5 | +import jakarta.annotation.Resource; | ||
| 6 | +import org.springframework.validation.annotation.Validated; | ||
| 7 | +import org.springframework.transaction.annotation.Transactional; | ||
| 8 | + | ||
| 9 | +import java.util.*; | ||
| 10 | +import com.zteits.urbanops.module.garden.controller.admin.unitintegralsub.vo.*; | ||
| 11 | +import com.zteits.urbanops.module.garden.dal.dataobject.unitintegralsub.UnitIntegralSubDO; | ||
| 12 | +import com.zteits.urbanops.framework.common.pojo.PageResult; | ||
| 13 | +import com.zteits.urbanops.framework.common.pojo.PageParam; | ||
| 14 | +import com.zteits.urbanops.framework.common.util.object.BeanUtils; | ||
| 15 | + | ||
| 16 | +import com.zteits.urbanops.module.garden.dal.mysql.unitintegralsub.UnitIntegralSubMapper; | ||
| 17 | + | ||
| 18 | +import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 19 | +import static com.zteits.urbanops.framework.common.util.collection.CollectionUtils.convertList; | ||
| 20 | +import static com.zteits.urbanops.framework.common.util.collection.CollectionUtils.diffList; | ||
| 21 | +import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.*; | ||
| 22 | + | ||
| 23 | +/** | ||
| 24 | + * 积分扣减记录 Service 实现类 | ||
| 25 | + * | ||
| 26 | + * @author 超级管理员 | ||
| 27 | + */ | ||
| 28 | +@Service | ||
| 29 | +@Validated | ||
| 30 | +public class UnitIntegralSubServiceImpl implements UnitIntegralSubService { | ||
| 31 | + | ||
| 32 | + @Resource | ||
| 33 | + private UnitIntegralSubMapper unitIntegralSubMapper; | ||
| 34 | + | ||
| 35 | + @Override | ||
| 36 | + public Long createUnitIntegralSub(UnitIntegralSubSaveReqVO createReqVO) { | ||
| 37 | + // 插入 | ||
| 38 | + UnitIntegralSubDO unitIntegralSub = BeanUtils.toBean(createReqVO, UnitIntegralSubDO.class); | ||
| 39 | + unitIntegralSubMapper.insert(unitIntegralSub); | ||
| 40 | + | ||
| 41 | + // 返回 | ||
| 42 | + return unitIntegralSub.getId(); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + @Override | ||
| 46 | + public void updateUnitIntegralSub(UnitIntegralSubSaveReqVO updateReqVO) { | ||
| 47 | + // 校验存在 | ||
| 48 | + validateUnitIntegralSubExists(updateReqVO.getId()); | ||
| 49 | + // 更新 | ||
| 50 | + UnitIntegralSubDO updateObj = BeanUtils.toBean(updateReqVO, UnitIntegralSubDO.class); | ||
| 51 | + unitIntegralSubMapper.updateById(updateObj); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + @Override | ||
| 55 | + public void deleteUnitIntegralSub(Long id) { | ||
| 56 | + // 校验存在 | ||
| 57 | + validateUnitIntegralSubExists(id); | ||
| 58 | + // 删除 | ||
| 59 | + unitIntegralSubMapper.deleteById(id); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + @Override | ||
| 63 | + public void deleteUnitIntegralSubListByIds(List<Long> ids) { | ||
| 64 | + // 删除 | ||
| 65 | + unitIntegralSubMapper.deleteByIds(ids); | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + | ||
| 69 | + private void validateUnitIntegralSubExists(Long id) { | ||
| 70 | + if (unitIntegralSubMapper.selectById(id) == null) { | ||
| 71 | + throw exception(UNIT_INTEGRAL_SUB_NOT_EXISTS); | ||
| 72 | + } | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + @Override | ||
| 76 | + public UnitIntegralSubDO getUnitIntegralSub(Long id) { | ||
| 77 | + return unitIntegralSubMapper.selectById(id); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + @Override | ||
| 81 | + public PageResult<UnitIntegralSubDO> getUnitIntegralSubPage(UnitIntegralSubPageReqVO pageReqVO) { | ||
| 82 | + return unitIntegralSubMapper.selectPage(pageReqVO); | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | +} | ||
| 0 | \ No newline at end of file | 86 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/unitintegraltotal/UnitIntegralService.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.service.unitintegraltotal; | ||
| 2 | + | ||
| 3 | +import com.zteits.urbanops.module.garden.controller.admin.unitintegraladd.vo.UnitIntegralAddRespVO; | ||
| 4 | +import com.zteits.urbanops.module.garden.controller.admin.unitintegraltotal.vo.UnitIntegralRespVO; | ||
| 5 | +import com.zteits.urbanops.module.garden.controller.admin.unitintegraltotal.vo.UnitIntegralSaveReqVO; | ||
| 6 | +import com.zteits.urbanops.module.garden.dal.dataobject.unitintegraladd.UnitIntegralAddDO; | ||
| 7 | +import jakarta.validation.Valid; | ||
| 8 | + | ||
| 9 | +import java.util.List; | ||
| 10 | +import java.util.Map; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * @Classname UnitIntegralService | ||
| 14 | + * @Description 单位积分操作 | ||
| 15 | + * @Date 2026/3/6 12:17 | ||
| 16 | + * @Created by wangqian | ||
| 17 | + */ | ||
| 18 | +public interface UnitIntegralService { | ||
| 19 | + | ||
| 20 | + /** | ||
| 21 | + * @Author wangqian | ||
| 22 | + * @Description 单位积分表初始化 | ||
| 23 | + * @Date 2026/3/7 11:10 | ||
| 24 | + * @Param unitType | ||
| 25 | + * @Param unitId | ||
| 26 | + * @param unitName | ||
| 27 | + * @Return void | ||
| 28 | + */ | ||
| 29 | + void createUnitIntegral(String unitType, String unitId, String unitName); | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * @Author wangqian | ||
| 33 | + * @Description 根据关联表id查询单位积分 | ||
| 34 | + * @Date 2026/3/8 11:34 | ||
| 35 | + * @Param relatedTaskId | ||
| 36 | + * @Return java.util.List<java.util.Map> | ||
| 37 | + */ | ||
| 38 | + List<UnitIntegralRespVO> queryIntegralByRelatedTaskIds(@Valid List<Long> relatedTaskIds); | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * @Author wangqian | ||
| 42 | + * @Description 获取最后一条增加的积分 | ||
| 43 | + * @Date 2026/3/8 13:39 | ||
| 44 | + */ | ||
| 45 | + UnitIntegralAddRespVO queryLastIntegralByRelatedTaskId(@Valid Long relatedTaskId); | ||
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * @Author wangqian | ||
| 49 | + * @Description 增加积分 | ||
| 50 | + * @Date 2026/3/6 12:20 | ||
| 51 | + * @Param updateReqVO | ||
| 52 | + * @Return void | ||
| 53 | + */ | ||
| 54 | + void addUnitIntegral(@Valid UnitIntegralSaveReqVO reqVO); | ||
| 55 | + | ||
| 56 | + | ||
| 57 | + /** | ||
| 58 | + * @Author wangqian | ||
| 59 | + * @Description 扣减积分 | ||
| 60 | + * @Date 2026/3/6 12:20 | ||
| 61 | + * @Param updateReqVO | ||
| 62 | + * @Return void | ||
| 63 | + */ | ||
| 64 | + void subUnitIntegral(@Valid UnitIntegralSaveReqVO reqVO); | ||
| 65 | + | ||
| 66 | + | ||
| 67 | + | ||
| 68 | + | ||
| 69 | +} |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/unitintegraltotal/UnitIntegralServiceImpl.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.service.unitintegraltotal; | ||
| 2 | + | ||
| 3 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||
| 4 | +import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||
| 5 | +import com.zteits.urbanops.framework.common.util.object.BeanUtils; | ||
| 6 | +import com.zteits.urbanops.module.garden.controller.admin.unitintegraladd.vo.UnitIntegralAddRespVO; | ||
| 7 | +import com.zteits.urbanops.module.garden.controller.admin.unitintegraladd.vo.UnitIntegralAddSaveReqVO; | ||
| 8 | +import com.zteits.urbanops.module.garden.controller.admin.unitintegralsub.vo.UnitIntegralSubSaveReqVO; | ||
| 9 | +import com.zteits.urbanops.module.garden.controller.admin.unitintegraltotal.vo.UnitIntegralRespVO; | ||
| 10 | +import com.zteits.urbanops.module.garden.controller.admin.unitintegraltotal.vo.UnitIntegralSaveReqVO; | ||
| 11 | +import com.zteits.urbanops.module.garden.dal.dataobject.unitintegraladd.UnitIntegralAddDO; | ||
| 12 | +import com.zteits.urbanops.module.garden.dal.dataobject.unitintegraltotal.UnitIntegralTotalDO; | ||
| 13 | +import com.zteits.urbanops.module.garden.dal.mysql.unitintegraladd.UnitIntegralAddMapper; | ||
| 14 | +import com.zteits.urbanops.module.garden.dal.mysql.unitintegraltotal.UnitIntegralTotalMapper; | ||
| 15 | +import com.zteits.urbanops.module.garden.service.unitintegraladd.UnitIntegralAddService; | ||
| 16 | +import com.zteits.urbanops.module.garden.service.unitintegralsub.UnitIntegralSubService; | ||
| 17 | +import jakarta.annotation.Resource; | ||
| 18 | +import lombok.extern.slf4j.Slf4j; | ||
| 19 | +import org.apache.commons.lang3.StringUtils; | ||
| 20 | +import org.redisson.api.RLock; | ||
| 21 | +import org.redisson.api.RedissonClient; | ||
| 22 | +import org.springframework.stereotype.Service; | ||
| 23 | +import org.springframework.transaction.annotation.Transactional; | ||
| 24 | + | ||
| 25 | +import java.time.LocalDate; | ||
| 26 | +import java.time.LocalDateTime; | ||
| 27 | +import java.time.format.DateTimeFormatter; | ||
| 28 | +import java.util.List; | ||
| 29 | +import java.util.concurrent.TimeUnit; | ||
| 30 | + | ||
| 31 | +import static com.zteits.urbanops.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST; | ||
| 32 | +import static com.zteits.urbanops.framework.common.exception.enums.GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR; | ||
| 33 | +import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception0; | ||
| 34 | +import static com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | ||
| 35 | + | ||
| 36 | +/** | ||
| 37 | + * @Classname UnitIntegralServiceImpl | ||
| 38 | + * @Description 单位积分操作 | ||
| 39 | + * @Date 2026/3/6 12:39 | ||
| 40 | + * @Created by wangqian | ||
| 41 | + */ | ||
| 42 | +@Service | ||
| 43 | +@Slf4j | ||
| 44 | +public class UnitIntegralServiceImpl implements UnitIntegralService{ | ||
| 45 | + | ||
| 46 | + @Resource | ||
| 47 | + private UnitIntegralTotalMapper unitIntegralTotalMapper; | ||
| 48 | + @Resource | ||
| 49 | + private UnitIntegralAddMapper unitIntegralAddMapper; | ||
| 50 | + | ||
| 51 | + @Resource | ||
| 52 | + private UnitIntegralSubService unitIntegralSubService; | ||
| 53 | + | ||
| 54 | + @Resource | ||
| 55 | + private UnitIntegralAddService unitIntegralAddService; | ||
| 56 | + @Resource | ||
| 57 | + private RedissonClient redissonClient; | ||
| 58 | + | ||
| 59 | + // 锁前缀(区分加/减积分锁) | ||
| 60 | + private static final String LOCK_PREFIX_INTEGRAL = "integral:"; | ||
| 61 | + | ||
| 62 | + // 统一构建锁Key | ||
| 63 | + private String buildLockKey(String unitId, String statDate) { | ||
| 64 | + return LOCK_PREFIX_INTEGRAL + unitId + ":" + statDate; | ||
| 65 | + } | ||
| 66 | + /** | ||
| 67 | + * 初始化积分表 | ||
| 68 | + */ | ||
| 69 | + @Override | ||
| 70 | + public void createUnitIntegral(String unitType, String unitId, String unitName) { | ||
| 71 | + String statDate = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy")); | ||
| 72 | + // 1. 参数校验 | ||
| 73 | + if (StringUtils.isEmpty(unitType)) { | ||
| 74 | + throw exception0(BAD_REQUEST.getCode(),"单位类型不能为空"); | ||
| 75 | + } | ||
| 76 | + if (StringUtils.isEmpty(unitId)) { | ||
| 77 | + throw exception0(BAD_REQUEST.getCode(),"单位编码不能为空"); | ||
| 78 | + } | ||
| 79 | + LambdaQueryWrapper<UnitIntegralTotalDO> queryWrapper = Wrappers.lambdaQuery(UnitIntegralTotalDO.class) | ||
| 80 | + .eq(UnitIntegralTotalDO::getUnitType, unitType) | ||
| 81 | + .eq(UnitIntegralTotalDO::getStatDate, statDate) | ||
| 82 | + .eq(UnitIntegralTotalDO::getUnitId, unitId) | ||
| 83 | + .eq(UnitIntegralTotalDO::getDeleted, 0); | ||
| 84 | + UnitIntegralTotalDO unitIntegralTotalDO = unitIntegralTotalMapper.selectOne(queryWrapper); | ||
| 85 | + if (unitIntegralTotalDO != null) { | ||
| 86 | + String errorMsg = String.format("初始化单位积分,单位ID:%s,已存在", unitId); | ||
| 87 | + throw exception0(BAD_REQUEST.getCode(),errorMsg); | ||
| 88 | + } | ||
| 89 | + UnitIntegralTotalDO saveDO = new UnitIntegralTotalDO(); | ||
| 90 | + saveDO.setStatDate(statDate); | ||
| 91 | + saveDO.setTotalAdd(0); // 累计增加 = 本次增加 | ||
| 92 | + saveDO.setTotalSub(0); // 初始扣减为0 | ||
| 93 | + saveDO.setTotalIntegral(0); // 初始总积分 = 本次增加 | ||
| 94 | + saveDO.setUnitType(unitType); | ||
| 95 | + saveDO.setUnitId(unitId); | ||
| 96 | + if (StringUtils.isEmpty(unitName)) { | ||
| 97 | + //数据库查询补全 | ||
| 98 | + } else { | ||
| 99 | + saveDO.setUnitName(unitName); | ||
| 100 | + } | ||
| 101 | + unitIntegralTotalMapper.insert(saveDO); | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + @Override | ||
| 105 | + public List<UnitIntegralRespVO> queryIntegralByRelatedTaskIds(List<Long> relatedTaskIds) { | ||
| 106 | + return unitIntegralTotalMapper.queryIntegralByRelatedTaskIds(relatedTaskIds); | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + @Override | ||
| 110 | + public UnitIntegralAddRespVO queryLastIntegralByRelatedTaskId(Long relatedTaskId) { | ||
| 111 | + LambdaQueryWrapper<UnitIntegralAddDO> queryWrapper = Wrappers.lambdaQuery(UnitIntegralAddDO.class) | ||
| 112 | + .eq(UnitIntegralAddDO::getRelatedTaskId, relatedTaskId) | ||
| 113 | + .eq(UnitIntegralAddDO::getDeleted, 0) | ||
| 114 | + .orderByDesc(UnitIntegralAddDO::getId) | ||
| 115 | + .last("LIMIT 1"); // 取第一条(MyBatis-Plus通用写法,兼容多数数据库) | ||
| 116 | + UnitIntegralAddDO unitIntegralAddDO = unitIntegralAddMapper.selectOne(queryWrapper); | ||
| 117 | + if (unitIntegralAddDO == null) { | ||
| 118 | + return null; | ||
| 119 | + } | ||
| 120 | + return BeanUtils.toBean(unitIntegralAddDO, UnitIntegralAddRespVO.class); | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + /** | ||
| 124 | + * 增加单位积分(核心方法) | ||
| 125 | + * @param reqVO 积分增加请求(注意:totalIntegral 为「本次增加积分」) | ||
| 126 | + */ | ||
| 127 | + @Override | ||
| 128 | + @Transactional(rollbackFor = Exception.class) | ||
| 129 | + public void addUnitIntegral(UnitIntegralSaveReqVO reqVO){ | ||
| 130 | + // 1. 参数校验 | ||
| 131 | + if (reqVO.getTotalIntegral() <= 0) { | ||
| 132 | + throw exception0(BAD_REQUEST.getCode(),"本次增加积分必须为正数"); | ||
| 133 | + } | ||
| 134 | + | ||
| 135 | + // 2. 构建细粒度锁Key:单位ID + 统计日期 + 操作类型 | ||
| 136 | + String lockKey = buildLockKey(reqVO.getUnitId(), reqVO.getStatDate()); | ||
| 137 | + RLock lock = redissonClient.getLock(lockKey); | ||
| 138 | + | ||
| 139 | + // 3. 获取锁(非阻塞,避免线程等待;3秒获取超时,10秒自动过期防死锁) | ||
| 140 | + boolean lockAcquired = false; | ||
| 141 | + try { | ||
| 142 | + lockAcquired = lock.tryLock(3, 10, TimeUnit.SECONDS); | ||
| 143 | + if (!lockAcquired) { | ||
| 144 | + String errorMsg = String.format("获取积分增加锁失败,单位ID:%s,统计日期:%s(请稍后重试)", reqVO.getUnitId(), reqVO.getStatDate()); | ||
| 145 | + log.error(errorMsg); | ||
| 146 | + throw exception0(INTERNAL_SERVER_ERROR.getCode(), errorMsg); | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + // 2. 构建查询条件 | ||
| 150 | + LambdaQueryWrapper<UnitIntegralTotalDO> queryWrapper = Wrappers.lambdaQuery(UnitIntegralTotalDO.class) | ||
| 151 | + .eq(UnitIntegralTotalDO::getUnitType, reqVO.getUnitType()) | ||
| 152 | + .eq(UnitIntegralTotalDO::getStatDate, reqVO.getStatDate()) | ||
| 153 | + .eq(UnitIntegralTotalDO::getUnitId, reqVO.getUnitId()) | ||
| 154 | + .eq(UnitIntegralTotalDO::getDeleted, 0); | ||
| 155 | + | ||
| 156 | + // 3. 可加行锁(FOR UPDATE)防止多线程同时扣减,保证数据一致性 | ||
| 157 | + UnitIntegralTotalDO unitIntegralTotalDO = unitIntegralTotalMapper.selectOne(queryWrapper); | ||
| 158 | + | ||
| 159 | + // 4. 初始化变量(语义清晰,避免冗余) | ||
| 160 | + int beforeIntegral = 0; // 本次增加前的累计增加积分 | ||
| 161 | + int afterIntegral = 0; // 本次增加后的累计增加积分 | ||
| 162 | + int currentAdd = reqVO.getTotalIntegral(); // 本次增加积分(重命名,语义更准) | ||
| 163 | + | ||
| 164 | + // 5. 新增/更新总积分表(核心逻辑) | ||
| 165 | + if (unitIntegralTotalDO != null) { | ||
| 166 | + // 5.1 已有记录:更新积分 | ||
| 167 | + beforeIntegral = unitIntegralTotalDO.getTotalAdd(); | ||
| 168 | + int newTotalAdd = beforeIntegral + currentAdd; | ||
| 169 | + // 更新累计增加积分 + 当前总积分(累计增加 - 累计扣减) | ||
| 170 | + unitIntegralTotalDO.setTotalAdd(newTotalAdd); | ||
| 171 | + unitIntegralTotalDO.setTotalIntegral(newTotalAdd - unitIntegralTotalDO.getTotalSub()); | ||
| 172 | + unitIntegralTotalDO.setUpdateTime(LocalDateTime.now()); | ||
| 173 | + unitIntegralTotalDO.setUpdater(String.valueOf(getLoginUserId())); | ||
| 174 | + unitIntegralTotalMapper.updateById(unitIntegralTotalDO); | ||
| 175 | + afterIntegral = newTotalAdd; | ||
| 176 | + | ||
| 177 | + log.info("更新单位积分成功,单位ID:{},统计日期:{},本次增加:{},累计增加:{}", | ||
| 178 | + reqVO.getUnitId(), reqVO.getStatDate(), currentAdd, newTotalAdd); | ||
| 179 | + } else { | ||
| 180 | + // 5.2 无记录:插入新记录 | ||
| 181 | + UnitIntegralTotalDO saveDO = new UnitIntegralTotalDO(); | ||
| 182 | + BeanUtils.copyProperties(reqVO, saveDO); | ||
| 183 | + saveDO.setTotalAdd(currentAdd); // 累计增加 = 本次增加 | ||
| 184 | + saveDO.setTotalSub(0); // 初始扣减为0 | ||
| 185 | + saveDO.setTotalIntegral(currentAdd); // 初始总积分 = 本次增加 | ||
| 186 | + unitIntegralTotalMapper.insert(saveDO); | ||
| 187 | + afterIntegral = currentAdd; | ||
| 188 | + | ||
| 189 | + log.info("新增单位积分成功,单位ID:{},统计日期:{},本次增加:{}", | ||
| 190 | + reqVO.getUnitId(), reqVO.getStatDate(), currentAdd); | ||
| 191 | + } | ||
| 192 | + // 5. 新增积分明细 | ||
| 193 | + createAddDetail(reqVO, beforeIntegral, afterIntegral, currentAdd); | ||
| 194 | + log.info("积分增加成功,单位ID:{},本次增加:{}", reqVO.getUnitId(), currentAdd); | ||
| 195 | + | ||
| 196 | + } catch (InterruptedException e) { | ||
| 197 | + log.error("获取锁被中断,单位ID:{}", reqVO.getUnitId(), e); | ||
| 198 | + Thread.currentThread().interrupt(); // 恢复中断状态 | ||
| 199 | + throw exception0(INTERNAL_SERVER_ERROR.getCode(), "积分增加操作被中断,请重试"); | ||
| 200 | + } finally { | ||
| 201 | + // 6. 释放锁(仅当前线程持有锁时释放,避免误删) | ||
| 202 | + if (lockAcquired && lock.isHeldByCurrentThread()) { | ||
| 203 | + lock.unlock(); | ||
| 204 | + log.debug("释放积分增加锁,锁Key:{}", lockKey); | ||
| 205 | + } | ||
| 206 | + } | ||
| 207 | + } | ||
| 208 | + /** | ||
| 209 | + * 封装增加明细创建逻辑 | ||
| 210 | + */ | ||
| 211 | + private void createAddDetail(UnitIntegralSaveReqVO reqVO, int before, int after, int currentAdd) { | ||
| 212 | + UnitIntegralAddSaveReqVO detailVO = new UnitIntegralAddSaveReqVO(); | ||
| 213 | + BeanUtils.copyProperties(reqVO, detailVO); | ||
| 214 | + detailVO.setAddIntegral(currentAdd); // 本次增加积分 | ||
| 215 | + detailVO.setBeforeIntegral(before); // 增加前累计扣减积分 | ||
| 216 | + detailVO.setAfterIntegral(after); // 增加后累计扣减积分 | ||
| 217 | + detailVO.setAddReason(reqVO.getReason()); | ||
| 218 | + unitIntegralAddService.createUnitIntegralAdd(detailVO); | ||
| 219 | + } | ||
| 220 | + /** | ||
| 221 | + * 扣减单位积分(核心方法) | ||
| 222 | + * @param reqVO 积分扣减请求(totalIntegral 为「本次扣减积分」) | ||
| 223 | + */ | ||
| 224 | + @Override | ||
| 225 | + @Transactional(rollbackFor = Exception.class) | ||
| 226 | + public void subUnitIntegral(UnitIntegralSaveReqVO reqVO){ | ||
| 227 | + // 1. 前置参数校验 | ||
| 228 | + if (reqVO.getTotalIntegral() <= 0) { | ||
| 229 | + throw exception0(BAD_REQUEST.getCode(),"本次增加积分必须为正数"); | ||
| 230 | + } | ||
| 231 | + | ||
| 232 | + // 2. 构建细粒度锁Key:单位ID + 统计日期 | ||
| 233 | + String lockKey = buildLockKey(reqVO.getUnitId(), reqVO.getStatDate()); | ||
| 234 | + RLock lock = redissonClient.getLock(lockKey); | ||
| 235 | + | ||
| 236 | + // 3. 获取锁(非阻塞,避免线程等待;3秒获取超时,10秒自动过期防死锁) | ||
| 237 | + boolean lockAcquired = false; | ||
| 238 | + try { | ||
| 239 | + lockAcquired = lock.tryLock(3, 10, TimeUnit.SECONDS); | ||
| 240 | + if (!lockAcquired) { | ||
| 241 | + String errorMsg = String.format("获取积分增加锁失败,单位ID:%s,统计日期:%s(请稍后重试)", reqVO.getUnitId(), reqVO.getStatDate()); | ||
| 242 | + log.error(errorMsg); | ||
| 243 | + throw exception0(INTERNAL_SERVER_ERROR.getCode(), errorMsg); | ||
| 244 | + } | ||
| 245 | + // 2. 构建查询条件 | ||
| 246 | + LambdaQueryWrapper<UnitIntegralTotalDO> queryWrapper = Wrappers.lambdaQuery(UnitIntegralTotalDO.class) | ||
| 247 | + .eq(UnitIntegralTotalDO::getUnitType, reqVO.getUnitType()) | ||
| 248 | + .eq(UnitIntegralTotalDO::getStatDate, reqVO.getStatDate()) | ||
| 249 | + .eq(UnitIntegralTotalDO::getUnitId, reqVO.getUnitId()) | ||
| 250 | + .eq(UnitIntegralTotalDO::getDeleted, 0); // 排除已删除的积分记录 | ||
| 251 | + | ||
| 252 | + // 3. 可加行锁(FOR UPDATE)防止多线程同时扣减,保证数据一致性 | ||
| 253 | + //UnitIntegralTotalDO unitIntegralTotalDO = unitIntegralTotalMapper.selectOne(queryWrapper.last("FOR UPDATE")); | ||
| 254 | + UnitIntegralTotalDO unitIntegralTotalDO = unitIntegralTotalMapper.selectOne(queryWrapper); | ||
| 255 | + // 4. 校验积分记录是否存在 | ||
| 256 | + if (unitIntegralTotalDO == null) { | ||
| 257 | + String errorMsg = String.format("单位积分记录不存在,单位ID:%s,统计日期:%s", | ||
| 258 | + reqVO.getUnitId(), reqVO.getStatDate()); | ||
| 259 | + log.error(errorMsg); | ||
| 260 | + throw exception0(BAD_REQUEST.getCode(),errorMsg); | ||
| 261 | + } | ||
| 262 | + | ||
| 263 | + // 5. 初始化核心变量 | ||
| 264 | + int currentSub = reqVO.getTotalIntegral(); // 本次扣减积分 | ||
| 265 | + int beforeSub = unitIntegralTotalDO.getTotalSub(); // 扣减前累计扣减积分 | ||
| 266 | + int afterSub = beforeSub + currentSub; // 扣减后累计扣减积分 | ||
| 267 | + int currentTotalIntegral = unitIntegralTotalDO.getTotalAdd() - afterSub; // 扣减后总积分 | ||
| 268 | + | ||
| 269 | + // 6. 业务规则校验:扣减后总积分不能为负数 | ||
| 270 | + if (currentTotalIntegral < 0) { | ||
| 271 | + String errorMsg = String.format("单位积分扣减失败,扣减后总积分为负!单位ID:%s,当前累计增加:%s,本次扣减:%s,累计扣减:%s", | ||
| 272 | + reqVO.getUnitId(), unitIntegralTotalDO.getTotalAdd(), currentSub, beforeSub); | ||
| 273 | + log.error(errorMsg); | ||
| 274 | + throw exception0(BAD_REQUEST.getCode(),errorMsg); | ||
| 275 | + } | ||
| 276 | + | ||
| 277 | + // 7. 更新积分总表(核心扣减逻辑) | ||
| 278 | + unitIntegralTotalDO.setTotalSub(afterSub); // 更新累计扣减积分 | ||
| 279 | + unitIntegralTotalDO.setTotalIntegral(currentTotalIntegral); // 更新当前总积分 | ||
| 280 | + unitIntegralTotalDO.setUpdateTime(LocalDateTime.now()); | ||
| 281 | + unitIntegralTotalDO.setUpdater(String.valueOf(getLoginUserId())); | ||
| 282 | + unitIntegralTotalMapper.updateById(unitIntegralTotalDO); | ||
| 283 | + | ||
| 284 | + log.info("单位积分扣减成功,单位ID:{},统计日期:{},本次扣减:{},扣减前累计扣减:{},扣减后累计扣减:{},扣减后总积分:{}", | ||
| 285 | + reqVO.getUnitId(), reqVO.getStatDate(), currentSub, beforeSub, afterSub, currentTotalIntegral); | ||
| 286 | + | ||
| 287 | + // 8. 新增扣减明细 | ||
| 288 | + // 新增减积分明细 | ||
| 289 | + createSubDetail(reqVO, beforeSub, afterSub, currentSub); | ||
| 290 | + log.info("单位{}减积分成功,本次减{},累计减{},剩余{}", | ||
| 291 | + reqVO.getUnitId(), currentSub, afterSub, currentSub); | ||
| 292 | + } catch (InterruptedException e) { | ||
| 293 | + Thread.currentThread().interrupt(); | ||
| 294 | + throw exception0(INTERNAL_SERVER_ERROR.getCode(), "积分操作被中断,请重试"); | ||
| 295 | + } finally { | ||
| 296 | + if (lockAcquired && lock.isHeldByCurrentThread()) { | ||
| 297 | + lock.unlock(); | ||
| 298 | + } | ||
| 299 | + } | ||
| 300 | + } | ||
| 301 | + | ||
| 302 | + /** | ||
| 303 | + * 封装扣减明细创建逻辑 | ||
| 304 | + */ | ||
| 305 | + private void createSubDetail(UnitIntegralSaveReqVO updateReqVO, int beforeSub, int afterSub, int currentSub) { | ||
| 306 | + UnitIntegralSubSaveReqVO detailVO = new UnitIntegralSubSaveReqVO(); | ||
| 307 | + BeanUtils.copyProperties(updateReqVO, detailVO); | ||
| 308 | + detailVO.setSubIntegral(currentSub); // 本次扣减积分 | ||
| 309 | + detailVO.setBeforeIntegral(beforeSub); // 扣减前累计扣减积分 | ||
| 310 | + detailVO.setAfterIntegral(afterSub); // 扣减后累计扣减积分 | ||
| 311 | + detailVO.setSubReason(updateReqVO.getReason()); | ||
| 312 | + unitIntegralSubService.createUnitIntegralSub(detailVO); | ||
| 313 | + log.info("新增积分扣减明细成功,单位ID:{},明细ID:{}", updateReqVO.getUnitId(), detailVO.getId()); | ||
| 314 | + } | ||
| 315 | + | ||
| 316 | +} |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/unitintegraltotal/UnitIntegralTotalService.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.service.unitintegraltotal; | ||
| 2 | + | ||
| 3 | +import java.util.*; | ||
| 4 | +import jakarta.validation.*; | ||
| 5 | +import com.zteits.urbanops.module.garden.controller.admin.unitintegraltotal.vo.*; | ||
| 6 | +import com.zteits.urbanops.module.garden.dal.dataobject.unitintegraltotal.UnitIntegralTotalDO; | ||
| 7 | +import com.zteits.urbanops.framework.common.pojo.PageResult; | ||
| 8 | +import com.zteits.urbanops.framework.common.pojo.PageParam; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 单位积分累计 Service 接口 | ||
| 12 | + * | ||
| 13 | + * @author 超级管理员 | ||
| 14 | + */ | ||
| 15 | +public interface UnitIntegralTotalService { | ||
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * 创建单位积分累计 | ||
| 19 | + * | ||
| 20 | + * @param createReqVO 创建信息 | ||
| 21 | + * @return 编号 | ||
| 22 | + */ | ||
| 23 | + Long createUnitIntegralTotal(@Valid UnitIntegralTotalSaveReqVO createReqVO); | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 更新单位积分累计 | ||
| 27 | + * | ||
| 28 | + * @param updateReqVO 更新信息 | ||
| 29 | + */ | ||
| 30 | + void updateUnitIntegralTotal(@Valid UnitIntegralTotalSaveReqVO updateReqVO); | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * 删除单位积分累计 | ||
| 34 | + * | ||
| 35 | + * @param id 编号 | ||
| 36 | + */ | ||
| 37 | + void deleteUnitIntegralTotal(Long id); | ||
| 38 | + | ||
| 39 | + /** | ||
| 40 | + * 批量删除单位积分累计 | ||
| 41 | + * | ||
| 42 | + * @param ids 编号 | ||
| 43 | + */ | ||
| 44 | + void deleteUnitIntegralTotalListByIds(List<Long> ids); | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 获得单位积分累计 | ||
| 48 | + * | ||
| 49 | + * @param id 编号 | ||
| 50 | + * @return 单位积分累计 | ||
| 51 | + */ | ||
| 52 | + UnitIntegralTotalDO getUnitIntegralTotal(Long id); | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * 获得单位积分累计分页 | ||
| 56 | + * | ||
| 57 | + * @param pageReqVO 分页查询 | ||
| 58 | + * @return 单位积分累计分页 | ||
| 59 | + */ | ||
| 60 | + PageResult<UnitIntegralTotalDO> getUnitIntegralTotalPage(UnitIntegralTotalPageReqVO pageReqVO); | ||
| 61 | + | ||
| 62 | +} | ||
| 0 | \ No newline at end of file | 63 | \ No newline at end of file |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/unitintegraltotal/UnitIntegralTotalServiceImpl.java
0 → 100644
| 1 | +package com.zteits.urbanops.module.garden.service.unitintegraltotal; | ||
| 2 | + | ||
| 3 | +import cn.hutool.core.collection.CollUtil; | ||
| 4 | +import org.springframework.stereotype.Service; | ||
| 5 | +import jakarta.annotation.Resource; | ||
| 6 | +import org.springframework.validation.annotation.Validated; | ||
| 7 | +import org.springframework.transaction.annotation.Transactional; | ||
| 8 | + | ||
| 9 | +import java.util.*; | ||
| 10 | +import com.zteits.urbanops.module.garden.controller.admin.unitintegraltotal.vo.*; | ||
| 11 | +import com.zteits.urbanops.module.garden.dal.dataobject.unitintegraltotal.UnitIntegralTotalDO; | ||
| 12 | +import com.zteits.urbanops.framework.common.pojo.PageResult; | ||
| 13 | +import com.zteits.urbanops.framework.common.pojo.PageParam; | ||
| 14 | +import com.zteits.urbanops.framework.common.util.object.BeanUtils; | ||
| 15 | + | ||
| 16 | +import com.zteits.urbanops.module.garden.dal.mysql.unitintegraltotal.UnitIntegralTotalMapper; | ||
| 17 | + | ||
| 18 | +import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 19 | +import static com.zteits.urbanops.framework.common.util.collection.CollectionUtils.convertList; | ||
| 20 | +import static com.zteits.urbanops.framework.common.util.collection.CollectionUtils.diffList; | ||
| 21 | +import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.*; | ||
| 22 | + | ||
| 23 | +/** | ||
| 24 | + * 单位积分累计 Service 实现类 | ||
| 25 | + * | ||
| 26 | + * @author 超级管理员 | ||
| 27 | + */ | ||
| 28 | +@Service | ||
| 29 | +@Validated | ||
| 30 | +public class UnitIntegralTotalServiceImpl implements UnitIntegralTotalService { | ||
| 31 | + | ||
| 32 | + @Resource | ||
| 33 | + private UnitIntegralTotalMapper unitIntegralTotalMapper; | ||
| 34 | + | ||
| 35 | + @Override | ||
| 36 | + public Long createUnitIntegralTotal(UnitIntegralTotalSaveReqVO createReqVO) { | ||
| 37 | + // 插入 | ||
| 38 | + UnitIntegralTotalDO unitIntegralTotal = BeanUtils.toBean(createReqVO, UnitIntegralTotalDO.class); | ||
| 39 | + unitIntegralTotalMapper.insert(unitIntegralTotal); | ||
| 40 | + | ||
| 41 | + // 返回 | ||
| 42 | + return unitIntegralTotal.getId(); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + @Override | ||
| 46 | + public void updateUnitIntegralTotal(UnitIntegralTotalSaveReqVO updateReqVO) { | ||
| 47 | + // 校验存在 | ||
| 48 | + validateUnitIntegralTotalExists(updateReqVO.getId()); | ||
| 49 | + // 更新 | ||
| 50 | + UnitIntegralTotalDO updateObj = BeanUtils.toBean(updateReqVO, UnitIntegralTotalDO.class); | ||
| 51 | + unitIntegralTotalMapper.updateById(updateObj); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + @Override | ||
| 55 | + public void deleteUnitIntegralTotal(Long id) { | ||
| 56 | + // 校验存在 | ||
| 57 | + validateUnitIntegralTotalExists(id); | ||
| 58 | + // 删除 | ||
| 59 | + unitIntegralTotalMapper.deleteById(id); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + @Override | ||
| 63 | + public void deleteUnitIntegralTotalListByIds(List<Long> ids) { | ||
| 64 | + // 删除 | ||
| 65 | + unitIntegralTotalMapper.deleteByIds(ids); | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + | ||
| 69 | + private void validateUnitIntegralTotalExists(Long id) { | ||
| 70 | + if (unitIntegralTotalMapper.selectById(id) == null) { | ||
| 71 | + throw exception(UNIT_INTEGRAL_TOTAL_NOT_EXISTS); | ||
| 72 | + } | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + @Override | ||
| 76 | + public UnitIntegralTotalDO getUnitIntegralTotal(Long id) { | ||
| 77 | + return unitIntegralTotalMapper.selectById(id); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + @Override | ||
| 81 | + public PageResult<UnitIntegralTotalDO> getUnitIntegralTotalPage(UnitIntegralTotalPageReqVO pageReqVO) { | ||
| 82 | + return unitIntegralTotalMapper.selectPage(pageReqVO); | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | +} | ||
| 0 | \ No newline at end of file | 86 | \ No newline at end of file |
urbanops-module-garden/src/main/resources/mapper/unitintegraltotal/UnitIntegralTotalMapper.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||
| 3 | +<mapper namespace="com.zteits.urbanops.module.garden.dal.mysql.unitintegraltotal.UnitIntegralTotalMapper"> | ||
| 4 | + | ||
| 5 | + <!-- 根据related_task_id统计总积分(add_integral - sub_integral) --> | ||
| 6 | + <select id="queryIntegralByRelatedTaskIds" resultType="com.zteits.urbanops.module.garden.controller.admin.unitintegraltotal.vo.UnitIntegralRespVO"> | ||
| 7 | + SELECT | ||
| 8 | + COALESCE(a.related_task_id, b.related_task_id) AS relatedTaskId, | ||
| 9 | + COALESCE(a.add_integral, 0) - COALESCE(b.sub_integral, 0) AS totalIntegral | ||
| 10 | + FROM | ||
| 11 | + -- 子查询1:统计增加积分 | ||
| 12 | + (SELECT | ||
| 13 | + related_task_id, | ||
| 14 | + SUM(add_integral) AS add_integral | ||
| 15 | + FROM garden_unit_integral_add | ||
| 16 | + WHERE deleted = '0' | ||
| 17 | + AND related_task_id IN | ||
| 18 | + <foreach collection="relatedTaskIds" item="taskId" open="(" separator="," close=")"> | ||
| 19 | + #{taskId} | ||
| 20 | + </foreach> | ||
| 21 | + GROUP BY related_task_id) a | ||
| 22 | + -- 左连接扣减积分表 | ||
| 23 | + LEFT JOIN | ||
| 24 | + (SELECT | ||
| 25 | + related_task_id, | ||
| 26 | + SUM(sub_integral) AS sub_integral | ||
| 27 | + FROM garden_unit_integral_sub | ||
| 28 | + WHERE deleted = '0' | ||
| 29 | + AND related_task_id IN | ||
| 30 | + <foreach collection="relatedTaskIds" item="taskId" open="(" separator="," close=")"> | ||
| 31 | + #{taskId} | ||
| 32 | + </foreach> | ||
| 33 | + GROUP BY related_task_id) b | ||
| 34 | + ON a.related_task_id = b.related_task_id | ||
| 35 | + </select> | ||
| 36 | + | ||
| 37 | +</mapper> |