智慧保安后台管理-外网项目备份
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
 
package org.springblade.modules.securityapply.service.impl;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.support.Condition;
import org.springblade.modules.securityapply.entity.SecurityApply;
import org.springblade.modules.securityapply.mapper.SecurityApplyMapper;
import org.springblade.modules.securityapply.service.SecurityApplyService;
import org.springblade.modules.securityapply.vo.SecurityApplyVO;
import org.springblade.modules.securitypaper.entity.SecurityPaper;
import org.springblade.modules.securitypaper.service.SecurityPaperService;
import org.springblade.modules.system.entity.User;
import org.springblade.modules.system.service.IUserService;
import org.springblade.modules.system.service.MyAsyncService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
 
/**
 *  保安员证申诉服务实现类
 *
 * @author zhongrj
 * @since 2022-03-03
 */
@Service
public class SecurityApplyServiceImpl extends ServiceImpl<SecurityApplyMapper, SecurityApply> implements SecurityApplyService {
 
    @Autowired
    private MyAsyncService myAsyncService;
 
    @Autowired
    private IUserService userService;
 
    @Autowired
    private SecurityPaperService securityPaperService;
 
    /**
     * 自定义分页查询保安员证申诉数据
     * @param page
     * @param securityApply
     * @return
     */
    @Override
    public IPage<SecurityApplyVO> selectSecurityApplyPage(IPage<SecurityApplyVO> page, SecurityApplyVO securityApply) {
        return page.setRecords(baseMapper.selectSecurityApplyPage(page, securityApply));
    }
 
    /**
     * 审核
     * @param securityApply
     * @return
     */
    @Override
    public Object audit(SecurityApply securityApply) {
        //查询用户信息
        SecurityApply apply = this.getById(securityApply.getId());
        User user = userService.getById(apply.getUserId());
        //判断审核状态
        if (securityApply.getAuditStatus().equals(1)){
            //审核通过,判断是否为重复审核通过,即查询保安证编号库是否已存在该编号,如果已存在,则不新增,否则则新增,同时修改改保安员的保安证编号
            //1.1 查询该编号是否已在存储库存在
            SecurityPaper securityPaper = new SecurityPaper();
            securityPaper.setNumber(apply.getNumber());
            List<SecurityPaper> list = securityPaperService.list(Condition.getQueryWrapper(securityPaper));
            if (list.size()>0){
                //判断该编号对应的人员是否为同一人
                for (SecurityPaper paper : list) {
                    if (!paper.getIdCardNo().equals(user.getCardid())){
                        //其他人员已占用该编号
                        throw new ServiceException("保安证编号:["+ apply.getNumber() +"] 已存在");
                    }
                }
            }else {
                //新增
                SecurityPaper securityPaper1 = new SecurityPaper();
                securityPaper1.setNumber(apply.getNumber());
                securityPaper1.setCreateTime(new Date());
                securityPaper1.setIdCardNo(user.getCardid());
                securityPaper1.setUserId(user.getId());
                securityPaper1.setExamId(apply.getId());
                securityPaper1.setPeopleName(user.getRealName());
                securityPaper1.setSource(2);
                //插入保安证存储库
                securityPaperService.save(securityPaper1);
                //用户保安证编号更新
                user.setHold("1");
                user.setSecuritynumber(apply.getNumber());
                user.setUpdateTime(new Date());
                boolean status = userService.updateById(user);
 
                if (status) {
                    //内网数据同步
                    String s1 =
                        "update blade_user set hold = " + user.getHold() +
                            ",securitynumber = " + "'" + user.getSecuritynumber() + "'" +
                            ",update_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:dd").format(user.getUpdateTime()) + "'" +
                            " " + "where id = " + "'" + user.getId() + "'";
                    myAsyncService.FTP(s1);
                }
            }
        }
        //证件核实申请更新并返回
        return this.updateById(securityApply);
    }
 
    /**
     * 批量审核
     * @param securityApply
     * @return
     */
    @Override
    public Object batchAudit(SecurityApplyVO securityApply) {
        //取出id
        List<String> list = Arrays.asList(securityApply.getIds().split(","));
        //遍历
        for (String s : list) {
            SecurityApply securityApply1 = new SecurityApply();
            securityApply1.setAuditTime(securityApply.getAuditTime());
            securityApply1.setAuditStatus(securityApply.getAuditStatus());
            securityApply1.setId(Long.parseLong(s));
            //审核
            audit(securityApply1);
        }
        //返回
        return null;
    }
}