Commit 3ce82e9f by wancheng

屏报显示优化

parent 0738d0c9
package com.baosight.hpjx.hp.bi.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baosight.eplat.be.dz.constants.BEDZConstants;
import com.baosight.hpjx.aspect.annotation.OperationLogAnnotation;
import com.baosight.hpjx.common.DdynamicEnum;
import com.baosight.hpjx.common.InventTypeEnum;
import com.baosight.hpjx.core.security.UserSessionUtils;
import com.baosight.hpjx.hp.bi.domain.HPBI001;
import com.baosight.hpjx.util.CommonMethod;
import com.baosight.hpjx.util.LogUtils;
import com.baosight.hpjx.util.StringUtils;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.service.impl.ServiceBase;
import com.baosight.iplat4j.core.service.soa.XServiceManager;
import com.baosight.iplat4j.core.web.threadlocal.UserSession;
import java.util.*;
import static com.baosight.eplat.be.dz.service.ServiceBEDZ04.PARAMS_KEY_STR;
/**
* @author wancheng
* @date 2024年02月01日 17:18
*/
public class ServiceHPBI002 extends ServiceBase {
// 指定存货类型
private static final Integer[] DEFAULT_INVENT_CODE = {InventTypeEnum.RAW.getCode(),
InventTypeEnum.CONSUMABLE.getCode()};
/**
* 查询报屏模块日产量 fb84fbe85bdd45a3a6a0806f489bc774
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "生产管理驾驶舱1",operType = "查询",operDesc = "查询报屏模块日产量")
public EiInfo queryRCLInfo(EiInfo inInfo) {
String paramsStr = inInfo.getString(PARAMS_KEY_STR);
JSONArray jsonArray = (JSONArray) JSONArray.parse(paramsStr);
JSONObject jsonObject = (JSONObject) jsonArray.get(0);
JSONArray idsArr = (JSONArray) jsonObject.get("ids");
String idsStr = idsArr.getString(0);
JSONObject paramsObj = null;
if (jsonObject.get("params") instanceof String) {
paramsObj=JSON.parseObject((String) jsonObject.get("params"));
} else {
paramsObj= (JSONObject) jsonObject.get("params");
}
String factStr = paramsObj.getString("factorycode");
String dateStr = paramsObj.getString("date").replace("-","");
EiInfo eiInfo = new EiInfo();
String serviceId = "S_BE_XP_17";
eiInfo.set(EiConstant.serviceId,serviceId);
Map map = new HashMap();
map.put("uuid","fb84fbe85bdd45a3a6a0806f489bc774");
map.put("offset",0);
map.put("limit",1000);
//获取公司代码
String company_code = "%";
if(!StringUtils.isEmpty(UserSessionUtils.getCompanyCode().trim())){
company_code = UserSessionUtils.getCompanyCode();
}
//数据集入参
Map params =new HashMap();
params.put("company_code",company_code);
params.put("factorycode",factStr);
params.put("date",dateStr);
map.put("params",params);
List list =new ArrayList();
list.add(map);
eiInfo.set("queryInfo",list);
//服务接口调用
EiInfo outInfo = XServiceManager.call(eiInfo);
//调用微服务后的结果
Map result = (Map) outInfo.get("result");
Map result1 = (Map) result.get("fb84fbe85bdd45a3a6a0806f489bc774");
List<Map> list1 = (List) result1.get("data");
JSONArray tempArr = new JSONArray();
String json = "YGL,JHCL,SJCL,RJCL";
List tempContentList = Arrays.asList(json.split(","));
tempArr.add(tempContentList);
JSONObject item = new JSONObject();
list1.forEach(obj -> {
// 处理obj
List datalist =new ArrayList();
datalist.add(obj.get("YGL"));
datalist.add(obj.get("JHCL"));
datalist.add(obj.get("SJCL"));
datalist.add(obj.get("RJCL"));
tempArr.add(datalist);
});
JSONArray ids = new JSONArray();
ids.add(idsStr);
item.put("ids", ids);
item.put("component", null);
item.put("data", tempArr);
List list2 =new ArrayList();
list2.add(item);
outInfo.set("result",list2);
return outInfo;
}
/**
* 查询报屏模块月累计产量 ebf3840d85714bc181a1ed036425a45f
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "生产管理驾驶舱1",operType = "查询",operDesc = "查询报屏模块月累计产量")
public EiInfo queryYCLinfo(EiInfo inInfo) {
String paramsStr = inInfo.getString(PARAMS_KEY_STR);
JSONArray jsonArray = (JSONArray) JSONArray.parse(paramsStr);
JSONObject jsonObject = (JSONObject) jsonArray.get(0);
JSONArray idsArr = (JSONArray) jsonObject.get("ids");
String idsStr = idsArr.getString(0);
JSONObject paramsObj = null;
if (jsonObject.get("params") instanceof String) {
paramsObj=JSON.parseObject((String) jsonObject.get("params"));
} else {
paramsObj= (JSONObject) jsonObject.get("params");
}
String factStr = paramsObj.getString("factorycode");
String dateStr = paramsObj.getString("date").replace("-","");
EiInfo eiInfo = new EiInfo();
String serviceId = "S_BE_XP_17";
eiInfo.set(EiConstant.serviceId,serviceId);
Map map = new HashMap();
map.put("uuid","ebf3840d85714bc181a1ed036425a45f");
map.put("offset",0);
map.put("limit",1000);
//获取公司代码
String company_code = "%";
if(!StringUtils.isEmpty(UserSessionUtils.getCompanyCode().trim())){
company_code = UserSessionUtils.getCompanyCode();
}
//数据集入参
Map params =new HashMap();
params.put("company_code",company_code);
params.put("factorycode",factStr);
params.put("date",dateStr);
map.put("params",params);
List list =new ArrayList();
list.add(map);
eiInfo.set("queryInfo",list);
//服务接口调用
EiInfo outInfo = XServiceManager.call(eiInfo);
//调用微服务后的结果
Map result = (Map) outInfo.get("result");
Map result1 = (Map) result.get("ebf3840d85714bc181a1ed036425a45f");
List<Map> list1 = (List) result1.get("data");
JSONArray tempArr = new JSONArray();
String json = "LJYGL,LJJHCL,LJSJCL,LJRJCL";
List tempContentList = Arrays.asList(json.split(","));
tempArr.add(tempContentList);
JSONObject item = new JSONObject();
list1.forEach(obj -> {
// 处理obj
List datalist =new ArrayList();
datalist.add(obj.get("LJYGL"));
datalist.add(obj.get("LJJHCL"));
datalist.add(obj.get("LJSJCL"));
datalist.add(obj.get("LJRJCL"));
tempArr.add(datalist);
});
JSONArray ids = new JSONArray();
ids.add(idsStr);
item.put("ids", ids);
item.put("component", null);
item.put("data", tempArr);
List list2 =new ArrayList();
list2.add(item);
outInfo.set("result",list2);
return outInfo;
}
/**
* 查询报屏模块年累计产量 3bb22a1155364389916169b902bbe0f7
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "生产管理驾驶舱1",operType = "查询",operDesc = "查询报屏模块年累计产量")
public EiInfo queryNCLinfo(EiInfo inInfo) {
String paramsStr = inInfo.getString(PARAMS_KEY_STR);
JSONArray jsonArray = (JSONArray) JSONArray.parse(paramsStr);
JSONObject jsonObject = (JSONObject) jsonArray.get(0);
JSONArray idsArr = (JSONArray) jsonObject.get("ids");
String idsStr = idsArr.getString(0);
JSONObject paramsObj = null;
if (jsonObject.get("params") instanceof String) {
paramsObj=JSON.parseObject((String) jsonObject.get("params"));
} else {
paramsObj= (JSONObject) jsonObject.get("params");
}
String factStr = paramsObj.getString("factorycode");
String dateStr = paramsObj.getString("date").replace("-","");
EiInfo eiInfo = new EiInfo();
String serviceId = "S_BE_XP_17";
eiInfo.set(EiConstant.serviceId,serviceId);
Map map = new HashMap();
map.put("uuid","3bb22a1155364389916169b902bbe0f7");
map.put("offset",0);
map.put("limit",1000);
//获取公司代码
String company_code = "%";
if(!StringUtils.isEmpty(UserSessionUtils.getCompanyCode().trim())){
company_code = UserSessionUtils.getCompanyCode();
}
//数据集入参
Map params =new HashMap();
params.put("company_code",company_code);
params.put("factorycode",factStr);
params.put("date",dateStr);
map.put("params",params);
List list =new ArrayList();
list.add(map);
eiInfo.set("queryInfo",list);
//服务接口调用
EiInfo outInfo = XServiceManager.call(eiInfo);
//调用微服务后的结果
Map result = (Map) outInfo.get("result");
Map result1 = (Map) result.get("3bb22a1155364389916169b902bbe0f7");
List<Map> list1 = (List) result1.get("data");
JSONArray tempArr = new JSONArray();
String json = "NLJYG,NLJJHCL,NLJSJCL,NLJRJCL";
List tempContentList = Arrays.asList(json.split(","));
tempArr.add(tempContentList);
JSONObject item = new JSONObject();
list1.forEach(obj -> {
// 处理obj
List datalist =new ArrayList();
datalist.add(obj.get("NLJYG"));
datalist.add(obj.get("NLJJHCL"));
datalist.add(obj.get("NLJSJCL"));
datalist.add(obj.get("NLJRJCL"));
tempArr.add(datalist);
});
JSONArray ids = new JSONArray();
ids.add(idsStr);
item.put("ids", ids);
item.put("component", null);
item.put("data", tempArr);
List list2 =new ArrayList();
list2.add(item);
outInfo.set("result",list2);
return outInfo;
}
/**
* 查询报屏模块组拼加焊综合总产量 cf86273ee74744e883b94ee781c044f2
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "生产管理驾驶舱1",operType = "查询",operDesc = "组拼加焊综合总产量")
public EiInfo queryZCLinfo(EiInfo inInfo) {
String paramsStr = inInfo.getString(PARAMS_KEY_STR);
JSONArray jsonArray = (JSONArray) JSONArray.parse(paramsStr);
JSONObject jsonObject = (JSONObject) jsonArray.get(0);
JSONArray idsArr = (JSONArray) jsonObject.get("ids");
String idsStr = idsArr.getString(0);
JSONObject paramsObj = null;
if (jsonObject.get("params") instanceof String) {
paramsObj=JSON.parseObject((String) jsonObject.get("params"));
} else {
paramsObj= (JSONObject) jsonObject.get("params");
}
String factStr = paramsObj.getString("factorycode");
String dateStr = paramsObj.getString("date").replace("-","");
EiInfo eiInfo = new EiInfo();
String serviceId = "S_BE_XP_17";
eiInfo.set(EiConstant.serviceId,serviceId);
Map map = new HashMap();
map.put("uuid","cf86273ee74744e883b94ee781c044f2");
map.put("offset",0);
map.put("limit",1000);
//获取公司代码
String company_code = "%";
if(!StringUtils.isEmpty(UserSessionUtils.getCompanyCode().trim())){
company_code = UserSessionUtils.getCompanyCode();
}
//数据集入参
Map params =new HashMap();
params.put("company_code",company_code);
params.put("factorycode",factStr);
params.put("date",dateStr);
map.put("params",params);
List list =new ArrayList();
list.add(map);
eiInfo.set("queryInfo",list);
//服务接口调用
EiInfo outInfo = XServiceManager.call(eiInfo);
//调用微服务后的结果
Map result = (Map) outInfo.get("result");
Map result1 = (Map) result.get("cf86273ee74744e883b94ee781c044f2");
List<Map> list1 = (List) result1.get("data");
JSONArray tempArr = new JSONArray();
String json = "ZP,JH,ZH";
List tempContentList = Arrays.asList(json.split(","));
tempArr.add(tempContentList);
JSONObject item = new JSONObject();
list1.forEach(obj -> {
// 处理obj
List datalist =new ArrayList();
datalist.add(obj.get("ZP"));
datalist.add(obj.get("JH"));
datalist.add(obj.get("ZH"));
tempArr.add(datalist);
});
JSONArray ids = new JSONArray();
ids.add(idsStr);
item.put("ids", ids);
item.put("component", null);
item.put("data", tempArr);
List list2 =new ArrayList();
list2.add(item);
outInfo.set("result",list2);
return outInfo;
}
/**
* 各组组拼加焊综合产量 10da64857f0e47b7b88dc9fd5152ceab
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "生产管理驾驶舱1",operType = "查询",operDesc = "各组组拼加焊综合产量")
public EiInfo queryGroupCLnfo(EiInfo inInfo) {
String paramsStr = inInfo.getString(PARAMS_KEY_STR);
JSONArray jsonArray = (JSONArray) JSONArray.parse(paramsStr);
JSONObject jsonObject = (JSONObject) jsonArray.get(0);
JSONArray idsArr = (JSONArray) jsonObject.get("ids");
String idsStr = idsArr.getString(0);
JSONObject paramsObj = null;
if (jsonObject.get("params") instanceof String) {
paramsObj=JSON.parseObject((String) jsonObject.get("params"));
} else {
paramsObj= (JSONObject) jsonObject.get("params");
}
String factStr = paramsObj.getString("factorycode");
String dateStr = paramsObj.getString("date").replace("-","");
EiInfo eiInfo = new EiInfo();
String serviceId = "S_BE_XP_17";
eiInfo.set(EiConstant.serviceId,serviceId);
Map map = new HashMap();
map.put("uuid","10da64857f0e47b7b88dc9fd5152ceab");
map.put("offset",0);
map.put("limit",1000);
//获取公司代码
String company_code = "%";
if(!StringUtils.isEmpty(UserSessionUtils.getCompanyCode().trim())){
company_code = UserSessionUtils.getCompanyCode();
}
//数据集入参
Map params =new HashMap();
params.put("company_code",company_code);
params.put("factorycode",factStr);
params.put("date",dateStr);
map.put("params",params);
List list =new ArrayList();
list.add(map);
eiInfo.set("queryInfo",list);
//服务接口调用
EiInfo outInfo = XServiceManager.call(eiInfo);
//调用微服务后的结果
Map result = (Map) outInfo.get("result");
Map result1 = (Map) result.get("10da64857f0e47b7b88dc9fd5152ceab");
List<Map> list1 = (List) result1.get("data");
JSONArray tempArr = new JSONArray();
String json = "appEname,date,unitCover";
List tempContentList = Arrays.asList(json.split(","));
tempArr.add(tempContentList);
JSONObject item = new JSONObject();
list1.forEach(obj -> {
// 处理obj
List datalist =new ArrayList();
datalist.add(obj.get("SERIES"));
datalist.add(obj.get("X"));
datalist.add(obj.get("VALUE"));
tempArr.add(datalist);
});
JSONArray ids = new JSONArray();
ids.add(idsStr);
item.put("ids", ids);
item.put("component", null);
item.put("data", tempArr);
List list2 =new ArrayList();
list2.add(item);
outInfo.set("result",list2);
return outInfo;
}
/**
* 生产项 8da92383157d4bf680ed08093590d847
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "生产管理驾驶舱1",operType = "查询",operDesc = "生产项")
public EiInfo querySCXInfo(EiInfo inInfo) {
String paramsStr = inInfo.getString(PARAMS_KEY_STR);
JSONArray jsonArray = (JSONArray) JSONArray.parse(paramsStr);
JSONObject jsonObject = (JSONObject) jsonArray.get(0);
JSONArray idsArr = (JSONArray) jsonObject.get("ids");
String idsStr = idsArr.getString(0);
JSONObject paramsObj = null;
if (jsonObject.get("params") instanceof String) {
paramsObj=JSON.parseObject((String) jsonObject.get("params"));
} else {
paramsObj= (JSONObject) jsonObject.get("params");
}
String factStr = paramsObj.getString("factorycode");
String dateStr = paramsObj.getString("date").replace("-","");
EiInfo eiInfo = new EiInfo();
String serviceId = "S_BE_XP_17";
eiInfo.set(EiConstant.serviceId,serviceId);
Map map = new HashMap();
map.put("uuid","8da92383157d4bf680ed08093590d847");
map.put("offset",0);
map.put("limit",1000);
//获取公司代码
String company_code = "%";
if(!StringUtils.isEmpty(UserSessionUtils.getCompanyCode().trim())){
company_code = UserSessionUtils.getCompanyCode();
}
//数据集入参
Map params =new HashMap();
params.put("company_code",company_code);
params.put("factorycode",factStr);
params.put("date",dateStr);
map.put("params",params);
List list =new ArrayList();
list.add(map);
eiInfo.set("queryInfo",list);
//服务接口调用
EiInfo outInfo = XServiceManager.call(eiInfo);
//调用微服务后的结果
Map result = (Map) outInfo.get("result");
Map result1 = (Map) result.get("8da92383157d4bf680ed08093590d847");
List<Map> list1 = (List) result1.get("data");
JSONArray tempArr = new JSONArray();
String json = "Z1,Z2,Z3,Z4";
List tempContentList = Arrays.asList(json.split(","));
tempArr.add(tempContentList);
JSONObject item = new JSONObject();
list1.forEach(obj -> {
// 处理obj
List datalist =new ArrayList();
datalist.add(obj.get("Z1"));
datalist.add(obj.get("Z2"));
datalist.add(obj.get("Z3"));
datalist.add(obj.get("Z4"));
tempArr.add(datalist);
});
JSONArray ids = new JSONArray();
ids.add(idsStr);
item.put("ids", ids);
item.put("component", null);
item.put("data", tempArr);
List list2 =new ArrayList();
list2.add(item);
outInfo.set("result",list2);
return outInfo;
}
/**
* 近5日综合产量 df9ae382415b4c8bab00058fe4bd99f7
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "生产管理驾驶舱1",operType = "查询",operDesc = "各组组拼加焊综合产量")
public EiInfo queryZHCLInfo(EiInfo inInfo) {
String paramsStr = inInfo.getString(PARAMS_KEY_STR);
JSONArray jsonArray = (JSONArray) JSONArray.parse(paramsStr);
JSONObject jsonObject = (JSONObject) jsonArray.get(0);
JSONArray idsArr = (JSONArray) jsonObject.get("ids");
String idsStr = idsArr.getString(0);
JSONObject paramsObj = null;
if (jsonObject.get("params") instanceof String) {
paramsObj=JSON.parseObject((String) jsonObject.get("params"));
} else {
paramsObj= (JSONObject) jsonObject.get("params");
}
String factStr = paramsObj.getString("factorycode");
String dateStr = paramsObj.getString("date").replace("-","");
EiInfo eiInfo = new EiInfo();
String serviceId = "S_BE_XP_17";
eiInfo.set(EiConstant.serviceId,serviceId);
Map map = new HashMap();
map.put("uuid","df9ae382415b4c8bab00058fe4bd99f7");
map.put("offset",0);
map.put("limit",1000);
//获取公司代码
String company_code = "%";
if(!StringUtils.isEmpty(UserSessionUtils.getCompanyCode().trim())){
company_code = UserSessionUtils.getCompanyCode();
}
//数据集入参
Map params =new HashMap();
params.put("company_code",company_code);
params.put("factorycode",factStr);
params.put("date",dateStr);
map.put("params",params);
List list =new ArrayList();
list.add(map);
eiInfo.set("queryInfo",list);
//服务接口调用
EiInfo outInfo = XServiceManager.call(eiInfo);
//调用微服务后的结果
Map result = (Map) outInfo.get("result");
Map result1 = (Map) result.get("df9ae382415b4c8bab00058fe4bd99f7");
List<Map> list1 = (List) result1.get("data");
JSONArray tempArr = new JSONArray();
String json = "appEname,date,unitCover";
List tempContentList = Arrays.asList(json.split(","));
tempArr.add(tempContentList);
JSONObject item = new JSONObject();
list1.forEach(obj -> {
// 处理obj
List datalist =new ArrayList();
datalist.add(obj.get("SERIES"));
datalist.add(obj.get("X"));
datalist.add(obj.get("VALUE"));
tempArr.add(datalist);
});
JSONArray ids = new JSONArray();
ids.add(idsStr);
item.put("ids", ids);
item.put("component", null);
item.put("data", tempArr);
List list2 =new ArrayList();
list2.add(item);
outInfo.set("result",list2);
return outInfo;
}
/**
* 主要项目进度 a02eed6a3e3f4dd39dbd0851e6a7572a
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "生产管理驾驶舱",operType = "查询",operDesc = "主要项目进度")
public EiInfo queryXMinfo(EiInfo inInfo) {
String paramsStr = inInfo.getString(PARAMS_KEY_STR);
JSONArray jsonArray = (JSONArray) JSONArray.parse(paramsStr);
JSONObject jsonObject = (JSONObject) jsonArray.get(0);
JSONArray idsArr = (JSONArray) jsonObject.get("ids");
String idsStr = idsArr.getString(0);
JSONObject paramsObj = null;
if (jsonObject.get("params") instanceof String) {
paramsObj=JSON.parseObject((String) jsonObject.get("params"));
} else {
paramsObj= (JSONObject) jsonObject.get("params");
}
String factStr = paramsObj.getString("factorycode");
String dateStr = paramsObj.getString("date").replace("-","");
EiInfo eiInfo = new EiInfo();
String serviceId = "S_BE_XP_17";
eiInfo.set(EiConstant.serviceId,serviceId);
Map map = new HashMap();
map.put("uuid","a02eed6a3e3f4dd39dbd0851e6a7572a");
map.put("offset",0);
map.put("limit",1000);
//获取公司代码
String company_code = "%";
if(!StringUtils.isEmpty(UserSessionUtils.getCompanyCode().trim())){
company_code = UserSessionUtils.getCompanyCode();
}
//数据集入参
Map params =new HashMap();
params.put("company_code",company_code);
params.put("factorycode",factStr);
params.put("date",dateStr);
map.put("params",params);
List list =new ArrayList();
list.add(map);
eiInfo.set("queryInfo",list);
//服务接口调用
EiInfo outInfo = XServiceManager.call(eiInfo);
//调用微服务后的结果
Map result = (Map) outInfo.get("result");
Map result1 = (Map) result.get("a02eed6a3e3f4dd39dbd0851e6a7572a");
List<Map> list1 = (List) result1.get("data");
JSONArray tempArr = new JSONArray();
String json = "项目名称,计划完成时间,计划产量,实际产量,进度";
List tempContentList = Arrays.asList(json.split(","));
tempArr.add(tempContentList);
JSONObject item = new JSONObject();
list1.forEach(obj -> {
// 处理obj
List datalist =new ArrayList();
datalist.add(obj.get("项目名称"));
datalist.add(obj.get("计划完成时间"));
datalist.add(obj.get("计划产量"));
datalist.add(obj.get("实际产量"));
datalist.add(obj.get("进度"));
tempArr.add(datalist);
});
JSONArray ids = new JSONArray();
ids.add(idsStr);
item.put("ids", ids);
item.put("component", null);
item.put("data", tempArr);
List list2 =new ArrayList();
list2.add(item);
outInfo.set("result",list2);
return outInfo;
}
/**
* 厂区 df9ae382415b4c8bab00058fe4bd99f7
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "生产管理驾驶舱1",operType = "查询",operDesc = "厂区")
public EiInfo queryCompanyInfo(EiInfo inInfo) {
String paramsStr = inInfo.getString(PARAMS_KEY_STR);
JSONArray jsonArray = (JSONArray) JSONArray.parse(paramsStr);
JSONObject jsonObject = (JSONObject) jsonArray.get(0);
JSONArray idsArr = (JSONArray) jsonObject.get("ids");
String idsStr = idsArr.getString(0);
EiInfo eiInfo = new EiInfo();
String serviceId = "S_BE_XP_17";
eiInfo.set(EiConstant.serviceId,serviceId);
Map map = new HashMap();
map.put("uuid","49badd3044f04d3e8b89b1d0b7d3ff0e");
map.put("offset",0);
map.put("limit",1000);
//获取公司代码
String company_code = "%";
if(!StringUtils.isEmpty(UserSessionUtils.getCompanyCode().trim())){
company_code = UserSessionUtils.getCompanyCode();
}
//数据集入参
Map params =new HashMap();
params.put("company_code",company_code);
map.put("params",params);
List list =new ArrayList();
list.add(map);
eiInfo.set("queryInfo",list);
//服务接口调用
EiInfo outInfo = XServiceManager.call(eiInfo);
//调用微服务后的结果
Map result = (Map) outInfo.get("result");
Map result1 = (Map) result.get("49badd3044f04d3e8b89b1d0b7d3ff0e");
List<Map> list1 = (List) result1.get("data");
JSONArray tempArr = new JSONArray();
String json = "appEname,date,unitCover";
List tempContentList = Arrays.asList(json.split(","));
tempArr.add(tempContentList);
JSONObject item = new JSONObject();
list1.forEach(obj -> {
// 处理obj
List datalist =new ArrayList();
datalist.add(obj.get("SERIES"));
datalist.add(obj.get("X"));
datalist.add(obj.get("VALUE"));
tempArr.add(datalist);
});
JSONArray ids = new JSONArray();
ids.add(idsStr);
item.put("ids", ids);
item.put("component", null);
item.put("data", tempArr);
List list2 =new ArrayList();
list2.add(item);
outInfo.set("result",list2);
return outInfo;
}
/**
* 微服务测试方法(柱形图、折线图、饼图)
* 微服务号:S_BE_DZ_04
*
* @return
*/
@OperationLogAnnotation(operModul = "生产管理驾驶舱1",operType = "查询",operDesc = "微服务测试方法(柱形图、折线图、饼图)")
public EiInfo queryMicroServiceBarData(EiInfo eiInfo) {
EiInfo returnInfo = new EiInfo();
String paramsStr = eiInfo.getString(PARAMS_KEY_STR);
if (StringUtils.isEmpty(paramsStr)) {
returnInfo.setStatus(BEDZConstants.STATUS_FAILURE);
returnInfo.setMsg("获取测试数据失败,原因为:参数不能为空!");
return returnInfo;
}
String[] jsonStrs = new String[]{
"appEname,date,unitCover&" +
"xdata-show,1月,50&dataworks-admin,1月,100&dataworks-market,1月,160&*" +
"xdata-show,2月,60&dataworks-admin,2月,150&dataworks-market,2月,80&*" +
"xdata-show,3月,80&dataworks-admin,3月,50&dataworks-market,3月,60&*" +
"xdata-show,4月,100&dataworks-admin,4月,70&dataworks-market,4月,100&*" +
"xdata-show,5月,30&dataworks-admin,5月,80&dataworks-market,5月,60&*" +
"xdata-show,6月,20&dataworks-admin,6月,30&dataworks-market,6月,50",
"appEname,date,unitCover&" +
"xdata-show,1月,90&dataworks-admin,1月,20&dataworks-market,1月,60&*" +
"xdata-show,2月,70&dataworks-admin,2月,50&dataworks-market,2月,70&*" +
"xdata-show,3月,60&dataworks-admin,3月,60&dataworks-market,3月,65&*" +
"xdata-show,4月,100&dataworks-admin,4月,70&dataworks-market,4月,90&*" +
"xdata-show,5月,20&dataworks-admin,5月,80&dataworks-market,5月,80&*" +
"xdata-show,6月,50&dataworks-admin,6月,90&dataworks-market,6月,70",
"appEname,date,unitCover&" +
"xdata-show,1月,80&dataworks-admin,1月,30&dataworks-market,1月,90&*" +
"xdata-show,2月,10&dataworks-admin,2月,100&dataworks-market,2月,10&*" +
"xdata-show,3月,180&dataworks-admin,3月,150&dataworks-market,3月,45&*" +
"xdata-show,4月,100&dataworks-admin,4月,170&dataworks-market,4月,40&*" +
"xdata-show,5月,66&dataworks-admin,5月,80&dataworks-market,5月,180&*" +
"xdata-show,6月,80&dataworks-admin,6月,90&dataworks-market,6月,40",
"appEname,date,unitCover&", ""
};
JSONArray jsonArr = JSONArray.parseArray(paramsStr);
List items = new ArrayList<>();
for (int index = 0; index < jsonArr.size(); index++) {
JSONObject jsonObject = jsonArr.getJSONObject(index);
JSONObject testDataObj = jsonObject.getJSONObject("params");
JSONObject item = new JSONObject();
if (testDataObj.size() == 0 || !testDataObj.containsKey("month")) {
item.put("data", new JSONArray());
item.put("ids", jsonObject.get("ids"));
items.add(item);
continue;
}
String monthStr = testDataObj.getString("month");
if (StringUtils.isNotEmpty(monthStr)) {
int month = Integer.parseInt(monthStr);
Random ran = new Random();
int x = ran.nextInt(4);
String contentStr = jsonStrs[x];
String[] monthDataStr = contentStr.split("\\*");
if (month > monthDataStr.length) {
month = monthDataStr.length;
}
StringBuilder resultStr = new StringBuilder();
for (int i = 0; i < month; i++) {
resultStr.append(monthDataStr[i]);
}
JSONArray tempArr = new JSONArray();
String[] contentStrArray = resultStr.toString().split("&");
for (int i = 0; i < contentStrArray.length; i++) {
String tempContentStr = contentStrArray[i];
List tempContentList = Arrays.asList(tempContentStr.split(","));
tempArr.add(tempContentList);
}
item.put("data", tempArr);
} else {
String json = "appEname,date,unitCover";
JSONArray tempArr = new JSONArray();
List tempContentList = Arrays.asList(json.split(","));
tempArr.add(tempContentList);
item.put("data", tempArr);
}
item.put("ids", jsonObject.get("ids"));
item.put("component", jsonObject.get("component"));
items.add(item);
}
returnInfo.set("result", items);
returnInfo.setStatus(BEDZConstants.STATUS_SUCCESS);
returnInfo.setMsg("获取测试数据成功!");
return returnInfo;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment