增加标准地址业务及数据库

This commit is contained in:
gaoben 2021-04-02 21:22:53 +08:00
parent c1532ee4c9
commit 54db89a719
19 changed files with 131178 additions and 168 deletions

130239
cell_db_tcp-20210402.sql Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,16 +1,23 @@
package net.shapelight.modules.job.task;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import net.shapelight.modules.sys.entity.SysUserEntity;
import net.shapelight.modules.sys.service.SysUserService;
import net.shapelight.modules.ten.entity.TenAddressEntity;
import net.shapelight.modules.ten.entity.TenCellEntity;
import net.shapelight.modules.ten.service.TenAddressService;
import net.shapelight.modules.ten.service.TenCellService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -24,6 +31,9 @@ public class XaAddressTask implements ITask {
@Autowired
private TenCellService tenCellService;
@Autowired
private TenAddressService tenAddressService;
public void run(String params) {
log.debug("xaApiTask定时任务正在执行", params);
List<SysUserEntity> allSysTenUser = this.sysUserService.findAllSysTenUser();
@ -43,6 +53,92 @@ public class XaAddressTask implements ITask {
}
}
}
try {
// String src = "D:\\VsCode\\11.18\\anputest.js";
// File file = new File(src);
// String js = FileUtils.readFileToString(src,"utf-8");
String src = "/home/huangyifang/gb/社区/oufeng";
File file = new File(src);
FileReader fileReader = new FileReader(file);
BufferedReader br = new BufferedReader(fileReader);
StringBuilder sb = new StringBuilder();
String temp = "";
while ((temp = br.readLine()) != null) {
// 拼接换行符
sb.append(temp + "\n");
}
br.close();
String js = sb.toString();
System.out.println(js);
JSONObject xml = JSONObject.parseObject(js);
JSONArray hlwtable = xml.getJSONObject("xml").getJSONObject("data").getJSONArray("HLWTable");
List<TenAddressEntity> list = new ArrayList<>();
for(int i = 0;i<hlwtable.size();i++){
JSONObject object = (JSONObject) hlwtable.get(i);
/*
{
"@JWSID": "610113600000000001202",
"@SWJID": "610113003012013",
"@SSXQBM": "A61011304538",
"@XZQHNAME": "西安市雁塔区",
"@DZSC": "",
"@DZQC": "陕西省西安市雁塔区长安南路439号1栋1单元2层1121号",
"@P_ID": "1820580963",
"@JLXMC": "长安南路",
"@WD": "34.206951",
"@DZJB": "14",
"@MPHLX": "10",
"@XQID": "610113600000000004538",
"@DZGSDW": "610113600000",
"@XT_ZHXGSJ": "2021-03-23 16: 50: 08",
"@SJ": "",
"@XZQH": "610113",
"@XQ": "欧风园小区",
"@JD": "108.942541",
"@JWSMC": "陕师大警务室",
"@DZDM": "000268000029000010000001000002000001",
"@JLXDM": "000268"
}
*/
TenAddressEntity addressEntity = new TenAddressEntity();
addressEntity.setJwsid(object.getString("@JWSID"));
addressEntity.setSwjid(object.getString("@SWJID"));
addressEntity.setSsxqbm(object.getString("@SSXQBM"));
addressEntity.setXzqhname(object.getString("@XZQHNAME"));
addressEntity.setDzsc(object.getString("@DZSC"));
addressEntity.setDzqc(object.getString("@DZQC"));
addressEntity.setPId(Long.parseLong(object.getString("@P_ID")));
addressEntity.setJlxmc(object.getString("@JLXMC"));
addressEntity.setWd(object.getString("@WD"));
addressEntity.setDzjb(object.getString("@DZJB"));
addressEntity.setMphlx(object.getString("@MPHLX"));
addressEntity.setXqid(object.getString("@XQID"));
addressEntity.setDzgsdw(object.getString("@DZGSDW"));
addressEntity.setXtZhxgsj(object.getString("@XT_ZHXGSJ"));
addressEntity.setSj(object.getString("@SJ"));
addressEntity.setXzqh(object.getString("@XZQH"));
addressEntity.setXq(object.getString("@XQ"));
addressEntity.setJd(object.getString("@JD"));
addressEntity.setJwsmc(object.getString("@JWSMC"));
addressEntity.setDzdm(object.getString("@DZDM"));
addressEntity.setJlxdm(object.getString("@JLXDM"));
list.add(addressEntity);
tenAddressService.saveOrUpdate(addressEntity);
}
System.out.println("");
// tenAddressService.saveBatch(list);
}catch (Exception e){
log.error(e.getMessage());
}
log.debug("xaApiTask定时任务执行完毕");
}
}

View File

@ -112,9 +112,9 @@ public class XaRealDataTask implements ITask {
xaData.put("datas", syncRooms);
XaPages xapage = new XaPages();
xapage.setPno("1");
xapage.setPsize(count);
xapage.setTcount(0);
xapage.setTsize(0);
// xapage.setPsize(count);
// xapage.setTcount(0);
// xapage.setTsize(0);
String realRoomRes = XaApi.postData(fwikUrl, appId, appSecret, "1", "SYFW", "SYFW", xaData);
}

View File

