智慧保安后台管理-外网项目备份
Administrator
2021-08-25 678417ec81cb111f3897b81d5ff09c6247465351
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 org.springblade.modules.equipage.controller;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.common.utils.arg;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.FTP.FtpUtil;
import org.springblade.modules.equipage.entity.Gun;
import org.springblade.modules.equipage.service.GunService;
import org.springblade.modules.equipage.vo.GunVo;
import org.springframework.web.bind.annotation.*;
 
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
 
/**
 * @author zhongrj
 * @time 2021-07-06
 * @desc 枪支控制层
 */
@RestController
@AllArgsConstructor
@RequestMapping("/gun")
public class GunController {
 
    private final GunService gunService;
 
    /**
     * 自定义分页
     * @param query page,size
     * @param gun 枪支信息对象
     */
    @GetMapping("/page")
    public R<IPage<GunVo>> page(GunVo gun, Query query) {
        IPage<GunVo> pages = gunService.selectGunPage(Condition.getPage(query), gun);
        return R.data(pages);
    }
 
    /**
     * 新增
     * @param gun 枪支信息对象
     */
    @PostMapping("/save")
    @ApiOperation(value = "新增", notes = "传入gun")
    public R save(@RequestBody Gun gun) {
        return R.status(gunService.save(gun));
    }
 
    /**
     * 修改
     * @param gun 枪支信息对象
     */
    @PostMapping("/update")
    public R update(@RequestBody Gun gun) {
        return R.status(gunService.updateById(gun));
    }
 
    /**
     * 新增或修改
     * @param gun 枪支信息对象
     */
    @PostMapping("/submit")
    public R submit(@RequestBody Gun gun){
        boolean status = false;
        if (null==gun.getId()) {
            //新增
            status = gunService.save(gun);
 
            //数据同步
            String s1 =
                "insert into sys_gun(id,gun_card_number,issue_unit,card_number,gun_mode," +
                    "dept_id,person_in_charge,issue_time,valid_time,jurisdiction) " +
                    "values(" + "'" + gun.getId() + "'" + "," +
                    "'" + gun.getGunCardNumber() + "'" + "," +
                    "'" + gun.getIssueUnit() + "'" + "," +
                    "'" + gun.getCardNumber() + "'" + "," +
                    "'" + gun.getGunMode() + "'" + "," +
                    "'" + gun.getDeptId() + "'" + "," +
                    "'" + gun.getPersonInCharge() + "'" + "," +
                    "'" + new SimpleDateFormat("yyyy-MM-dd").format(gun.getIssueTime()) + "'" + "," +
                    "'" + new SimpleDateFormat("yyyy-MM-dd").format(gun.getValidTime()) + "'" + "," +
                    "'" +gun.getJurisdiction() + "'" + ")";
            FtpUtil.sqlFileUpload(s1);
        }else {
            //修改
            status = gunService.updateById(gun);
            //内网同步
            String s1 =
                "update sys_gun set gun_card_number = " + "'" + gun.getGunCardNumber() + "'" +
                    ",issue_unit = " + "'" + gun.getIssueUnit() + "'" +
                    ",card_number = " + "'" + gun.getCardNumber() + "'" +
                    ",gun_mode = " + "'" + gun.getGunMode() + "'" +
                    ",dept_id = " + "'" + gun.getDeptId() + "'" +
                    ",person_in_charge = " + "'" + gun.getJurisdiction() + "'" +
                    ",issue_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd").format(gun.getIssueTime()) + "'" +
                    ",valid_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd").format(gun.getValidTime()) + "'" +
                    ",jurisdiction = " + "'" + gun.getJurisdiction() + "'" +
                    " " +"where id = " + "'" + gun.getId() + "'";
            FtpUtil.sqlFileUpload(s1);
        }
        return R.status(status);
    }
 
    /**
     * 删除
     * @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_gun where id = " + "'" + id + "'";
            FtpUtil.sqlFileUpload(s1);
        });
        return R.status(gunService.removeByIds(Func.toLongList(ids)));
    }
 
    /**
     * 详情
     * @param gun 枪支信息对象
     */
    @GetMapping("/detail")
    @ApiOperation(value = "详情", notes = "传入gun")
    public R<GunVo> detail(Gun gun) {
        GunVo detail = gunService.selectGunInfo(gun);
        return R.data(detail);
    }
 
}