陈昶聿
8 天以前 fc1f48f6cb2736bf03b7750563e5d9830d6fd4ba
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceOutPathController.java
@@ -1,22 +1,33 @@
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.ServiceOutPath;
import com.smartor.service.IServiceOutPathService;
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.ibatis.annotations.Param;
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
@@ -29,6 +40,21 @@
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;
    /**
     * 查询主键列表
@@ -43,20 +69,58 @@
    }
    /**
     * param就是进制
     * 外链落地页取任务信息(患者短信里的 {@code /wt?p=XXXXXX},匿名访问,不能加登录态鉴权)。
     *
     * @param param
     * @return
     * <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(@Param("param") String param) {
        ServiceOutPath serviceOutPath = new ServiceOutPath();
        serviceOutPath.setRadix(param);
        List<ServiceOutPath> list = serviceOutPathService.selectServiceOutPathList(serviceOutPath);
    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);
@@ -89,9 +153,21 @@
     */
    @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));
    }
    /**
@@ -100,6 +176,7 @@
    @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));