admin
2024-06-15 8cfe20288690f2ba46c804f41f39e8aa48c2dea0
提交 | 用户 | 时间
e57a89 1 package com.jcdm.main.da.collectionParamConf.controller;
2
caebfa 3 import cn.hutool.json.JSONArray;
W 4 import cn.hutool.json.JSONObject;
e57a89 5 import com.jcdm.common.annotation.Log;
6 import com.jcdm.common.core.controller.BaseController;
7 import com.jcdm.common.core.domain.AjaxResult;
caebfa 8 import com.jcdm.common.core.domain.R;
e57a89 9 import com.jcdm.common.core.page.TableDataInfo;
10 import com.jcdm.common.enums.BusinessType;
11 import com.jcdm.common.utils.poi.ExcelUtil;
caebfa 12 import com.jcdm.main.config.RestTemplateConfig;
e57a89 13 import com.jcdm.main.da.collectionParamConf.domain.DaCollectionParamConf;
14 import com.jcdm.main.da.collectionParamConf.service.IDaCollectionParamConfService;
15 import org.springframework.beans.factory.annotation.Autowired;
caebfa 16 import org.springframework.http.ResponseEntity;
e57a89 17 import org.springframework.security.access.prepost.PreAuthorize;
18 import org.springframework.web.bind.annotation.*;
19
caebfa 20 import javax.annotation.Resource;
e57a89 21 import javax.servlet.http.HttpServletResponse;
caebfa 22 import java.util.HashMap;
e57a89 23 import java.util.List;
caebfa 24 import java.util.Objects;
e57a89 25
26 /**
27  * 采集参数配置Controller
28  * 
29  * @author ruimin
30  * @date 2023-12-25
31  */
32 @RestController
33 @RequestMapping("/da/collectionParamConf")
34 public class DaCollectionParamConfController extends BaseController
35 {
36     @Autowired
37     private IDaCollectionParamConfService daCollectionParamConfService;
caebfa 38
W 39     @Resource
40     private RestTemplateConfig restTemplateConfig;
e57a89 41
42     /**
43      * 查询采集参数配置列表
44      */
45     @PreAuthorize("@ss.hasPermi('da:collectionParamConf:list')")
46     @GetMapping("/list")
47     public TableDataInfo list(DaCollectionParamConf daCollectionParamConf)
48     {
49         startPage();
50         List<DaCollectionParamConf> list = daCollectionParamConfService.selectDaCollectionParamConfList(daCollectionParamConf);
51         return getDataTable(list);
52     }
53
54     /**
55      * 导出采集参数配置列表
56      */
57     @PreAuthorize("@ss.hasPermi('da:collectionParamConf:export')")
58     @Log(title = "采集参数配置", businessType = BusinessType.EXPORT)
59     @PostMapping("/export")
60     public void export(HttpServletResponse response, DaCollectionParamConf daCollectionParamConf)
61     {
62         List<DaCollectionParamConf> list = daCollectionParamConfService.selectDaCollectionParamConfList(daCollectionParamConf);
63         ExcelUtil<DaCollectionParamConf> util = new ExcelUtil<DaCollectionParamConf>(DaCollectionParamConf.class);
64         util.exportExcel(response, list, "采集参数配置数据");
65     }
66
67     /**
68      * 获取采集参数配置详细信息
69      */
70     @PreAuthorize("@ss.hasPermi('da:collectionParamConf:query')")
71     @GetMapping(value = "/{id}")
72     public AjaxResult getInfo(@PathVariable("id") Long id)
73     {
74         return success(daCollectionParamConfService.selectDaCollectionParamConfById(id));
75     }
76
77     /**
78      * 新增采集参数配置
79      */
80     @PreAuthorize("@ss.hasPermi('da:collectionParamConf:add')")
81     @Log(title = "采集参数配置", businessType = BusinessType.INSERT)
82     @PostMapping
83     public AjaxResult add(@RequestBody DaCollectionParamConf daCollectionParamConf)
84     {
85         return toAjax(daCollectionParamConfService.insertDaCollectionParamConf(daCollectionParamConf));
86     }
87
88     /**
89      * 修改采集参数配置
90      */
91     @PreAuthorize("@ss.hasPermi('da:collectionParamConf:edit')")
92     @Log(title = "采集参数配置", businessType = BusinessType.UPDATE)
93     @PutMapping
94     public AjaxResult edit(@RequestBody DaCollectionParamConf daCollectionParamConf)
95     {
96         return toAjax(daCollectionParamConfService.updateDaCollectionParamConf(daCollectionParamConf));
97     }
98
99     /**
100      * 删除采集参数配置
101      */
102     @PreAuthorize("@ss.hasPermi('da:collectionParamConf:remove')")
103     @Log(title = "采集参数配置", businessType = BusinessType.DELETE)
104     @DeleteMapping("/{ids}")
105     public AjaxResult remove(@PathVariable Long[] ids)
106     {
107         return toAjax(daCollectionParamConfService.deleteDaCollectionParamConfByIds(ids));
108     }
caebfa 109
W 110
111     /**
112      * 测试使用resttemplate实现接口对接
113      * @return R
114      */
115     @GetMapping("/testHttpClientConnect")
116     public R testHttpClientConnect(){
117 //        String url = "http://localhost:81/dev-api/system/dict/data/type/{param}";
118 //        String param = "sys_user_sex";
119 //        ResponseEntity<JSONObject> forEntity = restTemplateConfig.restTemplate().getForEntity(url, JSONObject.class,param);
120 //        JSONObject body = forEntity.getBody();
121 //        System.out.println(body.toString());
122
123         String url = "http://localhost:81/dev-api/bs/formulaChild/getProductProcess";
124         HashMap<String,String> map = new HashMap<>();
125         map.put("productCode","2V91");
126         ResponseEntity<JSONObject> jsonObjectResponseEntity = restTemplateConfig.restTemplate().postForEntity(url, map, JSONObject.class);
127         System.out.println(Objects.requireNonNull(jsonObjectResponseEntity.getBody()));
128         return R.ok();
129     }
130
e57a89 131 }