From 35f6bd0e69018621c2293b96ddcde55b2bc58d36 Mon Sep 17 00:00:00 2001
From: wl <173@qq.com>
Date: 星期五, 30 九月 2022 16:31:23 +0800
Subject: [PATCH] 结案 暂不处理 我的待办 功能实现

---
 ycl-platform/src/main/java/com/ycl/vo/MyBacklogVO.java                                    |   48 ++++++++++++
 ycl-platform/src/main/java/com/ycl/controller/caseHandler/BaseCaseController.java         |   49 ++++++++++-
 ycl-platform/src/main/java/com/ycl/service/caseHandler/impl/DisposeRecordServiceImpl.java |   34 ++++++++
 ycl-platform/src/main/java/com/ycl/service/caseHandler/IDisposeRecordService.java         |    6 +
 ycl-platform/src/main/java/com/ycl/service/caseHandler/impl/BaseCaseServiceImpl.java      |   26 ++++++
 ycl-platform/src/main/java/com/ycl/controller/caseHandler/DispatchHandleController.java   |    1 
 ycl-platform/src/main/java/com/ycl/controller/caseHandler/DisposeRecordController.java    |   29 ++++++
 ycl-platform/src/main/java/com/ycl/dto/casePool/IllegalBuildingParam.java                 |    3 
 ycl-platform/src/main/java/com/ycl/service/caseHandler/IBaseCaseService.java              |    2 
 9 files changed, 186 insertions(+), 12 deletions(-)

diff --git a/ycl-platform/src/main/java/com/ycl/controller/caseHandler/BaseCaseController.java b/ycl-platform/src/main/java/com/ycl/controller/caseHandler/BaseCaseController.java
index c607977..6b74abf 100644
--- a/ycl-platform/src/main/java/com/ycl/controller/caseHandler/BaseCaseController.java
+++ b/ycl-platform/src/main/java/com/ycl/controller/caseHandler/BaseCaseController.java
@@ -2,6 +2,7 @@
 
 
 import com.alibaba.druid.util.StringUtils;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ycl.api.CommonResult;
@@ -9,6 +10,7 @@
 import com.ycl.dto.casePool.IllegalBuildingParam;
 import com.ycl.dto.casePool.ViolationParam;
 import com.ycl.entity.caseHandler.BaseCase;
+import com.ycl.entity.caseHandler.DisposeRecord;
 import com.ycl.service.caseHandler.IBaseCaseService;
 import com.ycl.service.caseHandler.IDisposeRecordService;
 import com.ycl.service.caseHandler.IIllegalBuildingService;
@@ -36,7 +38,7 @@
  * @since 2022-09-24
  */
 @RestController
-@RequestMapping("/base-case")
+@RequestMapping("/base_case")
 @Api(tags = "妗堜欢姹�")
 public class BaseCaseController extends BaseController {
 
@@ -204,7 +206,7 @@
         return CommonResult.success(baseCaseService.baseCaseDetail(code));
     }
 
-    @ApiOperation("浜哄伐璺緞妗堜欢鍥剧墖灞曠ず")
+    @ApiOperation(value = "浜哄伐璺緞妗堜欢鍥剧墖灞曠ず")
     @GetMapping("/hand_work_case_images")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "type", value = "01 杩濊,02 杩濆缓", dataType = "Integer")
@@ -213,13 +215,46 @@
         return CommonResult.success(baseCaseService.listCaseImages(id, type));
     }
 
