智慧保安后台管理-外网项目备份
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
 
package org.springblade.modules.accreditation.service.impl;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import org.springblade.common.utils.QRCodeUtil;
import org.springblade.modules.FTP.FtpUtil;
import org.springblade.modules.accreditation.excel.ExportSecurityBookPaperExcel;
import org.springblade.modules.accreditation.excel.ExportSecurityPaperExcel;
import org.springblade.modules.accreditation.entity.AccreditationRecords;
import org.springblade.modules.accreditation.mapper.AccreditationRecordsMapper;
import org.springblade.modules.accreditation.service.AccreditationRecordsService;
import org.springblade.modules.accreditation.vo.AccreditationRecordsVo;
import org.springframework.stereotype.Service;
 
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
 
/**
 * 制证记录服务实现类
 * @author zhongrj
 */
@Service
@AllArgsConstructor
public class AccreditationRecordsServiceImpl extends ServiceImpl<AccreditationRecordsMapper, AccreditationRecords> implements AccreditationRecordsService {
 
 
    /**
     * 自定义分页
     * @param page
     * @param accreditationRecords
     * @return
     */
    @Override
    public IPage<AccreditationRecordsVo> selectAccreditationRecordsPage(IPage<AccreditationRecordsVo> page, AccreditationRecordsVo accreditationRecords) {
        List<AccreditationRecordsVo> accreditationRecordsVos = baseMapper.selectAccreditationRecordsPage(page, accreditationRecords);
        return page.setRecords(accreditationRecordsVos);
    }
 
    /**
     * 制证申请(批量)
     * @param accreditationRecords 制证记录信息对象
     */
    @Override
    public boolean securityApply(AccreditationRecordsVo accreditationRecords) {
        //读取ids
        List<String> list = Arrays.asList(accreditationRecords.getIds().split(","));
        //遍历
        list.forEach(id->{
            AccreditationRecords records = new AccreditationRecords();
            records.setCreateTime(new Date());
            records.setCreateUser(accreditationRecords.getCreateUser());
            records.setStatus(1);
            records.setAuditStatus(1);
            records.setType(accreditationRecords.getType());
            records.setUserId(Long.parseLong(id));
            //判断类型,如果是上岗证则判断是否有申请,有申请的不在新增记录
            if (accreditationRecords.getType()==1){
                //查询当前人员是否有申请记录
                int count  = baseMapper.getAccreditationRecordsByUserIdCount(id);
                if (count<1){
                    //新增
                    this.save(records);
 
                    //内网新增
                    String s = "insert into sys_accreditation_records(id,user_id,create_time,create_user,status,type,audit_status) " +
                        "values(" + "'" + records.getId() + "'" + ","
                        + "'" + records.getUserId() + "'" + ","
                        + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(records.getCreateTime()) + "'" + ","
                        + "'" + records.getCreateUser() +"'" + ","
                        + "'" + records.getStatus() +"'" + ","
                        + "'" + records.getType() +"'" + ","
                        +"'" + records.getAuditStatus() + "'" + ")";
                    FtpUtil.sqlFileUpload(s);
                }
            }
            //判断类型,如果是证书的,审核未通过的可以再次申请,审核通过的,暂时不给于新增记录
            if (accreditationRecords.getType()==2){
                //查询当前人员是否有待审核和审核通过的记录数
                int count  = baseMapper.getAccreditationRecordsByUserIdAuditCount(id);
                if (count<1){
                    //新增
                    this.save(records);
 
                    //内网新增
                    String s = "insert into sys_accreditation_records(id,user_id,create_time,create_user,status,type,audit_status) " +
                        "values(" + "'" + records.getId() + "'" + ","
                        + "'" + records.getUserId() + "'" + ","
                        + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(records.getCreateTime()) + "'" + ","
                        + "'" + records.getCreateUser() +"'" + ","
                        + "'" + records.getStatus() +"'" + ","
                        + "'" + records.getType() +"'" + ","
                        +"'" + records.getAuditStatus() + "'" + ")";
                    FtpUtil.sqlFileUpload(s);
                }
            }
 
        });
        return true;
    }
 
    /**
     * 自定义详情信息
     * @param accreditationRecords
     * @return
     */
    @Override
    public AccreditationRecordsVo getAccreditationRecordsDetails(AccreditationRecords accreditationRecords) {
        return baseMapper.getAccreditationRecordsDetails(accreditationRecords);
    }
 
    /**
     * 导出保安员证信息
     * @param accreditationRecords
     * @return
     */
    @Override
    public List<ExportSecurityPaperExcel> exportSecurityPaperList(AccreditationRecordsVo accreditationRecords) {
        //查询数据
        List<AccreditationRecordsVo> accreditationRecordsVos = baseMapper.exportSecurityPaperList(accreditationRecords);
        if (accreditationRecordsVos.size()>0) {
            //返回的集合数据
            List<ExportSecurityPaperExcel> list = new ArrayList<>();
            //遍历
            accreditationRecordsVos.forEach(accreditationRecordsVo -> {
                ExportSecurityPaperExcel excel = new ExportSecurityPaperExcel();
                //数据转换封装
                excel.setRealName(accreditationRecordsVo.getRealName());
                excel.setIdCardNo(accreditationRecordsVo.getIdCardNo());
                excel.setDeptName(accreditationRecordsVo.getDeptName());
                //如果头像有
                if (null != accreditationRecordsVo.getAvatar() && accreditationRecordsVo.getAvatar() != "") {
                    try {
                        if (accreditationRecordsVo.getAvatar().contains("http:")) {
                            excel.setAvatar(new URL(accreditationRecordsVo.getAvatar()));
                        }
                    } catch (MalformedURLException e) {
                        e.printStackTrace();
                    }
                }
                //如果保安证编号不为空
                if (null != accreditationRecordsVo.getSecurityNumber() && accreditationRecordsVo.getSecurityNumber() != "") {
                    //去生成二维码
                    String url = "http://223.82.109.183:2080/securityInfo.html";
                    String encoded = null;
                    try {
                        encoded = URLEncoder.encode(accreditationRecordsVo.getSecurityNumber(), "UTF-8");
                        String content = url + "?securityNumber=" + encoded;
                        URLEncoder.encode(content, "utf-8");
                        byte[] qrCodeImage = QRCodeUtil.getQRCodeImage(content, 350, 350);
                        //设置二维码
                        excel.setQrCode(qrCodeImage);
                        excel.setSecurityNumber(accreditationRecordsVo.getSecurityNumber());
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                list.add(excel);
            });
            return list;
        }
        return null;
    }
 
    /**
     * 导出证书制证信息
     * @param accreditationRecords
     * @return
     */
    @Override
    public List<ExportSecurityBookPaperExcel> exportSecurityBookPaper(AccreditationRecordsVo accreditationRecords) {
        //查询数据
        List<ExportSecurityBookPaperExcel> accreditationRecordsVos = baseMapper.exportSecurityBookPaper(accreditationRecords);
        return accreditationRecordsVos;
    }
 
    /**
     * 导出证书制证信息(包含照片)
     */
    @Override
    public List<AccreditationRecordsVo> exportSecurityBookPapers(AccreditationRecordsVo accreditationRecords) {
        //查询数据
        List<AccreditationRecordsVo> accreditationRecordsVos = baseMapper.exportSecurityBookPapers(accreditationRecords);
        System.out.println("accreditationRecordsVos = " + accreditationRecordsVos.size());
        return accreditationRecordsVos;
    }
}