Commit a001a999 authored by 陈明豪's avatar 陈明豪

Merge remote-tracking branch 'origin/import' into import

parents 7058ef37 05721770
......@@ -35,6 +35,13 @@ public interface IJieLinkService {
*/
public boolean pushModifyUserData(SysUser userData);
/**
* 推送更新的用户信息到接口服务中
* @param userData
* @return
*/
public boolean pushDelUserData(SysUser userData);
/**
* 推送方可邀请记录到接口服务中
......
......@@ -97,7 +97,7 @@ public class JieLinkServiceImpl implements IJieLinkService {
try{
ResponseEntity<JSONObject> responseEntity = restTemplate.postForEntity(uriAddr.toString(), httpEntity, JSONObject.class);
if(HttpStatus.OK.value() ==responseEntity.getStatusCode().value()) {
log.debug("getAppKeyInfo接口返回信息:{0}",responseEntity.getBody().toJSONString());
log.debug("getAppKeyInfo接口返回信息:"+responseEntity.getBody().toJSONString());
JSONObject body = responseEntity.getBody();
if(StringUtils.equals(body.getString("code"),"0")){
List<AppInfoDto> appInfoDtoList = JSONArray.parseArray(body.getJSONArray("data").toJSONString(),AppInfoDto.class);
......@@ -145,7 +145,7 @@ public class JieLinkServiceImpl implements IJieLinkService {
ResponseEntity<JSONObject> responseEntity = restTemplate.postForEntity(uriAddr.toString(), httpEntity, JSONObject.class);
try{
if(HttpStatus.OK.value() ==responseEntity.getStatusCode().value()) {
log.debug("pushAddUserData接口返回信息:{0}",responseEntity.getBody().toJSONString());
log.debug("pushAddUserData接口返回信息:"+responseEntity.getBody().toJSONString());
JieLinkResultDto<JieLinkPersonDto> resultData = JSONObject.toJavaObject(responseEntity.getBody(), JieLinkResultDto.class);
if(StringUtils.equals(resultData.getCode(),"0")){
JieLinkPersonDto persion = resultData.getData();
......@@ -206,7 +206,7 @@ public class JieLinkServiceImpl implements IJieLinkService {
ResponseEntity<JSONObject> responseEntity = restTemplate.postForEntity(uriAddr.toString(), httpEntity, JSONObject.class);
try{
if(HttpStatus.OK.value() ==responseEntity.getStatusCode().value()) {
log.debug("pushModifyUserData接口返回信息:{0}",responseEntity.getBody().toJSONString());
log.debug("pushModifyUserData接口返回信息:"+responseEntity.getBody().toJSONString());
JieLinkResultDto<JieLinkPersonDto> resultData = JSONObject.toJavaObject(responseEntity.getBody(), JieLinkResultDto.class);
if(StringUtils.equals(resultData.getCode(),"0")){
return true;
......@@ -235,6 +235,49 @@ public class JieLinkServiceImpl implements IJieLinkService {
}
}
@Override
public boolean pushDelUserData(SysUser userData) {
if(userData!=null && StringUtils.isNotBlank(userData.getPersonId())){
String apiUri = "/api/base/deleteperson";
HttpHeaders headers = this.loadHeaderHandle();
if(headers!=null){
JSONObject paramMap = new JSONObject();
paramMap.put("personId",userData.getPersonId());
HttpEntity<JSONObject> httpEntity = new HttpEntity<>(paramMap,headers);
StringBuffer uriAddr = new StringBuffer();
uriAddr.append(jieLinkUri).append(apiUri);
ResponseEntity<JSONObject> responseEntity = restTemplate.postForEntity(uriAddr.toString(), httpEntity, JSONObject.class);
try{
if(HttpStatus.OK.value() ==responseEntity.getStatusCode().value()) {
log.debug("pushDelUserData接口返回信息:"+responseEntity.getBody().toJSONString());
JieLinkResultDto<JieLinkPersonDto> resultData = JSONObject.toJavaObject(responseEntity.getBody(), JieLinkResultDto.class);
if(StringUtils.equals(resultData.getCode(),"0")){
return true;
}else{
log.error("pushDelUserData接口返回错误信息:"+resultData.getMsg());
//请求返回结果错误啦
return false;
}
}else{
//请求失败啦
log.error("pushDelUserData接口请求失败");
return false;
}
}catch (Exception ex){
log.error(ex.getMessage(),ex);
return false;
}
}else{
//认证信息获取失败
log.error("pushDelUserData接口获取认证参数失败");
return false;
}
}else{
log.error("当前用户没有捷顺系统的ID,无法更新");
return true;
}
}
/**
* 用户对象转换
* @param userData
......@@ -287,7 +330,7 @@ public class JieLinkServiceImpl implements IJieLinkService {
try{
if(HttpStatus.OK.value() ==responseEntity.getStatusCode().value()) {
//后续处理逻辑
log.debug("pushVisitorData接口返回信息:{0}",responseEntity.getBody().toJSONString());
log.debug("pushVisitorData接口返回信息:"+responseEntity.getBody().toJSONString());
JieLinkResultDto<JSONObject> resultData = JSONObject.toJavaObject(responseEntity.getBody(), JieLinkResultDto.class);
if(StringUtils.equals(resultData.getCode(),"0")){
return true;
......@@ -340,7 +383,7 @@ public class JieLinkServiceImpl implements IJieLinkService {
ResponseEntity<JSONObject> responseEntity = restTemplate.postForEntity(uriAddr.toString(), httpEntity, JSONObject.class);
try{
if(HttpStatus.OK.value() ==responseEntity.getStatusCode().value()) {
log.debug("cancelVisitorData接口返回信息:{0}",responseEntity.getBody().toJSONString());
log.debug("cancelVisitorData接口返回信息:"+responseEntity.getBody().toJSONString());
JieLinkResultDto resultData = JSONObject.toJavaObject(responseEntity.getBody(), JieLinkResultDto.class);
if(StringUtils.equals(resultData.getCode(),"0")){
return true;
......@@ -490,7 +533,7 @@ public class JieLinkServiceImpl implements IJieLinkService {
ResponseEntity<JSONObject> responseEntity = restTemplate.postForEntity(uriAddr.toString(), httpEntity, JSONObject.class);
try{
if(HttpStatus.OK.value() ==responseEntity.getStatusCode().value()) {
log.debug("pullVisitUserQrCode接口返回信息:{0}",responseEntity.getBody().toJSONString());
log.debug("pullVisitUserQrCode接口返回信息:"+responseEntity.getBody().toJSONString());
JieLinkResultDto<JSONObject> resultData = JSONObject.toJavaObject(responseEntity.getBody(), JieLinkResultDto.class);
if(StringUtils.equals(resultData.getCode(),"0")){
JSONObject data = resultData.getData();
......@@ -643,21 +686,24 @@ public class JieLinkServiceImpl implements IJieLinkService {
ResponseEntity<JSONObject> responseEntity = restTemplate.postForEntity(uriAddr.toString(), httpEntity, JSONObject.class);
try{
if(HttpStatus.OK.value() ==responseEntity.getStatusCode().value()) {
log.info("syncDeviceInfo接口返回信息:{0}",responseEntity.getBody().toJSONString());
log.info("syncDeviceInfo接口返回信息:"+responseEntity.getBody().toJSONString());
JSONObject body = responseEntity.getBody();
if(StringUtils.equals(body.getString("code"),"0")){
List<Devices> devicesList =JSONObject.parseArray(body.getString("data"),Devices.class);
if(devicesList!=null && !devicesList.isEmpty()){
List<Devices> searchList = devicesService.findAll(null);
Map<String,Devices> searchMap = new HashMap<>();
for(Devices d: searchList){
searchMap.put(d.getDeviceGuid(),d);
}
for(Devices inDevice:devicesList){
if(searchMap.containsKey(inDevice.getDeviceGuid())){
devicesService.merge(inDevice);
}else{
devicesService.persist(inDevice);
JSONObject data = body.getJSONObject("data");
if(data.containsKey("devices") && StringUtils.isNotBlank(data.getString("devices"))){
List<Devices> devicesList =JSONArray.parseArray(data.getJSONArray("devices").toJSONString(),Devices.class);
if(devicesList!=null && !devicesList.isEmpty()){
List<Devices> searchList = devicesService.findAll(null);
Map<String,Devices> searchMap = new HashMap<>();
for(Devices d: searchList){
searchMap.put(d.getDeviceGuid(),d);
}
for(Devices inDevice:devicesList){
if(searchMap.containsKey(inDevice.getDeviceGuid())){
devicesService.merge(inDevice);
}else{
devicesService.persist(inDevice);
}
}
}
}
......
......@@ -11,7 +11,6 @@ import org.rcisoft.core.util.CyCompareToolUtils;
import org.rcisoft.core.util.CyUserUtil;
import org.rcisoft.core.model.CyPersistModel;
import org.rcisoft.integration.jieLink.service.impl.JieLinkServiceImpl;
import org.rcisoft.sys.constant.CyDictCons;
import org.rcisoft.sys.dictionary.dao.DictDataRepository;
import org.rcisoft.sys.dictionary.entity.DictData;
import org.rcisoft.sys.dictionary.service.DictionaryService;
......@@ -44,11 +43,11 @@ import org.springframework.transaction.annotation.Transactional;
import org.rcisoft.core.model.CyPageInfo;
import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
......@@ -84,6 +83,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserRepositorys, SysUser>
private PasswordEncoder passwordEncoder;
@Value("${cy.init.password}")
private String password;
/**
* 接口密码
*/
@Value("${jieLink.synchronization}")
private boolean synchronization;
/**
* 保存 用户表
......@@ -97,6 +101,16 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserRepositorys, SysUser>
// 如果传入的sysUser有id,则说明传入的用户为访客,则删除其作为访客的数据
if (sysUser.getBusinessId() != null) {
visitPersonRepositorys.delSysUser(Long.valueOf(sysUser.getBusinessId()));
if(synchronization) {
if (!jieLinkService.pushDelUserData(sysUser)) {
try {
throw new CyServiceException(500, "添加员工失败,请稍后重试");
} finally {
//手工回滚异常
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
}
}
}
// 判断是否存在用户
List<SysUser> userList = sysUserRepositorys.querySysUsersByPhone(sysUser.getPhone());
......@@ -109,10 +123,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserRepositorys, SysUser>
}
return new CyPersistModel(1);
} else {
/* //判断手机号在访客中是否重复
if (userList.size() != 0 && userList.get(0).getUserType().equals("1")) {
sysUserRepositorys.delSysUser(Long.valueOf(userList.get(0).getBusinessId()));
}*/
// 新增员工
if (userList.size() > 0) {
throw new CyServiceException(500, "手机号已存在");
......@@ -128,14 +138,16 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserRepositorys, SysUser>
//添加身份
sysUser.setIdentity("1");
sysUserRepositorys.addSysUsers(sysUser);
/* if (!jieLinkService.pushAddUserData(sysUser)) {
try {
throw new CyServiceException(500, "添加员工失败,请稍后重试");
} finally {
//手工回滚异常
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
if (synchronization) {
if (!jieLinkService.pushAddUserData(sysUser)) {
try {
throw new CyServiceException(500, "添加员工失败,请稍后重试");
} finally {
//手工回滚异常
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
}
}*/
}
log.debug(CyUserUtil.getAuthenUsername() + "新增了ID为" +
sysUser.getBusinessId() + "的用户表信息");
return new CyPersistModel(1);
......@@ -147,10 +159,10 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserRepositorys, SysUser>
**/
@Override
public SysUser persistIsVisitPerson(SysUser sysUser) {
List<SysUser> visitPersonList = visitPersonRepositorys.queryVisitPersonByPhone(sysUser.getPhone());
if (visitPersonList.size() > 0) {
sysUser.setBusinessId(visitPersonList.get(0).getBusinessId());
sysUser.setPersonId(visitPersonList.get(0).getPersonId());
}
return sysUser;
}
......@@ -222,14 +234,15 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserRepositorys, SysUser>
}
line = sysUserRepositorys.updateSysUser(sysUser);
// 修改员工和外部系统同步数据
if (sysUser.getUserType().equals("0")) {
/* if(!jieLinkService.pushModifyUserData(sysUser))
if (sysUser.getUserType().equals("0") && synchronization) {
if (!jieLinkService.pushModifyUserData(sysUser)) {
try {
throw new CyServiceException(500, "修改员工失败,请稍后重试");
} finally {
//手工回滚异常
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}*/
}
}
}
log.debug(CyUserUtil.getAuthenUsername() + "修改了ID为" + sysUser.getBusinessId() + "的用户表信息");
return new CyPersistModel(line);
......@@ -305,19 +318,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserRepositorys, SysUser>
sysUserIPage.getRecords().get(i).setDictLabelByPosition(dictLabel);
sysUserIPage.getRecords().get(i).setDictSort(dictSort);
}
/*
//查询班次id
String nltBz = sysUserIPage.getRecords().get(i).getNltBz();
List<SysDictData> sysDictData1 = sysDictDataRepositorys.queryDataByNltBz(nltBz);
if (sysDictData1.size() != 0) {
//查询班次中文名
String dictLabel = sysDictData1.get(0).getDictLabel();
sysUserIPage.getRecords().get(i).setDictLabelBynltBz(dictLabel);
}
//查询园区id
String address = sysUserIPage.getRecords().get(i).getAddress();
*/
}
return sysUserIPage;
}
......
......@@ -48,7 +48,7 @@ public class CheckUtil {
if (StringUtils.isEmpty(sysUser.getName()))
notTrue.add("姓名不能为空");
else if (sysUser.getName().length() > 32)
notTrue.add("姓名超过最大长度");
notTrue.add("姓名超过最大长度32");
if (StringUtils.isEmpty(sysUser.getPhone())) {
notTrue.add("手机号不能为空");
} else {
......
......@@ -235,7 +235,7 @@ public class VisitInfomationController extends CyPaginationController<VisitInfoM
return CyResultGenUtil.builder(new CyPersistModel(1),
CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR,
visitInfomationServiceImpl.importUserExcel(file,response));
visitInfomationServiceImpl.importUserExcel(file, response));
}
@CyOpeLogAnno(title = "内勤系统-用户管理-导出用户", businessType = CyLogTypeEnum.EXPORT)
......
......@@ -22,6 +22,7 @@ import org.rcisoft.sys.visit.service.VisitUserService;
import org.rcisoft.sys.wbac.user.dto.ErrorDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
......@@ -214,42 +215,12 @@ public class VisitUserServiceImpl extends ServiceImpl<VisitUserRepository, Visit
if (!flag) {
throw new CyServiceException(500, "非模板文件");
}
// if (!flag || !CyCompareToolUtils.compareFileName(file, "访客信息", 0, 0)) {
// String errorBefore = "上传模板错误请重新下载!";
// errorText(errorBefore, importUserDTO, maps, fileName);
// try {
// errorTxt.exportTxtPaper(maps, fileName);
// } catch (Exception e) {
// throw new CyServiceException(CyResSvcExcEnum.EXCEL_IMPORT_HEADER_ERROR);
// }
// return importUserDTO;
// }
/** 从excel表中读到数据,有一部分为空值 */
List<ExportVisitUserDTO> sysUserList = CyEpExcelUtil.importExcel(file, 2, 1, ExportVisitUserDTO.class);
List<ExportVisitUserDTO> addUserList = new ArrayList<>();
/** 遍历 从Excel表中读到的数据 抛出不合适的数据 */
//判断整个Excel是不是为空 计算非空数据有多少条
int information = CyCompareToolUtils.cmpareInformation(sysUserList);
// if (information == 0) {
// String errorBefore = "Excel文件不可为空,请检查Excel文件是否填写!";
// errorText(errorBefore, importUserDTO, maps, fileName);
// try {
// errorTxt.exportTxtPaper(maps, fileName);
// } catch (Exception e) {
// throw new CyServiceException(CyResSvcExcEnum.ERROR_NETWORK);
// }
// return importUserDTO;
// } else if (information > 500) {
// String errorMore = "单次导入数据不可超过500,请检查!";
// errorText(errorMore, importUserDTO, maps, fileName);
// try {
// errorTxt.exportTxtPaper(maps, fileName);
// } catch (Exception e) {
// throw new CyServiceException(CyResSvcExcEnum.ERROR_NETWORK);
// }
// return importUserDTO;
// }
if (information == 0) {
throw new CyServiceException(500, "Excel文件不可为空,请检查Excel文件是否填写!");
} else if (information > 500) {
......@@ -261,20 +232,19 @@ public class VisitUserServiceImpl extends ServiceImpl<VisitUserRepository, Visit
} catch (Exception e) {
throw new CyServiceException(CyResSvcExcEnum.ERROR_NETWORK);
}
//校验 将错误信息放入maps
// int index = 3; //从第3行开始
for (ExportVisitUserDTO sysUser : sysUserList) {
//判断 是否为空
VisitPersonDTO userNull = CheckUtil.visvitNotNull(sysUser);
List sysUsers = sysUserRepositorys.querySysUsersByPhones(sysUser.getPhone());
if (userNull != null) {
visitPersonList.add(userNull);
} else {
addUserList.add(sysUser);
if (sysUsers.size() != 0) {
userNull.setError("已有员工绑定此手机号");
}
visitPersonList.add(userNull);
} else
addUserList.add(sysUser);
// index++;
}
}
}
int i = 0;
......@@ -320,4 +290,10 @@ public class VisitUserServiceImpl extends ServiceImpl<VisitUserRepository, Visit
}
return null;
}
@Async
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
public void updateTest(){
}
}
......@@ -17,8 +17,8 @@ mybatis-plus:
db-config:
logic-delete-value: 1 # 逻辑已删除值(默认为 1)
logic-not-delete-value: 0 # 逻辑未删除值(默认为 0)
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# configuration:
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
spring:
main:
......
......@@ -103,3 +103,4 @@ jieLink:
apiUrl: http://192.168.18.192:8091
account: 9999
pwd: 123456
synchronization: false
......@@ -98,3 +98,4 @@ jieLink:
apiUrl: http://192.168.18.192:8091
account: 9999
pwd: 123456
synchronization: false
......@@ -271,6 +271,7 @@
vi.create_date,
vi.visit_reason,
vi.visit_region,
vi.visit_reason_other,
vi.visit_date,
vi.visit_time,
vi.visit_status,
......@@ -328,7 +329,7 @@
<select id="queryVisitInfomationsByUserIdPaged" resultMap="BaseResultMap">
select
vi.business_id,vi.user_name,vi.dept_name,vi.post_name,vi.visit_reason_other,vi.create_date,vi.visit_reason_code,vi.visit_reason,vi.visit_region_code,vi.visit_region,vi.visit_date,vi.visit_time,vi.visit_status,vi.visit_real_time
vi.business_id,vi.user_name,vi.dept_name,vi.post_name,vi.visit_reason_other,vi.create_date,vi.visit_reason_code,vi.visit_reason,vi.visit_region_code,vi.visit_reason_other,vi.visit_region,vi.visit_date,vi.visit_time,vi.visit_status,vi.visit_real_time
from visit_infomation vi
where 1=1 and del_flag = 0
and vi.user_id = #{userId}
......@@ -402,6 +403,7 @@
vi.visit_real_time
</if>
</if>
order by vi.visit_real_time desc
</select>
<select id="findByUser" resultType="org.rcisoft.sys.visit.entity.VisitInfoMation">
......
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