|
@@ -198,148 +198,6 @@ public class TUInterfaceinfoServiceImpl implements ITUInterfaceinfoService
|
|
|
/**
|
|
|
* 刷新数据
|
|
|
*/
|
|
|
- @Override
|
|
|
- public void refreshData(){
|
|
|
- //(164-57) t_guiji_gas_zenner_gas_purchase_center_infor - 归集-市燃气(真兰收费系统)-中心计费购气信息 - 467184 ms total:[12746163]
|
|
|
- //(123-29) t_guiji_gas_zenner_meter_reading_infor - 归集-市燃气(真兰收费系统)-抄表信息 - 324043 ms total:[12703733]
|
|
|
- //t_guiji_naturalresources_bdcdjxx - 归集-市自然资源(不动产)-个人基本信息 - updating database... id = 672238a3-3687-433c-888e-5db0c81eb8a8
|
|
|
- TUInterfaceinfo param = new TUInterfaceinfo();
|
|
|
- param.setNeedRefresh("1");
|
|
|
- List<TUInterfaceinfo> tuInterfaceinfoList = tUInterfaceinfoMapper.selectTUInterfaceinfoList(param);
|
|
|
- for (int i = 0; i < tuInterfaceinfoList.size(); i++) {
|
|
|
- TUInterfaceinfo tuInterfaceinfo = tuInterfaceinfoList.get(i);
|
|
|
- String tableName = tuInterfaceinfo.getTableName();
|
|
|
- if(tableName == null || tableName.equals("")){
|
|
|
- System.out.println("(" + tuInterfaceinfoList.size() + "-" + (i + 1) + ") " + tuInterfaceinfo.getTableName() + " - " + tuInterfaceinfo.getInterfaceName() + " - " + 0 + " ms");
|
|
|
- continue;
|
|
|
- }
|
|
|
- System.out.println(tuInterfaceinfo.getTableName() + " - " + tuInterfaceinfo.getInterfaceName() + " - " + "updating database... id = " + tuInterfaceinfo.getId());
|
|
|
- //select count(id) callsuccnum from ${tableName}
|
|
|
- Date dateBegin = new Date();
|
|
|
- TUInterfaceinfo result = tUInterfaceinfoMapper.selectCountByTableName(tuInterfaceinfo);
|
|
|
- Long interval = new Date().getTime() - dateBegin.getTime();//接口查询总数所用时间
|
|
|
- System.out.println("(" + tuInterfaceinfoList.size() + "-" + (i + 1) + ") " + tuInterfaceinfo.getTableName() + " - " + tuInterfaceinfo.getInterfaceName() + " - " + interval + " ms total:[" + result.getCallsuccnum() + "]");
|
|
|
- tuInterfaceinfo.setCallsuccnum(result.getCallsuccnum());
|
|
|
- tuInterfaceinfo.setRefreshTime(new Date());
|
|
|
- tuInterfaceinfo.setNeedRefresh("2");
|
|
|
- tUInterfaceinfoMapper.updateInterfaceCallsuccnum(tuInterfaceinfo);
|
|
|
- //update t_u_interfaceinfo set callsuccnum = #{callsuccnum} where id = #{id}
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 刷新归集数据分析
|
|
|
- */
|
|
|
- @Override
|
|
|
- public void imputationData(){
|
|
|
- String year = "2022";
|
|
|
- TUInterfaceinfo param = new TUInterfaceinfo();
|
|
|
-// param.setNeedRefresh("1");
|
|
|
- //(164-57) t_guiji_gas_zenner_gas_purchase_center_infor - 归集-市燃气(真兰收费系统)-中心计费购气信息 - 237962 ms
|
|
|
- //(164-70) t_guiji_gas_zenner_meter_reading_infor - 归集-市燃气(真兰收费系统)-抄表信息 - 352968 ms
|
|
|
- List<TUInterfaceinfo> tuInterfaceinfoList = tUInterfaceinfoMapper.selectTUInterfaceinfoList(param);
|
|
|
- for (int i = 0; i < tuInterfaceinfoList.size(); i++) {
|
|
|
- TUInterfaceinfo tuInterfaceinfo = tuInterfaceinfoList.get(i);
|
|
|
- String tableName = tuInterfaceinfo.getTableName();
|
|
|
- if (tableName == null || tableName.equals("") || tableName.equals("t_u_interfaceinfo_emptytable")) {
|
|
|
- System.out.println("(" + tuInterfaceinfoList.size() + "-" + (i + 1) + ") " + tuInterfaceinfo.getTableName() + " - " + tuInterfaceinfo.getInterfaceName() + " - " + 0 + " ms");
|
|
|
- continue;
|
|
|
- }
|
|
|
- ImputationData imputationDataParam = new ImputationData();
|
|
|
- imputationDataParam.setYear(year);
|
|
|
- imputationDataParam.setTableName(tableName);
|
|
|
- boolean isExist = !(imputationDataMapper.selectImputationInterface(imputationDataParam).size() == 0);
|
|
|
- if(isExist){
|
|
|
- continue;
|
|
|
- }
|
|
|
- Map map = new HashMap();
|
|
|
- map.put("year", year);
|
|
|
- map.put("tableName", tableName);
|
|
|
- System.out.println(tuInterfaceinfo.getTableName() + " - " + tuInterfaceinfo.getInterfaceName() + " - " + "updating database... id = " + tuInterfaceinfo.getId());
|
|
|
- Date dateBegin = new Date();
|
|
|
- ImputationData imputationData = tUInterfaceinfoMapper.imputationData(map);
|
|
|
- Long interval = new Date().getTime() - dateBegin.getTime();//接口查询总数所用时间
|
|
|
- ImputationData imputationDataInsert = new ImputationData();
|
|
|
- imputationDataInsert.setYear(year);
|
|
|
- imputationDataInsert.setTableName(tableName);
|
|
|
- imputationDataInsert.setInterfaceName(tuInterfaceinfo.getInterfaceName());
|
|
|
- imputationDataInsert.setJan(imputationData.getJan());
|
|
|
- imputationDataInsert.setFeb(imputationData.getFeb());
|
|
|
- imputationDataInsert.setMar(imputationData.getMar());
|
|
|
- imputationDataInsert.setApr(imputationData.getApr());
|
|
|
- imputationDataInsert.setMay(imputationData.getMay());
|
|
|
- imputationDataInsert.setJun(imputationData.getJun());
|
|
|
- imputationDataInsert.setJul(imputationData.getJul());
|
|
|
- imputationDataInsert.setAug(imputationData.getAug());
|
|
|
- imputationDataInsert.setSep(imputationData.getSep());
|
|
|
- imputationDataInsert.setOct(imputationData.getOct());
|
|
|
- imputationDataInsert.setNov(imputationData.getNov());
|
|
|
- imputationDataInsert.setDecb(imputationData.getDecb());
|
|
|
- imputationDataMapper.insertImputationInterface(imputationDataInsert);
|
|
|
- System.out.println("(" + tuInterfaceinfoList.size() + "-" + (i + 1) + ") " + tuInterfaceinfo.getTableName() + " - " + tuInterfaceinfo.getInterfaceName() + " - " + interval + " ms");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 按月刷新归集数据分析
|
|
|
- */
|
|
|
- @Override
|
|
|
- public void imputationDataByMonth(){
|
|
|
- String year = new SimpleDateFormat("yyyy").format(new Date());//String year = "2022";
|
|
|
- String month = new SimpleDateFormat("M").format(new Date());
|
|
|
- TUInterfaceinfo param = new TUInterfaceinfo();
|
|
|
- param.setShareType("share_type_2");//市归集
|
|
|
-// param.setNeedRefresh("1");
|
|
|
- //(164-57) t_guiji_gas_zenner_gas_purchase_center_infor - 归集-市燃气(真兰收费系统)-中心计费购气信息 - 237962 ms
|
|
|
- //(164-70) t_guiji_gas_zenner_meter_reading_infor - 归集-市燃气(真兰收费系统)-抄表信息 - 352968 ms
|
|
|
- //t_guiji_naturalresources_qlrjbxx - 归集-市自然资源(不动产)-权利人基本信息 - updating database... id = 1de6752d-19c2-4010-9b61-9450a9d718b6
|
|
|
- List<TUInterfaceinfo> tuInterfaceinfoList = tUInterfaceinfoMapper.selectTUInterfaceinfoList(param);
|
|
|
- for (int i = 0; i < tuInterfaceinfoList.size(); i++) {
|
|
|
- TUInterfaceinfo tuInterfaceinfo = tuInterfaceinfoList.get(i);
|
|
|
- String tableName = tuInterfaceinfo.getTableName();
|
|
|
- if (tableName == null || tableName.equals("") || tableName.equals("t_u_interfaceinfo_emptytable")) {
|
|
|
- System.out.println("(" + tuInterfaceinfoList.size() + "-" + (i + 1) + ") " + tuInterfaceinfo.getTableName() + " - " + tuInterfaceinfo.getInterfaceName() + " - " + 0 + " ms");
|
|
|
- continue;
|
|
|
- }
|
|
|
- ImputationData imputationDataParam = new ImputationData();
|
|
|
- imputationDataParam.setYear(year);
|
|
|
- imputationDataParam.setTableName(tableName);
|
|
|
- boolean isExist = !(imputationDataMapper.selectImputationInterface(imputationDataParam).size() == 0);
|
|
|
- if(!isExist){
|
|
|
- continue;
|
|
|
- }
|
|
|
- Map map = new HashMap();
|
|
|
- map.put("year", year);
|
|
|
- map.put("month", month);
|
|
|
- map.put("tableName", tableName);
|
|
|
- System.out.println(tuInterfaceinfo.getTableName() + " - " + tuInterfaceinfo.getInterfaceName() + " - " + "updating database... id = " + tuInterfaceinfo.getId());
|
|
|
- Map column = new HashMap();
|
|
|
- column.put("tableSchema", tableName.contains("\\.") ? tableName.split("\\.")[0] : "thsjzt");//thgjj / thsjzt
|
|
|
- column.put("tableName", tableName.contains("\\.") ? tableName.split("\\.")[1] : tableName);//thgjj.tgjj_gtjkrxx / t_guiji_gas_zenner_meter_reading_infor
|
|
|
- column.put("columnName", "create_time");//create_time / LAST_UPDATE_TIME
|
|
|
- System.out.println(column.get("tableSchema"));
|
|
|
- System.out.println(column.get("tableName"));
|
|
|
- System.out.println(column.get("columnName"));
|
|
|
- List<Object> objectList = tUInterfaceinfoMapper.checkColumnExists(column);
|
|
|
- System.out.println(objectList.size() + "=object");
|
|
|
- Date dateBegin = new Date();
|
|
|
- ImputationData imputationData;
|
|
|
- if(objectList.size() != 0){
|
|
|
- imputationData = tUInterfaceinfoMapper.imputationDataByMonth(map);
|
|
|
- }else {
|
|
|
- imputationData = tUInterfaceinfoMapper.imputationDataByMonthLastUpdateTime(map);
|
|
|
- }
|
|
|
- Long interval = new Date().getTime() - dateBegin.getTime();//接口查询总数所用时间
|
|
|
- ImputationData imputationDataInsert = new ImputationData();
|
|
|
- imputationDataInsert.setYear(year);
|
|
|
- imputationDataInsert.setMonth(month);
|
|
|
- imputationDataInsert.setTableName(tableName);
|
|
|
-// imputationDataInsert.setInterfaceName(tuInterfaceinfo.getInterfaceName());//接口名称可能会变
|
|
|
- imputationDataInsert.setCount(imputationData.getCount());
|
|
|
- imputationDataMapper.updateImputationInterfaceByYearMonthTableName(imputationDataInsert);
|
|
|
- System.out.println("(" + tuInterfaceinfoList.size() + "-" + (i + 1) + ") " + tuInterfaceinfo.getTableName() + " - " + tuInterfaceinfo.getInterfaceName() + " - " + interval + " ms");
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* 查询接口数量
|
|
@@ -458,52 +316,7 @@ public class TUInterfaceinfoServiceImpl implements ITUInterfaceinfoService
|
|
|
|
|
|
@Override
|
|
|
public Long getGuijiCountByDeptId(String deptId){
|
|
|
- new Thread() {
|
|
|
- public void run() {
|
|
|
- try{
|
|
|
- TUInterfaceinfo tuInterfaceinfo = new TUInterfaceinfo();
|
|
|
- tuInterfaceinfo.setDeptId(deptId);
|
|
|
- tuInterfaceinfo.setStatus("0");//状态(0可用,2禁用)
|
|
|
- tuInterfaceinfo.setShareType("share_type_2");//数据来源 只统计市归集类型接口对应表中数据条数综合
|
|
|
- /*
|
|
|
- t_guiji_gas_zenner_gas_purchase_center_infor 真兰中心计费信息
|
|
|
- */
|
|
|
- List<TUInterfaceinfo> tuInterfaceinfoList = tUInterfaceinfoMapper.selectTUInterfaceinfoDataNumList(tuInterfaceinfo);
|
|
|
- for (int i = 0; i < tuInterfaceinfoList.size(); i ++) {
|
|
|
- TUInterfaceinfo interfaceinfo = tuInterfaceinfoList.get(i);
|
|
|
- boolean uninitialized = interfaceinfo.getUpdateTime() == null;//未初始化
|
|
|
- boolean oldData = interfaceinfo.getUpdateTime() != null && new Date().getTime() - interfaceinfo.getUpdateTime().getTime() > 10 * 60 * 1000;//最多10分钟刷新一次最新数据
|
|
|
- boolean isValid = interfaceinfo.getStatus().equals("0");//有效数据
|
|
|
- if(uninitialized || (oldData && isValid)){
|
|
|
- interfaceinfo.setUpdateTime(new Date());
|
|
|
- Date dateBegin = new Date();
|
|
|
- tUInterfaceinfoMapper.updateTUInterfaceinfoDataNum(interfaceinfo);//更新更新时间 防止多次操作
|
|
|
- System.out.println("(" + tuInterfaceinfoList.size() + "-" + (i + 1) + ") " + interfaceinfo.getInterfaceName() + "更新更新时间 防止多次操作");
|
|
|
- tUInterfaceinfoMapper.updateDataNum(interfaceinfo);//更新更新时间为最新的以及数据条数
|
|
|
- Long interval = new Date().getTime() - dateBegin.getTime();//接口查询总数所用时间
|
|
|
- System.out.println("(" + tuInterfaceinfoList.size() + "-" + (i + 1) + ") " + interfaceinfo.getTableName() + " - " + interfaceinfo.getInterfaceName() + " - " + interval + " ms");
|
|
|
- // update t_u_interfaceinfo_datanum set datanum = 0, update_time = null 重置数据总数重新查询 使用updateTime控制min分钟内只能查询一次
|
|
|
- // select count(*) from t_guiji_gas_zenner_gas_purchase_center_infor - 归集-真兰收费系统-中心计费购气信息 12452820
|
|
|
- // (17-4) t_guiji_gas_zenner_gas_purchase_center_infor - 归集-真兰收费系统-中心计费购气信息 - 32424 ms
|
|
|
- // (17-5) t_guiji_gas_zenner_meter_reading_infor - 归集-真兰收费系统-抄表信息 - 222659 ms
|
|
|
- /*
|
|
|
- update t_u_interfaceinfo_datanum set datanum = 0, update_time = null;
|
|
|
- update t_u_interfaceinfo_datanum set status = 2 where table_name = 't_guiji_gas_zenner_gas_purchase_center_infor'; -- 12489514 17ms
|
|
|
- update t_u_interfaceinfo_datanum set status = 2 where table_name = 't_guiji_gas_zenner_meter_reading_infor'; -- 12389252 23ms
|
|
|
- */
|
|
|
- // 燃气 25010409 26114283
|
|
|
- }
|
|
|
- }
|
|
|
- System.out.println((tuInterfaceinfoList.size()>0?tuInterfaceinfoList.get(0).getDeptName():deptId)+": 查询接口数据结束,共" + tuInterfaceinfoList.size() + "个接口");
|
|
|
- }catch (Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- }.start();
|
|
|
- Map<String, Object> param = new HashMap<>();
|
|
|
- param.put("deptId", deptId);
|
|
|
- tUInterfaceinfoMapper.getGuijiCountByDeptId(param);
|
|
|
- return Long.valueOf(String.valueOf(param.get("count"))).longValue();
|
|
|
+ return tUInterfaceinfoMapper.getGuijiCountByDeptId(deptId);
|
|
|
}
|
|
|
|
|
|
/**
|