|
|
|
@ -35,13 +35,13 @@ import com.utils.BaiduUtil;
|
|
|
|
|
import com.utils.FileUtil;
|
|
|
|
|
import com.utils.R;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 通用接口
|
|
|
|
|
*/
|
|
|
|
|
@RestController
|
|
|
|
|
public class CommonController{
|
|
|
|
|
public class CommonController{
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(CommonController.class);
|
|
|
|
|
// 注入CommonService,处理通用业务逻辑
|
|
|
|
|
@Autowired
|
|
|
|
|
private CommonService commonService;
|
|
|
|
|
|
|
|
|
@ -53,14 +53,18 @@ public class CommonController{
|
|
|
|
|
private static String BAIDU_DITU_AK = null;
|
|
|
|
|
|
|
|
|
|
@RequestMapping("/location")
|
|
|
|
|
public R location(String lng,String lat) {
|
|
|
|
|
if(BAIDU_DITU_AK==null) {
|
|
|
|
|
public R location(String lng, String lat) {
|
|
|
|
|
// 如果BAIDU_DITU_AK为空,从配置中获取
|
|
|
|
|
if (BAIDU_DITU_AK == null) {
|
|
|
|
|
BAIDU_DITU_AK = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "baidu_ditu_ak")).getValue();
|
|
|
|
|
if(BAIDU_DITU_AK==null) {
|
|
|
|
|
// 如果配置中未正确配置,返回错误信息
|
|
|
|
|
if (BAIDU_DITU_AK == null) {
|
|
|
|
|
return R.error("请在配置管理中正确配置baidu_ditu_ak");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 调用百度工具类获取城市信息
|
|
|
|
|
Map<String, String> map = BaiduUtil.getCityByLonLat(BAIDU_DITU_AK, lng, lat);
|
|
|
|
|
// 返回包含城市信息的结果对象
|
|
|
|
|
return R.ok().put("data", map);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -68,102 +72,132 @@ public class CommonController{
|
|
|
|
|
* 人脸比对
|
|
|
|
|
* @param face1 人脸1
|
|
|
|
|
* @param face2 人脸2
|
|
|
|
|
* @return
|
|
|
|
|
* @param request HttpServletRequest对象
|
|
|
|
|
* @return 返回人脸比对结果
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/matchFace")
|
|
|
|
|
public R matchFace(String face1, String face2, HttpServletRequest request) {
|
|
|
|
|
if(client==null) {
|
|
|
|
|
/*String AppID = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "AppID")).getValue();*/
|
|
|
|
|
// 如果客户端未初始化,进行初始化
|
|
|
|
|
if (client == null) {
|
|
|
|
|
// 获取APIKey和SecretKey
|
|
|
|
|
String APIKey = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "APIKey")).getValue();
|
|
|
|
|
String SecretKey = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "SecretKey")).getValue();
|
|
|
|
|
// 获取访问令牌
|
|
|
|
|
String token = BaiduUtil.getAuth(APIKey, SecretKey);
|
|
|
|
|
if(token==null) {
|
|
|
|
|
// 如果令牌获取失败,返回错误信息
|
|
|
|
|
if (token == null) {
|
|
|
|
|
return R.error("请在配置管理中正确配置APIKey和SecretKey");
|
|
|
|
|
}
|
|
|
|
|
// 初始化AipFace客户端
|
|
|
|
|
client = new AipFace(null, APIKey, SecretKey);
|
|
|
|
|
// 设置连接超时时间
|
|
|
|
|
client.setConnectionTimeoutInMillis(2000);
|
|
|
|
|
// 设置套接字超时时间
|
|
|
|
|
client.setSocketTimeoutInMillis(60000);
|
|
|
|
|
}
|
|
|
|
|
JSONObject res = null;
|
|
|
|
|
try {
|
|
|
|
|
File file1 = new File(request.getSession().getServletContext().getRealPath("/upload")+"/"+face1);
|
|
|
|
|
File file2 = new File(request.getSession().getServletContext().getRealPath("/upload")+"/"+face2);
|
|
|
|
|
// 获取人脸图片文件
|
|
|
|
|
File file1 = new File(request.getSession().getServletContext().getRealPath("/upload") + "/" + face1);
|
|
|
|
|
File file2 = new File(request.getSession().getServletContext().getRealPath("/upload") + "/" + face2);
|
|
|
|
|
// 将文件转换为Base64编码的字符串
|
|
|
|
|
String img1 = Base64Util.encode(FileUtil.FileToByte(file1));
|
|
|
|
|
String img2 = Base64Util.encode(FileUtil.FileToByte(file2));
|
|
|
|
|
// 创建MatchRequest对象
|
|
|
|
|
MatchRequest req1 = new MatchRequest(img1, "BASE64");
|
|
|
|
|
MatchRequest req2 = new MatchRequest(img2, "BASE64");
|
|
|
|
|
// 创建请求列表
|
|
|
|
|
ArrayList<MatchRequest> requests = new ArrayList<MatchRequest>();
|
|
|
|
|
requests.add(req1);
|
|
|
|
|
requests.add(req2);
|
|
|
|
|
// 进行人脸比对
|
|
|
|
|
res = client.match(requests);
|
|
|
|
|
// 打印比对结果
|
|
|
|
|
System.out.println(res.get("result"));
|
|
|
|
|
} catch (FileNotFoundException e) {
|
|
|
|
|
// 处理文件未找到异常
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
return R.error("文件不存在");
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
// 处理IO异常
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return R.ok().put("data", com.alibaba.fastjson.JSONObject.parse(res.get("result").toString()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取table表中的column列表(联动接口)
|
|
|
|
|
* @return
|
|
|
|
|
* @param tableName 表名
|
|
|
|
|
* @param columnName 列名
|
|
|
|
|
* @param level 层级
|
|
|
|
|
* @param parent 父级
|
|
|
|
|
* @return 返回包含列列表的结果对象
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/option/{tableName}/{columnName}")
|
|
|
|
|
@IgnoreAuth
|
|
|
|
|
public R getOption(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName,String level,String parent) {
|
|
|
|
|
public R getOption(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName, String level, String parent) {
|
|
|
|
|
// 创建参数Map
|
|
|
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
|
params.put("table", tableName);
|
|
|
|
|
params.put("column", columnName);
|
|
|
|
|
if(StringUtils.isNotBlank(level)) {
|
|
|
|
|
// 如果层级不为空,添加到参数Map中
|
|
|
|
|
if (StringUtils.isNotBlank(level)) {
|
|
|
|
|
params.put("level", level);
|
|
|
|
|
}
|
|
|
|
|
if(StringUtils.isNotBlank(parent)) {
|
|
|
|
|
// 如果父级不为空,添加到参数Map中
|
|
|
|
|
if (StringUtils.isNotBlank(parent)) {
|
|
|
|
|
params.put("parent", parent);
|
|
|
|
|
}
|
|
|
|
|
// 调用CommonService获取列列表
|
|
|
|
|
List<String> data = commonService.getOption(params);
|
|
|
|
|
// 返回包含列列表的结果对象
|
|
|
|
|
return R.ok().put("data", data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据table中的column获取单条记录
|
|
|
|
|
* @return
|
|
|
|
|
* @param tableName 表名
|
|
|
|
|
* @param columnName 列名
|
|
|
|
|
* @param columnValue 列值
|
|
|
|
|
* @return 返回包含单条记录的结果对象
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/follow/{tableName}/{columnName}")
|
|
|
|
|
@IgnoreAuth
|
|
|
|
|
public R getFollowByOption(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName, @RequestParam String columnValue) {
|
|
|
|
|
// 创建参数Map
|
|
|
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
|
params.put("table", tableName);
|
|
|
|
|
params.put("column", columnName);
|
|
|
|
|
params.put("columnValue", columnValue);
|
|
|
|
|
// 调用CommonService获取单条记录
|
|
|
|
|
Map<String, Object> result = commonService.getFollowByOption(params);
|
|
|
|
|
// 返回包含单条记录的结果对象
|
|
|
|
|
return R.ok().put("data", result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改table表的sfsh状态
|
|
|
|
|
* @param map
|
|
|
|
|
* @return
|
|
|
|
|
* @param tableName 表名
|
|
|
|
|
* @param map 包含修改信息的Map
|
|
|
|
|
* @return 返回操作结果
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/sh/{tableName}")
|
|
|
|
|
public R sh(@PathVariable("tableName") String tableName, @RequestBody Map<String, Object> map) {
|
|
|
|
|
// 将表名添加到参数Map中
|
|
|
|
|
map.put("table", tableName);
|
|
|
|
|
// 调用CommonService进行状态修改
|
|
|
|
|
commonService.sh(map);
|
|
|
|
|
// 返回操作成功结果
|
|
|
|
|
return R.ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取需要提醒的记录数
|
|
|
|
|
* @param tableName
|
|
|
|
|
* @param columnName
|
|
|
|
|
* @param type 1:数字 2:日期
|
|
|
|
|
* @param map
|
|
|
|
|
* @return
|
|
|
|
|
* @param tableName 表名
|
|
|
|
|
* @param columnName 列名
|
|
|
|
|
* @param type 类型,1:数字 2:日期
|
|
|
|
|
* @param map 包含查询条件的Map
|
|
|
|
|
* @return 返回包含提醒记录数的结果对象
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/remind/{tableName}/{columnName}/{type}")
|
|
|
|
|
@IgnoreAuth
|
|
|
|
@ -175,104 +209,130 @@ public class CommonController{
|
|
|
|
|
|
|
|
|
|
if(type.equals("2")) {
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
// 获取当前日期
|
|
|
|
|
Calendar c = Calendar.getInstance();
|
|
|
|
|
Date remindStartDate = null;
|
|
|
|
|
Date remindEndDate = null;
|
|
|
|
|
if(map.get("remindstart")!=null) {
|
|
|
|
|
// 如果提醒开始日期不为空
|
|
|
|
|
if (map.get("remindstart") != null) {
|
|
|
|
|
// 解析提醒开始日期偏移量
|
|
|
|
|
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
|
|
|
|
|
c.setTime(new Date());
|
|
|
|
|
c.add(Calendar.DAY_OF_MONTH,remindStart);
|
|
|
|
|
remindStartDate = c.getTime();
|
|
|
|
|
// 将提醒开始日期格式化后添加到参数Map中
|
|
|
|
|
map.put("remindstart", sdf.format(remindStartDate));
|
|
|
|
|
}
|
|
|
|
|
if(map.get("remindend")!=null) {
|
|
|
|
|
// 如果提醒结束日期不为空
|
|
|
|
|
if (map.get("remindend") != null) {
|
|
|
|
|
// 解析提醒结束日期偏移量
|
|
|
|
|
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
|
|
|
|
|
// 设置日期
|
|
|
|
|
c.setTime(new Date());
|
|
|
|
|
c.add(Calendar.DAY_OF_MONTH,remindEnd);
|
|
|
|
|
// 计算提醒结束日期
|
|
|
|
|
c.add(Calendar.DAY_OF_MONTH, remindEnd);
|
|
|
|
|
remindEndDate = c.getTime();
|
|
|
|
|
// 将提醒结束日期格式化后添加到参数Map中
|
|
|
|
|
map.put("remindend", sdf.format(remindEndDate));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int count = commonService.remindCount(map);
|
|
|
|
|
// 返回包含提醒记录数的结果对象
|
|
|
|
|
return R.ok().put("count", count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 圖表统计
|
|
|
|
|
* @param tableName 表名
|
|
|
|
|
* @param params 包含查询参数的Map
|
|
|
|
|
* @return 返回包含统计结果的结果对象
|
|
|
|
|
*/
|
|
|
|
|
@IgnoreAuth
|
|
|
|
|
@RequestMapping("/group/{tableName}")
|
|
|
|
|
public R group1(@PathVariable("tableName") String tableName, @RequestParam Map<String,Object> params) {
|
|
|
|
|
public R group1(@PathVariable("tableName") String tableName, @RequestParam Map<String, Object> params) {
|
|
|
|
|
// 将表名添加到参数Map中
|
|
|
|
|
params.put("table1", tableName);
|
|
|
|
|
// 调用CommonService进行图表统计
|
|
|
|
|
List<Map<String, Object>> result = commonService.chartBoth(params);
|
|
|
|
|
// 返回包含统计结果的结果对象
|
|
|
|
|
return R.ok().put("data", result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 单列求和
|
|
|
|
|
* @param tableName 表名
|
|
|
|
|
* @param columnName 列名
|
|
|
|
|
* @return 返回包含求和结果的结果对象
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/cal/{tableName}/{columnName}")
|
|
|
|
|
@IgnoreAuth
|
|
|
|
|
public R cal(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName) {
|
|
|
|
|
// 创建参数Map
|
|
|
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
|
params.put("table", tableName);
|
|
|
|
|
params.put("column", columnName);
|
|
|
|
|
// 调用CommonService进行单列求和
|
|
|
|
|
Map<String, Object> result = commonService.selectCal(params);
|
|
|
|
|
// 返回包含求和结果的结果对象
|
|
|
|
|
return R.ok().put("data", result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 分组统计
|
|
|
|
|
* @param tableName 表名
|
|
|
|
|
* @param columnName 列名
|
|
|
|
|
* @return 返回包含分组统计结果的结果对象
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/group/{tableName}/{columnName}")
|
|
|
|
|
@IgnoreAuth
|
|
|
|
|
public R group(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName) {
|
|
|
|
|
// 创建参数Map
|
|
|
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
|
params.put("table", tableName);
|
|
|
|
|
params.put("column", columnName);
|
|
|
|
|
// 调用CommonService进行分组统计
|
|
|
|
|
List<Map<String, Object>> result = commonService.selectGroup(params);
|
|
|
|
|
// 返回包含分组统计结果的结果对象
|
|
|
|
|
return R.ok().put("data", result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* (按值统计)
|
|
|
|
|
* @param tableName 表名
|
|
|
|
|
* @param yColumnName y轴列名
|
|
|
|
|
* @param xColumnName x轴列名
|
|
|
|
|
* @return 返回包含按值统计结果的结果对象
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/value/{tableName}/{xColumnName}/{yColumnName}")
|
|
|
|
|
@IgnoreAuth
|
|
|
|
|
public R value(@PathVariable("tableName") String tableName, @PathVariable("yColumnName") String yColumnName, @PathVariable("xColumnName") String xColumnName) {
|
|
|
|
|
// 创建参数Map
|
|
|
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
|
params.put("table", tableName);
|
|
|
|
|
params.put("xColumn", xColumnName);
|
|
|
|
|
params.put("yColumn", yColumnName);
|
|
|
|
|
// 调用CommonService进行按值统计
|
|
|
|
|
List<Map<String, Object>> result = commonService.selectValue(params);
|
|
|
|
|
// 返回包含按值统计结果的结果对象
|
|
|
|
|
return R.ok().put("data", result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询字典表的分组求和
|
|
|
|
|
* tableName 表名
|
|
|
|
|
* groupColumn 分组字段
|
|
|
|
|
* sumCloum 统计字段
|
|
|
|
|
* @return
|
|
|
|
|
* @param params 包含查询参数的Map
|
|
|
|
|
* @return 返回包含分组求和结果的结果对象
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/newSelectGroupSum")
|
|
|
|
|
public R newSelectGroupSum(@RequestParam Map<String,Object> params) {
|
|
|
|
|
logger.debug("newSelectGroupSum:,,Controller:{},,params:{}",this.getClass().getName(),params);
|
|
|
|
|
public R newSelectGroupSum(@RequestParam Map<String, Object> params) {
|
|
|
|
|
// 记录日志
|
|
|
|
|
logger.debug("newSelectGroupSum:,,Controller:{},,params:{}", this.getClass().getName(), params);
|
|
|
|
|
// 调用CommonService进行字典表分组求和
|
|
|
|
|
List<Map<String, Object>> result = commonService.newSelectGroupSum(params);
|
|
|
|
|
// 返回包含分组求和结果的结果对象
|
|
|
|
|
return R.ok().put("data", result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
tableName 查询表
|
|
|
|
|
condition1 条件1
|
|
|
|
@ -282,257 +342,233 @@ public class CommonController{
|
|
|
|
|
有值 Number(res.data.value.toFixed(1))
|
|
|
|
|
无值 if(res.data){}
|
|
|
|
|
* */
|
|
|
|
|
@IgnoreAuth
|
|
|
|
|
@RequestMapping("/queryScore")
|
|
|
|
|
public R queryScore(@RequestParam Map<String, Object> params) {
|
|
|
|
|
logger.debug("queryScore:,,Controller:{},,params:{}",this.getClass().getName(),params);
|
|
|
|
|
Map<String, Object> queryScore = commonService.queryScore(params);
|
|
|
|
|
return R.ok().put("data", queryScore);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@IgnoreAuth
|
|
|
|
|
@RequestMapping("/queryScore")
|
|
|
|
|
public R queryScore(@RequestParam Map<String, Object> params) {
|
|
|
|
|
logger.debug("queryScore:,,Controller:{},,params:{}",this.getClass().getName(),params);
|
|
|
|
|
Map<String, Object> queryScore = commonService.queryScore(params);
|
|
|
|
|
return R.ok().put("data", queryScore);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询字典表的分组统计总条数
|
|
|
|
|
* tableName 表名
|
|
|
|
|
* groupColumn 分组字段
|
|
|
|
|
* @return
|
|
|
|
|
* @param params 包含查询参数的Map
|
|
|
|
|
* @return 返回包含分组统计总条数结果的结果对象
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/newSelectGroupCount")
|
|
|
|
|
public R newSelectGroupCount(@RequestParam Map<String,Object> params) {
|
|
|
|
|
logger.debug("newSelectGroupCount:,,Controller:{},,params:{}",this.getClass().getName(),params);
|
|
|
|
|
public R newSelectGroupCount(@RequestParam Map<String, Object> params) {
|
|
|
|
|
// 记录日志
|
|
|
|
|
logger.debug("newSelectGroupCount:,,Controller:{},,params:{}", this.getClass().getName(), params);
|
|
|
|
|
// 调用CommonService进行字典表分组统计总条数
|
|
|
|
|
List<Map<String, Object>> result = commonService.newSelectGroupCount(params);
|
|
|
|
|
// 返回包含分组统计总条数结果的结果对象
|
|
|
|
|
return R.ok().put("data", result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 当前表的日期分组求和
|
|
|
|
|
* tableName 表名
|
|
|
|
|
* groupColumn 分组字段
|
|
|
|
|
* sumCloum 统计字段
|
|
|
|
|
* dateFormatType 日期格式化类型 1:年 2:月 3:日
|
|
|
|
|
* @return
|
|
|
|
|
* @param params 包含查询参数的Map
|
|
|
|
|
* @return 返回包含日期分组求和结果的结果对象
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/newSelectDateGroupSum")
|
|
|
|
|
public R newSelectDateGroupSum(@RequestParam Map<String,Object> params) {
|
|
|
|
|
logger.debug("newSelectDateGroupSum:,,Controller:{},,params:{}",this.getClass().getName(),params);
|
|
|
|
|
public R newSelectDateGroupSum(@RequestParam Map<String, Object> params) {
|
|
|
|
|
// 记录日志
|
|
|
|
|
logger.debug("newSelectDateGroupSum:,,Controller:{},,params:{}", this.getClass().getName(), params);
|
|
|
|
|
// 获取日期格式化类型
|
|
|
|
|
String dateFormatType = String.valueOf(params.get("dateFormatType"));
|
|
|
|
|
if("1".equals(dateFormatType)){
|
|
|
|
|
// 根据日期格式化类型设置日期格式
|
|
|
|
|
if ("1".equals(dateFormatType)) {
|
|
|
|
|
params.put("dateFormat", "%Y");
|
|
|
|
|
}else if("2".equals(dateFormatType)){
|
|
|
|
|
} else if ("2".equals(dateFormatType)) {
|
|
|
|
|
params.put("dateFormat", "%Y-%m");
|
|
|
|
|
}else if("3".equals(dateFormatType)){
|
|
|
|
|
} else if ("3".equals(dateFormatType)) {
|
|
|
|
|
params.put("dateFormat", "%Y-%m-%d");
|
|
|
|
|
}else{
|
|
|
|
|
R.error("日期格式化不正确");
|
|
|
|
|
} else {
|
|
|
|
|
// 日期格式化类型不正确,返回错误信息
|
|
|
|
|
return R.error("日期格式化不正确");
|
|
|
|
|
}
|
|
|
|
|
// 调用CommonService进行日期分组求和
|
|
|
|
|
List<Map<String, Object>> result = commonService.newSelectDateGroupSum(params);
|
|
|
|
|
// 返回包含日期分组求和结果的结果对象
|
|
|
|
|
return R.ok().put("data", result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 1查询字典表的分组统计总条数
|
|
|
|
|
* tableName 表名
|
|
|
|
|
* groupColumn 分组字段
|
|
|
|
|
* dateFormatType 日期格式化类型 1:年 2:月 3:日
|
|
|
|
|
* @return
|
|
|
|
|
* 查询字典表的日期分组统计总条数
|
|
|
|
|
* @param params 包含查询参数的Map
|
|
|
|
|
* @return 返回包含日期分组统计总条数结果的结果对象
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/newSelectDateGroupCount")
|
|
|
|
|
public R newSelectDateGroupCount(@RequestParam Map<String,Object> params) {
|
|
|
|
|
logger.debug("newSelectDateGroupCount:,,Controller:{},,params:{}",this.getClass().getName(),params);
|
|
|
|
|
public R newSelectDateGroupCount(@RequestParam Map<String, Object> params) {
|
|
|
|
|
// 记录日志
|
|
|
|
|
logger.debug("newSelectDateGroupCount:,,Controller:{},,params:{}", this.getClass().getName(), params);
|
|
|
|
|
// 获取日期格式化类型
|
|
|
|
|
String dateFormatType = String.valueOf(params.get("dateFormatType"));
|
|
|
|
|
if("1".equals(dateFormatType)){
|
|
|
|
|
// 根据日期格式化类型设置日期格式
|
|
|
|
|
if ("1".equals(dateFormatType)) {
|
|
|
|
|
params.put("dateFormat", "%Y");
|
|
|
|
|
}else if("2".equals(dateFormatType)){
|
|
|
|
|
} else if ("2".equals(dateFormatType)) {
|
|
|
|
|
params.put("dateFormat", "%Y-%m");
|
|
|
|
|
}else if("3".equals(dateFormatType)){
|
|
|
|
|
} else if ("3".equals(dateFormatType)) {
|
|
|
|
|
params.put("dateFormat", "%Y-%m-%d");
|
|
|
|
|
}else{
|
|
|
|
|
R.error("日期格式化类型不正确");
|
|
|
|
|
} else {
|
|
|
|
|
// 日期格式化类型不正确,返回错误信息
|
|
|
|
|
return R.error("日期格式化类型不正确");
|
|
|
|
|
}
|
|
|
|
|
// 调用CommonService进行日期分组统计总条数
|
|
|
|
|
List<Map<String, Object>> result = commonService.newSelectDateGroupCount(params);
|
|
|
|
|
// 返回包含日期分组统计总条数结果的结果对象
|
|
|
|
|
return R.ok().put("data", result);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 饼状图
|
|
|
|
|
* -- 饼状图 查询当前表
|
|
|
|
|
-- 查询字典表【月】
|
|
|
|
|
-- 统计 -- 查询某个月的每个类型的订单销售数量
|
|
|
|
|
-- 求和 -- 查询某个月的每个类型的订单销售额
|
|
|
|
|
-- 查询某个字符串【月】
|
|
|
|
|
-- 统计 -- 查询某个月的每个员工的订单销售数量
|
|
|
|
|
-- 求和 -- 查询某个月的每个员工的订单销售额
|
|
|
|
|
-- 查询时间【年】
|
|
|
|
|
-- 统计 -- 查询每个月的订单销售数量
|
|
|
|
|
-- 求和 -- 查询每个月的订单销售额
|
|
|
|
|
-- 饼状图 查询级联表
|
|
|
|
|
-- 查询字典表
|
|
|
|
|
-- 统计 -- 查询某个月的每个类型的订单销售数量
|
|
|
|
|
-- 求和 -- 查询某个月的每个类型的订单销售额
|
|
|
|
|
-- 查询某个字符串
|
|
|
|
|
-- 统计 -- 查询某个月的每个员工的订单销售数量
|
|
|
|
|
-- 求和 -- 查询某个月的每个员工的订单销售额
|
|
|
|
|
-- 查询时间
|
|
|
|
|
-- 统计 -- 统计每个月的订单销售数量
|
|
|
|
|
-- 求和 -- 查询每个月的订单销售额
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 柱状图
|
|
|
|
|
-- 柱状图 查询当前表
|
|
|
|
|
-- 某个【年,月】
|
|
|
|
|
-- 当前表 2 级联表 1
|
|
|
|
|
-- 统计
|
|
|
|
|
-- 【日期,字符串,下拉框】
|
|
|
|
|
-- 求和
|
|
|
|
|
-- 【日期,字符串,下拉框】
|
|
|
|
|
-- 柱状图 查询级联表
|
|
|
|
|
-- 某个【年,月】
|
|
|
|
|
-- 统计
|
|
|
|
|
-- 【日期,字符串,下拉框】
|
|
|
|
|
-- 求和
|
|
|
|
|
-- 【日期,字符串,下拉框】
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 柱状图求和
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/barSum")
|
|
|
|
|
public R barSum(@RequestParam Map<String,Object> params) {
|
|
|
|
|
logger.debug("barSum方法:,,Controller:{},,params:{}",this.getClass().getName(), com.alibaba.fastjson.JSONObject.toJSONString(params));
|
|
|
|
|
Boolean isJoinTableFlag = false;//是否有级联表相关
|
|
|
|
|
String one = "";//第一优先
|
|
|
|
|
String two = "";//第二优先
|
|
|
|
|
/**
|
|
|
|
|
* 柱状图求和
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/barSum")
|
|
|
|
|
public R barSum(@RequestParam Map<String,Object> params) {
|
|
|
|
|
logger.debug("barSum方法:,,Controller:{},,params:{}",this.getClass().getName(), com.alibaba.fastjson.JSONObject.toJSONString(params));
|
|
|
|
|
Boolean isJoinTableFlag = false;//是否有级联表相关
|
|
|
|
|
String one = "";//第一优先
|
|
|
|
|
String two = "";//第二优先
|
|
|
|
|
|
|
|
|
|
//处理thisTable和joinTable 处理内容是把json字符串转为Map并把带有,的切割为数组
|
|
|
|
|
//当前表
|
|
|
|
|
Map<String,Object> thisTable = JSON.parseObject(String.valueOf(params.get("thisTable")),Map.class);
|
|
|
|
|
params.put("thisTable",thisTable);
|
|
|
|
|
|
|
|
|
|
//级联表
|
|
|
|
|
String joinTableString = String.valueOf(params.get("joinTable"));
|
|
|
|
|
if(StringUtil.isNotEmpty(joinTableString)) {
|
|
|
|
|
Map<String, Object> joinTable = JSON.parseObject(joinTableString, Map.class);
|
|
|
|
|
params.put("joinTable", joinTable);
|
|
|
|
|
isJoinTableFlag = true;
|
|
|
|
|
}
|
|
|
|
|
//当前表
|
|
|
|
|
Map<String,Object> thisTable = JSON.parseObject(String.valueOf(params.get("thisTable")),Map.class);
|
|
|
|
|
params.put("thisTable",thisTable);
|
|
|
|
|
|
|
|
|
|
//级联表
|
|
|
|
|
String joinTableString = String.valueOf(params.get("joinTable"));
|
|
|
|
|
if(StringUtil.isNotEmpty(joinTableString)) {
|
|
|
|
|
Map<String, Object> joinTable = JSON.parseObject(joinTableString, Map.class);
|
|
|
|
|
params.put("joinTable", joinTable);
|
|
|
|
|
isJoinTableFlag = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("date")))){//当前表日期
|
|
|
|
|
thisTable.put("date",String.valueOf(thisTable.get("date")).split(","));
|
|
|
|
|
// 处理当前表日期
|
|
|
|
|
if (StringUtil.isNotEmpty(String.valueOf(thisTable.get("date")))) {
|
|
|
|
|
thisTable.put("date", String.valueOf(thisTable.get("date")).split(","));
|
|
|
|
|
one = "thisDate0";
|
|
|
|
|
}
|
|
|
|
|
if(isJoinTableFlag){//级联表日期
|
|
|
|
|
// 处理级联表日期
|
|
|
|
|
if (isJoinTableFlag) {
|
|
|
|
|
Map<String, Object> joinTable = (Map<String, Object>) params.get("joinTable");
|
|
|
|
|
if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("date")))){
|
|
|
|
|
joinTable.put("date",String.valueOf(joinTable.get("date")).split(","));
|
|
|
|
|
if(StringUtil.isEmpty(one)){
|
|
|
|
|
one ="joinDate0";
|
|
|
|
|
}else{
|
|
|
|
|
if(StringUtil.isEmpty(two)){
|
|
|
|
|
two ="joinDate0";
|
|
|
|
|
if (StringUtil.isNotEmpty(String.valueOf(joinTable.get("date")))) {
|
|
|
|
|
joinTable.put("date", String.valueOf(joinTable.get("date")).split(","));
|
|
|
|
|
if (StringUtil.isEmpty(one)) {
|
|
|
|
|
one = "joinDate0";
|
|
|
|
|
} else {
|
|
|
|
|
if (StringUtil.isEmpty(two)) {
|
|
|
|
|
two = "joinDate0";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("string")))){//当前表字符串
|
|
|
|
|
thisTable.put("string",String.valueOf(thisTable.get("string")).split(","));
|
|
|
|
|
if(StringUtil.isEmpty(one)){
|
|
|
|
|
one ="thisString0";
|
|
|
|
|
}else{
|
|
|
|
|
if(StringUtil.isEmpty(two)){
|
|
|
|
|
two ="thisString0";
|
|
|
|
|
// 处理当前表字符串
|
|
|
|
|
if (StringUtil.isNotEmpty(String.valueOf(thisTable.get("string")))) {
|
|
|
|
|
thisTable.put("string", String.valueOf(thisTable.get("string")).split(","));
|
|
|
|
|
if (StringUtil.isEmpty(one)) {
|
|
|
|
|
one = "thisString0";
|
|
|
|
|
} else {
|
|
|
|
|
if (StringUtil.isEmpty(two)) {
|
|
|
|
|
two = "thisString0";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(isJoinTableFlag){//级联表字符串
|
|
|
|
|
// 处理级联表字符串
|
|
|
|
|
if (isJoinTableFlag) {
|
|
|
|
|
Map<String, Object> joinTable = (Map<String, Object>) params.get("joinTable");
|
|
|
|
|
if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("string")))){
|
|
|
|
|
joinTable.put("string",String.valueOf(joinTable.get("string")).split(","));
|
|
|
|
|
if(StringUtil.isEmpty(one)){
|
|
|
|
|
one ="joinString0";
|
|
|
|
|
}else{
|
|
|
|
|
if(StringUtil.isEmpty(two)){
|
|
|
|
|
two ="joinString0";
|
|
|
|
|
if (StringUtil.isNotEmpty(String.valueOf(joinTable.get("string")))) {
|
|
|
|
|
joinTable.put("string", String.valueOf(joinTable.get("string")).split(","));
|
|
|
|
|
if (StringUtil.isEmpty(one)) {
|
|
|
|
|
one = "joinString0";
|
|
|
|
|
} else {
|
|
|
|
|
if (StringUtil.isEmpty(two)) {
|
|
|
|
|
two = "joinString0";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("types")))){//当前表类型
|
|
|
|
|
thisTable.put("types",String.valueOf(thisTable.get("types")).split(","));
|
|
|
|
|
if(StringUtil.isEmpty(one)){
|
|
|
|
|
one ="thisTypes0";
|
|
|
|
|
}else{
|
|
|
|
|
if(StringUtil.isEmpty(two)){
|
|
|
|
|
two ="thisTypes0";
|
|
|
|
|
// 处理当前表类型
|
|
|
|
|
if (StringUtil.isNotEmpty(String.valueOf(thisTable.get("types")))) {
|
|
|
|
|
thisTable.put("types", String.valueOf(thisTable.get("types")).split(","));
|
|
|
|
|
if (StringUtil.isEmpty(one)) {
|
|
|
|
|
one = "thisTypes0";
|
|
|
|
|
} else {
|
|
|
|
|
if (StringUtil.isEmpty(two)) {
|
|
|
|
|
two = "thisTypes0";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(isJoinTableFlag){//级联表类型
|
|
|
|
|
// 处理级联表类型
|
|
|
|
|
if (isJoinTableFlag) {
|
|
|
|
|
Map<String, Object> joinTable = (Map<String, Object>) params.get("joinTable");
|
|
|
|
|
if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("types")))){
|
|
|
|
|
joinTable.put("types",String.valueOf(joinTable.get("types")).split(","));
|
|
|
|
|
if(StringUtil.isEmpty(one)){
|
|
|
|
|
one ="joinTypes0";
|
|
|
|
|
}else{
|
|
|
|
|
if(StringUtil.isEmpty(two)){
|
|
|
|
|
two ="joinTypes0";
|
|
|
|
|
if (StringUtil.isNotEmpty(String.valueOf(joinTable.get("types")))) {
|
|
|
|
|
joinTable.put("types", String.valueOf(joinTable.get("types")).split(","));
|
|
|
|
|
if (StringUtil.isEmpty(one)) {
|
|
|
|
|
one = "joinTypes0";
|
|
|
|
|
} else {
|
|
|
|
|
if (StringUtil.isEmpty(two)) {
|
|
|
|
|
two = "joinTypes0";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 调用CommonService进行柱状图求和
|
|
|
|
|
List<Map<String, Object>> result = commonService.barSum(params);
|
|
|
|
|
|
|
|
|
|
List<String> xAxis = new ArrayList<>();//报表x轴
|
|
|
|
|
List<List<String>> yAxis = new ArrayList<>();//y轴
|
|
|
|
|
List<String> legend = new ArrayList<>();//标题
|
|
|
|
|
// 报表x轴
|
|
|
|
|
List<String> xAxis = new ArrayList<>();
|
|
|
|
|
// y轴
|
|
|
|
|
List<List<String>> yAxis = new ArrayList<>();
|
|
|
|
|
// 标题
|
|
|
|
|
List<String> legend = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
if(StringUtil.isEmpty(two)){//不包含第二列
|
|
|
|
|
// 如果不包含第二列
|
|
|
|
|
if (StringUtil.isEmpty(two)) {
|
|
|
|
|
List<String> yAxis0 = new ArrayList<>();
|
|
|
|
|
yAxis.add(yAxis0);
|
|
|
|
|
legend.add("数值");
|
|
|
|
|
for(Map<String, Object> map :result){
|
|
|
|
|
for (Map<String, Object> map : result) {
|
|
|
|
|
String oneValue = String.valueOf(map.get(one));
|
|
|
|
|
String value = String.valueOf(map.get("value"));
|
|
|
|
|
xAxis.add(oneValue);
|
|
|
|
|
yAxis0.add(value);
|
|
|
|
|
}
|
|
|
|
|
}else{//包含第二列
|
|
|
|
|
} else {
|
|
|
|
|
// 包含第二列
|
|
|
|
|
Map<String, HashMap<String, String>> dataMap = new LinkedHashMap<>();
|
|
|
|
|
if(StringUtil.isNotEmpty(two)){
|
|
|
|
|
for(Map<String, Object> map :result){
|
|
|
|
|
if (StringUtil.isNotEmpty(two)) {
|
|
|
|
|
for (Map<String, Object> map : result) {
|
|
|
|
|
String oneValue = String.valueOf(map.get(one));
|
|
|
|
|
String twoValue = String.valueOf(map.get(two));
|
|
|
|
|
String value = String.valueOf(map.get("value"));
|
|
|
|
|
if(!legend.contains(twoValue)){
|
|
|
|
|
legend.add(twoValue);//添加完成后 就是最全的第二列的类型
|
|
|
|
|
if (!legend.contains(twoValue)) {
|
|
|
|
|
legend.add(twoValue);
|
|
|
|
|
}
|
|
|
|
|
if(dataMap.containsKey(oneValue)){
|
|
|
|
|
dataMap.get(oneValue).put(twoValue,value);
|
|
|
|
|
}else{
|
|
|
|
|
if (dataMap.containsKey(oneValue)) {
|
|
|
|
|
dataMap.get(oneValue).put(twoValue, value);
|
|
|
|
|
} else {
|
|
|
|
|
HashMap<String, String> oneData = new HashMap<>();
|
|
|
|
|
oneData.put(twoValue,value);
|
|
|
|
|
dataMap.put(oneValue,oneData);
|
|
|
|
|
oneData.put(twoValue, value);
|
|
|
|
|
dataMap.put(oneValue, oneData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(int i =0; i<legend.size(); i++){
|
|
|
|
|
for (int i = 0; i < legend.size(); i++) {
|
|
|
|
|
yAxis.add(new ArrayList<String>());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Set<String> keys = dataMap.keySet();
|
|
|
|
|
for(String key:keys){
|
|
|
|
|
for (String key : keys) {
|
|
|
|
|
xAxis.add(key);
|
|
|
|
|
HashMap<String, String> map = dataMap.get(key);
|
|
|
|
|
for(int i =0; i<legend.size(); i++){
|
|
|
|
|
for (int i = 0; i < legend.size(); i++) {
|
|
|
|
|
List<String> data = yAxis.get(i);
|
|
|
|
|
if(StringUtil.isNotEmpty(map.get(legend.get(i)))){
|
|
|
|
|
if (StringUtil.isNotEmpty(map.get(legend.get(i)))) {
|
|
|
|
|
data.add(map.get(legend.get(i)));
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
data.add("0");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -540,151 +576,163 @@ public class CommonController{
|
|
|
|
|
System.out.println();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 创建结果Map
|
|
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
|
|
resultMap.put("xAxis",xAxis);
|
|
|
|
|
resultMap.put("yAxis",yAxis);
|
|
|
|
|
resultMap.put("legend",legend);
|
|
|
|
|
resultMap.put("xAxis", xAxis);
|
|
|
|
|
resultMap.put("yAxis", yAxis);
|
|
|
|
|
resultMap.put("legend", legend);
|
|
|
|
|
// 返回包含柱状图求和结果的结果对象
|
|
|
|
|
return R.ok().put("data", resultMap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 柱状图统计
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/barCount")
|
|
|
|
|
public R barCount(@RequestParam Map<String,Object> params) {
|
|
|
|
|
logger.debug("barCount方法:,,Controller:{},,params:{}",this.getClass().getName(), com.alibaba.fastjson.JSONObject.toJSONString(params));
|
|
|
|
|
Boolean isJoinTableFlag = false;//是否有级联表相关
|
|
|
|
|
String one = "";//第一优先
|
|
|
|
|
String two = "";//第二优先
|
|
|
|
|
* 柱状图统计
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/barCount")
|
|
|
|
|
public R barCount(@RequestParam Map<String,Object> params) {
|
|
|
|
|
logger.debug("barCount方法:,,Controller:{},,params:{}",this.getClass().getName(), com.alibaba.fastjson.JSONObject.toJSONString(params));
|
|
|
|
|
Boolean isJoinTableFlag = false;//是否有级联表相关
|
|
|
|
|
String one = "";//第一优先
|
|
|
|
|
String two = "";//第二优先
|
|
|
|
|
|
|
|
|
|
//处理thisTable和joinTable 处理内容是把json字符串转为Map并把带有,的切割为数组
|
|
|
|
|
//当前表
|
|
|
|
|
Map<String,Object> thisTable = JSON.parseObject(String.valueOf(params.get("thisTable")),Map.class);
|
|
|
|
|
params.put("thisTable",thisTable);
|
|
|
|
|
|
|
|
|
|
//级联表
|
|
|
|
|
String joinTableString = String.valueOf(params.get("joinTable"));
|
|
|
|
|
if(StringUtil.isNotEmpty(joinTableString)) {
|
|
|
|
|
Map<String, Object> joinTable = JSON.parseObject(joinTableString, Map.class);
|
|
|
|
|
params.put("joinTable", joinTable);
|
|
|
|
|
isJoinTableFlag = true;
|
|
|
|
|
}
|
|
|
|
|
//当前表
|
|
|
|
|
Map<String,Object> thisTable = JSON.parseObject(String.valueOf(params.get("thisTable")),Map.class);
|
|
|
|
|
params.put("thisTable",thisTable);
|
|
|
|
|
|
|
|
|
|
//级联表
|
|
|
|
|
String joinTableString = String.valueOf(params.get("joinTable"));
|
|
|
|
|
if(StringUtil.isNotEmpty(joinTableString)) {
|
|
|
|
|
Map<String, Object> joinTable = JSON.parseObject(joinTableString, Map.class);
|
|
|
|
|
params.put("joinTable", joinTable);
|
|
|
|
|
isJoinTableFlag = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("date")))){//当前表日期
|
|
|
|
|
thisTable.put("date",String.valueOf(thisTable.get("date")).split(","));
|
|
|
|
|
// 处理当前表日期
|
|
|
|
|
if (StringUtil.isNotEmpty(String.valueOf(thisTable.get("date")))) {
|
|
|
|
|
thisTable.put("date", String.valueOf(thisTable.get("date")).split(","));
|
|
|
|
|
one = "thisDate0";
|
|
|
|
|
}
|
|
|
|
|
if(isJoinTableFlag){//级联表日期
|
|
|
|
|
// 处理级联表日期
|
|
|
|
|
if (isJoinTableFlag) {
|
|
|
|
|
Map<String, Object> joinTable = (Map<String, Object>) params.get("joinTable");
|
|
|
|
|
if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("date")))){
|
|
|
|
|
joinTable.put("date",String.valueOf(joinTable.get("date")).split(","));
|
|
|
|
|
if(StringUtil.isEmpty(one)){
|
|
|
|
|
one ="joinDate0";
|
|
|
|
|
}else{
|
|
|
|
|
if(StringUtil.isEmpty(two)){
|
|
|
|
|
two ="joinDate0";
|
|
|
|
|
if (StringUtil.isNotEmpty(String.valueOf(joinTable.get("date")))) {
|
|
|
|
|
joinTable.put("date", String.valueOf(joinTable.get("date")).split(","));
|
|
|
|
|
if (StringUtil.isEmpty(one)) {
|
|
|
|
|
one = "joinDate0";
|
|
|
|
|
} else {
|
|
|
|
|
if (StringUtil.isEmpty(two)) {
|
|
|
|
|
two = "joinDate0";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("string")))){//当前表字符串
|
|
|
|
|
thisTable.put("string",String.valueOf(thisTable.get("string")).split(","));
|
|
|
|
|
if(StringUtil.isEmpty(one)){
|
|
|
|
|
one ="thisString0";
|
|
|
|
|
}else{
|
|
|
|
|
if(StringUtil.isEmpty(two)){
|
|
|
|
|
two ="thisString0";
|
|
|
|
|
// 处理当前表字符串
|
|
|
|
|
if (StringUtil.isNotEmpty(String.valueOf(thisTable.get("string")))) {
|
|
|
|
|
thisTable.put("string", String.valueOf(thisTable.get("string")).split(","));
|
|
|
|
|
if (StringUtil.isEmpty(one)) {
|
|
|
|
|
one = "thisString0";
|
|
|
|
|
} else {
|
|
|
|
|
if (StringUtil.isEmpty(two)) {
|
|
|
|
|
two = "thisString0";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(isJoinTableFlag){//级联表字符串
|
|
|
|
|
// 处理级联表字符串
|
|
|
|
|
if (isJoinTableFlag) {
|
|
|
|
|
Map<String, Object> joinTable = (Map<String, Object>) params.get("joinTable");
|
|
|
|
|
if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("string")))){
|
|
|
|
|
joinTable.put("string",String.valueOf(joinTable.get("string")).split(","));
|
|
|
|
|
if(StringUtil.isEmpty(one)){
|
|
|
|
|
one ="joinString0";
|
|
|
|
|
}else{
|
|
|
|
|
if(StringUtil.isEmpty(two)){
|
|
|
|
|
two ="joinString0";
|
|
|
|
|
if (StringUtil.isNotEmpty(String.valueOf(joinTable.get("string")))) {
|
|
|
|
|
joinTable.put("string", String.valueOf(joinTable.get("string")).split(","));
|
|
|
|
|
if (StringUtil.isEmpty(one)) {
|
|
|
|
|
one = "joinString0";
|
|
|
|
|
} else {
|
|
|
|
|
if (StringUtil.isEmpty(two)) {
|
|
|
|
|
two = "joinString0";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("types")))){//当前表类型
|
|
|
|
|
thisTable.put("types",String.valueOf(thisTable.get("types")).split(","));
|
|
|
|
|
if(StringUtil.isEmpty(one)){
|
|
|
|
|
one ="thisTypes0";
|
|
|
|
|
}else{
|
|
|
|
|
if(StringUtil.isEmpty(two)){
|
|
|
|
|
two ="thisTypes0";
|
|
|
|
|
// 处理当前表类型
|
|
|
|
|
if (StringUtil.isNotEmpty(String.valueOf(thisTable.get("types")))) {
|
|
|
|
|
thisTable.put("types", String.valueOf(thisTable.get("types")).split(","));
|
|
|
|
|
if (StringUtil.isEmpty(one)) {
|
|
|
|
|
one = "thisTypes0";
|
|
|
|
|
} else {
|
|
|
|
|
if (StringUtil.isEmpty(two)) {
|
|
|
|
|
two = "thisTypes0";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(isJoinTableFlag){//级联表类型
|
|
|
|
|
// 处理级联表类型
|
|
|
|
|
if (isJoinTableFlag) {
|
|
|
|
|
Map<String, Object> joinTable = (Map<String, Object>) params.get("joinTable");
|
|
|
|
|
if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("types")))){
|
|
|
|
|
joinTable.put("types",String.valueOf(joinTable.get("types")).split(","));
|
|
|
|
|
if(StringUtil.isEmpty(one)){
|
|
|
|
|
one ="joinTypes0";
|
|
|
|
|
}else{
|
|
|
|
|
if(StringUtil.isEmpty(two)){
|
|
|
|
|
two ="joinTypes0";
|
|
|
|
|
if (StringUtil.isNotEmpty(String.valueOf(joinTable.get("types")))) {
|
|
|
|
|
joinTable.put("types", String.valueOf(joinTable.get("types")).split(","));
|
|
|
|
|
if (StringUtil.isEmpty(one)) {
|
|
|
|
|
one = "joinTypes0";
|
|
|
|
|
} else {
|
|
|
|
|
if (StringUtil.isEmpty(two)) {
|
|
|
|
|
two = "joinTypes0";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 调用CommonService进行柱状图统计
|
|
|
|
|
List<Map<String, Object>> result = commonService.barCount(params);
|
|
|
|
|
|
|
|
|
|
List<String> xAxis = new ArrayList<>();//报表x轴
|
|
|
|
|
List<List<String>> yAxis = new ArrayList<>();//y轴
|
|
|
|
|
List<String> legend = new ArrayList<>();//标题
|
|
|
|
|
// 报表x轴
|
|
|
|
|
List<String> xAxis = new ArrayList<>();
|
|
|
|
|
// y轴
|
|
|
|
|
List<List<String>> yAxis = new ArrayList<>();
|
|
|
|
|
// 标题
|
|
|
|
|
List<String> legend = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
if(StringUtil.isEmpty(two)){//不包含第二列
|
|
|
|
|
// 如果不包含第二列
|
|
|
|
|
if (StringUtil.isEmpty(two)) {
|
|
|
|
|
List<String> yAxis0 = new ArrayList<>();
|
|
|
|
|
yAxis.add(yAxis0);
|
|
|
|
|
legend.add("数值");
|
|
|
|
|
for(Map<String, Object> map :result){
|
|
|
|
|
for (Map<String, Object> map : result) {
|
|
|
|
|
String oneValue = String.valueOf(map.get(one));
|
|
|
|
|
String value = String.valueOf(map.get("value"));
|
|
|
|
|
xAxis.add(oneValue);
|
|
|
|
|
yAxis0.add(value);
|
|
|
|
|
}
|
|
|
|
|
}else{//包含第二列
|
|
|
|
|
} else {
|
|
|
|
|
// 包含第二列
|
|
|
|
|
Map<String, HashMap<String, String>> dataMap = new LinkedHashMap<>();
|
|
|
|
|
if(StringUtil.isNotEmpty(two)){
|
|
|
|
|
for(Map<String, Object> map :result){
|
|
|
|
|
if (StringUtil.isNotEmpty(two)) {
|
|
|
|
|
for (Map<String, Object> map : result) {
|
|
|
|
|
String oneValue = String.valueOf(map.get(one));
|
|
|
|
|
String twoValue = String.valueOf(map.get(two));
|
|
|
|
|
String value = String.valueOf(map.get("value"));
|
|
|
|
|
if(!legend.contains(twoValue)){
|
|
|
|
|
legend.add(twoValue);//添加完成后 就是最全的第二列的类型
|
|
|
|
|
if (!legend.contains(twoValue)) {
|
|
|
|
|
legend.add(twoValue);
|
|
|
|
|
}
|
|
|
|
|
if(dataMap.containsKey(oneValue)){
|
|
|
|
|
dataMap.get(oneValue).put(twoValue,value);
|
|
|
|
|
}else{
|
|
|
|
|
if (dataMap.containsKey(oneValue)) {
|
|
|
|
|
dataMap.get(oneValue).put(twoValue, value);
|
|
|
|
|
} else {
|
|
|
|
|
HashMap<String, String> oneData = new HashMap<>();
|
|
|
|
|
oneData.put(twoValue,value);
|
|
|
|
|
dataMap.put(oneValue,oneData);
|
|
|
|
|
oneData.put(twoValue, value);
|
|
|
|
|
dataMap.put(oneValue, oneData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(int i =0; i<legend.size(); i++){
|
|
|
|
|
for (int i = 0; i < legend.size(); i++) {
|
|
|
|
|
yAxis.add(new ArrayList<String>());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Set<String> keys = dataMap.keySet();
|
|
|
|
|
for(String key:keys){
|
|
|
|
|
for (String key : keys) {
|
|
|
|
|
xAxis.add(key);
|
|
|
|
|
HashMap<String, String> map = dataMap.get(key);
|
|
|
|
|
for(int i =0; i<legend.size(); i++){
|
|
|
|
|
for (int i = 0; i < legend.size(); i++) {
|
|
|
|
|
List<String> data = yAxis.get(i);
|
|
|
|
|
if(StringUtil.isNotEmpty(map.get(legend.get(i)))){
|
|
|
|
|
if (StringUtil.isNotEmpty(map.get(legend.get(i)))) {
|
|
|
|
|
data.add(map.get(legend.get(i)));
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
data.add("0");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -692,10 +740,12 @@ public class CommonController{
|
|
|
|
|
System.out.println();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 创建结果Map
|
|
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
|
|
resultMap.put("xAxis",xAxis);
|
|
|
|
|
resultMap.put("yAxis",yAxis);
|
|
|
|
|
resultMap.put("legend",legend);
|
|
|
|
|
resultMap.put("xAxis", xAxis);
|
|
|
|
|
resultMap.put("yAxis", yAxis);
|
|
|
|
|
resultMap.put("legend", legend);
|
|
|
|
|
// 返回包含柱状图统计结果的结果对象
|
|
|
|
|
return R.ok().put("data", resultMap);
|
|
|
|
|
}
|
|
|
|
|
}
|