修复bug:1运行运营商添加设备先判断是否平台已经添加2批量删除人员大于23条后sql函数拼接限制3平台用户不能禁用自己4添加用户redis缓存bug

This commit is contained in:
gaoben 2021-04-07 19:07:27 +08:00
parent f76bf8491b
commit 2fab6df4a4
13 changed files with 527 additions and 185 deletions

View File

@ -252,4 +252,93 @@ public class CarOpenApi {
res.put("msg", "成功");
return res;
}
@PostMapping({"/pushCarRecord"})
@ApiOperation("第三方推送")
public Map pushCarRecord(@RequestBody Object object) {
Map<String, String> res = new HashMap<>();
res.put("code", "401");
res.put("msg", "签名结果不一致");
JSONObject msgJson = (JSONObject)JSONObject.toJSON(object);
log.debug("收到数据"+ msgJson.toString());
String sign = msgJson.getString("sign");
String pid = msgJson.getString("pid");
Long timestamp = msgJson.getLong("timestamp");
String serviceName = msgJson.getString("serviceName");
JSONObject bizContent = msgJson.getJSONObject("bizContent");
String parkCode = bizContent.getString("parkCode");
String parkName = bizContent.getString("parkName");
String orderNum = bizContent.getString("orderNum");
String plateNum = bizContent.getString("plateNum");
String channelName = bizContent.getString("channelName");
int type = bizContent.getIntValue("type");
int carType = bizContent.getIntValue("carType");
String imgUrl = bizContent.getString("imgUrl");
String fileName = "car/" + parkCode + "/" + UUIDUtil.uuid() + ".jpg";
if (!StringUtils.isEmpty(imgUrl)) {
URL url = null;
InputStream is = null;
HttpURLConnection httpUrl = null;
try {
url = new URL(imgUrl);
httpUrl = (HttpURLConnection)url.openConnection();
httpUrl.connect();
httpUrl.getInputStream();
is = httpUrl.getInputStream();
PutObjectOptions putObjectOptions = new PutObjectOptions(is.available(), -1L);
putObjectOptions.setContentType("image/jpeg");
this.minioClient.putObject(this.minioConfig
.getBucketName(), fileName, is, putObjectOptions);
} catch (Exception e) {
e.printStackTrace();
fileName = "";
} finally {
if (is != null)
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
if (httpUrl != null)
httpUrl.disconnect();
}
}
if (serviceName.equals("enter")) {
long enterTimeLong = bizContent.getLongValue("enterTime");
Date enterTime = new Date(enterTimeLong * 1000L);
TenPackRecordEnterEntity enter = new TenPackRecordEnterEntity();
enter.setParkCode(parkCode);
enter.setParkName(parkName);
enter.setOrderNumber(orderNum);
enter.setPlateNumber(plateNum);
enter.setChannelName(channelName);
enter.setType(Integer.valueOf(type));
enter.setCarType(Integer.valueOf(carType));
enter.setEnterTime(enterTime);
if (fileName.length() > 0)
enter.setImage(fileName);
this.tenPackRecordEnterService.save(enter);
} else if (serviceName.equals("exit")) {
long exitTimeLong = bizContent.getLongValue("exitTime");
Date exitTime = new Date(exitTimeLong * 1000L);
long parkTime = bizContent.getLongValue("parkTime");
TenPackRecordExitEntity exit = new TenPackRecordExitEntity();
exit.setParkCode(parkCode);
exit.setParkName(parkName);
exit.setOrderNumber(orderNum);
exit.setPlateNumber(plateNum);
exit.setChannelName(channelName);
exit.setType(Integer.valueOf(type));
exit.setCarType(Integer.valueOf(carType));
exit.setExitTime(exitTime);
exit.setPackTime(Long.valueOf(parkTime));
if (fileName.length() > 0)
exit.setImage(fileName);
this.tenPackRecordExitService.save(exit);
}
res.put("code", "200");
res.put("msg", "成功");
return res;
}
}

View File

