zjh
2025-03-25 f5e009d6c7cdb7ec64ab68feed4456fec49187b8
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
package com.ltkj.web.jmreport;
 
import cn.hutool.http.server.HttpServerRequest;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ltkj.common.core.domain.AjaxResult;
import com.ltkj.common.enums.DataSourceType;
import com.ltkj.db.DataSourceConfig;
import com.ltkj.db.DataSourceContextHolder;
import com.ltkj.hosp.domain.DictHosp;
import com.ltkj.hosp.mapper.TestMapper;
import com.ltkj.hosp.service.IDictHospService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jodd.util.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.omg.CORBA.Environment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
 
import static jdk.nashorn.internal.runtime.regexp.joni.Config.log;
 
/**
 * @Company: 西安路泰科技有限公司
 * @Author: lige
 * @Date: 2023/3/7 11:49
 */
@RestController
@RequestMapping("/report/jmreport")
@Api(tags = "PC端 积木报表接口集")
@Slf4j
public class JimuController {
//    @Value("${jimu.path}")
    private static  String value;
 
 
    private static String CONFIG_PATH;
 
    @Autowired
    private TestMapper testMapper;
    @Autowired
    private DataSourceConfig dataSourceConfig;
    @Autowired
    private IDictHospService dictHospService;
 
    @Value ("${config.properties}")
    public void setConfigPath(String path) {
        CONFIG_PATH = path;
        try {
            FileInputStream inputStream = new FileInputStream(CONFIG_PATH);
            Properties props = new Properties();
            props.load(inputStream);
            value= props.getProperty("jmurl");
        } catch (IOException throwables) {
            throwables.printStackTrace();
        }
    }
 
//    static  {
//       Properties props = new Properties();
//       try {
//           // 从文件中读取配置信息
//           FileInputStream fis = null;
//           try {
//               fis = new FileInputStream("D:\\ltkjprojectconf\\sfconfig.properties");
//           } catch (FileNotFoundException e) {
//               e.printStackTrace();
//           }
//           props.load(fis);
//           fis.close();
//           // 获取属性值并赋值
//       } catch (Exception e) {
//           log.info("数据库连接失败  请联系管理员!");
//           e.printStackTrace();
//       }
//       value= props.getProperty("jmurl");
//    }
 
    @GetMapping("/index")
    @ApiOperation(value = "index")
//    @PreAuthorize("@ss.hasPermi('report:jmreport:index')")
    public String index(){
        return value+"/jmreport/list";
    }
 
//    @GetMapping("/index")
//    @PreAuthorize("@ss.hasPermi('report:jimu:index')")
//    public int index(){
//        return 1;
//    }
 
    @GetMapping("/view")
    @ApiOperation(value = "view")
    //@PreAuthorize("@ss.hasPermi('report:jimu:view')")
    public String view(HttpServletRequest request){
//        dataSourceConfig.addDataSource(DataSourceType.MASTER.name());
//        DataSourceContextHolder.setDataSourceKey(DataSourceType.MASTER.name());
//        String hospId = request.getHeader("hospId");
//        LambdaQueryWrapper<DictHosp> wrapper = new LambdaQueryWrapper<>();
//        wrapper.eq(DictHosp::getCode,hospId);
//        DictHosp hosp = dictHospService.getOne(wrapper);
//        if (hosp != null && StringUtil.isNotBlank(hosp.getDbname())) {
//            dataSourceConfig.addDataSource(hosp.getDbname());
//            DataSourceContextHolder.setDataSourceKey(hosp.getDbname());
//        }
        return value+"/jmreport/view";
    }
 
    @GetMapping("/exportPdf")
    @ApiOperation(value = "exportPdf")
    public String exportPdf(){
        return value+"/jmreport/exportPdfStream";
    }
 
 
//    @GetMapping("/view")
//    @PreAuthorize("@ss.hasPermi('report:jimu:view')")
//    public int view(){
//        return 1;
//    }
 
    @GetMapping("/getBingZhong")
    public String getBingZhongInfo(@RequestParam("start") String start, @RequestParam("end") String end){
        JSONObject object = JSONUtil.createObj();
        object.putOpt("data",testMapper.getBingZhongInfo(start,end));
        return JSONUtil.toJsonStr(object);
    }
}