Administrator
2023-06-19 49588f5a462ae7425e7eb030438a35fd80c246fa
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package com.gk.firework.Service.ServiceImpl;
 
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gk.firework.Domain.Enterprise;
import com.gk.firework.Domain.EnterpriseApply;
import com.gk.firework.Domain.Enum.ApplyStatus;
import com.gk.firework.Domain.Enum.CommitStatus;
import com.gk.firework.Domain.UserInfo;
import com.gk.firework.Domain.Utils.StringUtils;
import com.gk.firework.Domain.Vo.ApprovalVo;
import com.gk.firework.Mapper.EnterpriseApplyMapper;
import com.gk.firework.Service.EnterpriseApplyService;
import com.gk.firework.Service.EnterpriseService;
import com.gk.firework.Service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.lang.reflect.Field;
import java.util.*;
 
@Service("enterpriseApplyService")
public class EnterpriseApplyServiceImpl  extends ServiceImpl<EnterpriseApplyMapper, EnterpriseApply> implements EnterpriseApplyService {
 
    @Autowired
    private EnterpriseApplyMapper enterpriseApplyMapper;
    @Autowired
    private EnterpriseService enterpriseService;
    @Autowired
    private UserService userService;
 
    @Override
    public IPage<EnterpriseApply> selectEnterpriseApply(Page<EnterpriseApply> page, EnterpriseApply enterpriseApplyFilter,UserInfo user) {
        UserInfo userInfo = userService.getById(user.getId());
        LambdaQueryWrapper<EnterpriseApply> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.select(EnterpriseApply::getId,
                EnterpriseApply::getApplytime,
                EnterpriseApply::getApplypersonname,
                EnterpriseApply::getProcesstime,
                EnterpriseApply::getProcesspersonname,
                EnterpriseApply::getApplystatus
               )
                .orderByDesc(EnterpriseApply::getApplytime)
                .eq(EnterpriseApply::getValidflag, true);
 
        //企业用户
        if (userInfo.getCompanyid() != null) {
            queryWrapper.eq(EnterpriseApply::getId, userInfo.getCompanyid());
        }
        //监管部门 根据 地区看所有
        if(userInfo.getType()==3){
            if (StringUtils.isNotBlank(userInfo.getProvince()))
                queryWrapper.eq(EnterpriseApply::getProvince, userInfo.getProvince());
            if (StringUtils.isNotBlank(userInfo.getCity()))
                queryWrapper.eq(EnterpriseApply::getCity, userInfo.getCity());
            if (StringUtils.isNotBlank(userInfo.getArea()))
                queryWrapper.eq(EnterpriseApply::getDistrict, userInfo.getArea());
            if (StringUtils.isNotBlank(userInfo.getTown()))
                queryWrapper.eq(EnterpriseApply::getStreet, userInfo.getTown());
            if (StringUtils.isNotBlank(userInfo.getCommunity()))
                queryWrapper.eq(EnterpriseApply::getCommittee, userInfo.getCommunity());
        }
        return this.page(page, queryWrapper);
    }
 
    @Override
    public List getApplyList(EnterpriseApply enterpriseApplyFilter) {
        LambdaQueryWrapper<EnterpriseApply> queryWrapper = new LambdaQueryWrapper<>();
        return enterpriseApplyMapper.selectList(queryWrapper);
    }
 
 
    /**
    * @Description:
    * @param enterprise 需要更新字段的对象 updateObj 更新字段
    */
    private void updateSetFields(Enterprise enterprise, JSONObject updateObj) throws NoSuchFieldException, IllegalAccessException {
        Map<String, Object> innerMap = updateObj.getInnerMap();
        assert innerMap.size() > 0;
        for (Map.Entry<String, Object> entry : innerMap.entrySet()) {
            String field = entry.getKey();
            Field declaredField = enterprise.getClass().getDeclaredField(field);
            declaredField.setAccessible(true);
            declaredField.set(enterprise, entry.getValue());
 
        }
    }
 
 
}