@ -13,12 +13,14 @@ import java.util.ArrayList;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import net.shapelight.common.utils.StringUtils;
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 net.shapelight.modules.xian.service.XaApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -34,111 +36,167 @@ public class XaAddressTask implements ITask {
@Autowired
private TenAddressService tenAddressService;
//
public void run(String params) {
log.debug("xaApiTask定时任务正在执行", params);
log.debug("获取标准地址定时任务正在执行", params);
List<SysUserEntity> allSysTenUser = this.sysUserService.findAllSysTenUser();
for (SysUserEntity sysTenUser : allSysTenUser) {
//open_id 是json串
if (sysTenUser.getOpenId() != null && sysTenUser.getOpenId().length() > 0) {
JSONObject object = JSONObject.parseObject(sysTenUser.getOpenId());
Integer type = object.getInteger("type");
JSONObject objectOpenId = JSONObject.parseObject(sysTenUser.getOpenId());
Integer type = objectOpenId.getInteger("type");
if (type.intValue() == 1) {
String appId = object.getString("appId");
String appSecret = object.getString("appSecret");
String appId = objectOpenId.getString("appId");
String appSecret = objectOpenId.getString("appSecret");
List<TenCellEntity> allCells = this.tenCellService.list((Wrapper) (new QueryWrapper())
.eq("tenant_id", sysTenUser.getTenantId()));
for (TenCellEntity cellEntity : allCells) {
String xqid = cellEntity.getThirdId();
if (xqid == null || xqid.length() > 0) ;
if (xqid != null && xqid.length() > 0) {
//调用第三方接口获取所有信息
//6.1 获取标准地址接口---------------------------------------------------------------------------
// String address = XaApi.getAddress(xqid, appId, appSecret);
// String address = "{\"xml\":{\"data\":\"信息验证失败\"}}";
String address = "{\"xml\":{\"data\":{\"NEXTPAGE\":\"END\",\"HLWTable\":[{\"@JWSID\":\"610113600000000001202\",\"@SWJID\":\"610113003012013\",\"@SSXQBM\":\"A61011304538\",\"@XZQHNAME\":\"西安市雁塔区\",\"@DZSC\":\"殴风园\",\"@DZQC\":\"陕西省西安市雁塔区长安南路439号\",\"@P_ID\":\"1544038\",\"@JLXMC\":\"长安南路\",\"@WD\":\"34.207728945844494\",\"@DZJB\":\"10\",\"@MPHLX\":\"10\",\"@XQID\":\"610113600000000004538\",\"@DZGSDW\":\"610113600000\",\"@XT_ZHXGSJ\":\"2021-03-23 16:50:08\",\"@SJ\":\"\",\"@XZQH\":\"610113\",\"@XQ\":\"欧风园小区\",\"@JD\":\"108.94238923458721\",\"@JWSMC\":\"陕师大警务室\",\"@DZDM\":\"000268000029\",\"@JLXDM\":\"000268\"},{\"@JWSID\":\"610113600000000001202\",\"@SWJID\":\"610113003012013\",\"@SSXQBM\":\"A61011304538\",\"@XZQHNAME\":\"西安市雁塔区\",\"@DZSC\":\"\",\"@DZQC\":\"陕西省西安市雁塔区长安南路439号1栋\",\"@P_ID\":\"1820578255\",\"@JLXMC\":\"长安南路\",\"@WD\":\"34.206951\",\"@DZJB\":\"11\",\"@MPHLX\":\"10\",\"@XQID\":\"610113600000000004538\",\"@DZGSDW\":\"610113600000\",\"@XT_ZHXGSJ\":\"2021-03-23 16:50:08\",\"@SJ\":\"\",\"@XZQH\":\"610113\",\"@XQ\":\"欧风园小区\",\"@JD\":\"108.942541\",\"@JWSMC\":\"陕师大警务室\",\"@DZDM\":\"000268000029000010\",\"@JLXDM\":\"000268\"}]}}}";
log.debug("获取小区标准地址-" + cellEntity.getName() + ":返回数据" + address);
//解析json
JSONObject xml = JSONObject.parseObject(address);
if (xml == null) {
continue;
}
JSONObject data = xml.getJSONObject("xml").getJSONObject("data");
if (data == null) {
continue;
}
JSONArray hlwtable = data.getJSONArray("HLWTable");
if (hlwtable == null) {
continue;
}
// List<TenAddressEntity> list = new ArrayList<>();
for (int i = 0; i < hlwtable.size(); i++) {
JSONObject object = (JSONObject) hlwtable.get(i);
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);
}
}
}
}
}
}
try {
// String src = "D:\\VsCode\\11.18\\anputest.js";
// try {
// String src = "/home/huangyifang/gb/社区/oufeng";
// 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定时任务执行完毕");
// 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("获取标准地址定时任务执行完毕");
}
}

