liusheng
7 天以前 b6fce30916b9c432df2a46a49e69b21be08b860b
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
package com.ruoyi.web.controller.smartor;
 
import com.ruoyi.common.annotation.AddOrgId;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.RSAPublicKeyExample;
import com.ruoyi.common.utils.ShortCode;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.smartor.domain.BaseOrganization;
import com.smartor.service.IBaseOrganizationService;
import com.ruoyi.patarchive.service.IPatArchiveService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import com.ruoyi.common.core.domain.entity.PatArchive;
import com.ruoyi.task.domain.ServiceOutPath;
import com.ruoyi.task.service.IServiceOutPathService;
import com.ruoyi.task.service.IServiceTaskService;
 
/**
 * 主键Controller
 *
 * @author lihu
 */
@Api("主键")
@RestController
@RequestMapping("/smartor/outPath")
public class ServiceOutPathController extends BaseController {
    @Autowired
    private IServiceOutPathService serviceOutPathService;
 
    @Autowired
    private IServiceTaskService serviceTaskService;
 
    @Autowired
    IPatArchiveService patArchiveService;
 
    @Autowired
    private IBaseOrganizationService baseOrganizationService;
 
    @Autowired
    private RSAPublicKeyExample rsaPublicKeyExample;
 
    @Value("${pri_key}")
    private String pri_key;
 
    /**
     * 查询主键列表
     */
    @ApiOperation("查询主键列表")
    //@PreAuthorize("@ss.hasPermi('smartor:path:list')")
    @GetMapping("/list")
    public TableDataInfo list(ServiceOutPath serviceOutPath) {
        startPage();
        List<ServiceOutPath> list = serviceOutPathService.selectServiceOutPathList(serviceOutPath);
        return getDataTable(list);
    }
 
    /**
     * 外链落地页取任务信息(患者短信里的 {@code /wt?p=XXXXXX},匿名访问,不能加登录态鉴权)。
     *
     * <p>短码有两种形态,都要认:
     * <ul>
     *   <li><b>6 位 base62</b>(本次改造后)—— 由 {@link ShortCode} 对主键做带密钥双射得到,
     *       不可枚举;先反解出主键再按 id 查,这样即便 {@code radix} 列被截断或没落库也能查到;</li>
     *   <li><b>3~5 位十六进制</b>(历史链接)—— 直接按 {@code radix} 列查,保证已发出的短信还能打开。</li>
     * </ul>
     *
     * @param param 短码(旧称"进制")
     * @return 任务信息;短码无效时 data 为 null
     */
    @PostMapping("/getInfoByParam")
    public AjaxResult param(@RequestParam(value = "param", required = false) String param) {
        if (StringUtils.isEmpty(param)) {
            return success(null);
        }
        List<ServiceOutPath> list = null;
        Long id = ShortCode.decode(param);
        if (id != null) {
            ServiceOutPath byId = new ServiceOutPath();
            byId.setId(id);
            list = serviceOutPathService.selectServiceOutPathList(byId);
        }
        if (CollectionUtils.isEmpty(list)) {
            ServiceOutPath byRadix = new ServiceOutPath();
            byRadix.setRadix(param);
            list = serviceOutPathService.selectServiceOutPathList(byRadix);
        }
        if (CollectionUtils.isNotEmpty(list)) {
            ServiceOutPath serviceOutPath1 = list.get(0);
            serviceOutPath1.setId(null);
            serviceOutPath1.setRadix(null);
            if(StringUtils.isNotEmpty(serviceOutPath1.getOrgid())){
                String orgId = serviceOutPath1.getOrgid();
                BaseOrganization baseOrganization = new BaseOrganization();
                baseOrganization.setOrgid(orgId);
                List<BaseOrganization> orgs = baseOrganizationService.selectBaseOrganizationList(baseOrganization);
                if(CollectionUtils.isNotEmpty(orgs)){
                    String orgname = orgs.get(0).getOrganizationName();
                    serviceOutPath1.setOrgid(orgId);
                    serviceOutPath1.setOrgname(orgname);
                }
//            }
//            if(StringUtils.isNotEmpty(serviceOutPath1.getParam2())){
//                RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample();
//                Long patId = Long.valueOf(rsaPublicKeyExample.decryptedData(serviceOutPath1.getParam2(), pri_key));
//                if(patId != null){
//                    PatArchive patArchive = patArchiveService.selectPatArchiveByPatid(patId);
//                    serviceOutPath1.setPatArchive(patArchive);
//                }
            }
 
            return success(serviceOutPath1);
        }
        return success(null);
    }
 
    /**
     * 导出主键列表
     */
    @ApiOperation("导出主键列表")
    //@PreAuthorize("@ss.hasPermi('smartor:path:export')")
    @Log(title = "主键", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ServiceOutPath serviceOutPath) {
        List<ServiceOutPath> list = serviceOutPathService.selectServiceOutPathList(serviceOutPath);
        ExcelUtil<ServiceOutPath> util = new ExcelUtil<ServiceOutPath>(ServiceOutPath.class);
        util.exportExcel(response, list, "主键数据");
    }
 
    /**
     * 获取主键详细信息
     */
    @ApiOperation("获取主键详细信息")
    @GetMapping(value = "/getInfo/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(serviceOutPathService.selectServiceOutPathById(id));
    }
 
    /**
     * 新增主键
     */
    @ApiOperation("新增主键")
    @Log(title = "主键", businessType = BusinessType.INSERT)
    @AddOrgId(field = "orgid", paramIndex = 0, campusField = "campusid")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody ServiceOutPath serviceOutPath) {
        return toAjax(serviceOutPathService.insertServiceOutPath(serviceOutPath));
    }
 
 
    /**
     * 新增主键
     */
    @ApiOperation("新增主键")
    @Log(title = "主键", businessType = BusinessType.INSERT)
    @PostMapping("/addOutPath")
    public AjaxResult addOutPath(@RequestBody ServiceOutPath serviceOutPath) {
        return success(serviceOutPathService.addOutPath(serviceOutPath));
    }
 
    /**
     * 修改主键
     */
    @ApiOperation("修改主键")
    //@PreAuthorize("@ss.hasPermi('smartor:path:edit')")
    @Log(title = "主键", businessType = BusinessType.UPDATE)
    @AddOrgId(field = "orgid", paramIndex = 0, campusField = "campusid")
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody ServiceOutPath serviceOutPath) {
        return toAjax(serviceOutPathService.updateServiceOutPath(serviceOutPath));
    }
 
    /**
     * 删除主键
     */
    @ApiOperation("删除主键")
    //@PreAuthorize("@ss.hasPermi('smartor:path:remove')")
    @Log(title = "主键", businessType = BusinessType.DELETE)
    @GetMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(serviceOutPathService.deleteServiceOutPathByIds(ids));
    }
}