-    @ApiOperation("妗堜欢鏆備笉澶勭悊")
-    @PutMapping("/case_leave")
-    public CommonResult updateCaseStatus(@RequestParam Integer caseId) {
-        Integer leaveType = 8;
+    /**
+     * @return com.ycl.api.CommonResult
+     * @Description case status update
+     * @Param [caseId, status]
+     **/
+    @ApiOperation(value = "妗堜欢鐘舵�佷慨鏀�")
+    @PutMapping("/case_status_update")
+    @ApiImplicitParams({
+            @ApiImplicitParam(value = "澶勭悊鐘舵��(0璇姤 1涓婃姤 2绔嬫 3娲鹃仯 4澶勭疆 5鏍告煡 6缁撴7澶勭悊涓�8鏆備笉澶勭悊)",name = "state")
+    })
+    public CommonResult updateCaseStatus(@RequestParam Integer caseId, @RequestParam Integer state) {
         return CommonResult.success(baseCaseService
                 .update(new LambdaUpdateWrapper<BaseCase>()
                         .eq(BaseCase::getId, caseId)
-                        .set(BaseCase::getState, leaveType)));
+                        .set(BaseCase::getState, state)));
+    }
+
+    /**
+     * @return com.ycl.api.CommonResult
+     * @Description reset case
+     * @Param [caseId]
+     **/
+    @ApiOperation(value = "鏆備笉澶勭疆閲嶆柊澶勭疆")
+    @PutMapping("/reset")
+    public CommonResult resetCase(@RequestParam Integer caseId) {
+        Integer firstNum = 0;
+        Integer state = iDisposeRecordService
+                .list(new LambdaQueryWrapper<DisposeRecord>()
+                        .eq(DisposeRecord::getBaseCaseId, caseId).
+                        orderByDesc(DisposeRecord::getCreateTime)).get(firstNum).getState();
+        return CommonResult.success(baseCaseService
+                .update(new LambdaUpdateWrapper<BaseCase>()
+                        .eq(BaseCase::getId, caseId)
+                        .set(BaseCase::getState, state)));
+    }
+
+    @ApiOperation(value = "缁撴")
+    @PutMapping("/end_case")
+    public  CommonResult endCase(@RequestParam Integer caseId,@RequestParam String result){
+        baseCaseService.endCase(caseId,result);
+        return CommonResult.success("end case success~!");
     }
 }
diff --git a/ycl-platform/src/main/java/com/ycl/controller/caseHandler/DispatchHandleController.java b/ycl-platform/src/main/java/com/ycl/controller/caseHandler/DispatchHandleController.java
index 1fecdd0..447e0e0 100644
--- a/ycl-platform/src/main/java/com/ycl/controller/caseHandler/DispatchHandleController.java
+++ b/ycl-platform/src/main/java/com/ycl/controller/caseHandler/DispatchHandleController.java
@@ -85,6 +85,7 @@
             writ.setCreateUser(user.getUserId().intValue());
             iWritService.save(writ);
         }
+        /// TODO: 2022/9/30 娣诲姞鎴愬姛鍚庝慨鏀规浠朵笓棰� 娣诲姞娴佺▼ 
         return CommonResult.success("add success");
     }
 }
diff --git a/ycl-platform/src/main/java/com/ycl/controller/caseHandler/DisposeRecordController.java b/ycl-platform/src/main/java/com/ycl/controller/caseHandler/DisposeRecordController.java
index 315dbaa..624d095 100644
--- a/ycl-platform/src/main/java/com/ycl/controller/caseHandler/DisposeRecordController.java
+++ b/ycl-platform/src/main/java/com/ycl/controller/caseHandler/DisposeRecordController.java
@@ -1,9 +1,18 @@
 package com.ycl.controller.caseHandler;
 
 
+import com.ycl.api.CommonResult;
+import com.ycl.bo.AdminUserDetails;
 import com.ycl.controller.BaseController;
+import com.ycl.service.caseHandler.IDisposeRecordService;
+import com.ycl.vo.MyBacklogVO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
-
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 
@@ -16,7 +25,23 @@
  * @since 2022-09-24
  */
 @RestController
