Pu Zhibing
2025-02-25 91ebbdc5ef67699d166498f6cf5fcc21058817dd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package com.panzhihua.sangeshenbian.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.netflix.servo.monitor.LongGauge;
import com.panzhihua.common.exceptions.ServiceException;
import com.panzhihua.common.model.vos.LoginUserInfoVO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.service.user.UserService;
import com.panzhihua.sangeshenbian.enums.ReportTypeEnum;
import com.panzhihua.sangeshenbian.model.entity.*;
import com.panzhihua.sangeshenbian.dao.ComplaintFlowMapper;
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.context.annotation.Lazy;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.Date;
 
/**
 * <p>
 * 诉求流转记录表 服务实现类
 * </p>
 *
 * @author
 * @since 2025-02-22
 */
@Service
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
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;
    private final UserService userService;
 
    @Override
    public void createFlow(Long complaintId , Long superiorId, Integer reportType, Integer type, Long userId) {
 
 
        String name = getFlowName(reportType, superiorId);
 
        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, Long superiorId) {
        String name;
        if (reportType == ReportTypeEnum.COMMUNITY.getCode()) {
            ComAct byId = comActService.getById(superiorId);
            name = byId.getName();
        }else if (reportType == ReportTypeEnum.STREET.getCode()) {
            ComStreet comStreet = comStreetService.getById(superiorId);
            name = comStreet.getName();
        }  else if (reportType == ReportTypeEnum.CITY.getCode() || reportType == ReportTypeEnum.DISTRICT.getCode()){
            BcRegion bcRegion = bcRegionService.getOne(new LambdaQueryWrapper<BcRegion>()
                    .eq(BcRegion::getRegionCode, superiorId));
            name = bcRegion.getRegionName();
        } else {
            R<LoginUserInfoVO> userR = userService.getUserInfoByUserId(String.valueOf(superiorId));
            if (R.isOk(userR)) {
                throw new ServiceException("获取用户信息失败");
            }
            name =  userR.getData().getNickName();
        }
        return name;
    }
}