智慧保安后台管理-外网
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
package org.springblade.modules.licence.controller;
 
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.common.utils.DesensitizedUtil;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.information.entity.Information;
import org.springblade.modules.licence.entity.LicencePaper;
import org.springblade.modules.licence.service.LicencePaperService;
import org.springblade.modules.licence.vo.LicencePaperVo;
import org.springblade.modules.system.service.MyAsyncService;
import org.springframework.web.bind.annotation.*;
 
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Objects;
 
/**
 * @author zhongrj
 * @time 2021-12-27
 * @desc 许可证控制层
 */
@RestController
@AllArgsConstructor
@RequestMapping("/licencePaper")
public class LicencePaperController {
 
    private final LicencePaperService licencePaperService;
 
    private final MyAsyncService myAsyncService;
 
 
//    /**
//     * 自定义分页
//     * @param query page,size
//     * @param licencePaper 许可证信息对象
//     */
//    @GetMapping("/page")
//    public R<IPage<SecurityPaperVo>> page(SecurityPaperVo licencePaper, Query query) {
//        IPage<SecurityPaperVo> pages = licencePaperService.selectSecurityPaperPage(Condition.getPage(query), licencePaper);
//        return R.data(pages);
//    }
 
    /**
     * 新增
     * @param licencePaper 许可证信息对象
     */
    @PostMapping("/save")
    @ApiOperation(value = "新增", notes = "传入licencePaper")
    public R save(@RequestBody LicencePaper licencePaper){
        return R.data(licencePaperService.save(licencePaper));
    }
 
 
    /**
     * 修改
     * @param licencePaper 许可证信息对象
     */
    @PostMapping("/update")
    public R update(@RequestBody LicencePaper licencePaper){
        return R.status(licencePaperService.updateById(licencePaper));
    }
 