-@RequestMapping("/dispose-record")
+@RequestMapping("/my_backlog")
+@Api(tags = "鎴戠殑寰呭姙")
 public class DisposeRecordController extends BaseController {
 
+    @Autowired
+    IDisposeRecordService iDisposeRecordService;
+
+    /**
+     * @return com.ycl.api.CommonResult
+     * @Description query my task
+     * @Param [caseId]
+     **/
+    @ApiOperation(value = "鏌ヨ", response = MyBacklogVO.class)
+    @GetMapping("/query")
+    public CommonResult searchMyTask(@RequestParam Integer caseId) {
+        AdminUserDetails user = (AdminUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
+        return CommonResult.success(iDisposeRecordService.listMyTask(caseId, user.getUserId()));
+    }
+
 }
diff --git a/ycl-platform/src/main/java/com/ycl/dto/casePool/IllegalBuildingParam.java b/ycl-platform/src/main/java/com/ycl/dto/casePool/IllegalBuildingParam.java
index 49dbfd9..e9f7a8c 100644
--- a/ycl-platform/src/main/java/com/ycl/dto/casePool/IllegalBuildingParam.java
+++ b/ycl-platform/src/main/java/com/ycl/dto/casePool/IllegalBuildingParam.java
@@ -6,6 +6,7 @@
 import lombok.Data;
 
 import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
 import java.time.LocalDateTime;
 
 @Data
@@ -16,7 +17,7 @@
      * 杩濆缓绫诲埆
      */
     @ApiModelProperty(value = "杩濆缓绫诲埆")
-    @NotBlank(message = "涓嶅厑璁歌繚寤虹被鍒负绌�")
+    @NotNull(message = "涓嶅厑璁歌繚寤虹被鍒负绌�")
     private Integer categoryId;
 
 
diff --git a/ycl-platform/src/main/java/com/ycl/service/caseHandler/IBaseCaseService.java b/ycl-platform/src/main/java/com/ycl/service/caseHandler/IBaseCaseService.java
index a63356e..fd79ad5 100644
--- a/ycl-platform/src/main/java/com/ycl/service/caseHandler/IBaseCaseService.java
+++ b/ycl-platform/src/main/java/com/ycl/service/caseHandler/IBaseCaseService.java
@@ -48,4 +48,6 @@
     BaseCaseDetail baseCaseDetail(String code);
 
     ArrayList<String> listCaseImages(Integer id, Integer type);
+
+    void endCase(Integer caseId, String result);
 }
diff --git a/ycl-platform/src/main/java/com/ycl/service/caseHandler/IDisposeRecordService.java b/ycl-platform/src/main/java/com/ycl/service/caseHandler/IDisposeRecordService.java
index 104b4f5..362dbd1 100644
--- a/ycl-platform/src/main/java/com/ycl/service/caseHandler/IDisposeRecordService.java
+++ b/ycl-platform/src/main/java/com/ycl/service/caseHandler/IDisposeRecordService.java
@@ -1,7 +1,10 @@
 package com.ycl.service.caseHandler;
 
-import com.ycl.entity.caseHandler.DisposeRecord;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.ycl.entity.caseHandler.DisposeRecord;
+import com.ycl.vo.MyBacklogVO;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +16,5 @@
  */
 public interface IDisposeRecordService extends IService<DisposeRecord> {
 
+    List<MyBacklogVO> listMyTask(Integer caseId, Long userId);
 }
diff --git a/ycl-platform/src/main/java/com/ycl/service/caseHandler/impl/BaseCaseServiceImpl.java b/ycl-platform/src/main/java/com/ycl/service/caseHandler/impl/BaseCaseServiceImpl.java
index 936760c..62abac5 100644
--- a/ycl-platform/src/main/java/com/ycl/service/caseHandler/impl/BaseCaseServiceImpl.java
+++ b/ycl-platform/src/main/java/com/ycl/service/caseHandler/impl/BaseCaseServiceImpl.java
@@ -5,6 +5,7 @@
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ycl.bo.AdminUserDetails;
 import com.ycl.bo.casePool.CasePoolIllegalBuildingDO;
 import com.ycl.bo.casePool.CasePoolViolationDO;
 import com.ycl.dto.casePool.IllegalBuildingParam;
@@ -24,6 +25,7 @@
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -81,6 +83,8 @@
     InvestigationMapper investigationMapper;
     @Resource
     WritMapper writMapper;
+    @Resource
+    DisposeRecordMapper disposeRecordMapper;
 
     @Resource
     WorkflowConfigStepMapper workflowConfigStepMapper;
@@ -283,4 +287,26 @@
         }
         return caseImages;
     }
+
+    @Override
+    public void endCase(Integer caseId, String result) {
+        AdminUserDetails user = (AdminUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
+        Integer endCaseState = 6;
+        Integer state = 2;
+        String endCaseName = "缁撴";
+        BaseCase baseCase = new BaseCase();
+        baseCase.setState(endCaseState);
+        baseCase.setId(caseId);
+        baseCaseMapper.updateById(baseCase);
+        DisposeRecord disposeRecord = new DisposeRecord();
+        disposeRecord.setBaseCaseId(caseId);
+        disposeRecord.setWorkflowConfigStepId(workflowConfigStepMapper
+                .selectOne(new LambdaQueryWrapper<WorkflowConfigStep>().eq(WorkflowConfigStep::getName, endCaseName))
+                .getWorkflowConfigId());
+        disposeRecord.setCreateUser(user.getUserId().intValue());
+        disposeRecord.setResult(result);
+        disposeRecord.setState(state);
+        disposeRecord.setCreateTime(LocalDateTime.now());
+        disposeRecordMapper.insert(disposeRecord);
+    }
 }