@ -0,0 +1,87 @@
package net.shapelight.modules.ten.controller;
import java.util.Arrays;
import java.util.Map;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import net.shapelight.modules.ten.entity.TenAddressEntity;
import net.shapelight.modules.ten.service.TenAddressService;
import net.shapelight.common.utils.PageUtils;
import net.shapelight.common.utils.R;
/**
*
*
*/
@RestController
@RequestMapping("ten/address")
public class TenAddressController {
@Autowired
private TenAddressService tenAddressService;
/**
* 列表
*/
@RequestMapping("/list")
@RequiresPermissions("ten:address:list")
public R list(@RequestParam Map<String, Object> params){
PageUtils page = tenAddressService.queryPage(params);
return R.ok().put("data", page);
}
/**
* 信息
*/
@RequestMapping("/info/{pId}")
@RequiresPermissions("ten:address:info")
public R info(@PathVariable("pId") Long pId){
TenAddressEntity tenAddress = tenAddressService.getById(pId);
return R.ok().put("data", tenAddress);
}
/**
* 保存
*/
@RequestMapping("/save")
@RequiresPermissions("ten:address:save")
public R save(@RequestBody TenAddressEntity tenAddress){
tenAddressService.save(tenAddress);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
@RequiresPermissions("ten:address:update")
public R update(@RequestBody TenAddressEntity tenAddress){
tenAddressService.updateById(tenAddress);
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
@RequiresPermissions("ten:address:delete")
public R delete(@RequestBody Long[] pIds){
tenAddressService.removeByIds(Arrays.asList(pIds));
return R.ok();
}
}

View File

@ -0,0 +1,14 @@
package net.shapelight.modules.ten.dao;
import net.shapelight.modules.ten.entity.TenAddressEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
*
*
*/
@Mapper
public interface TenAddressDao extends BaseMapper<TenAddressEntity> {
}

View File

@ -0,0 +1,106 @@
package net.shapelight.modules.ten.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
*
*
*/
@Data
@TableName("ten_address")
public class TenAddressEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 地址序号
*/
@TableId(type = IdType.INPUT)
private Long pId;
/**
* 警务室id
*/
private String jwsid;
/**
* 社居委编码
*/
private String swjid;
/**
* 地址俗称
*/
private String dzsc;
/**
* 地址全称
*/
private String dzqc;
/**
* 街路巷名称
*/
private String jlxmc;
/**
* 经度
*/
private String jd;
/**
* 维度
*/
private String wd;
/**
* 地址级别
*/
private String dzjb;
/**
* 门牌号类型
*/
private String mphlx;
/**
* 小区id
*/
private String xqid;
/**
* 社居委名称
*/
private String sj;
/**
* 小区名称
*/
private String xq;
/**
* 所属县区编码
*/
private String xzqh;
/**
* 警务室名称
*/
private String jwsmc;
/**
* 地址编码唯一
*/
private String dzdm;
/**
* 街路巷编码
*/
private String jlxdm;
/**
* 申报小区编码
*/
private String ssxqbm;
/**
* 地址行政区划名称
*/
private String xzqhname;
/**
* 地址归属单位
*/
private String dzgsdw;
/**
* 最后更新时间
*/
private String xtZhxgsj;
}

View File

@ -136,7 +136,7 @@ public class TenRoomEntity extends BaseEntity implements Serializable {
private Integer xaSync;
@ApiModelProperty("地址序号")
private String pId;
private Long pId;
@ApiModelProperty("地址编码")
private String dzbm;

View File

@ -0,0 +1,17 @@
package net.shapelight.modules.ten.service;
import com.baomidou.mybatisplus.extension.service.IService;
import net.shapelight.common.utils.PageUtils;
import net.shapelight.modules.ten.entity.TenAddressEntity;
import java.util.Map;
/**
*
*
*/
public interface TenAddressService extends IService<TenAddressEntity> {
PageUtils queryPage(Map<String, Object> params);
}

View File

@ -0,0 +1,29 @@
package net.shapelight.modules.ten.service.impl;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.shapelight.common.utils.PageUtils;
import net.shapelight.common.utils.Query;
import net.shapelight.modules.ten.dao.TenAddressDao;
import net.shapelight.modules.ten.entity.TenAddressEntity;
import net.shapelight.modules.ten.service.TenAddressService;
@Service("tenAddressService")
public class TenAddressServiceImpl extends ServiceImpl<TenAddressDao, TenAddressEntity> implements TenAddressService {
@Override
public PageUtils queryPage(Map<String, Object> params) {
IPage<TenAddressEntity> page = this.page(
new Query<TenAddressEntity>().getPage(params),
new QueryWrapper<TenAddressEntity>()
);
return new PageUtils(page);
}
}

View File

@ -15,6 +15,7 @@ import net.shapelight.common.utils.Query;
import net.shapelight.modules.ten.dao.TenPersonSyncDao;
import net.shapelight.modules.ten.entity.TenPersonSyncEntity;
import net.shapelight.modules.ten.service.TenPersonSyncService;
import org.springframework.transaction.annotation.Transactional;
@Service("tenPersonSyncService")
@ -29,8 +30,18 @@ public class TenPersonSyncServiceImpl implements TenPersonSyncService {
}
@Override
@Transactional(rollbackFor = Exception.class)
public int insert(TenPersonSyncEntity tenLicenseEntity) {
return tenPersonSyncDao.insert(tenLicenseEntity);
TenPersonSyncEntity entity = this.findByDeviceIdAndPersonId(tenLicenseEntity.getDeviceId(),
tenLicenseEntity.getPersonId(),
tenLicenseEntity.getTenantId());
if(entity==null){
return tenPersonSyncDao.insert(tenLicenseEntity);
}else{
entity.setLastUpdateTime(tenLicenseEntity.getLastUpdateTime());
entity.setState(tenLicenseEntity.getState());
return tenPersonSyncDao.updateById(entity);
}
}
@Override

View File

@ -1,123 +1,344 @@
package net.shapelight.modules.xian.service;
import com.alibaba.fastjson.JSONObject;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.io.DataInputStream;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLDecoder;
import java.text.SimpleDateFormat;
import java.util.*;
import net.shapelight.common.utils.DateUtils;
import net.shapelight.common.utils.MD5Utils;
import net.shapelight.common.utils.UUIDUtil;
import net.shapelight.modules.xian.utils.AESUtils;
import net.shapelight.modules.xian.utils.XaHttpUtils;
import net.shapelight.modules.xian.utils.XaUtils;
import net.shapelight.modules.xian.vo.XaData;
import net.shapelight.modules.xian.vo.XaPages;
import net.shapelight.modules.xian.vo.XaSYFW;
import net.shapelight.modules.xian.vo.XaSYRK;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class XaApi {
private static final Logger log = LoggerFactory.getLogger(net.shapelight.modules.xian.service.XaApi.class);
private static final Logger log = LoggerFactory.getLogger(net.shapelight.modules.xian.service.XaApi.class);
private static final String getXqAddrUrl = "http://117.34.12.66:10011/zhxqgl/interface/get_xq_addr.jsp";
private static final String XqAddrUrl = "http://117.34.12.66:10011/zhxqgl/interface/get_xq_addr.jsp";
private static final String getFwikUrl = "http://117.34.12.66:10011/ywxzservice/get_fwjk_url.jsp";
private static final String FwikUrl = "http://117.34.12.66:10011/ywxzservice/get_fwjk_url.jsp";
/**
* appid: 1297164778041095
* appsecret: 22971647780410956329716477804109
* xqid: 610113600000000004538
*/
public static String getAddress(String xqid, String appId, String appSecret) {
Map<String, String> addressMap = new HashMap<>();
addressMap.put("appid", appId);
addressMap.put("appsecret", XaUtils.md5(appSecret));
addressMap.put("xqid", xqid);
String address = XaUtils.httpPOSTParam(XqAddrUrl,
appId, appSecret, addressMap);
return address;
}
public static String getAddress(String xqid, String appId, String appSecret) {
// Map<String, String> postParameters = new HashMap<>();
// String appsecretMd5 = MD5Utils.getMD5Str(appSecret);
// postParameters.put("xqid", xqid);
// postParameters.put("appid", appId);
// postParameters.put("appsecret", appsecretMd5);
JSONObject postParameters = new JSONObject();
String appsecretMd5 = MD5Utils.getMD5Str(appSecret);
postParameters.put("xqid", xqid);
postParameters.put("appid", appId);
postParameters.put("appsecret", appsecretMd5);
Map<String,String> headersMap = new HashMap<>();
headersMap.put("appId",appId);
String token = XaHttpUtils.getToken(appId,appSecret,"");
headersMap.put("token",token);
headersMap.put("tranId","202103310952250000000000000001");
return XaHttpUtils.postHttpEncryption("http://117.34.12.66:10011/zhxqgl/interface/get_xq_addr.jsp", headersMap,postParameters);
public static String getFwikUrl(String appId, String appSecret) {
Map<String, String> paramMap = new HashMap<>();
paramMap.put("appid", appId);
paramMap.put("appsecret", XaUtils.md5(appSecret));
String res = XaUtils.httpPOSTParam(FwikUrl, appId, appSecret, paramMap);
JSONObject resObject = JSONObject.parseObject(res);
if (resObject != null) {
log.debug(resObject.toJSONString());
JSONObject xmlObject = resObject.getJSONObject("xml");
String code = xmlObject.getString("code");
if (code != null && code.equals("0000"))
return xmlObject.getString("data");
log.error("获取接口地址错误,错误码:" + xmlObject.getString("code") + ",错误信息:" + xmlObject.getString("data"));
}
return null;
}
public static String getFwikUrl(String appId, String appSecret) {
JSONObject postParameters = new JSONObject();
String appsecretMd5 = MD5Utils.md5Str(appSecret);
// postParameters.put("xqid", xqid);
postParameters.put("appid", appId);
postParameters.put("appsecret", appsecretMd5);
Map<String,String> headersMap = new HashMap<>();
headersMap.put("appId",appId);
String token = XaHttpUtils.getToken(appId,appSecret,"");
headersMap.put("token",token);
headersMap.put("tranId","202103310952250000000000000001");
String res = XaHttpUtils.postHttpEncryption("http://117.34.12.66:10011/ywxzservice/get_fwjk_url.jsp", headersMap, postParameters);
JSONObject resObject = JSONObject.parseObject(res);
if (resObject != null) {
log.debug(resObject.toJSONString());
JSONObject xmlObject = resObject.getJSONObject("xml");
String code = xmlObject.getString("code");
if (code != null && code.equals("0000"))
return xmlObject.getString("data");
log.error("获取接口地址错误,错误码:"+ xmlObject.getString("code") + ",错误信息:"+ xmlObject.getString("data"));
}
public static String postData(String url, String appId, String appSecret, String tranId, String serviceId, String serviceValue, Map<String, Object> dataObject) {
String dataMingWen = JSONObject.toJSONString(dataObject);
String dataMiWen = null;
try {
dataMiWen = AESUtils.encrypt(dataMingWen, appSecret);
} catch (Exception e) {
log.error("加密数据时出错:" + e.getMessage());
return null;
}
if (dataMiWen != null) {
String tokenStr = appId + appSecret + DateUtils.format(new Date(), "YYYYMMDD") + dataMiWen;
String token = MD5Utils.getMD5Str(tokenStr);
Map<String, String> headerMaps = new HashMap<>();
headerMaps.put("appId", appId);
headerMaps.put("token", token);
headerMaps.put("tranId", tranId);
headerMaps.put("serviceId", serviceId);
headerMaps.put("serviceValue", serviceValue);
Map<String, String> postParameters = new HashMap<>();
postParameters.put("data", dataMiWen);
return "";
}
return null;
}
public static String postData(String url, String appId, String appSecret, String tranId, String serviceId, String serviceValue, Map<String, Object> dataObject) {
String dataMingWen = JSONObject.toJSONString(dataObject);
String dataMiWen = null;
/**
* @param url // * @param json 加密后的json
* // * @param serviceId
* // * @param serviceValue
* @param appid
* @param secre
* @return
*/
public static String httpPOSTJson(String url, String json, String serviceId, String serviceValue, String appid, String secre) {
String data = "";
try {
URL dataurl = new URL(url);
HttpURLConnection conn = (HttpURLConnection) dataurl.openConnection();
try {
dataMiWen = AESUtils.encrypt(dataMingWen, appSecret);
} catch (Exception e) {
log.error("加密数据时出错:"+ e.getMessage());
return null;
}
if (dataMiWen != null) {
String tokenStr = appId + appSecret + DateUtils.format(new Date(), "YYYYMMDD") + dataMiWen;
String token = MD5Utils.getMD5Str(tokenStr);
Map<String, String> headerMaps = new HashMap<>();
headerMaps.put("appId", appId);
headerMaps.put("token", token);
headerMaps.put("tranId", tranId);
headerMaps.put("serviceId", serviceId);
headerMaps.put("serviceValue", serviceValue);
Map<String, String> postParameters = new HashMap<>();
postParameters.put("data", dataMiWen);
conn.setRequestMethod("POST");
String currdate = new SimpleDateFormat("yyyyMMdd").format(new Date());
String token = XaUtils.md5(appid + secre + currdate + json.replaceAll("\r\n", ""));
System.out.println("json****" + json);
System.out.println("333appid***" + appid);
System.out.println("333token***" + token);
System.out.println("333serviceId***" + serviceId);
System.out.println("333serviceValue***" + serviceValue);
conn.setRequestProperty("appid", appid);
conn.setRequestProperty("token", token);
conn.setRequestProperty("tranId", "12312321312321321321312");//可固定这么写
conn.setRequestProperty("serviceId", serviceId);
conn.setRequestProperty("serviceValue", serviceValue);
conn.setRequestProperty("versionCode", "");
conn.setDoOutput(true);
conn.setDoInput(true);
// String params = "appid=" + URLEncoder.encode(appid, "UTF-8") + "&appsecret=" + URLEncoder.encode(secre, "UTF-8");
// OutputStream outputStream = conn.getOutputStream();
// outputStream.write(params.getBytes());
// outputStream.flush();
// outputStream.close();
OutputStreamWriter os = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
os.write(json);
os.flush();
os.close();
//conn.setConnectTimeout(10000);
} catch (Exception ex) {
System.out.println("errir=" + ex.getMessage());
conn.disconnect();
return "";
}
return null;
InputStream is = conn.getInputStream();
DataInputStream dis = new DataInputStream(is);
byte bt[] = new byte[dis.available()];
dis.read(bt);
data = URLDecoder.decode(new String(bt, "UTF-8"), "UTF-8");
conn.disconnect();
is.close();
dis.close();
} catch (Exception e) {
data = "";
}
return data;
}
public static void syncRoom() {
String appid = "1297164778041095";
String appsecret = "22971647780410956329716477804109";
String xqid = "610113600000000004538";
//6.2 获取数据对接接口---------------------------------------------------------------------------
String apiUrl = getFwikUrl(appid, appsecret);
System.out.println(apiUrl);
List<XaSYFW> syncRooms = new ArrayList<>();
XaSYFW xaSYFW = new XaSYFW();
xaSYFW.setLV_FWBM("610113600000000004538" + "01820591355");//xqid(21)+0+P_ID
xaSYFW.setLV_DZBM("000268000029000013000001000003000002");
xaSYFW.setLV_DZMC("陕西省西安市雁塔区长安南路439号4栋1单元3层4131号");
xaSYFW.setLV_FWLB("1");//1单元楼2筒子楼3别墅4自建小楼5独立平房6四合院平房7其他
xaSYFW.setLV_FWXZ("2");//房屋性质1.公有2私有3其他
xaSYFW.setLV_FWYT("4");//房屋用途1.办公2厂房3商用4居住5商住两用6其他
xaSYFW.setLV_SFCZF("");
xaSYFW.setLV_FZ_GMSFHM("610122196404160321");//房主公民身份证
xaSYFW.setLV_FZ_XM("文淑利");
xaSYFW.setLV_FZ_ZJZL("10");//房主证件类型
xaSYFW.setLV_FZ_ZJHM("610122196404160321");//房主证件号码
xaSYFW.setLV_FZ_LXDH("15325635588");//联系电话
// xaSYFW.setLV_DJDWGAJGJGMC("西图之光智能科技有限公司"); //承建商名称
// xaSYFW.setLV_DJDWGAJGJGDM("xtzg");
xaSYFW.setLV_DJSJ(DateUtils.format(new Date(), "yyyyMMddHHmmss"));
xaSYFW.setLV_FWXZZ("1000");//房屋现状 1020借用 1000 自用 1010 闲置 1030 租用 1900 其他 9000空挂 9010 拆迁
xaSYFW.setLV_FWJG("1");//1钢混 2混合 3 砖木 4其他
xaSYFW.setLV_COMPUTERID(xqid); //XQID
xaSYFW.setLV_SSXQBM("A61011304538");//SSXQBM
xaSYFW.setLV_PROCMODE("PMINSERT");
syncRooms.add(xaSYFW);
XaData jsonData = new XaData();
jsonData.setDatas(syncRooms);
List<XaPages> listPages = new ArrayList<>();
XaPages pages = new XaPages();
pages.setPno("1");
pages.setPsize("1");
listPages.add(pages);
jsonData.setPages(listPages);
String json = JSONObject.toJSONString(jsonData);
String b = XaUtils.encryptStr(json.trim(), appsecret);
// String c = XaUtils.decodeStr(b,appsecret);
try {
// String b = AESUtils.encrypt(json.trim(), appsecret);
String c = AESUtils.decrypt(b, appsecret);
System.out.println(c);
} catch (Exception e) {
e.printStackTrace();
}
public static void main(String args[]){
/**
* appid: 1297164778041095
* appsecret: 22971647780410956329716477804109
* xqid: 610113600000000004538
*/
String appid = "1297164778041095";
String appsecret = "22971647780410956329716477804109";
String xqid = "610113600000000004538";
// String s = httpPOSTJson(apiUrl,b,"SYFW","SYFW",appid,appsecret);
// System.out.println(s);
}
public static void syncPerson() {
/**
* appid: 1297164778041095
* appsecret: 22971647780410956329716477804109
* xqid: 610113600000000004538
*/
String appid = "1297164778041095";
String appsecret = "22971647780410956329716477804109";
String xqid = "610113600000000004538";
// String address = getAddress(xqid,appid,appsecret);
// System.out.println(address);
String apiUrl = getFwikUrl(appid,appsecret);
System.out.println(apiUrl);
//6.2 获取数据对接接口---------------------------------------------------------------------------
String apiUrl = getFwikUrl(appid, appsecret);
System.out.println(apiUrl);
/**
{
"@JWSID": "610113600000000001202",
"@SWJID": "610113003012013",
"@SSXQBM": "A61011304538",
"@XZQHNAME": "西安市雁塔区",
"@DZSC": "",
"@DZQC": "陕西省西安市雁塔区长安南路439号1栋1单元1层1111号",
"@P_ID": "1820580961",
"@JLXMC": "长安南路",
"@WD": "34.206951",
"@DZJB": "14",
"@MPHLX": "10",
"@XQID": "610113600000000004538",
"@DZGSDW": "610113600000",
"@XT_ZHXGSJ": "2021-03-23 16: 50: 08",
"@SJ": "",
"@XZQH": "610113",
"@XQ": "欧风园小区",
"@JD": "108.942541",
"@JWSMC": "陕师大警务室",
"@DZDM": "000268000029000010000001000001000001",
"@JLXDM": "000268"
}
*/
List<XaSYRK> syncPersons = new ArrayList<>();
/**
1820591355 610113600000000001202 610113003012013 陕西省西安市雁塔区长安南路439号4栋1单元3层4131号 长安南路 108.942481 34.207741 14 10 610113600000000004538 欧风园小区 610113 陕师大警务室 000268000029000013000001000003000002 000268 A61011304538 西安市雁塔区 610113600000 2021-03-23 16:50:08
*/
XaSYRK realPerson = new XaSYRK();
realPerson.setLV_SYRKBM("10610122196404160321001820591355"); //实有人口编码
realPerson.setLV_GMSFHM("610122196404160321"); //身份证号
realPerson.setLV_XM("文淑利"); //姓名
realPerson.setLV_ZJZL("10");
realPerson.setLV_ZJHM("610122196404160321"); //身份证号
realPerson.setLV_JZDZ_DZBM("000268000029000013000001000003000002"); //地址编码 DZDM
realPerson.setLV_JZDZ_SSXQ("610113"); //行政区划 XZQH
realPerson.setLV_JZDZ_QHLXXDZ("陕西省西安市雁塔区长安南路439号4栋1单元3层4131号"); //地址名称 DZQC
realPerson.setLV_DJDWGAJGJGMC("西图之光智能科技有限公司"); //承建商名称
realPerson.setLV_DJDWGAJGJGDM("xtzg");
realPerson.setLV_DJSJ(DateUtils.format(new Date(), "yyyyMMddHHmmss"));
realPerson.setLV_COMPUTERID(xqid); //XQID
realPerson.setLV_PROCMODE("PMINSERT");
syncPersons.add(realPerson);
XaData jsonData = new XaData();
jsonData.setDatas(syncPersons);
List<XaPages> listPages = new ArrayList<>();
XaPages pages = new XaPages();
pages.setPno("1");
pages.setPsize("1");
// pages.setTcount("1");
listPages.add(pages);
jsonData.setPages(listPages);
String json = JSONObject.toJSONString(jsonData);
String b = XaUtils.encryptStr(json.trim(), appsecret);
// String c = XaUtils.decodeStr(b,appsecret);
try {
// String b = AESUtils.encrypt(json.trim(), appsecret);
String c = AESUtils.decrypt(b, appsecret);
System.out.println(c);
} catch (Exception e) {
e.printStackTrace();
}
// String s = httpPOSTJson(apiUrl,b,"SYRK","SYRK",appid,appsecret);
// System.out.println(s);
}
public static void main(String args[]) {
/**
* appid: 1297164778041095
* appsecret: 22971647780410956329716477804109
* xqid: 610113600000000004538
*/
// String appid = "1297164778041095";
// String appsecret = "22971647780410956329716477804109";
// String xqid = "610113600000000004538";
// String address = getAddress(xqid,appid,appsecret);
// System.out.println(address);
//6.2 获取数据对接接口---------------------------------------------------------------------------
// String apiUrl = getFwikUrl(appid, appsecret);
// System.out.println(apiUrl);
//6.1 获取标准地址接口---------------------------------------------------------------------------
// String address = getAddress(xqid, appid, appsecret);
// System.out.println(address);
//6.3.1 实有房屋信息----------------------------------------------------------------------------
//1820591355 610113600000000001202 610113003012013 陕西省西安市雁塔区长安南路439号4栋1单元3层4131号 长安南路 108.942481 34.207741 14 10 610113600000000004538 欧风园小区 610113 陕师大警务室 000268000029000013000001000003000002 000268 A61011304538 西安市雁塔区 610113600000 2021-03-23 16:50:08
// syncRoom();
//6.3.2 实有人口信息----------------------------------------------------------------------------
// syncPerson();
}
}

View File

@ -73,31 +73,44 @@ public class AESUtils {
}
public static void main(String[] args) throws Exception {
Date now = new Date();
SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
String s = df.format(now);
XaSYFW realRoom = new XaSYFW();
realRoom.setLV_FWBM("123456781234567812345678");
realRoom.setLV_DZBM("123456781234567812345678");
realRoom.setLV_DZMC("陕西省西安市雁塔区科技二路78号太白阁c座10304室");
realRoom.setLV_FWLB("1");
realRoom.setLV_FWXZ("2");
realRoom.setLV_FWYT("4");
realRoom.setLV_SFCZF("");
realRoom.setLV_FZ_GMSFHM("123456781234567812");
realRoom.setLV_FZ_XM("令狐传奇");
realRoom.setLV_FZ_ZJZL("10");
realRoom.setLV_FZ_ZJHM("123456781234567812");
realRoom.setLV_FZ_LXDH("12345678912");
realRoom.setLV_DJSJ(DateUtils.format(new Date(), "yyyyMMddHHmmss"));
realRoom.setLV_FWXZZ("1000");
realRoom.setLV_FWJG("1");
realRoom.setLV_COMPUTERID("123456781234567812345678");
realRoom.setLV_SSXQBM("123456781234567812345678");
realRoom.setLV_PROCMODE("PMINSERT");
String object = JSONObject.toJSONString(realRoom);
int count = object.length();
System.out.println(count);
String mingwen = "2015021115122300";
String password = "ADED51171767497B94368AF51050754D";
String miwen = encrypt(mingwen,password);
System.out.println(miwen);
String jiemi = decrypt(miwen,password);
System.out.println(jiemi);
// Date now = new Date();
// SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
// String s = df.format(now);
// XaSYFW realRoom = new XaSYFW();
// realRoom.setLV_FWBM("123456781234567812345678");
// realRoom.setLV_DZBM("123456781234567812345678");
// realRoom.setLV_DZMC("陕西省西安市雁塔区科技二路78号太白阁c座10304室");
// realRoom.setLV_FWLB("1");
// realRoom.setLV_FWXZ("2");
// realRoom.setLV_FWYT("4");
// realRoom.setLV_SFCZF("");
// realRoom.setLV_FZ_GMSFHM("123456781234567812");
// realRoom.setLV_FZ_XM("令狐传奇");
// realRoom.setLV_FZ_ZJZL("10");
// realRoom.setLV_FZ_ZJHM("123456781234567812");
// realRoom.setLV_FZ_LXDH("12345678912");
// realRoom.setLV_DJSJ(DateUtils.format(new Date(), "yyyyMMddHHmmss"));
// realRoom.setLV_FWXZZ("1000");
// realRoom.setLV_FWJG("1");
// realRoom.setLV_COMPUTERID("123456781234567812345678");
// realRoom.setLV_SSXQBM("123456781234567812345678");
// realRoom.setLV_PROCMODE("PMINSERT");
// String object = JSONObject.toJSONString(realRoom);
// int count = object.length();
// System.out.println(count);
}
}

View File

@ -78,6 +78,32 @@ public class XaUtils {
}
private static String decryptData_AES(String content, String password) {
try {
if (password == null)
return null;
if (password.length() != 32)
return null;
byte[] raw = parseHexStr2Byte(password);
SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
cipher.init(2, skeySpec);
byte[] encrypted1 = parseHexStr2Byte(content);
try {
byte[] original = cipher.doFinal(encrypted1);
String originalString = parseByte2HexStr(original);
return originalString;
} catch (Exception e) {
System.out.println(e.toString());
return null;
}
} catch (Exception ex) {
System.out.println(ex.toString());
return null;
}
}
/**
* 将16进制转换为二进制
*
@ -131,6 +157,22 @@ public class XaUtils {
}
// /**
// *
// * @param srcStr
// * @param password
// * @return
// */
// public static String decodeStr(String srcStr, String password) {
//
// byte[] encryptResult = encryptData_AES(srcStr, password);
//
// String encryptResultStr = parseByte2HexStr(encryptResult);
//
// return encryptResultStr;
// }
/**
*
* @param url
@ -216,32 +258,12 @@ public class XaUtils {
String data = "";
try {
URL dataurl = new URL(url);
HttpURLConnection conn = (HttpURLConnection) dataurl.openConnection();
try {
conn.setRequestMethod("POST");
String currdate = new SimpleDateFormat("yyyyMMdd").format(new Date());
String token = md5(appid + secre + currdate);
// System.out.println("json****" + json);
System.out.println("appid***" + appid);
System.out.println("token***" + token);
// System.out.println("333serviceId***" + serviceId);
// System.out.println("333serviceValue***" + serviceValue);
conn.setRequestProperty("appid", appid);
conn.setRequestProperty("token", token);
conn.setRequestProperty("tranId", "12312321312321321321312");//可固定这么写
// conn.setRequestProperty("serviceId", "");
// conn.setRequestProperty("serviceValue", "");
// conn.setRequestProperty("versionCode", "");
conn.setDoOutput(true);
conn.setDoInput(true);
StringBuffer paramsBuffer = new StringBuffer();
mapParams.forEach((key,value)->{
paramsBuffer.append("&"+key+"=");
try {
@ -249,25 +271,13 @@ public class XaUtils {
}catch (Exception e){
log.error(e.getMessage());
}
// System.out.println(key);
// System.out.println(value);
});
String params = paramsBuffer.toString().substring(1);
System.out.println(params);
// String s = "appid=" + URLEncoder.encode(appid, "UTF-8") + "&appsecret=" + URLEncoder.encode(secre, "UTF-8");
OutputStream outputStream = conn.getOutputStream();
outputStream.write(params.getBytes());
outputStream.flush();
outputStream.close();
// OutputStreamWriter os = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
// os.write(json);
// os.flush();
// os.close();
//conn.setConnectTimeout(10000);
} catch (Exception ex) {
System.out.println("errir=" + ex.getMessage());
conn.disconnect();
@ -321,8 +331,6 @@ public class XaUtils {
//获取借口接口地址
String appid = "1297164778041095";
String secre = "22971647780410956329716477804109";
// String secreMd5 = md5("22971647780410956329716477804109");
// System.out.println("secretMd5:"+secreMd5);
Map<String,String> paramMap = new HashMap<>();
paramMap.put("appid",appid);
paramMap.put("appsecret",md5(secre));
@ -334,14 +342,14 @@ public class XaUtils {
//获取标准地址
String xqid = "610113600000000004538";
Map<String,String> addressMap = new HashMap<>();
addressMap.put("appid",appid);
addressMap.put("appsecret",md5(secre));
addressMap.put("xqid",xqid);
String address = httpPOSTParam("http://117.34.12.66:10011/zhxqgl/interface/get_xq_addr.jsp",
appid,secre,addressMap);
System.out.println("Address:"+address);
// Map<String,String> addressMap = new HashMap<>();
// addressMap.put("appid",appid);
// addressMap.put("appsecret",md5(secre));
// addressMap.put("xqid",xqid);
// String address = httpPOSTParam("http://117.34.12.66:10011/zhxqgl/interface/get_xq_addr.jsp",
// appid,secre,addressMap);
//
// System.out.println("Address:"+address);

View File

@ -7,6 +7,6 @@ import java.util.List;
@Data
public class XaData {
private List<Object> datas;
private XaPages pages;
private List datas;
private List<XaPages> pages;
}

View File

@ -12,8 +12,8 @@ public class XaPages {
* pno 整型 请求页从1开始
* tsize 整型 总包数为空时平台计算返回不为空时不返回
*/
private Integer psize;
private Integer tcount;
private String psize = "1";
private String tcount = "";
private String pno = "1";
private Integer tsize;
private String tsize = "";
}

View File

@ -1,45 +1,64 @@
package net.shapelight.modules.xian.vo;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
@Data
public class XaSYFW {
@JSONField(name="LV_FWBM")
private String LV_FWBM;
@JSONField(name="LV_DZBM")
private String LV_DZBM;
@JSONField(name="LV_DZMC")
private String LV_DZMC;
@JSONField(name="LV_FWLB")
private String LV_FWLB = "1";
@JSONField(name="LV_FWXZ")
private String LV_FWXZ = "2";
@JSONField(name="LV_FWYT")
private String LV_FWYT = "4";
@JSONField(name="LV_SFCZF")
private String LV_SFCZF = "";
@JSONField(name="LV_FZ_GMSFHM")
private String LV_FZ_GMSFHM;
@JSONField(name="LV_FZ_XM")
private String LV_FZ_XM;
@JSONField(name="LV_FZ_ZJZL")
private String LV_FZ_ZJZL = "10";
@JSONField(name="LV_FZ_ZJHM")
private String LV_FZ_ZJHM;
@JSONField(name="LV_FZ_LXDH")
private String LV_FZ_LXDH;
@JSONField(name="LV_DJSJ")
private String LV_DJSJ;
@JSONField(name="LV_FWXZZ")
private String LV_FWXZZ = "1000";
@JSONField(name="LV_FWJG")
private String LV_FWJG = "1";
@JSONField(name="LV_COMPUTERID")
private String LV_COMPUTERID;
@JSONField(name="LV_SSXQBM")
private String LV_SSXQBM;
@JSONField(name="LV_PROCMODE")
private String LV_PROCMODE = "PMINSERT";

View File

@ -1,5 +1,6 @@
package net.shapelight.modules.xian.vo;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
@Data
@ -61,58 +62,73 @@ public class XaSYRK {
/**
* 实有人口编码
*/
@JSONField(name="LV_SYRKBM")
private String LV_SYRKBM;
/**
* 公民身份号码
*/
@JSONField(name="LV_GMSFHM")
private String LV_GMSFHM;
/**
* 姓名
*/
@JSONField(name="LV_XM")
private String LV_XM;
/**
* 证件种类
*/
@JSONField(name="ZJZL")
private String ZJZL;
/**
* 证件号码
*/
@JSONField(name="LV_ZJHM")
private String LV_ZJHM;
/**
* 居住地址_地址编码
*/
@JSONField(name="LV_JZDZ_DZBM")
private String LV_JZDZ_DZBM;
/**
* 居住地址_省市县区 LV_JZDZ_SSXQ 字符 6 必填 引用标注地址对应行政区划(XZQH)
*/
@JSONField(name="LV_JZDZ_SSXQ")
private String LV_JZDZ_SSXQ;
/**
* 居住地址_区划内详细地址 LV_JZDZ_QHLXXDZ 字符 120 必填 引用标注地址对应地址名称(DZQC)
*/
@JSONField(name="LV_JZDZ_QHLXXDZ")
private String LV_JZDZ_QHLXXDZ;
/**
* 登记公司名称 LV_DJDWGAJGJGMC 字符 100 必填 公安注册的承建商名称
*/
@JSONField(name="LV_DJDWGAJGJGMC")
private String LV_DJDWGAJGJGMC;
/**
* 登记公司编码 LV_DJDWGAJGJGDM 字符 12 必填 公安注册的承建商账号
*/
@JSONField(name="LV_DJDWGAJGJGDM")
private String LV_DJDWGAJGJGDM;
/**
*登记时间 LV_DJSJ 日期 - 必填 YYYYMMDDHHMISS
*/
@JSONField(name="LV_DJSJ")
private String LV_DJSJ;
/**
* 对接小区id LV_COMPUTERID 字符 32 必填 引用标注地址小区ID(XQID)和分局提供的小区ID一直
*/
@JSONField(name="LV_COMPUTERID")
private String LV_COMPUTERID;
/**
* 操作方式 LV_PROCMODE 字符 20 必填 填写PMINSERT
*/
@JSONField(name="LV_PROCMODE")
private String LV_PROCMODE = "PMINSERT";
@JSONField(name="LV_ZJZL")
private String LV_ZJZL = "10";

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="net.shapelight.modules.ten.dao.TenAddressDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="net.shapelight.modules.ten.entity.TenAddressEntity" id="tenAddressMap">
<result property="pId" column="p_id"/>
<result property="jwsid" column="jwsid"/>
<result property="swjid" column="swjid"/>
<result property="dzsc" column="dzsc"/>
<result property="dzqc" column="dzqc"/>
<result property="jlxmc" column="jlxmc"/>
<result property="jd" column="jd"/>
<result property="wd" column="wd"/>
<result property="dzjb" column="dzjb"/>
<result property="mphlx" column="mphlx"/>
<result property="xqid" column="xqid"/>
<result property="sj" column="sj"/>
<result property="xq" column="xq"/>
<result property="xzqh" column="xzqh"/>
<result property="jwsmc" column="jwsmc"/>
<result property="dzdm" column="dzdm"/>
<result property="jlxdm" column="jlxdm"/>
<result property="ssxqbm" column="ssxqbm"/>
<result property="xzqhname" column="xzqhname"/>
<result property="dzgsdw" column="dzgsdw"/>
<result property="xtZhxgsj" column="xt_zhxgsj"/>
</resultMap>
</mapper>

View File

@ -1,30 +1,132 @@
package net.shapelight;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import net.shapelight.common.utils.RedisUtils;
import net.shapelight.modules.sys.entity.SysUserEntity;
import org.apache.commons.lang.builder.ToStringBuilder;
import net.shapelight.modules.ten.entity.TenAddressEntity;
import net.shapelight.modules.ten.service.TenAddressService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;
@RunWith(SpringRunner.class)
@SpringBootTest
public class RedisTest {
@Autowired
private RedisUtils redisUtils;
@Autowired
private TenAddressService tenAddressService;
@Test
public void contextLoads() {
SysUserEntity user = new SysUserEntity();
user.setEmail("123456@qq.com");
redisUtils.set("user", user);
// SysUserEntity user = new SysUserEntity();
// user.setEmail("123456@qq.com");
// redisUtils.set("user", user);
//
// SysUserEntity ss = (SysUserEntity) redisUtils.get("user");
// System.out.println(ss.getEmail());
//
//// System.out.println(ToStringBuilder.reflectionToString(redisUtils.get("user", SysUserEntity.class)));
try {
// String src = "D:\\VsCode\\11.18\\anputest.js";
// File file = new File(src);
// String js = FileUtils.readFileToString(src,"utf-8");
String src = "/home/huangyifang/gb/社区/oufeng";
File file = new File(src);
FileReader fileReader = new FileReader(file);
BufferedReader br = new BufferedReader(fileReader);
StringBuilder sb = new StringBuilder();
String temp = "";
while ((temp = br.readLine()) != null) {
// 拼接换行符
sb.append(temp + "\n");
}
br.close();
String js = sb.toString();
System.out.println(js);
JSONObject xml = JSONObject.parseObject(js);
JSONArray hlwtable = xml.getJSONObject("xml").getJSONObject("data").getJSONArray("HLWTable");
List<TenAddressEntity> list = new ArrayList<>();
for(int i = 0;i<hlwtable.size();i++){
JSONObject object = (JSONObject) hlwtable.get(i);
/*
{
"@JWSID": "610113600000000001202",
"@SWJID": "610113003012013",
"@SSXQBM": "A61011304538",
"@XZQHNAME": "西安市雁塔区",
"@DZSC": "",
"@DZQC": "陕西省西安市雁塔区长安南路439号1栋1单元2层1121号",
"@P_ID": "1820580963",
"@JLXMC": "长安南路",
"@WD": "34.206951",
"@DZJB": "14",
"@MPHLX": "10",
"@XQID": "610113600000000004538",
"@DZGSDW": "610113600000",
"@XT_ZHXGSJ": "2021-03-23 16: 50: 08",
"@SJ": "",
"@XZQH": "610113",
"@XQ": "欧风园小区",
"@JD": "108.942541",
"@JWSMC": "陕师大警务室",
"@DZDM": "000268000029000010000001000002000001",
"@JLXDM": "000268"
}
*/
TenAddressEntity addressEntity = new TenAddressEntity();
addressEntity.setJwsid(object.getString("@JWSID"));
addressEntity.setSwjid(object.getString("@SWJID"));
addressEntity.setSsxqbm(object.getString("@SSXQBM"));
addressEntity.setXzqhname(object.getString("@XZQHNAME"));
addressEntity.setDzsc(object.getString("@DZSC"));
addressEntity.setDzqc(object.getString("@DZQC"));
addressEntity.setPId(Long.parseLong(object.getString("@P_ID")));
addressEntity.setJlxmc(object.getString("@JLXMC"));
addressEntity.setWd(object.getString("@WD"));
addressEntity.setDzjb(object.getString("@DZJB"));
addressEntity.setMphlx(object.getString("@MPHLX"));
addressEntity.setXqid(object.getString("@XQID"));
addressEntity.setDzgsdw(object.getString("@DZGSDW"));
addressEntity.setXtZhxgsj(object.getString("@XT_ZHXGSJ"));
addressEntity.setSj(object.getString("@SJ"));
addressEntity.setXzqh(object.getString("@XZQH"));
addressEntity.setXq(object.getString("@XQ"));
addressEntity.setJd(object.getString("@JD"));
addressEntity.setJwsmc(object.getString("@JWSMC"));
addressEntity.setDzdm(object.getString("@DZDM"));
addressEntity.setJlxdm(object.getString("@JLXDM"));
list.add(addressEntity);
tenAddressService.save(addressEntity);
}
System.out.println("");
// tenAddressService.saveBatch(list);
}catch (Exception e){
}
SysUserEntity ss = (SysUserEntity) redisUtils.get("user");
System.out.println(ss.getEmail());
// System.out.println(ToStringBuilder.reflectionToString(redisUtils.get("user", SysUserEntity.class)));
}
}