|
@@ -1,9 +1,11 @@
|
|
package com.boman.web.core.service.czrk;
|
|
package com.boman.web.core.service.czrk;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.boman.common.core.utils.DateUtils;
|
|
import com.boman.common.core.utils.DateUtils;
|
|
import com.boman.common.core.utils.SecurityUtils;
|
|
import com.boman.common.core.utils.SecurityUtils;
|
|
import com.boman.common.core.utils.StringUtils;
|
|
import com.boman.common.core.utils.StringUtils;
|
|
|
|
+import com.boman.common.core.utils.ip.IpUtils;
|
|
import com.boman.common.core.utils.number.NumberUtils;
|
|
import com.boman.common.core.utils.number.NumberUtils;
|
|
import com.boman.common.core.utils.obj.ObjectUtils;
|
|
import com.boman.common.core.utils.obj.ObjectUtils;
|
|
import com.boman.common.core.utils.sql.SqlUtil;
|
|
import com.boman.common.core.utils.sql.SqlUtil;
|
|
@@ -17,6 +19,8 @@ import com.boman.system.api.RemoteDeptService;
|
|
import com.boman.web.core.domain.GridInfo;
|
|
import com.boman.web.core.domain.GridInfo;
|
|
import com.boman.web.core.mapper.CzrkMapper;
|
|
import com.boman.web.core.mapper.CzrkMapper;
|
|
import com.boman.web.core.mapper.GridInfoMapper;
|
|
import com.boman.web.core.mapper.GridInfoMapper;
|
|
|
|
+import com.boman.web.core.service.ip.IpTimesService;
|
|
|
|
+import com.boman.web.core.service.ip.IpTimesServiceImpl;
|
|
import com.boman.web.core.utils.AuthUtils;
|
|
import com.boman.web.core.utils.AuthUtils;
|
|
import com.boman.web.core.utils.IdCardUtils;
|
|
import com.boman.web.core.utils.IdCardUtils;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageHelper;
|
|
@@ -26,6 +30,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Isolation;
|
|
import org.springframework.transaction.annotation.Isolation;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+import org.springframework.web.context.request.RequestContextHolder;
|
|
|
|
+import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.sql.Date;
|
|
import java.sql.Date;
|
|
@@ -39,6 +45,7 @@ import java.util.concurrent.TimeUnit;
|
|
import static com.boman.common.core.utils.StringUtils.isNotEmpty;
|
|
import static com.boman.common.core.utils.StringUtils.isNotEmpty;
|
|
import static com.boman.common.core.utils.fieldTranslator.IdCardUtils.getSex;
|
|
import static com.boman.common.core.utils.fieldTranslator.IdCardUtils.getSex;
|
|
import static com.boman.common.core.utils.obj.ObjectUtils.*;
|
|
import static com.boman.common.core.utils.obj.ObjectUtils.*;
|
|
|
|
+import static com.boman.common.redis.RedisKey.IP_TIMES;
|
|
import static com.boman.common.redis.RedisKey.STS_CZRK_;
|
|
import static com.boman.common.redis.RedisKey.STS_CZRK_;
|
|
import static com.boman.web.core.utils.IdCardUtils.getAge;
|
|
import static com.boman.web.core.utils.IdCardUtils.getAge;
|
|
import static com.google.common.base.Strings.nullToEmpty;
|
|
import static com.google.common.base.Strings.nullToEmpty;
|
|
@@ -66,6 +73,8 @@ public class CzrkServiceImpl implements ICzrkService {
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private GridInfoMapper gridInfoMapper;
|
|
private GridInfoMapper gridInfoMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ private IpTimesService ipTimesService;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 功能描述: 市领导查询,deptId不起作用,具体到村,需要czrk的villageId有值就可以,只是villageId起作用
|
|
* 功能描述: 市领导查询,deptId不起作用,具体到村,需要czrk的villageId有值就可以,只是villageId起作用
|
|
@@ -76,6 +85,8 @@ public class CzrkServiceImpl implements ICzrkService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public List<Czrk> listByRlry(Czrk czrk) {
|
|
public List<Czrk> listByRlry(Czrk czrk) {
|
|
|
|
+ log.info("{}于{}查询常住人员列表,查询条件:{}"
|
|
|
|
+ , AuthUtils.getLoginUser().getSysUser().getUserName(), DateUtils.dateTimeNow(), JSON.toJSONString(czrk));
|
|
setDeptIdList(czrk);
|
|
setDeptIdList(czrk);
|
|
setAgeScope(czrk);
|
|
setAgeScope(czrk);
|
|
|
|
|
|
@@ -123,6 +134,8 @@ public class CzrkServiceImpl implements ICzrkService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<Czrk> listByXz(Czrk czrk) {
|
|
public List<Czrk> listByXz(Czrk czrk) {
|
|
|
|
+ log.info("{}于{}查询新增常住人员列表,查询条件:{}"
|
|
|
|
+ , AuthUtils.getLoginUser().getSysUser().getUserName(), DateUtils.dateTimeNow(), JSON.toJSONString(czrk));
|
|
setDeptIdList(czrk);
|
|
setDeptIdList(czrk);
|
|
|
|
|
|
czrk.setStartTime(DateUtils.getTodayStartStr());
|
|
czrk.setStartTime(DateUtils.getTodayStartStr());
|
|
@@ -135,6 +148,8 @@ public class CzrkServiceImpl implements ICzrkService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<Czrk> listByJs(Czrk czrk) {
|
|
public List<Czrk> listByJs(Czrk czrk) {
|
|
|
|
+ log.info("{}于{}查询减少常住人员列表,查询条件:{}"
|
|
|
|
+ , AuthUtils.getLoginUser().getSysUser().getUserName(), DateUtils.dateTimeNow(), JSON.toJSONString(czrk));
|
|
setDeptIdList(czrk);
|
|
setDeptIdList(czrk);
|
|
|
|
|
|
czrk.setStartTime(DateUtils.getTodayStartStr());
|
|
czrk.setStartTime(DateUtils.getTodayStartStr());
|
|
@@ -257,6 +272,8 @@ public class CzrkServiceImpl implements ICzrkService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public Czrk selectCzrkById(Long id) {
|
|
public Czrk selectCzrkById(Long id) {
|
|
|
|
+ log.info("{}于{}根据id:{},获取信息"
|
|
|
|
+ , AuthUtils.getLoginUser().getSysUser().getUserName(), DateUtils.dateTimeNow(), id);
|
|
Czrk czrk = czrkMapper.selectCzrkById(id);
|
|
Czrk czrk = czrkMapper.selectCzrkById(id);
|
|
if (czrk != null){
|
|
if (czrk != null){
|
|
Long gridId = czrk.getGridId();
|
|
Long gridId = czrk.getGridId();
|
|
@@ -290,6 +307,8 @@ public class CzrkServiceImpl implements ICzrkService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public int insertCzrk(Czrk czrk) {
|
|
public int insertCzrk(Czrk czrk) {
|
|
|
|
+ log.info("{}于{}新增常住人口:{}"
|
|
|
|
+ , AuthUtils.getLoginUser().getSysUser().getUserName(), DateUtils.dateTimeNow(), JSON.toJSONString(czrk));
|
|
return czrkMapper.insertCzrk(czrk);
|
|
return czrkMapper.insertCzrk(czrk);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -301,6 +320,8 @@ public class CzrkServiceImpl implements ICzrkService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public int updateCzrk(Czrk czrk) {
|
|
public int updateCzrk(Czrk czrk) {
|
|
|
|
+ log.info("{}于{}修改常住人口:{}"
|
|
|
|
+ , AuthUtils.getLoginUser().getSysUser().getUserName(), DateUtils.dateTimeNow(), JSON.toJSONString(czrk));
|
|
return czrkMapper.updateCzrk(czrk);
|
|
return czrkMapper.updateCzrk(czrk);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -313,6 +334,8 @@ public class CzrkServiceImpl implements ICzrkService {
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
|
|
@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
|
|
public int deleteCzrk(Czrk czrk) {
|
|
public int deleteCzrk(Czrk czrk) {
|
|
|
|
+ log.info("{}于{}删除常住人口:{}"
|
|
|
|
+ , AuthUtils.getLoginUser().getSysUser().getUserName(), DateUtils.dateTimeNow(), JSON.toJSONString(czrk));
|
|
czrk.setUpdateBy(AuthUtils.getLoginUser().getSysUser().getUserName());
|
|
czrk.setUpdateBy(AuthUtils.getLoginUser().getSysUser().getUserName());
|
|
if (isEmpty(czrk.getDeleteReason())) {
|
|
if (isEmpty(czrk.getDeleteReason())) {
|
|
log.error("删除原因不能为空, id={}", czrk.getId());
|
|
log.error("删除原因不能为空, id={}", czrk.getId());
|
|
@@ -347,6 +370,8 @@ public class CzrkServiceImpl implements ICzrkService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public int reduction(String id) {
|
|
public int reduction(String id) {
|
|
|
|
+ log.info("{}于{}使用回收站还原功能,id:{}"
|
|
|
|
+ , AuthUtils.getLoginUser().getSysUser().getUserName(), DateUtils.dateTimeNow(), id);
|
|
if (isEmpty(id)) return 0;
|
|
if (isEmpty(id)) return 0;
|
|
|
|
|
|
return czrkMapper.reduction(id);
|
|
return czrkMapper.reduction(id);
|
|
@@ -354,6 +379,8 @@ public class CzrkServiceImpl implements ICzrkService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<Czrk> family(String code) {
|
|
public List<Czrk> family(String code) {
|
|
|
|
+ log.info("{}于{}根据户号查找家庭中所有人员,户号:{}"
|
|
|
|
+ , AuthUtils.getLoginUser().getSysUser().getUserName(), DateUtils.dateTimeNow(), code);
|
|
if (isEmpty(code)) {
|
|
if (isEmpty(code)) {
|
|
return Collections.emptyList();
|
|
return Collections.emptyList();
|
|
}
|
|
}
|
|
@@ -972,6 +999,38 @@ public class CzrkServiceImpl implements ICzrkService {
|
|
return hjInfo;
|
|
return hjInfo;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public AjaxResult getInfo(String appKey, String appSecret, String idCard) {
|
|
|
|
+ // checkAuth(appKey, appSecret);
|
|
|
|
+ String ip = IpUtils.getIpAddr(((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
|
|
|
+ JSONObject jsonObject = ipTimesService.getByIp(ip);
|
|
|
|
+ if (jsonObject == null || jsonObject.size() == 0) {
|
|
|
|
+ String errorMsg = "当前ip非法访问, ip: " + ip;
|
|
|
|
+ log.error(errorMsg + "appKey:{}, appSecret:{}, idCard:{}", appKey, appSecret, idCard);
|
|
|
|
+ return AjaxResult.error(errorMsg);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String today = DateUtils.getDate();
|
|
|
|
+ String redisKey = IP_TIMES + jsonObject.getString("ip") + ":" + today;
|
|
|
|
+ Integer cacheTimes = redisService.getCacheObject(redisKey);
|
|
|
|
+ if (cacheTimes == null) cacheTimes = 0;
|
|
|
|
+ int times = jsonObject.getIntValue("times");
|
|
|
|
+ if (++cacheTimes > times) {
|
|
|
|
+ log.error("ip:{}, 时间:{}, 访问超次数, 已经查询了 {} 次", ip, today, cacheTimes);
|
|
|
|
+ return AjaxResult.error("今日访问次数已用尽,请明日再试");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Czrk czrk = czrkMapper.getColumnNamesByIdCard(jsonObject.getString("column_names"), idCard);
|
|
|
|
+ if (czrk == null) {
|
|
|
|
+ log.error("ip:{}, 时间:{}, 根据idCard:{}, 未查询到信息, 已经查询了 {} 次", ip, today, idCard, cacheTimes);
|
|
|
|
+ return AjaxResult.error("根据身份证号码未查询到信息");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ long time = DateUtils.getTodayEnd().getTime(),time1 = DateUtils.getNowDate().getTime();
|
|
|
|
+ redisService.setCacheObject(redisKey, cacheTimes, ((time - time1) / 1000), TimeUnit.SECONDS);
|
|
|
|
+ return AjaxResult.success(czrk);
|
|
|
|
+ }
|
|
|
|
+
|
|
private String packRedisKey(String deptId) {
|
|
private String packRedisKey(String deptId) {
|
|
return STS_CZRK_ + deptId + ":" + DateUtils.getDate();
|
|
return STS_CZRK_ + deptId + ":" + DateUtils.getDate();
|
|
}
|
|
}
|