Browse Source

add:考勤统计页面 查询服务单元-sop方法优化

caozixuan 1 năm trước cách đây
mục cha
commit
c4aa5893ba

+ 20 - 3
sop-api/src/main/java/com/qmth/sop/server/api/TBDingController.java

@@ -277,9 +277,26 @@ public class TBDingController {
     @RequestMapping(value = "/ding_find_all_sop", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "查询成功", response = DingElementResult.class)})
     @OperationLog
-    public Result findDingAllSop(@ApiParam(value = "服务单元id", required = true) @RequestParam String serviceUnitId) {
+    public Result findDingAllSop() {
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
-        List<SopInfoResult> list = tbSopInfoService.findFlowByServiceId(SystemConstant.convertIdToLong(serviceUnitId), requestUser.getId());
-        return ResultUtil.ok(list);
+        List<DingSopInfo> resultList = new ArrayList<>();
+        List<SopInfoResult> list = tbSopInfoService.findFlowByServiceId(null, requestUser.getId());
+        List<Long> serviceUnitIdList = list.stream().map(SopInfoResult::getServiceId).distinct().collect(Collectors.toList());
+        for (Long serviceUnitId : serviceUnitIdList) {
+            DingSopInfo cell = new DingSopInfo();
+            TBService service = tbServiceService.getById(serviceUnitId);
+            if (Objects.isNull(service)) {
+                throw ExceptionResultEnum.ERROR.exception("未找到服务单元");
+            }
+
+            cell.setServiceUnitId(serviceUnitId);
+            cell.setServiceUnitName(service.getName());
+            List<SopInfoResult> sopInServiceList = list.stream()
+                    .filter(e -> serviceUnitId.equals(e.getServiceId()))
+                    .distinct().collect(Collectors.toList());
+            cell.setSopInfo(sopInServiceList);
+            resultList.add(cell);
+        }
+        return ResultUtil.ok(resultList);
     }
 }