package com.ltkj.web.controller.system;
|
|
import cn.hutool.core.date.DateUtil;
|
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONObject;
|
import com.ltkj.common.core.controller.BaseController;
|
import com.ltkj.common.core.domain.AjaxResult;
|
import com.ltkj.hosp.domain.TjCustomer;
|
import com.ltkj.hosp.service.ITjCustomerService;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiParam;
|
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.annotation.Resource;
|
import java.io.Serializable;
|
import java.sql.ResultSet;
|
import java.sql.ResultSetMetaData;
|
import java.util.Date;
|
import java.util.List;
|
|
/**
|
* @Company: 西安路泰科技有限公司
|
* @Author: lige
|
* @Date: 2023/12/13 19:33
|
*/
|
@RestController
|
@RequestMapping("/json/parse")
|
public class JsonController extends BaseController implements Serializable {
|
@Resource
|
private ITjCustomerService tjCustomerService;
|
|
|
/**
|
* 化验检查页面列表
|
*/
|
@GetMapping("/huaYangetProList")
|
@ApiOperation("影像/化验检查页面列表")
|
public AjaxResult huaYangetProList(@RequestParam String deptId,
|
@RequestParam(defaultValue = "1") Integer page,
|
@RequestParam(defaultValue = "10") Integer pageSize,
|
@RequestParam String cusName,
|
@RequestParam String tjNumber) {
|
return AjaxResult.success(tjCustomerService.getJsonParseCustomerList(deptId, page, pageSize, cusName, tjNumber));
|
}
|
|
|
/**
|
* 将结果集信息转换为JSON数组的形式
|
*
|
* @param rs sql语句查询出来的结果集
|
* @return 返回一个JSON数组
|
* @throws Exception
|
*/
|
public static JSONArray formatRsToJsonArray(ResultSet rs) throws Exception {
|
ResultSetMetaData md = rs.getMetaData();
|
int num = md.getColumnCount();
|
JSONArray array = new JSONArray();
|
while (rs.next()) {
|
JSONObject mapOfColValues = new JSONObject();
|
for (int i = 1; i <= num; i++) {
|
Object o = rs.getObject(i);
|
mapOfColValues.put(md.getColumnName(i), rs.getObject(i));
|
}
|
array.add(mapOfColValues);
|
}
|
return array;
|
}
|
|
}
|