Commit bd5a1722 authored by xulihui's avatar xulihui

对接液化气接口

parent 8d824bcf
......@@ -180,7 +180,8 @@ public class TWorkOrderController extends BaseController
}else {
enterpriseId= String.valueOf(user.getDeptId());
}
return AjaxResult.success(tWorkOrderService.selectWorkOrderNum(enterpriseId));
Map<String, Object> stringObjectMap = tWorkOrderService.selectWorkOrderNum(enterpriseId);
return AjaxResult.success(stringObjectMap);
}
}
......@@ -2,36 +2,58 @@ package com.zehong.web.controller.task;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.zehong.common.core.domain.entity.SysUser;
import com.zehong.common.core.page.PageDomain;
import com.zehong.common.core.page.TableSupport;
import com.zehong.common.core.redis.RedisCache;
import com.zehong.common.exception.CustomException;
import com.zehong.common.utils.DateUtils;
import com.zehong.common.utils.GovernmentDataCopyUtil;
import com.zehong.common.utils.StringUtils;
import com.zehong.common.utils.http.HttpClientUtils;
import com.zehong.common.utils.sql.SqlUtil;
import com.zehong.system.domain.TLpgAirChargeFiles;
import com.zehong.system.domain.TLpgGasBottleFiles;
import com.zehong.system.domain.TProAppInforBrowse;
import com.zehong.system.domain.TUserLocation;
import com.zehong.system.domain.vo.ProAppInforBrowseVo;
import com.zehong.system.service.ISysUserService;
import com.zehong.system.service.ITLpgAirChargeFilesService;
import com.zehong.system.service.ITLpgGasBottleFilesService;
import com.zehong.system.service.ITUserLocationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.TimeUnit;
@Component("timeTasks")
public class TimeTasksController {
@Value("${wjyhq.apiUrl}")
private String apiUrl;
@Value("${wjyhq.authCode}")
private String authCode;
@Value("${wjyhq.accessKey}")
private String accessKey;
@Value("${wjyhq.secretKey}")
private String secretKey;
@Autowired
private RedisCache redisCache;
@Autowired
ITUserLocationService tUserLocationService;
@Autowired
private ITLpgGasBottleFilesService tLpgGasBottleFilesService;
@Autowired
private ITLpgAirChargeFilesService tLpgAirChargeFilesService;
/**
* 获取token
* @return token
......@@ -52,13 +74,16 @@ public class TimeTasksController {
*/
public String getNewToken()throws Exception{
JSONObject param = new JSONObject();
param.put("authcode","LPG-HSRQ-101807423011");
param.put("accessKey","3D4B933297C6CA68E2FD9CEB3697FC78");
param.put("secretKey","pu8s3Z8TsPi09fCFpOFunWqbi9TDtXTq");
param.put("authCode", authCode);
param.put("accessKey",accessKey);
param.put("secretKey",secretKey);
String result = HttpClientUtils.doPost(apiUrl+"/SyncDataApi/CreateToken",param.toJSONString(),null);
if(StringUtils.isEmpty(result)) throw new CustomException("获取液化气token接口失败!");
JSONObject resultJson = JSONObject.parseObject(result);
redisCache.setCacheObject("yhqToken", resultJson.getJSONObject("result").getString("token"),30, TimeUnit.DAYS);
redisCache.setCacheObject("yhqToken", resultJson.getJSONObject("result").getString("token"));
String dateString = resultJson.getJSONObject("result").getString("expdate");
Date date = DateUtils.dateTime("yyyy-MM-dd HH:mm:ss", dateString);
redisCache.setCacheObjectExpireAt("yhqToken", date);
return resultJson.getJSONObject("result").getString("token");
}
......@@ -68,26 +93,164 @@ public class TimeTasksController {
* @throws Exception
*/
public void getArchivesList()throws Exception{
//String token = getToken();
String token = getToken();
JSONObject param = new JSONObject();
param.put("maxReturnNum","100");
param.put("lastUpTime","2000-03-12 00:00:00");
param.put("maxReturnNum",100);
PageHelper.startPage(1, 1, "f_gas_bottle_files_id desc");
List<TLpgGasBottleFiles> selectUpTime = tLpgGasBottleFilesService.selectTLpgGasBottleFilesList(new TLpgGasBottleFiles());
String lastRowVersion = "0";
if(selectUpTime!=null && selectUpTime.size()>0){
lastRowVersion = selectUpTime.get(0).getfRowVersion();
}
param.put("lastUpTime","");
param.put("state",0);
param.put("lastRowVersion",lastRowVersion);
Map<String,Object> head = new HashMap<>();
head.put("authorization","token");
head.put("authorization","Bearer "+token);
String result = HttpClientUtils.doPost(apiUrl+"/SyncDataApi/ArchivesList",param.toJSONString(),head);
if(StringUtils.isEmpty(result)) throw new CustomException("获取钢瓶档案接口失败!");
JSONObject json = JSONObject.parseObject(result);
//结果入库
if(null != json && "0".equals(json.getString("resultCode")) && null != json.getJSONArray("data")){
JSONArray data = json.getJSONArray("data");
List<TProAppInforBrowse> proAppInforBrowseList = new ArrayList<>();
if(null != json && "1".equals(json.getString("code")) && null != json.getJSONArray("result")){
JSONArray data = json.getJSONArray("result");
//List<TLpgGasBottleFiles> lpgGasBottleFilesList = new ArrayList<>();
for(int i = 0; i < data.size(); i++){
ProAppInforBrowseVo proAppInforBrowseVo = JSONObject.toJavaObject(data.getJSONObject(i), ProAppInforBrowseVo.class);
TProAppInforBrowse tProAppInforBrowse = new TProAppInforBrowse();
GovernmentDataCopyUtil.copyToLocalData(proAppInforBrowseVo,tProAppInforBrowse);
proAppInforBrowseList.add(tProAppInforBrowse);
JSONObject jsonObject = data.getJSONObject(i);
TLpgGasBottleFiles tLpgGasBottleFiles = new TLpgGasBottleFiles();
tLpgGasBottleFiles.setfRegCode(jsonObject.getString("regCode"));
tLpgGasBottleFiles.setfEquNo(jsonObject.getString("equNo"));
tLpgGasBottleFiles.setfEquType(jsonObject.getString("equType"));
tLpgGasBottleFiles.setfMedium(jsonObject.getString("medium"));
tLpgGasBottleFiles.setfMakeDate(jsonObject.getDate("makeDate"));
tLpgGasBottleFiles.setfMakeInfo(jsonObject.getString("makeInfo"));
tLpgGasBottleFiles.setfSelfId(jsonObject.getString("selfId"));
String pressure = jsonObject.getString("pressure");
if (pressure != null && !pressure.isEmpty()) {
tLpgGasBottleFiles.setfPressure(new BigDecimal(pressure));
} else {
tLpgGasBottleFiles.setfPressure(new BigDecimal(0));
}
String volume = jsonObject.getString("volume");
if (volume != null && !volume.isEmpty()) {
tLpgGasBottleFiles.setfVolume(new BigDecimal(volume));
} else {
tLpgGasBottleFiles.setfVolume(new BigDecimal(0));
}
tLpgGasBottleFiles.setfAppId(jsonObject.getString("appId"));
tLpgGasBottleFiles.setfQRcode(jsonObject.getString("qRcode"));
tLpgGasBottleFiles.setfBuildUser(jsonObject.getString("buildUser"));
tLpgGasBottleFiles.setfAddTime(jsonObject.getDate("addtime"));
tLpgGasBottleFiles.setfOptName(jsonObject.getString("optName"));
tLpgGasBottleFiles.setfUpTime(jsonObject.getDate("uptime"));
tLpgGasBottleFiles.setfState(jsonObject.getString("state"));
tLpgGasBottleFiles.setfUpOptName(jsonObject.getString("upOptName"));
tLpgGasBottleFiles.setfPChkDate(jsonObject.getDate("pChkDate"));
tLpgGasBottleFiles.setfNChkDate(jsonObject.getDate("nChkDate"));
tLpgGasBottleFiles.setfProductDate(jsonObject.getDate("productDate"));
tLpgGasBottleFiles.setfDiscardDate(jsonObject.getDate("discardDate"));
tLpgGasBottleFiles.setfSafeJudgeDate(jsonObject.getDate("safeJudgeDate"));
String gpressure = jsonObject.getString("gpressure");
if (gpressure != null && !gpressure.isEmpty()) {
tLpgGasBottleFiles.setfGPressure(new BigDecimal(gpressure));
} else {
tLpgGasBottleFiles.setfGPressure(new BigDecimal(0));
}
String wpressure = jsonObject.getString("wpressure");
if (wpressure != null && !wpressure.isEmpty()) {
tLpgGasBottleFiles.setfWPressure(new BigDecimal(wpressure));
} else {
tLpgGasBottleFiles.setfWPressure(new BigDecimal(0));
}
String selfWeight = jsonObject.getString("selfWeight");
if (selfWeight != null && !selfWeight.isEmpty()) {
tLpgGasBottleFiles.setfSelfWeight(new BigDecimal(selfWeight));
} else {
tLpgGasBottleFiles.setfSelfWeight(new BigDecimal(0));
}
String thickness = jsonObject.getString("thickness");
if (thickness != null && !thickness.isEmpty()) {
tLpgGasBottleFiles.setfThickness(new BigDecimal(thickness));
} else {
tLpgGasBottleFiles.setfThickness(new BigDecimal(0));
}
tLpgGasBottleFiles.setfPermitNo(jsonObject.getString("permitNo"));
tLpgGasBottleFiles.setfValveName(jsonObject.getString("valveTypeName"));
tLpgGasBottleFiles.setfPayImage(jsonObject.getString("payImage"));
tLpgGasBottleFiles.setfBatchImage(jsonObject.getString("batchImage"));
tLpgGasBottleFiles.setfDeviceImage(jsonObject.getString("deviceImage"));
tLpgGasBottleFiles.setfCheckImage(jsonObject.getString("checkImage"));
tLpgGasBottleFiles.setfEquNoImage(jsonObject.getString("equNoImage"));
tLpgGasBottleFiles.setfSelfIdImage(jsonObject.getString("selfIdImage"));
tLpgGasBottleFiles.setfBotImage(jsonObject.getString("botImage"));
tLpgGasBottleFiles.setfBotSpecName(jsonObject.getString("botSpecName"));
tLpgGasBottleFiles.setfBottleType(jsonObject.getString("bottleType"));
String inspectedTimes = jsonObject.getString("inspectedTimes");
if (inspectedTimes != null && !inspectedTimes.isEmpty()) {
tLpgGasBottleFiles.setfInspectedTimes(Long.valueOf(inspectedTimes));
} else {
tLpgGasBottleFiles.setfInspectedTimes(0L);
}
tLpgGasBottleFiles.setfIsSpecialized(jsonObject.getString("isSpecialized"));
tLpgGasBottleFiles.setfValveManuFacturer(jsonObject.getString("valveManufacturer"));
tLpgGasBottleFiles.setfInspectionLabel(jsonObject.getString("inspectionLabel"));
tLpgGasBottleFiles.setfThirdPartyLabel(jsonObject.getString("thirdPartyLabel"));
tLpgGasBottleFiles.setfHoleCode(jsonObject.getString("holeCode"));
tLpgGasBottleFiles.setfBottleStorageType(jsonObject.getString("bottleStorageType"));
tLpgGasBottleFiles.setfRowVersion(jsonObject.getString("rowVersion"));
tLpgGasBottleFilesService.insertTLpgGasBottleFiles(tLpgGasBottleFiles);
}
if(data.size()==100){
this.getArchivesList();
}
}
}
/**
* 获取充装记录
* @return token
* @throws Exception
*/
public void getFillingData()throws Exception{
String token = getToken();
JSONObject param = new JSONObject();
//Integer pageIndex = 1;
//Integer startNum = 0;
Integer tLpgAirChargeFilesTotal = tLpgAirChargeFilesService.selectTLpgAirChargeFilesTotal();
Integer pageIndex = tLpgAirChargeFilesTotal / 100 + 1;
Integer startNum = tLpgAirChargeFilesTotal%100;
param.put("pageIndex",pageIndex);
param.put("pageSize",100);
Map<String,Object> head = new HashMap<>();
head.put("authorization","Bearer "+token);
String result = HttpClientUtils.doPost(apiUrl+"/SyncDataApi/FillingData",param.toJSONString(),head);
if(StringUtils.isEmpty(result)) throw new CustomException("获取充装记录接口失败!");
JSONObject json = JSONObject.parseObject(result);
//结果入库
if(null != json && "1".equals(json.getString("code")) && null != json.getJSONArray("result")){
JSONArray data = json.getJSONArray("result");
for(int i = startNum; i < data.size(); i++){
JSONObject jsonObject = data.getJSONObject(i);
TLpgAirChargeFiles tLpgAirChargeFile = new TLpgAirChargeFiles();
tLpgAirChargeFile.setfGzId(jsonObject.getLong("gzId"));
tLpgAirChargeFile.setfStationName(jsonObject.getString("stationName"));
tLpgAirChargeFile.setfBarCode(jsonObject.getString("barCode"));
tLpgAirChargeFile.setfVaseCode(jsonObject.getString("vaseCode"));
tLpgAirChargeFile.setfScaleNum(jsonObject.getString("scaleNum"));
tLpgAirChargeFile.setfFillStatrTime(jsonObject.getString("fillStatrTime"));
tLpgAirChargeFile.setfFillEndTime(jsonObject.getString("fillEndTime"));
tLpgAirChargeFile.setfSetWeight(jsonObject.getString("setWeight"));
tLpgAirChargeFile.setfWtNet(jsonObject.getString("wtNet"));
tLpgAirChargeFile.setfSetBottleWeight(jsonObject.getString("setBottleWeight"));
tLpgAirChargeFile.setfBottleWeight(jsonObject.getString("bottleWeight"));
tLpgAirChargeFile.setfWtGross(jsonObject.getString("wtGross"));
tLpgAirChargeFile.setfOprateName(jsonObject.getString("oprateName"));
tLpgAirChargeFilesService.insertTLpgAirChargeFiles(tLpgAirChargeFile);
}
if(data.size()==100){
this.getFillingData();
}
//tProAppInforBrowseMapper.batchInsertTProAppInforBrowse(proAppInforBrowseList);
//List<TLpgGasBottleFiles> lpgGasBottleFilesList = new ArrayList<>();
}
}
}
......@@ -106,4 +106,9 @@ zhengfu:
#链接访问地址
apiUrl: http://test.zfcxjst.hebei.gov.cn:8082/openApi/index/sync/v1/entrypoint
wjyhq:
#无极液化气对接地址
apiUrl: https://api.117915.com/openapi
#获取Token接口参数
authCode: LPG_WJXHTYHQA_101855528016
accessKey: 41D714AC92234B1488961805E6AB8E15
secretKey: 38FAB0FA472E4354895085F1251052D8
package com.zehong.common.core.redis;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.BoundSetOperations;
......@@ -49,6 +45,11 @@ public class RedisCache
redisTemplate.opsForValue().set(key, value, timeout, timeUnit);
}
public <T> void setCacheObjectExpireAt(final String key, final Date date)
{
redisTemplate.expireAt(key,date);
}
/**
* 设置有效时间
*
......
......@@ -133,6 +133,8 @@ public class HttpClientUtils {
response = httpClient.execute(httpPost);
if (response!=null && response.getStatusLine().getStatusCode() == 200) {
resultString = EntityUtils.toString(response.getEntity(),"UTF-8");
}else{
System.out.println(response.getStatusLine().getStatusCode());
}
}finally {
close(response,httpClient);
......
......@@ -198,6 +198,16 @@ public class TLpgGasBottleFiles extends BaseEntity
@Excel(name = "存储类型")
private String fBottleStorageType;
private String fRowVersion;
public String getfRowVersion() {
return fRowVersion;
}
public void setfRowVersion(String fRowVersion) {
this.fRowVersion = fRowVersion;
}
public String getfValveName() {
return fValveName;
}
......
......@@ -19,6 +19,8 @@ public interface TLpgAirChargeFilesMapper
*/
public TLpgAirChargeFiles selectTLpgAirChargeFilesById(Long fGasAirChargeId);
public Integer selectTLpgAirChargeFilesTotal();
/**
* 查询液化石油气-充装记录列表
*
......
......@@ -19,6 +19,8 @@ public interface ITLpgAirChargeFilesService
*/
public TLpgAirChargeFiles selectTLpgAirChargeFilesById(Long fGasAirChargeId);
public Integer selectTLpgAirChargeFilesTotal();
/**
* 查询液化石油气-充装记录列表
*
......
......@@ -31,6 +31,13 @@ public class TLpgAirChargeFilesServiceImpl implements ITLpgAirChargeFilesService
return tLpgAirChargeFilesMapper.selectTLpgAirChargeFilesById(fGasAirChargeId);
}
@Override
public Integer selectTLpgAirChargeFilesTotal()
{
return tLpgAirChargeFilesMapper.selectTLpgAirChargeFilesTotal();
}
/**
* 查询液化石油气-充装记录列表
*
......
......@@ -37,6 +37,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where f_gas_air_charge_id = #{fGasAirChargeId}
</select>
<select id="selectTLpgAirChargeFilesTotal" resultType="int">
SELECT COUNT(*) FROM t_lpg_air_charge_files
</select>
<insert id="insertTLpgAirChargeFiles" parameterType="TLpgAirChargeFiles" useGeneratedKeys="true" keyProperty="fGasAirChargeId">
insert into t_lpg_air_charge_files
<trim prefix="(" suffix=")" suffixOverrides=",">
......
......@@ -50,6 +50,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="fThirdPartyLabel" column="f_third_party_label" />
<result property="fHoleCode" column="f_hole_code" />
<result property="fBottleStorageType" column="f_bottle_storage_type" />
<result property="fRowVersion" column="f_row_version" />
</resultMap>
<sql id="selectTLpgGasBottleFilesVo">
......@@ -57,7 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
( CASE f_is_specialized WHEN '1' THEN '专用' WHEN '2' THEN '托管' ELSE '-' END ) AS f_is_specialized,
f_valve_manu_facturer, f_inspection_label, f_third_party_label, f_hole_code, f_bottle_storage_type,
( CASE f_state WHEN '1' THEN '新增' WHEN '2' THEN '修改' WHEN '-1' THEN '删除' ELSE '-' END ) AS f_state,
f_opt_name, f_add_time, f_up_time, f_up_opt_name from t_lpg_gas_bottle_files
f_opt_name, f_add_time, f_up_time, f_up_opt_name, f_row_version from t_lpg_gas_bottle_files
</sql>
<select id="selectTLpgGasBottleFilesList" parameterType="TLpgGasBottleFiles" resultMap="TLpgGasBottleFilesResult">
......@@ -130,6 +131,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="fAddTime != null">f_add_time,</if>
<if test="fUpTime != null">f_up_time,</if>
<if test="fUpOptName != null">f_up_opt_name,</if>
<if test="fRowVersion != null">f_row_version,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="fRegCode != null">#{fRegCode},</if>
......@@ -178,6 +180,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="fUpTime != null">#{fUpTime},</if>
<if test="fUpOptName != null">#{fUpOptName},</if>
<if test="fRowVersion != null">#{fRowVersion},</if>
</trim>
</insert>
......@@ -229,6 +232,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="fAddTime != null">f_add_time = #{fAddTime},</if>
<if test="fUpTime != null">f_up_time = #{fUpTime},</if>
<if test="fUpOptName != null">f_up_opt_name = #{fUpOptName},</if>
<if test="fRowVersion != null">f_row_version = #{fRowVersion},</if>
</trim>
where f_gas_bottle_files_id = #{fGasBottleFilesId}
</update>
......
......@@ -79,10 +79,10 @@
return{
user:{name:'',type:'',num:'',price:''},
stu: [
// {
//
// },
{
},
/*{
name: "河北省石家庄平山县",
type: "中诚燃气",
num: "管道燃气",
......@@ -101,7 +101,7 @@
ts: "20次",
kh: 100,
jg: "优秀",
},
},*/
// {
// name: "河北省石家庄平山县",
// type: "盈德气体",
......
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