郑永安
2023-06-19 59e91a4e9ddaf23cebb12993c774aa899ab22d16
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package com.gk.firework.Service.ServiceImpl;
 
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.Exception.BusinessException;
import com.gk.firework.Domain.StandardLawList;
import com.gk.firework.Domain.UserInfo;
import com.gk.firework.Domain.Utils.Properties;
import com.gk.firework.Domain.Utils.StringUtils;
import com.gk.firework.Domain.Utils.UploadUtil;
import com.gk.firework.Mapper.StandardLawListMapper;
import com.gk.firework.Service.StandardLawListService;
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.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
 
@Service("standardLawListService")
public class StandardLawListServiceImpl extends ServiceImpl<StandardLawListMapper, StandardLawList> implements StandardLawListService {
 
    @Autowired
    private UserService userService;
    @Autowired
    private StandardLawListMapper standardLawListMapper;
 
    /**
    * @Description: 适用法律法规分页查询
    * @date 2021/5/8 13:54
    */
    @Override
    public IPage selectPage(Page<StandardLawList> page, Map filter, UserInfo userInfo) {
 
        UserInfo user = userService.getById(userInfo.getId());
        Map<String, Object> params = new HashMap<>();
        //菜单
        //可视权限
        {
            params.put("enterprisenumber", user.getCompanynumber());
            params.put("province", user.getProvince());
            params.put("city", user.getCity());
            params.put("district", user.getArea());
            params.put("street", user.getTown());
            params.put("committee", user.getCommunity());
        }
 
        params.put("filterProvince", filter.get("province"));
        params.put("filterCity", filter.get("city"));
        params.put("filterDistrict", filter.get("district"));
        params.put("filterStreet", filter.get("street"));
        params.put("filterCommittee", filter.get("committee"));
        params.put("safetysupervision", filter.get("safetysupervision"));
        params.put("enterprisename", filter.get("enterprisename"));
        //按法律法规标准查
        params.put("name", filter.get("name"));
        List<StandardLawList> list =  standardLawListMapper.selectPages(page,params);
        return page.setRecords(list);
    }
 
 
    /**
    * @Description: 新增法律法规清单
    * @date 2021/5/8 14:06
    */
    @Override
    @Transactional
    public void addStandardLawList(StandardLawList standardLawList, UserInfo userInfo) {
        if (standardLawList.getFile() == null) {
            throw new BusinessException("需要上传文件");
        }
 
        UserInfo user = userService.getById(userInfo.getId());
        standardLawList.setCreateby(user.getId());
        standardLawList.setCreatebyname(user.getUsername());
        standardLawList.setCreatetime(new Date());
        standardLawList.setValidflag(true);
        standardLawList.setEnterprisenumber(user.getUsername());
        standardLawList.setEnterprisename(user.getUsername());
 
        assert standardLawList.getFile() != null;
        try {
            String name = UploadUtil.uploadFile(standardLawList.getFile(), Properties.standardPath);
            standardLawList.setFilename(standardLawList.getFile().getOriginalFilename());
            standardLawList.setUrl(Properties.standard + name);
        } catch (Exception e) {
            e.printStackTrace();
            throw new BusinessException("上传文件失败");
        }
        this.save(standardLawList);
    }
 
 
    /**
    * @Description: 修改法律法规清单
    * @date 2021/5/8 14:07
    */
    @Override
    public void modStandardLawList(StandardLawList standardLawList, UserInfo user) {
        standardLawList.setUpdateby(user.getId());
        standardLawList.setUpdatebyname(user.getUsername());
        standardLawList.setUpdatetime(new Date());
 
        try {
            if (standardLawList.getFile() != null) {
                String name = UploadUtil.uploadFile(standardLawList.getFile(), Properties.standardPath);
                standardLawList.setFilename(standardLawList.getFile().getOriginalFilename());
                standardLawList.setUrl(Properties.standard + name);
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new BusinessException("上传文件失败");
        }
        this.updateById(standardLawList);
    }
 
 
    /**
    * @Description: 删除法律法规清单
    * @date 2021/5/8 14:11
    */
    @Override
    public void delStandardLawList(Long id, UserInfo user) {
        LambdaUpdateWrapper<StandardLawList> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.set(StandardLawList::getValidflag, false)
                .set(StandardLawList::getUpdatetime, new Date())
                .set(StandardLawList::getUpdateby, user.getId())
                .set(StandardLawList::getUpdatebyname,user.getUsername())
                .eq(StandardLawList::getId, id);
        this.update(updateWrapper);
    }
}