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
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
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.StandardEducationLeger;
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.UploadUtil;
import com.gk.firework.Mapper.StandardEducationLegerMapper;
import com.gk.firework.Service.StandardEducationLegerService;
import com.gk.firework.Service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
@Service("standardEducationLegerService")
public class StandardEducationLegerServiceImpl  extends ServiceImpl<StandardEducationLegerMapper, StandardEducationLeger> implements StandardEducationLegerService {
 
    @Autowired
    private UserService userService;
    @Autowired
    private StandardEducationLegerMapper standardEducationLegerMapper;
 
    /**
    * @Description: 查询从业人员教育培训台账
    * @date 2021/5/8 16:33
    */
    @Override
    public IPage selectPage(Page<StandardEducationLeger> 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"));
        List<StandardEducationLeger> list =  standardEducationLegerMapper.selectPages(page,params);
        return page.setRecords(list);
    }
 
    @Override
    public void addStandardEducationLeger(StandardEducationLeger standardEducationLeger, UserInfo userInfo) {
        if (standardEducationLeger.getFile() == null) {
            throw new BusinessException("需要上传文件");
        }
 
        UserInfo user = userService.getById(userInfo.getId());
        standardEducationLeger.setCreateby(user.getId());
        standardEducationLeger.setCreatebyname(user.getUsername());
        standardEducationLeger.setCreatetime(new Date());
        standardEducationLeger.setValidflag(true);
        standardEducationLeger.setEnterprisenumber(user.getUsername());
        standardEducationLeger.setEnterprisename(user.getUsername());
 
        assert standardEducationLeger.getFile() != null;
        try {
            String name = UploadUtil.uploadFile(standardEducationLeger.getFile(), Properties.standardPath);
            standardEducationLeger.setFilename(standardEducationLeger.getFile().getOriginalFilename());
            standardEducationLeger.setUrl(Properties.standard + name);
        } catch (Exception e) {
            e.printStackTrace();
            throw new BusinessException("上传文件失败");
        }
        this.save(standardEducationLeger);
    }
 
 
 
    @Override
    public void modStandardEducationLeger(StandardEducationLeger standardEducationLeger, UserInfo user) {
        standardEducationLeger.setUpdateby(user.getId());
        standardEducationLeger.setUpdatebyname(user.getUsername());
        standardEducationLeger.setUpdatetime(new Date());
 
        try {
            if (standardEducationLeger.getFile() != null) {
                String name = UploadUtil.uploadFile(standardEducationLeger.getFile(), Properties.standardPath);
                standardEducationLeger.setFilename(standardEducationLeger.getFile().getOriginalFilename());
                standardEducationLeger.setUrl(Properties.standard + name);
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new BusinessException("上传文件失败");
        }
        this.updateById(standardEducationLeger);
    }
 
    @Override
    public void delStandardEducationLeger(Long id, UserInfo user) {
        LambdaUpdateWrapper<StandardEducationLeger> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.set(StandardEducationLeger::getValidflag, false)
                .set(StandardEducationLeger::getUpdatetime, new Date())
                .set(StandardEducationLeger::getUpdateby, user.getId())
                .set(StandardEducationLeger::getUpdatebyname,user.getUsername())
                .eq(StandardEducationLeger::getId, id);
        this.update(updateWrapper);
    }
}