From e5ca6b1d9e961d51cb607e34ad259f7495d917e0 Mon Sep 17 00:00:00 2001
From: luofl <1442745593@qq.com>
Date: 星期日, 23 二月 2025 23:52:59 +0800
Subject: [PATCH] 1.

---
 springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/ComplaintFlowServiceImpl.java |   51 +++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/ComplaintFlowServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/ComplaintFlowServiceImpl.java
index b2e91f5..a97576b 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/ComplaintFlowServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/ComplaintFlowServiceImpl.java
@@ -1,10 +1,17 @@
 package com.panzhihua.sangeshenbian.service.impl;
 
-import com.panzhihua.sangeshenbian.model.entity.ComplaintFlow;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.panzhihua.common.exceptions.ServiceException;
+import com.panzhihua.sangeshenbian.enums.ReportTypeEnum;
+import com.panzhihua.sangeshenbian.model.entity.*;
 import com.panzhihua.sangeshenbian.dao.ComplaintFlowMapper;
-import com.panzhihua.sangeshenbian.service.IComplaintFlowService;
+import com.panzhihua.sangeshenbian.service.*;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.RequiredArgsConstructor;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+
+import java.util.Date;
 
 /**
  * <p>
@@ -15,6 +22,46 @@
  * @since 2025-02-22
  */
 @Service
+@RequiredArgsConstructor(onConstructor = @__(@Autowired))
 public class ComplaintFlowServiceImpl extends ServiceImpl<ComplaintFlowMapper, ComplaintFlow> implements IComplaintFlowService {
+    private final IComplaintService complaintService;
+    private final IBcRegionService bcRegionService;
+    private final IComStreetService comStreetService;
+    private final IComActService comActService;
 
+    @Override
+    public void createFlow(Long complaintId , Integer type, Long userId) {
+
+        Complaint complaint = complaintService.getById(complaintId);
+        Integer reportType = complaint.getReportType();
+
+        String name = getFlowName(reportType, complaint);
+
+        ComplaintFlow complaintFlow = new ComplaintFlow();
+        complaintFlow.setComplaintId(complaintId);
+        complaintFlow.setLevel(reportType);
+        complaintFlow.setName(name);
+        complaintFlow.setCreateTime(new Date(System.currentTimeMillis()));
+        complaintFlow.setType(type);
+        save(complaintFlow);
+    }
+
+    private String getFlowName(Integer reportType, Complaint complaint) {
+        String name;
+        if (reportType == ReportTypeEnum.COMMUNITY.getCode()) {
+            ComAct byId = comActService.getById(complaint.getSuperiorId());
+            name = byId.getName();
+        }else if (reportType == ReportTypeEnum.STREET.getCode()) {
+            ComStreet comStreet = comStreetService.getById(complaint.getSuperiorId());
+            name = comStreet.getName();
+        }  else if (reportType == ReportTypeEnum.CITY.getCode() || reportType == ReportTypeEnum.DISTRICT.getCode()){
+            BcRegion bcRegion = bcRegionService.getOne(new LambdaQueryWrapper<BcRegion>()
+                    .eq(BcRegion::getRegionCode, complaint.getSuperiorId()));
+            name = bcRegion.getRegionName();
+        } else {
+            // 处理未预期的账号等级
+            throw new ServiceException("未知的账号等级");
+        }
+        return name;
+    }
 }

--
Gitblit v1.7.1