View File

@ -4,6 +4,7 @@ package net.shapelight.modules.job.task;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
@ -14,21 +15,12 @@ import lombok.extern.slf4j.Slf4j;
import net.shapelight.common.utils.DateUtils;
import net.shapelight.modules.sys.entity.SysUserEntity;
import net.shapelight.modules.sys.service.SysUserService;
import net.shapelight.modules.ten.entity.TenCellEntity;
import net.shapelight.modules.ten.entity.TenDeviceEntity;
import net.shapelight.modules.ten.entity.TenPersonEntity;
import net.shapelight.modules.ten.entity.TenRoomEntity;
import net.shapelight.modules.ten.service.TenCellService;
import net.shapelight.modules.ten.service.TenDeviceService;
import net.shapelight.modules.ten.service.TenDoorCardService;
import net.shapelight.modules.ten.service.TenPersonService;
import net.shapelight.modules.ten.service.TenRoomService;
import net.shapelight.modules.ten.entity.*;
import net.shapelight.modules.ten.service.*;
import net.shapelight.modules.xian.service.XaApi;
import net.shapelight.modules.xian.vo.XaMJKXX;
import net.shapelight.modules.xian.vo.XaMJSBXX;
import net.shapelight.modules.xian.vo.XaPages;
import net.shapelight.modules.xian.vo.XaSYFW;
import net.shapelight.modules.xian.vo.XaSYRK;
import net.shapelight.modules.xian.utils.AESUtils;
import net.shapelight.modules.xian.utils.XaUtils;
import net.shapelight.modules.xian.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -44,11 +36,12 @@ public class XaRealDataTask implements ITask {
@Autowired
private TenPersonService tenPersonService;
@Autowired
private TenDoorCardService tenDoorCardService;
@Autowired
private TenDeviceService tenDeviceService;
@Autowired
private TenAddressService tenAddressService;
public void run(String params) {
log.debug("xaApiTask定时任务正在执行", params);
log.debug("一标三实定时任务正在执行", params);
List<SysUserEntity> allSysTenUser = this.sysUserService.findAllSysTenUser();
for (SysUserEntity sysTenUser : allSysTenUser) {
if (sysTenUser.getOpenId() != null && sysTenUser.getOpenId().length() > 0) {
@ -57,18 +50,22 @@ public class XaRealDataTask implements ITask {
if (type.intValue() == 1) {
String appId = object.getString("appId");
String appSecret = object.getString("appSecret");
String fwikUrl = "http://";
if (fwikUrl != null) {
List<TenCellEntity> allCells = this.tenCellService.list((Wrapper)(new QueryWrapper())
//6.2 获取数据对接接口---------------------------------------------------------------------------
// String fwikUrl = XaApi.getFwikUrl(appId, appSecret);
String fwikUrl = "http://";
if (fwikUrl != null) {
List<TenCellEntity> allCells = this.tenCellService.list((Wrapper) (new QueryWrapper())
.eq("tenant_id", sysTenUser.getTenantId()));
for (TenCellEntity cellEntity : allCells) {
String xqid = cellEntity.getThirdId();
Long cellId = cellEntity.getCellId();
if (xqid != null && xqid.length() > 0) {
processRealRoom(appId, appSecret, xqid, fwikUrl, cellId);
processRealPerson(appId, appSecret, xqid, fwikUrl, cellId);
processDoorCard(appId, appSecret, xqid, fwikUrl, cellId);
processRealPerson(appId, appSecret, xqid, fwikUrl, cellId);
processDevice(appId, appSecret, xqid, fwikUrl, cellId);
}
}
@ -76,105 +73,276 @@ public class XaRealDataTask implements ITask {
}
}
}
log.debug("xaApiTask定时任务执行完毕");
log.debug("一标三实定时任务执行完毕");
}
private void processRealRoom(String appId, String appSecret, String xqid, String fwikUrl, Long cellId) {
List<TenRoomEntity> rooms = this.tenRoomService.getNotSync(cellId);
List<XaSYFW> syncRooms = new ArrayList();
List<TenRoomEntity> updateRooms = new ArrayList<>();
int count = 0;
for (TenRoomEntity room : rooms) {
TenPersonEntity owner = this.tenPersonService.getOwner(room.getRoomId());
if (owner != null) {
XaSYFW realRoom = new XaSYFW();
realRoom.setLV_FWLB("1");
realRoom.setLV_FWXZ("2");
realRoom.setLV_FWYT("4");
realRoom.setLV_SFCZF("");
realRoom.setLV_FZ_GMSFHM(owner.getIdCard());
realRoom.setLV_FZ_XM(owner.getName());
realRoom.setLV_FZ_ZJZL("10");
realRoom.setLV_FZ_ZJHM(owner.getIdCard());
realRoom.setLV_FZ_LXDH(owner.getMobile());
realRoom.setLV_DJSJ(DateUtils.format(new Date(), "yyyyMMddHHmmss"));
realRoom.setLV_FWXZZ("1000");
realRoom.setLV_FWJG("1");
realRoom.setLV_COMPUTERID(xqid);
realRoom.setLV_PROCMODE("PMINSERT");
syncRooms.add(realRoom);
TenAddressEntity addressEntity = tenAddressService.getById(room.getPId());
if (owner != null && addressEntity != null) {
XaSYFW xaSYFW = new XaSYFW();
xaSYFW.setLV_FWBM(String.format("%s%011d", addressEntity.getXqid(), addressEntity.getPId()));//xqid(21)+0+P_ID
xaSYFW.setLV_DZBM(addressEntity.getDzdm());
xaSYFW.setLV_DZMC(addressEntity.getDzqc());
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(owner.getIdCard());//房主公民身份证
xaSYFW.setLV_FZ_XM(owner.getName());
xaSYFW.setLV_FZ_ZJZL("10");//房主证件类型
xaSYFW.setLV_FZ_ZJHM(owner.getIdCard());//房主证件号码
xaSYFW.setLV_FZ_LXDH(owner.getMobile());//联系电话
// 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(addressEntity.getSsxqbm());//SSXQBM
xaSYFW.setLV_PROCMODE("PMINSERT");
// 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);
updateRooms.add(room);
count++;
if (count >= 60)
if (count >= 50)
break;
}
}
Map<String, Object> xaData = new HashMap<>();
if (syncRooms.size() > 0)
xaData.put("datas", syncRooms);
XaPages xapage = new XaPages();
xapage.setPno("1");
// xapage.setPsize(count);
// xapage.setTcount(0);
// xapage.setTsize(0);
String realRoomRes = XaApi.postData(fwikUrl, appId, appSecret, "1", "SYFW", "SYFW", xaData);
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 enJson = XaUtils.encryptStr(json.trim(), appSecret);
// String resJson = XaApi.httpPOSTJson(fwikUrl, enJson, "SYFW", "SYFW", appId, appSecret);
// String resJons = "{\"sta\":{\"code\":\"0000\",\"des\":\"成功\",\"ErrorLineParameter\":\"empty\"},\"datas\":[{\"Result\":\"接收成功\"}],\"pages\":[{\"psize\":\"1\",\"tcount\":\"1\",\"pno\":\"1\",\"tsize\":\"0\"}]}";
String resJons = "23232";
// System.out.println(s);
log.debug("上传实有房屋返回数据:" + resJons);
//上传成功修改sync状态
if (resJons.contains("\"code\":\"0000\"")) {
for (TenRoomEntity room : updateRooms) {
room.setXaSync(1);
tenRoomService.updateById(room);
}
}
}
private void processRealPerson(String appId, String appSecret, String xqid, String fwikUrl, Long cellId) {
List<TenPersonEntity> realPersons = this.tenPersonService.getNotSync(cellId);
List<XaSYRK> syncPersons = new ArrayList<>();
List<TenPersonEntity> persons = this.tenPersonService.getNotSync(cellId);
List<XaSYRK> syncPersons = new ArrayList();
List<TenPersonEntity> updatePersons = new ArrayList<>();
int count = 0;
for (TenPersonEntity person : realPersons) {
TenRoomEntity room = this.tenRoomService.getById(person.getRoomId(), person.getCellId());
for (TenPersonEntity person : persons) {
XaSYRK realPerson = new XaSYRK();
realPerson.setLV_GMSFHM(person.getIdCard());
realPerson.setLV_XM(person.getName());
TenRoomEntity roomEntity = tenRoomService.getById(person.getRoomId(), person.getCellId());
TenAddressEntity addressEntity = tenAddressService.getById(roomEntity.getRoomId());
String idcard = person.getIdCard();
if (idcard.length() >= 18) {
idcard = idcard.substring(0, 18);
} else {
StringBuffer zeroBuf = new StringBuffer();
for (int i = 0; i < 18 - idcard.length(); i++) {
zeroBuf.append("0");
}
zeroBuf.append(idcard);
idcard = zeroBuf.toString();
}
String syrkbm = String.format("10%s%012d", idcard, addressEntity.getPId());//证件类型10+身份证号(18位)+p_id(12位)
realPerson.setLV_SYRKBM(syrkbm); //实有人口编码
realPerson.setLV_GMSFHM(person.getIdCard()); //身份证号
realPerson.setLV_XM(person.getName()); //姓名
realPerson.setLV_ZJZL("10");
realPerson.setLV_ZJHM(person.getIdCard());
realPerson.setLV_JZDZ_DZBM(room.getDzbm());
realPerson.setLV_ZJHM(person.getIdCard()); //身份证号
realPerson.setLV_JZDZ_DZBM(addressEntity.getDzdm()); //地址编码 DZDM
realPerson.setLV_JZDZ_SSXQ(addressEntity.getXzqh()); //行政区划 XZQH
realPerson.setLV_JZDZ_QHLXXDZ(addressEntity.getDzqc()); //地址名称 DZQC
realPerson.setLV_DJDWGAJGJGMC("西图之光智能科技有限公司"); //承建商名称
realPerson.setLV_DJDWGAJGJGDM("xtzg");
realPerson.setLV_DJSJ(DateUtils.format(new Date(), "yyyyMMddHHmmss"));
realPerson.setLV_COMPUTERID(xqid);
realPerson.setLV_COMPUTERID(xqid); //XQID
realPerson.setLV_PROCMODE("PMINSERT");
syncPersons.add(realPerson);
updatePersons.add(person);
count++;
if (count >= 60)
if (count >= 50)
break;
}
XaData jsonData = new XaData();
jsonData.setDatas(syncPersons);
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 enJson = XaUtils.encryptStr(json.trim(), appSecret);
// String resJson = XaApi.httpPOSTJson(fwikUrl, enJson, "SYRK", "SYRK", appId, appSecret);
// String resJson = "{\"sta\":{\"code\":\"0000\",\"des\":\"成功\",\"ErrorLineParameter\":\"empty\"},\"datas\":[{\"Result\":\"接收成功\"}],\"pages\":[{\"psize\":\"1\",\"tcount\":\"1\",\"pno\":\"1\",\"tsize\":\"0\"}]}";
String resJson = "23232";
// System.out.println(s);
log.debug("上传实有房屋返回数据:" + resJson);
//上传成功修改sync状态
if (resJson.contains("\"code\":\"0000\"")) {
for (TenPersonEntity personEntity : updatePersons) {
personEntity.setXaSync(1);
tenPersonService.updateNonal(personEntity);
}
}
}
private void processDoorCard(String appId, String appSecret, String xqid, String fwikUrl, Long cellId) {
List<TenPersonEntity> realPersons = this.tenPersonService.getNotSyncCard(cellId);
List<XaMJKXX> syncDoorCard = new ArrayList<>();
List<TenPersonEntity> persons = this.tenPersonService.getNotSyncCard(cellId);
List<XaMJKXX> syncDoorCards = new ArrayList<>();
List<TenPersonEntity> updatePersons = new ArrayList<>();
int count = 0;
for (TenPersonEntity person : realPersons) {
for (TenPersonEntity person : persons) {
TenRoomEntity roomEntity = tenRoomService.getById(person.getRoomId(), person.getCellId());
TenAddressEntity addressEntity = tenAddressService.getById(roomEntity.getRoomId());
XaMJKXX realCard = new XaMJKXX();
realCard.setLV_MJKLX("4");
realCard.setLV_DJSJ(DateUtils.format(new Date(), "yyyyMMddHHmmss"));
realCard.setLV_SSXQBM(addressEntity.getSsxqbm());
realCard.setLV_SBXT("10");
realCard.setLV_CKR(person.getIdCard());
realCard.setLV_BH(person.getPersonId().toString());
realCard.setLV_PROCMODE("PMINSERT");
syncDoorCard.add(realCard);
syncDoorCards.add(realCard);
updatePersons.add(person);
count++;
if (count >= 60)
if (count >= 50)
break;
}
XaData jsonData = new XaData();
jsonData.setDatas(syncDoorCards);
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 enJson = XaUtils.encryptStr(json.trim(), appSecret);
// String resJson = XaApi.httpPOSTJson(fwikUrl, enJson, "MJKXX", "MJKXX", appId, appSecret);
// String resJson = "{\"sta\":{\"code\":\"0000\",\"des\":\"成功\",\"ErrorLineParameter\":\"empty\"},\"datas\":[{\"Result\":\"接收成功\"}],\"pages\":[{\"psize\":\"1\",\"tcount\":\"1\",\"pno\":\"1\",\"tsize\":\"0\"}]}";
String resJson = "23232";
// System.out.println(s);
log.debug("上传实有房屋返回数据:" + resJson);
//上传成功修改sync状态
if (resJson.contains("\"code\":\"0000\"")) {
for (TenPersonEntity personEntity : updatePersons) {
personEntity.setXaSyncCard(1);
tenPersonService.updateNonal(personEntity);
}
}
}
private void processDevice(String appId, String appSecret, String xqid, String fwikUrl, Long cellId) {
List<TenDeviceEntity> realDevices = this.tenDeviceService.getNotSync(cellId);
List<TenDeviceEntity> devices = tenDeviceService.getNotSync(cellId);
List<XaMJSBXX> syncDevices = new ArrayList<>();
List<TenDeviceEntity> updateDevices = new ArrayList<>();
int count = 0;
for (TenDeviceEntity device : realDevices) {
for (TenDeviceEntity device : devices) {
TenAddressEntity addressEntity = tenAddressService.getOne(new QueryWrapper<TenAddressEntity>()
.eq("xqid",xqid).last("LIMIT 1"));
String ssxqbm = addressEntity.getSsxqbm();
XaMJSBXX realDevice = new XaMJSBXX();
realDevice.setLV_MJMC(device.getName());
realDevice.setLV_WZMS("1");
realDevice.setLV_SFYSXT("1");
realDevice.setLV_SBXT("10");
realDevice.setLV_MJXTWYBM(device.getSn());
realDevice.setLV_MJMC(device.getName());//门禁名称同一小区不可重复
realDevice.setLV_WZMS("1");//位置描述1门禁终端设备安装在小区的大门2设备安装在小区某栋楼的出入口3设备安装在小区某栋楼的某几个单元的出入口4设备安装在房屋单位学校医院的出入口
realDevice.setLV_SFYSXT("1");//是否有摄像头 1有0无
realDevice.setLV_SSXQBM(ssxqbm);//SSXQBM
realDevice.setLV_SBXT("10");//申报系统默认10
realDevice.setLV_MJXTWYBM(device.getSn());//接入方门禁主键
realDevice.setLV_PROCMODE("PMINSERT");
syncDevices.add(realDevice);
updateDevices.add(device);
count++;
if (count >= 60)
if (count >= 50)
break;
}
XaData jsonData = new XaData();
jsonData.setDatas(syncDevices);
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 enJson = XaUtils.encryptStr(json.trim(), appSecret);
// String resJson = XaApi.httpPOSTJson(fwikUrl, enJson, "MJSBXX", "MJSBXX", appId, appSecret);
// String resJson = "{\"sta\":{\"code\":\"0000\",\"des\":\"成功\",\"ErrorLineParameter\":\"empty\"},\"datas\":[{\"Result\":\"接收成功\"}],\"pages\":[{\"psize\":\"1\",\"tcount\":\"1\",\"pno\":\"1\",\"tsize\":\"0\"}]}";
String resJson = "23232";
// System.out.println(s);
log.debug("上传实有房屋返回数据:" + resJson);
//上传成功修改sync状态
if (resJson.contains("\"code\":\"0000\"")) {
for (TenDeviceEntity deviceEntity : updateDevices) {
deviceEntity.setXaSync(1);
tenDeviceService.evictupdateById(deviceEntity);
}
}
}
}

View File

@ -41,12 +41,12 @@ public class MessageServiceImpl implements MessageService {
case CmdConstant.CMD_LOGIN: {
// deviceLogin(ctx, msg.content);
deviceApiService.login(channel,content);
log.debug("登录信息:" + msg.cmd);
log.debug("登录信息:" + content);
break;
}
case CmdConstant.CMD_GETALL: {
log.debug("全量获取:" + msg.cmd);
log.debug("全量获取:" + content);
if(!clientMap.hasUser(channel)){
Result res = Result.error(403,"No permission");
String resContent = JSONObject.toJSONString(res);
@ -58,7 +58,7 @@ public class MessageServiceImpl implements MessageService {
break;
}
case CmdConstant.CMD_GETONE: {
log.debug("获取详情:" + msg.cmd);
log.debug("获取详情:" + content);
deviceApiService.getMemberInfo(channel,content);
if(!clientMap.hasUser(channel)){
Result res = Result.error(403,"No permission");
@ -70,7 +70,7 @@ public class MessageServiceImpl implements MessageService {
break;
}
case CmdConstant.CMD_HART: {
log.debug("收到心跳:" + msg.cmd);
log.debug("收到心跳:" + content);
if(!clientMap.hasUser(channel)){
Result res = Result.error(403,"No permission");
String resContent = JSONObject.toJSONString(res);
@ -83,7 +83,7 @@ public class MessageServiceImpl implements MessageService {
}
case CmdConstant.CMD_UPRECORD: {
log.debug("收到上传记录:" + msg.cmd);
// log.debug("收到上传记录:" + msg.cmd);
if(!clientMap.hasUser(channel)){
Result res = Result.error(403,"No permission");
String resContent = JSONObject.toJSONString(res);
@ -96,7 +96,7 @@ public class MessageServiceImpl implements MessageService {
}
case CmdConstant.CMD_EXTRACT: {
log.debug("提取失败log" + msg.cmd);
// log.debug("提取失败log" + msg.cmd);
if(!clientMap.hasUser(channel)){
Result res = Result.error(403,"No permission");
String resContent = JSONObject.toJSONString(res);
@ -110,43 +110,28 @@ public class MessageServiceImpl implements MessageService {
case CmdConstant.CMD_CONFIG: {
log.debug("配置成功:" + msg.cmd);
break;
}
case CmdConstant.CMD_CHANGE: {
log.debug("人员变更成功:" + msg.cmd);
break;
}
case CmdConstant.CMD_OPENDOOR: {
log.debug("远程开门:" + msg.cmd);
break;
}
case CmdConstant.CMD_RESTART: {
log.debug("重启设备:" + msg.cmd);
break;
}
case CmdConstant.CMD_APPUPDATE: {
log.debug("app升级" + msg.cmd);
break;
}
case CmdConstant.CMD_CLEANDATA: {
log.debug("清除数据:" + msg.cmd);
serverApiService.cleanDataRes(channel,content);
break;
}
case CmdConstant.CMD_ENABLE: {
log.debug("停用设备:" + msg.cmd);
break;
}
default:
log.debug("未知类型:" + msg.cmd);
break;
}
}

View File

@ -114,6 +114,11 @@ public class TenDeviceController extends AbstractController {
if(dev!=null){
return R.error("设备已绑定");
}
SysDeviceEntity sysDeviceEntity = sysDeviceService.getOne(new QueryWrapper<SysDeviceEntity>()
.eq("sn",tenDevice.getSn()));
if(sysDeviceEntity==null){
return R.error("设备未备案,请联系管理员");
}
// tenDeviceService.save(tenDevice);
tenDeviceService.evictSave(tenDevice);
return R.ok();

View File

@ -530,7 +530,9 @@ public class TenPersonController extends AbstractController {
})
public R delete(@RequestBody List<Map<String, String>> params) {
//tenRoomService.removeByIds(Arrays.asList(roomIds));
if(params.size()>20){
return R.error("最多选择20条数据");
}
tenPersonService.removeByIdList(params);
return R.ok();
}

View File

@ -236,6 +236,9 @@ public class TenUserController extends AbstractController {
return R.error("系统管理员禁止修改");
}
}
if(user.getUserId().longValue() == getUserId().longValue()){
return R.error("您不能停用自己");
}
sysUserService.updateById(user);
return R.ok();
}

View File

@ -65,7 +65,7 @@ public interface TenDeviceService extends IService<TenDeviceEntity> {
void evictupdateById(TenDeviceEntity tenDevice);
List<TenDeviceEntity> getNotSync(Long paramLong);
List<TenDeviceEntity> getNotSync(Long cellId);
}

View File

@ -191,6 +191,7 @@ public class TenPersonServiceImpl implements TenPersonService {
@Override
@Transactional(rollbackFor = Exception.class)
@CacheEvict(value = "TenPerson", allEntries = true)
public int save(TenPersonEntity entity) {
String userFileUrl = globalValue.getImagesDir() + "/" +
entity.getCellId().toString() + "/" +

View File

@ -0,0 +1,29 @@
package net.shapelight.modules.xian.service;
public class RunMain {
public static void main(String args[]){
String xqid = "610113600000000004538";
String idcard = "10325219890212";
Long pid = 1820591355l;
String s =String.format("%s%011d",xqid,pid);
String d =String.format("10%s%012d",idcard,pid);//证件类型10+身份证号(18位)+p_id(12位)
System.out.println(d);
if(idcard.length()>=18){
idcard = idcard.substring(0,18);
}else{
StringBuffer zeroBuf = new StringBuffer();
for(int i = 0;i<18-idcard.length();i++){
zeroBuf.append("0");
}
zeroBuf.append(idcard);
idcard = zeroBuf.toString();
}
System.out.println(idcard);
}
}

View File

@ -29,6 +29,7 @@ spring:
max-file-size: 1000MB
max-request-size: 1000MB
enabled: true
file-size-threshold: 1000MB
redis:
database: 0
host: 192.168.50.232

View File

@ -418,6 +418,7 @@
select * from ten_room where delete_flag = 0
and xa_sync = 0
and cell_id = #{cellId}
and p_id is not null
</select>