\ No newline at end of file
diff --git a/ycl-platform/src/main/java/com/ycl/service/caseHandler/impl/DisposeRecordServiceImpl.java b/ycl-platform/src/main/java/com/ycl/service/caseHandler/impl/DisposeRecordServiceImpl.java
index 444a47f..1777567 100644
--- a/ycl-platform/src/main/java/com/ycl/service/caseHandler/impl/DisposeRecordServiceImpl.java
+++ b/ycl-platform/src/main/java/com/ycl/service/caseHandler/impl/DisposeRecordServiceImpl.java
@@ -1,10 +1,19 @@
 package com.ycl.service.caseHandler.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ycl.entity.caseHandler.BaseCase;
 import com.ycl.entity.caseHandler.DisposeRecord;
+import com.ycl.mapper.caseHandler.BaseCaseMapper;
 import com.ycl.mapper.caseHandler.DisposeRecordMapper;
 import com.ycl.service.caseHandler.IDisposeRecordService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ycl.vo.MyBacklogVO;
+import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -17,4 +26,27 @@
 @Service
 public class DisposeRecordServiceImpl extends ServiceImpl<DisposeRecordMapper, DisposeRecord> implements IDisposeRecordService {
 
+    @Resource
+    BaseCaseMapper baseCaseMapper;
+
+    @Resource
+    DisposeRecordMapper disposeRecordMapper;
+
+    @Override
+    public List<MyBacklogVO> listMyTask(Integer caseId, Long userId) {
+        return disposeRecordMapper.selectList(
+                        new LambdaQueryWrapper<DisposeRecord>()
+                                .eq(DisposeRecord::getHandlerId, userId.intValue())
+                                .isNull(DisposeRecord::getEndTime))
+                .stream()
+                .map(item -> {
+                    MyBacklogVO myBacklogVO = new MyBacklogVO();
+                    BeanUtils.copyProperties(item, myBacklogVO);
+                    BaseCase baseCase = baseCaseMapper.selectById(caseId);
+                    myBacklogVO.setCategory(baseCase.getCategory());
+                    myBacklogVO.setEventSource(baseCase.getEventSource());
+                    myBacklogVO.setCode(baseCase.getCode());
+                    return myBacklogVO;
+                }).collect(Collectors.toList());
+    }
 }
diff --git a/ycl-platform/src/main/java/com/ycl/vo/MyBacklogVO.java b/ycl-platform/src/main/java/com/ycl/vo/MyBacklogVO.java
new file mode 100644
index 0000000..30a938f
--- /dev/null
+++ b/ycl-platform/src/main/java/com/ycl/vo/MyBacklogVO.java
@@ -0,0 +1,48 @@
+package com.ycl.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@Data
+@ApiModel(value = "鎴戠殑寰呭姙")
+public class MyBacklogVO {
+
+    /**
+     * 浜嬩欢缂栧彿
+     */
+    @ApiModelProperty(value = "浜嬩欢缂栧彿")
+    private String code;
+
+    /**
+     * 浜嬩欢鏉ユ簮(1-瑙嗛 2-鎵嬪姩鐧昏)
+     */
+    @ApiModelProperty(value = "浜嬩欢鏉ユ簮(1-瑙嗛 2-鎵嬪姩鐧昏)")
+    private Integer eventSource;
+
+    /**
+     * 闂绫诲埆锛�1-杩濊 2-杩濆缓锛�
+     */
+    @ApiModelProperty(value = "闂绫诲埆锛�1-杩濊 2-杩濆缓锛�")
+    private Integer category;
+
+    /**
+     * 鐜妭鍚嶇О
+     */
+    @ApiModelProperty(value = "鐜妭鍚嶇О")
+    private String stepName;
+
+    /**
+     * 鍒涘缓鏃堕棿
+     */
+    @ApiModelProperty(value = "鍒涘缓鏃堕棿")
+    private LocalDateTime createTime;
+
+    /**
+     * 鍓╀綑鏃堕棿
+     */
+    @ApiModelProperty(value = "寮�濮嬫椂闂�")
+    private LocalDateTime limitTime;
+}
\ No newline at end of file

--
Gitblit v1.8.0