    /**
     * 新增或修改
     * @param licencePaper 许可证信息对象
     */
    @PostMapping("/submit")
    public R submit(@RequestBody LicencePaper licencePaper){
        LicencePaper licencePaper1 = Objects.requireNonNull(BeanUtil.copy(licencePaper, LicencePaper.class));
        //脱敏处理
        if (null!= licencePaper.getApprovalNumber() && !licencePaper.getApprovalNumber().equals("")){
            licencePaper.setApprovalNumber(DesensitizedUtil.desensitizedSecurityNumber(licencePaper.getApprovalNumber()));
        }
        if (null!= licencePaper.getLicenceIssuingUnit() && !licencePaper.getLicenceIssuingUnit().equals("")){
            licencePaper.setLicenceIssuingUnit(DesensitizedUtil.desensitizedSecurityNumber(licencePaper.getLicenceIssuingUnit()));
        }
        if (null!= licencePaper.getRegisterCapital() && !licencePaper.getRegisterCapital().equals("")){
            licencePaper.setRegisterCapital("**");
        }
        if (null!= licencePaper.getCode() && !licencePaper.getCode().equals("")){
            licencePaper.setCode(DesensitizedUtil.desensitizedSecurityNumber(licencePaper.getCode()));
        }
        if (null==licencePaper.getId()){
            licencePaper.setCreateTime(new Date());
            licencePaper.setUpdateTime(new Date());
            licencePaperService.save(licencePaper);
            //内网同步
            String s = "insert into sys_licence_paper(" +
                "id,type,unit_name,address,legal_people,content,approval_number,licence_issuing_unit,register_capital,code," +
                "licence_issuing_time,create_user,create_time,update_time,dept_id,url) " +
                "values(" + "'" + licencePaper.getId() + "'" + "," +
                "'" + licencePaper1.getType() + "'" + "," +
                "'" + licencePaper1.getUnitName() + "'" + "," +
                "'" + licencePaper1.getLegalPeople() + "'" + "," +
                "'" + licencePaper1.getContent() + "'" + "," +
                "'" + licencePaper1.getApprovalNumber() + "'" + "," +
                "'" + licencePaper1.getLicenceIssuingUnit() + "'" + "," +
                "'" + licencePaper1.getRegisterCapital() + "'" + "," +
                "'" + licencePaper1.getCode() + "'" + "," +
                "'" + new SimpleDateFormat("yyyy-MM-dd").format(licencePaper1.getLicenceIssuingTime()) + "'" + "," +
                "'" + licencePaper1.getCreateUser() + "'" + "," +
                "," + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(licencePaper1.getCreateTime()) + "'" +
                "," + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(licencePaper1.getUpdateTime()) + "'" +
                "," + "'" + licencePaper1.getDeptId() + "'" +
                "," + "'" + licencePaper1.getUrl() + "'"
                + ")";
            myAsyncService.FTP(s);
        }else {
            licencePaper.setUpdateTime(new Date());
            licencePaperService.updateById(licencePaper);
            //内网同步
            String s1 =
                "update sys_licence_paper set unit_name = " + "'" + licencePaper1.getUnitName() + "'"
                    + ",address = " + "'" + licencePaper1.getAddress() + "'"
                    + ",legal_people = " + "'" + licencePaper1.getLegalPeople() + "'"
                    + ",content = " + "'" + licencePaper1.getContent() + "'"
                    + ",approval_number = " + "'" + licencePaper1.getApprovalNumber() + "'"
                    + ",licence_issuing_unit = " + "'" + licencePaper1.getLicenceIssuingUnit() + "'"
                    + ",register_capital = " + "'" + licencePaper1.getRegisterCapital() + "'"
                    + ",code = " + "'" + licencePaper1.getCode() + "'"
                    + ",licence_issuing_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd").format(licencePaper1.getLicenceIssuingTime())  + "'"
                    + ",update_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(licencePaper1.getUpdateTime()) + "'"
                    + ",dept_id = " + "'" + licencePaper1.getDeptId() + "'"
                    + ",url = " + "'" + licencePaper1.getUrl() + "'"
                    + " " + "where id = " + "'" + licencePaper1.getId() + "'";
            myAsyncService.FTP(s1);
        }
        return R.data(licencePaper);
    }
 
    /**
     * 新增或修改(分公司和总公司许可证信息)
     * @param licencePaper 许可证信息对象
     */
    @PostMapping("/submitGroup")
    public R submitGroup(@RequestBody LicencePaperVo licencePaper){
        if (null==licencePaper.getId()){
            //总公司许可证信息新增
            licencePaper.setCreateTime(new Date());
            licencePaper.setUpdateTime(new Date());
            //新增
            licencePaperService.save(licencePaper);
 
            //分公司许可证信息新增
            LicencePaper paper = new LicencePaper();
            //相同信息
            paper.setType(licencePaper.getType());
            paper.setUpdateTime(new Date());
            paper.setCreateTime(new Date());
            paper.setCreateUser(licencePaper.getCreateUser());
            paper.setUpdateUser(licencePaper.getUpdateUser());
            paper.setDeptId(licencePaper.getDeptId());
            //其他信息
            paper.setParentId(licencePaper.getId());
            paper.setUnitName(licencePaper.getUnitNames());
            paper.setAddress(licencePaper.getAddresss());
            paper.setApprovalNumber(licencePaper.getApprovalNumbers());
            paper.setCode(licencePaper.getCodes());
            paper.setContent(licencePaper.getContents());
            paper.setUrl(licencePaper.getUrls());
            paper.setLegalPeople(licencePaper.getLegalPeoples());
            paper.setLicenceIssuingUnit(licencePaper.getLicenceIssuingUnits());
            paper.setLicenceIssuingTime(licencePaper.getLicenceIssuingTimes());
            paper.setRegisterCapital(licencePaper.getRegisterCapitals());
            //新增
            licencePaperService.save(paper);
        }else {
            //总公司信息修改
            licencePaper.setUpdateTime(new Date());
            //修改
            licencePaperService.updateById(licencePaper);
 
            //分公司许可证信息修改
            LicencePaper paper = new LicencePaper();
            //相同信息
            paper.setUpdateTime(new Date());
            paper.setId(licencePaper.getSid());
            //其他信息
            paper.setUnitName(licencePaper.getUnitNames());
            paper.setAddress(licencePaper.getAddresss());
            paper.setApprovalNumber(licencePaper.getApprovalNumbers());
            paper.setCode(licencePaper.getCodes());
            paper.setContent(licencePaper.getContents());
            paper.setUrl(licencePaper.getUrls());
            paper.setLegalPeople(licencePaper.getLegalPeoples());
            paper.setLicenceIssuingUnit(licencePaper.getLicenceIssuingUnits());
            paper.setLicenceIssuingTime(licencePaper.getLicenceIssuingTimes());
            paper.setRegisterCapital(licencePaper.getRegisterCapitals());
            //修改
            licencePaperService.updateById(paper);
        }
        return R.data(licencePaper);
    }
 
    /**
     * 删除
     * @param ids 许可证信息ids 数组
     */
    @PostMapping("/remove")
    public R remove(@ApiParam(value = "主键集合") @RequestParam String ids) {
        //内网删除
        List<Long> list = Func.toLongList(ids);
        list.forEach(id -> {
            //内网同步
            String s1 = "delete from sys_licence_paper where id = " + "'" + id + "'";
            myAsyncService.FTP(s1);
        });
        return R.status(licencePaperService.removeByIds(Func.toLongList(ids)));
    }
 
    /**
     * 详情
     * @param licencePaper 许可证信息对象
     */
    @GetMapping("/detail")
    @ApiOperation(value = "详情", notes = "传入licencePaper")
    public R<LicencePaper> detail(LicencePaper licencePaper) {
        LicencePaper detail = licencePaperService.getOne(Condition.getQueryWrapper(licencePaper));
        return R.data(detail);
    }
 
    /**
     * 查询分公司的许可证信息(包含总公司)
     * @param licencePaper 许可证信息对象
     */
    @GetMapping("/getLicenceInfos")
    public R getLicenceInfos(LicencePaper licencePaper) {
        return R.data(licencePaperService.getLicenceInfos(licencePaper));
    }
 
}