Commit 012ab4fd by liuyang

调整同步设备日志接口

parent 0497ddfd
......@@ -3,9 +3,12 @@ package com.baosight.hggp.core.extapp.decheng.api;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baosight.hggp.hg.sb.domain.HGSB010;
import com.baosight.hggp.util.HttpUtils;
import com.baosight.hggp.util.MapUtils;
import com.baosight.hggp.util.StringUtils;
import com.baosight.hggp.util.contants.ACConstants;
import com.baosight.iplat4j.core.ei.EiBlock;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException;
......@@ -32,10 +35,12 @@ public class SbOpenApi {
*/
public static JSONArray list(EiInfo eiInfo) throws IOException, InstantiationException,
IllegalAccessException {
EiInfo eiInfo1 = new EiInfo();
eiInfo1.set(HGSB010.FIELD_CREATED_TIME,eiInfo.getCellStr(EiConstant.queryBlock, ACConstants.ROW_CODE_0, HGSB010.FIELD_CREATED_TIME));
Map headerMap = new HashMap();
headerMap.put("x-token", SbTokenApi.getToken());
String url = PlatApplicationContext.getProperty("hpjx.url");
String result = HttpUtils.post(url+"/S_HP_SB_01", headerMap, JSON.toJSONString(eiInfo),
String result = HttpUtils.post(url+"/S_HP_SB_01", headerMap, JSON.toJSONString(eiInfo1),
HttpUtils.JSON_MEDIA_TYPE);
if (StringUtils.isBlank(result)) {
throw new PlatException("【鸿鹏】获取设备日志列表失败");
......
......@@ -14,9 +14,11 @@ import com.baosight.hggp.util.DateUtils;
import com.baosight.hggp.util.EiInfoUtils;
import com.baosight.hggp.util.LogUtils;
import com.baosight.hggp.util.MapUtils;
import com.baosight.hggp.util.contants.ACConstants;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import org.apache.commons.collections4.CollectionUtils;
import java.io.IOException;
import java.util.*;
......@@ -176,10 +178,20 @@ public class ServiceHGSB010 extends ServiceEPBase {
public EiInfo add(EiInfo inInfo){
try {
Map paramMap = EiInfoUtils.getFirstRow(inInfo);
Map<String, String> paramMap = EiInfoUtils.getFirstRow(inInfo);
String accountCode = MapUtils.getString(paramMap, HGPZ009.FIELD_ACCOUNT_CODE);
List<Map> mapList = dao.query("HGSB010.queryMax", paramMap);
if (CollectionUtils.isEmpty(mapList)){
String year = DateUtils.shortDate().substring(0, 4);
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0,HGSB010.FIELD_CREATED_TIME, year+"0101000000");
} else {
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0,HGSB010.FIELD_CREATED_TIME, mapList.get(0).get(HGSB010.FIELD_CREATED_TIME));
}
JSONArray jsonArray = SbOpenApi.list(inInfo);
User user = HGXSTools.XsUser.getByLogin(paramMap.get(User.FIELD_LOGIN_NAME).toString());
User user = null;
if (paramMap.containsKey(User.FIELD_LOGIN_NAME)){
user = HGXSTools.XsUser.getByLogin(paramMap.get(User.FIELD_LOGIN_NAME));
}
List<Map> list = jsonArray.stream().map(o -> (Map) o).collect(Collectors.toList());
for (Map map:list) {
HGSB010 hgsb010 = new HGSB010();
......@@ -187,6 +199,7 @@ public class ServiceHGSB010 extends ServiceEPBase {
if (user!=null){
hgsb010.setCompanyCode(user.getAccountCode());
}else {
accountCode = accountCode.length() == 0?"Q24072514":accountCode;
hgsb010.setCompanyCode(accountCode);
}
dao.insert(HGSB010.INSERT, hgsb010);
......
......@@ -482,4 +482,11 @@
) a
order by a.DEVICE_CODE
</select>
<select id="queryMax" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
SELECT
MAX(CREATED_TIME) as "createdTime"
FROM ${hggpSchema}.HGSB010 WHERE 1=1 AND DELETE_FLAG = 0
<include refid="condition" />
</select>
</sqlMap>
\ No newline at end of file
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