Commit 762fcf303ddb4beeee11cf3d334fdd1e9f7154ad

Authored by 颜惠青
1 parent 4c64c91e

工单管理代码提交

urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/api/constant/BpmCommonConstant.java
... ... @@ -8,6 +8,10 @@ package com.zteits.urbanops.module.workorder.api.constant;
8 8 */
9 9 public class BpmCommonConstant {
10 10 /**
  11 + * 通用快速流程
  12 + */
  13 + public static final String COMMON_QUICK_PROCESS = "common_quick_process";
  14 + /**
11 15 * 园林巡检工单 流程业务key
12 16 */
13 17 public static final String BPM_GARDEN_INSPECT_WO = "garden_inspect_wo";
... ... @@ -31,5 +35,13 @@ public class BpmCommonConstant {
31 35 * 园林远景图片类型
32 36 */
33 37 public static final String GARDEN_INSPECT_WO_ATTACH3 = "03";
  38 + /**
  39 + * 园林工单编号前缀
  40 + */
  41 + public static final String WORK_ORDER_PREFFIX_GARDEN = "GWO";
  42 + /**
  43 + * 快速工单编号前缀
  44 + */
  45 + public static final String WORK_ORDER_PREFFIX_QUICK = "QWO";
34 46  
35 47 }
... ...
urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/api/workorder/WorkOrderApi.java 0 → 100644
  1 +package com.zteits.urbanops.module.workorder.api.workorder;
  2 +
  3 +public interface WorkOrderApi {
  4 + /**
  5 + * 生成工单编号
  6 + * @param prefix 前缀,为空时:workorder
  7 + * @return
  8 + */
  9 + public String generateWONum(String prefix);
  10 +}
... ...
urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/api/workorder/WorkOrderApiImpl.java 0 → 100644
  1 +package com.zteits.urbanops.module.workorder.api.workorder;
  2 +
  3 +import com.zteits.urbanops.module.workorder.api.constant.BpmCommonConstant;
  4 +import org.springframework.stereotype.Service;
  5 +import org.springframework.util.ObjectUtils;
  6 +
  7 +import java.time.LocalDateTime;
  8 +import java.time.format.DateTimeFormatter;
  9 +import java.util.concurrent.atomic.AtomicInteger;
  10 +
  11 +/**
  12 + * @author yanhuiqing
  13 + * @version 1.0
  14 + * @description: 工单对外api
  15 + * @date 2025/12/5 17:21
  16 + */
  17 +@Service
  18 +public class WorkOrderApiImpl implements WorkOrderApi{
  19 +
  20 + private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
  21 + private static final AtomicInteger counter = new AtomicInteger(1);
  22 +
  23 + @Override
  24 + public String generateWONum(String prefix) {
  25 + if (ObjectUtils.isEmpty(prefix)) {
  26 + prefix = BpmCommonConstant.WORK_ORDER_PREFFIX_GARDEN;
  27 + }
  28 + String dateStr = LocalDateTime.now().format(DATE_FORMAT);
  29 + int seqNum = counter.getAndIncrement();
  30 + if(seqNum>999){
  31 + synchronized (counter) {
  32 + if (counter.intValue() > 999) {
  33 + counter.set(1);
  34 + }
  35 + seqNum = counter.getAndIncrement();
  36 + }
  37 + }
  38 + return String.format("%s%03d_%s", prefix, seqNum,dateStr);
  39 + }
  40 +}
... ...
urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/controller/app/garden/AppGardenWorkOrderController.java 0 → 100644
  1 +package com.zteits.urbanops.module.workorder.controller.app.garden;
  2 +
  3 +import com.zteits.urbanops.framework.common.pojo.CommonResult;
  4 +import com.zteits.urbanops.framework.common.pojo.PageResult;
  5 +import com.zteits.urbanops.framework.common.util.object.BeanUtils;
  6 +import com.zteits.urbanops.module.workorder.controller.admin.garden.vo.BpmGardenWorkOrderPageReqVO;
  7 +import com.zteits.urbanops.module.workorder.controller.admin.garden.vo.BpmGardenWorkOrderRespVO;
  8 +import com.zteits.urbanops.module.workorder.controller.app.garden.vo.AppGardenWorkOrderReqVO;
  9 +import com.zteits.urbanops.module.workorder.dal.dataobject.garden.BpmGardenWorkOrderDO;
  10 +import com.zteits.urbanops.module.workorder.service.garden.BpmGardenService;
  11 +import io.swagger.v3.oas.annotations.Operation;
  12 +import io.swagger.v3.oas.annotations.Parameter;
  13 +import io.swagger.v3.oas.annotations.tags.Tag;
  14 +import jakarta.annotation.Resource;
  15 +import jakarta.validation.Valid;
  16 +import org.springframework.security.access.prepost.PreAuthorize;
  17 +import org.springframework.web.bind.annotation.*;
  18 +
  19 +import static com.zteits.urbanops.framework.common.pojo.CommonResult.success;
  20 +import static com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
  21 +
  22 +/**
  23 + * @author yanhuiqing
  24 + * @version 1.0
  25 + * @description: app端 园林工单请求入口
  26 + * @date 2025/12/6 10:07
  27 + */
  28 +@Tag(name = "APP - 园林工单bpm")
  29 +@RestController
  30 +@RequestMapping("/app/garden/workorder")
  31 +public class AppGardenWorkOrderController {
  32 + @Resource
  33 + private BpmGardenService gardenService;
  34 +
  35 + @PostMapping("/create")
  36 + @Operation(summary = "app-创建工单信息")
  37 + public CommonResult<Long> createMainInfo(@Valid @RequestBody AppGardenWorkOrderReqVO createReqVO) {
  38 + return success(gardenService.createWorkOrder(createReqVO));
  39 + }
  40 +
  41 + @PostMapping("/createQuick")
  42 + @Operation(summary = "app-创建快速工单信息")
  43 + public CommonResult<Long> createMainInfoQuick(@Valid @RequestBody AppGardenWorkOrderReqVO createReqVO) {
  44 + return success(gardenService.createWorkOrderQuick(createReqVO));
  45 + }
  46 +
  47 + @GetMapping("/get")
  48 + @Operation(summary = "app-获得工单详情")
  49 + @Parameter(name = "id", description = "编号", required = true, example = "1024")
  50 + public CommonResult<BpmGardenWorkOrderRespVO> getGardenInspection(@RequestParam("id") Long id) {
  51 + BpmGardenWorkOrderDO gardenInspection = gardenService.getWorkOrder(id);
  52 + return success(BeanUtils.toBean(gardenInspection, BpmGardenWorkOrderRespVO.class));
  53 + }
  54 +
  55 + @GetMapping("/page")
  56 + @Operation(summary = "app-获得园林巡检工单申请分页")
  57 + public CommonResult<PageResult<BpmGardenWorkOrderRespVO>> getGardenInspectionPage(@Valid BpmGardenWorkOrderPageReqVO pageVO) {
  58 + PageResult<BpmGardenWorkOrderDO> pageResult = gardenService.getGardenInspectionPage(getLoginUserId(), pageVO);
  59 + return success(BeanUtils.toBean(pageResult, BpmGardenWorkOrderRespVO.class));
  60 + }
  61 +
  62 +}
... ...
urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/controller/app/garden/vo/AppGardenWorkOrderReqVO.java 0 → 100644
  1 +package com.zteits.urbanops.module.workorder.controller.app.garden.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import jakarta.validation.constraints.NotEmpty;
  5 +import jakarta.validation.constraints.NotNull;
  6 +import lombok.Data;
  7 +import org.hibernate.validator.constraints.Length;
  8 +
  9 +import java.math.BigDecimal;
  10 +import java.util.List;
  11 +import java.util.Map;
  12 +
  13 +/**
  14 + * @author yanhuiqing
  15 + * @version 1.0
  16 + * @description: app端请求参数
  17 + * @date 2025/12/6 10:17
  18 + */
  19 +@Schema(description = "APP-园林工单请求创建 Request VO")
  20 +@Data
  21 +public class AppGardenWorkOrderReqVO {
  22 +
  23 +
  24 + @Schema(description = "道路ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "21128")
  25 + @NotNull(message = "道路ID不能为空")
  26 + private Long roadId;
  27 +
  28 + @Schema(description = "问题图片", example = "9184")
  29 + private List<String> imgs;
  30 +
  31 + @Schema(description = "处理完成照片", example = "9184")
  32 + private List<String> longRangeImgList;
  33 +
  34 + @Schema(description = "工单描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "你说的对")
  35 + @NotEmpty(message = "工单描述不能为空")
  36 + @Length(max = 500)
  37 + private String remark;
  38 +
  39 + @NotEmpty(message = "经纬度类型")
  40 + @Schema(description = "经纬度类型: 1:国标; 2:百度;3:高德;4:腾讯", example = "2")
  41 + private Integer latLonType;
  42 +
  43 + @Schema(description = "经度", requiredMode = Schema.RequiredMode.REQUIRED)
  44 + @NotNull(message = "经度不能为空")
  45 + private BigDecimal lat;
  46 +
  47 + @Schema(description = "维度", requiredMode = Schema.RequiredMode.REQUIRED)
  48 + @NotNull(message = "维度不能为空")
  49 + private BigDecimal lon;
  50 +
  51 + @Schema(description = "经纬度地址", requiredMode = Schema.RequiredMode.REQUIRED)
  52 + @NotEmpty(message = "经纬度地址不能为空")
  53 + private String lonLatAddress;
  54 +
  55 + @Schema(description = "紧急程度:1:特急;2:紧急;3:一般", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
  56 + @NotNull(message = "紧急程度:1:特急;2:紧急;3:一般不能为空")
  57 + private Integer pressingType;
  58 +
  59 + @Schema(description = "工单名称", example = "绿地卫生")
  60 + private String orderName;
  61 +
  62 + @Schema(description = "来源ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  63 + //@NotNull(message = "来源ID不能为空")
  64 + private Integer sourceId;
  65 +
  66 + @Schema(description = "来源名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "园林")
  67 + //@NotEmpty(message = "来源名称不能为空")
  68 + private String sourceName;
  69 +
  70 + @Schema(description = "三方工单ID")
  71 + private String thirdWorkNo;
  72 +
  73 + /* @Schema(description = "发起人自选审批人 Map", example = "{taskKey1: [1, 2]}")
  74 + private Map<String, List<Long>> startUserSelectAssignees;
  75 +
  76 + @Schema(description = "是否需要养护人员修复,'0' 是,'1' 否")
  77 + private String isYesOrNo;*/
  78 +
  79 +
  80 +}
... ...
urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/service/garden/BpmGardenService.java
... ... @@ -3,6 +3,7 @@ package com.zteits.urbanops.module.workorder.service.garden;
3 3 import com.zteits.urbanops.framework.common.pojo.PageResult;
4 4 import com.zteits.urbanops.module.workorder.controller.admin.garden.vo.BpmGardenWorkOrderCreateReqVo;
5 5 import com.zteits.urbanops.module.workorder.controller.admin.garden.vo.BpmGardenWorkOrderPageReqVO;
  6 +import com.zteits.urbanops.module.workorder.controller.app.garden.vo.AppGardenWorkOrderReqVO;
6 7 import com.zteits.urbanops.module.workorder.dal.dataobject.garden.BpmGardenWorkOrderDO;
7 8 import jakarta.validation.Valid;
8 9 /**
... ... @@ -13,6 +14,12 @@ import jakarta.validation.Valid;
13 14 */
14 15 public interface BpmGardenService {
15 16 /**
  17 + * 园林工单申请 app service 接口
  18 + * @param createRequestVo
  19 + * @return
  20 + */
  21 + Long createWorkOrder(@Valid AppGardenWorkOrderReqVO createRequestVo);
  22 + /**
16 23 * 园林工单申请 Service 接口
17 24 * @param userId
18 25 * @param createRequestVo
... ... @@ -43,4 +50,11 @@ public interface BpmGardenService {
43 50 * @return
44 51 */
45 52 PageResult<BpmGardenWorkOrderDO> getGardenInspectionPage(Long loginUserId, BpmGardenWorkOrderPageReqVO pageVO);
  53 +
  54 + /**
  55 + * 快速流程
  56 + * @param createReqVO
  57 + * @return
  58 + */
  59 + Long createWorkOrderQuick(@Valid AppGardenWorkOrderReqVO createReqVO);
46 60 }
... ...
urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/service/garden/BpmGardenServiceImpl.java
... ... @@ -4,13 +4,17 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
4 4 import com.zteits.urbanops.framework.common.pojo.PageResult;
5 5 import com.zteits.urbanops.framework.common.util.object.BeanUtils;
6 6 import com.zteits.urbanops.framework.common.util.object.ObjectUtils;
  7 +import com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils;
7 8 import com.zteits.urbanops.module.bpm.api.task.BpmProcessInstanceApi;
8 9 import com.zteits.urbanops.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
9 10 import com.zteits.urbanops.module.bpm.enums.task.BpmTaskStatusEnum;
  11 +import com.zteits.urbanops.module.bpm.service.task.BpmProcessInstanceService;
10 12 import com.zteits.urbanops.module.workorder.api.constant.BpmCommonConstant;
  13 +import com.zteits.urbanops.module.workorder.api.workorder.WorkOrderApi;
11 14 import com.zteits.urbanops.module.workorder.controller.admin.garden.vo.BpmGardenWorkOrderCreateReqVo;
12 15 import com.zteits.urbanops.module.workorder.controller.admin.garden.vo.BpmGardenWorkOrderPageReqVO;
13 16 import com.zteits.urbanops.module.workorder.controller.admin.maininfo.vo.MainInfoPageReqVO;
  17 +import com.zteits.urbanops.module.workorder.controller.app.garden.vo.AppGardenWorkOrderReqVO;
14 18 import com.zteits.urbanops.module.workorder.dal.dataobject.attachment.AttachmentDO;
15 19 import com.zteits.urbanops.module.workorder.dal.dataobject.garden.BpmGardenWorkOrderDO;
16 20 import com.zteits.urbanops.module.workorder.dal.dataobject.maininfo.MainInfoDO;
... ... @@ -45,6 +49,72 @@ public class BpmGardenServiceImpl implements BpmGardenService{
45 49 private MainInfoMapper workOrderMapper;
46 50 @Resource
47 51 private BpmProcessInstanceApi processInstanceApi;
  52 + @Resource
  53 + private WorkOrderApi workOrderApi;
  54 +
  55 + @Override
  56 + @Transactional(rollbackFor = Exception.class)
  57 + public Long createWorkOrderQuick(AppGardenWorkOrderReqVO createRequestVo) {
  58 +
  59 + List<String> imgList = createRequestVo.getImgs();
  60 + //List<String> streetImgList = createRequestVo.getStreetImgList();
  61 + List<String> longRangeImgList = createRequestVo.getLongRangeImgList();
  62 + // 插入 工单
  63 + MainInfoDO workOrder = BeanUtils.toBean(createRequestVo, MainInfoDO.class)
  64 + .setStatus(BpmTaskStatusEnum.RUNNING.getStatus());
  65 + //TODO 设置其它值 需从道路表获取
  66 + workOrder.setStreetId("test");
  67 + workOrder.setBuzStatus("t1");//需给出映射关系
  68 + workOrder.setCommitDate(LocalDateTime.now());
  69 + String workOrderNum = workOrderApi.generateWONum(BpmCommonConstant.WORK_ORDER_PREFFIX_QUICK);
  70 + workOrder.setOrderNo(workOrderNum);
  71 + workOrder.setOrderName("园林工单");
  72 + workOrder.setCompanyId(SecurityFrameworkUtils.getCompanyId());
  73 + workOrder.setBusiLine(SecurityFrameworkUtils.getBusiLine());
  74 + workOrderMapper.insert(workOrder);
  75 +
  76 + //附件插入
  77 + attachmentApend(imgList,null,longRangeImgList,workOrder);
  78 + // 发起 BPM 流程
  79 + Map<String, Object> processInstanceVariables = new HashMap<>();
  80 + processInstanceVariables.put("remark", workOrder.getRemark());
  81 + String processInstanceId = processInstanceApi.createProcessInstance(SecurityFrameworkUtils.getLoginUserId(),
  82 + new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(BpmCommonConstant.COMMON_QUICK_PROCESS)
  83 + .setVariables(processInstanceVariables).setBusinessKey(String.valueOf(workOrder.getId())));
  84 +
  85 + // 将工作流的编号,更新到 工单中
  86 + workOrderMapper.updateById(new MainInfoDO().setId(workOrder.getId()).setProcessInstanceId(processInstanceId));
  87 + return workOrder.getId();
  88 + }
  89 +
  90 + @Override
  91 + @Transactional(rollbackFor = Exception.class)
  92 + public Long createWorkOrder(AppGardenWorkOrderReqVO createRequestVo) {
  93 + List<String> imgList = createRequestVo.getImgs();
  94 + //List<String> streetImgList = createRequestVo.getStreetImgList();
  95 + List<String> longRangeImgList = createRequestVo.getLongRangeImgList();
  96 +
  97 + MainInfoDO workOrder = BeanUtils.toBean(createRequestVo, MainInfoDO.class)
  98 + .setStatus(BpmTaskStatusEnum.NOT_START.getStatus());
  99 + //TODO 设置其它值 需从道路表获取
  100 + workOrder.setStreetId("test");
  101 + //workOrder.setBuzStatus("t1");//需给出映射关系
  102 + //workOrder.setCommitDate(LocalDateTime.now());
  103 + workOrder.setCompanyId(SecurityFrameworkUtils.getCompanyId());
  104 + workOrder.setBusiLine(SecurityFrameworkUtils.getBusiLine());
  105 + String workOrderNum = workOrderApi.generateWONum(BpmCommonConstant.WORK_ORDER_PREFFIX_GARDEN);
  106 + workOrder.setOrderNo(workOrderNum);
  107 + //workOrder.setOrderName("园林工单");
  108 + Long userId = com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId();
  109 + String nickname = com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils.getLoginUserNickname();
  110 + workOrder.setUserId(userId);
  111 + workOrder.setUserName(nickname);
  112 + workOrderMapper.insert(workOrder);
  113 + //附件插入
  114 + attachmentApend(imgList,null,longRangeImgList,workOrder);
  115 + return workOrder.getId();
  116 + }
  117 +
48 118 @Override
49 119 @Transactional(rollbackFor = Exception.class)
50 120 public Long createWorkOrder(Long userId, BpmGardenWorkOrderCreateReqVo createRequestVo) {
... ... @@ -59,6 +129,11 @@ public class BpmGardenServiceImpl implements BpmGardenService{
59 129 workOrder.setStreetId("test");
60 130 workOrder.setBuzStatus("t1");//需给出映射关系
61 131 workOrder.setCommitDate(LocalDateTime.now());
  132 + String workOrderNum = workOrderApi.generateWONum(BpmCommonConstant.WORK_ORDER_PREFFIX_GARDEN);
  133 + workOrder.setOrderNo(workOrderNum);
  134 + workOrder.setOrderName("园林工单");
  135 + workOrder.setCompanyId(SecurityFrameworkUtils.getCompanyId());
  136 + workOrder.setBusiLine(SecurityFrameworkUtils.getBusiLine());
62 137 workOrderMapper.insert(workOrder);
63 138  
64 139 //附件插入
... ... @@ -160,4 +235,6 @@ public class BpmGardenServiceImpl implements BpmGardenService{
160 235 PageResult<BpmGardenWorkOrderDO> targetList = BeanUtils.toBean(pageList,BpmGardenWorkOrderDO.class);
161 236 return targetList;
162 237 }
  238 +
  239 +
163 240 }
... ...
urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/service/garden/listener/BomGardenWorkOrderStatusListener.java renamed to urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/service/garden/listener/BpmGardenWorkOrderStatusListener.java
... ... @@ -2,6 +2,7 @@ package com.zteits.urbanops.module.workorder.service.garden.listener;
2 2  
3 3 import com.zteits.urbanops.module.bpm.api.event.BpmProcessInstanceStatusEvent;
4 4 import com.zteits.urbanops.module.bpm.api.event.BpmProcessInstanceStatusEventListener;
  5 +import com.zteits.urbanops.module.workorder.api.constant.BpmCommonConstant;
5 6 import com.zteits.urbanops.module.workorder.service.garden.BpmGardenService;
6 7 import jakarta.annotation.Resource;
7 8 import org.springframework.stereotype.Component;
... ... @@ -13,13 +14,13 @@ import org.springframework.stereotype.Component;
13 14 * @date 2025/12/1 11:45
14 15 */
15 16 @Component
16   -public class BomGardenWorkOrderStatusListener extends BpmProcessInstanceStatusEventListener {
  17 +public class BpmGardenWorkOrderStatusListener extends BpmProcessInstanceStatusEventListener {
17 18 @Resource
18 19 private BpmGardenService gardenService;
19 20 @Override
20 21 protected String getProcessDefinitionKey() {
21 22  
22   - return null;
  23 + return BpmCommonConstant.BPM_GARDEN_INSPECT_WO;
23 24 }
24 25  
25 26 @Override
... ...
urbanops-module-workorder/src/main/java/com/zteits/urbanops/module/workorder/service/garden/listener/BpmQuickProcessTaskAutoCompleteListener.java 0 → 100644
  1 +package com.zteits.urbanops.module.workorder.service.garden.listener;
  2 +
  3 +import com.zteits.urbanops.module.bpm.api.event.BpmProcessInstanceStatusEvent;
  4 +import com.zteits.urbanops.module.bpm.api.event.BpmProcessInstanceStatusEventListener;
  5 +import com.zteits.urbanops.module.workorder.api.constant.BpmCommonConstant;
  6 +import com.zteits.urbanops.module.workorder.service.garden.BpmGardenService;
  7 +import jakarta.annotation.Resource;
  8 +import org.flowable.common.engine.api.delegate.event.FlowableEngineEntityEvent;
  9 +import org.springframework.stereotype.Component;
  10 +
  11 +/**
  12 + * @author yanhuiqing
  13 + * @version 1.0
  14 + * @description: 快速处理流程的任务自动完成监听器
  15 + * @date 2025/12/6 14:00
  16 + */
  17 +@Component
  18 +public class BpmQuickProcessTaskAutoCompleteListener extends BpmProcessInstanceStatusEventListener {
  19 + @Resource
  20 + private BpmGardenService gardenService;
  21 + @Override
  22 + protected String getProcessDefinitionKey() {
  23 + return BpmCommonConstant.COMMON_QUICK_PROCESS;
  24 + }
  25 +
  26 + @Override
  27 + protected void onEvent(BpmProcessInstanceStatusEvent event) {
  28 + gardenService.updateWorkOrderStatus(Long.parseLong(event.getBusinessKey()), event.getStatus());
  29 +
  30 + }
  31 +}
... ...