|
|
@@ -103,7 +103,7 @@ public class SlOpendoorApplyServiceImpl implements ISlOpendoorApplyService {
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
+ //@Transactional(rollbackFor = Exception.class)
|
|
|
public int insertSlOpendoorApply(SlOpendoorApply slOpendoorApply) {
|
|
|
|
|
|
SysUser sysUser = tokenService.getLoginUser().getSysUser();
|
|
|
@@ -120,17 +120,6 @@ public class SlOpendoorApplyServiceImpl implements ISlOpendoorApplyService {
|
|
|
throw new ServiceException("申请人:" + sysUser.getNickName() + "电话为空!");
|
|
|
}
|
|
|
|
|
|
- R<SysUser> r = remoteUserService.getUserInfoByUserId(slOpendoorApply.getUserId2(), "inner");
|
|
|
- if (StringUtils.isEmpty(r.getData().getPhonenumber())) {
|
|
|
- throw new ServiceException("申请人:" + r.getData().getNickName() + "电话为空!");
|
|
|
- }
|
|
|
-
|
|
|
- slOpendoorApply.setUserId2(r.getData().getUserId());
|
|
|
- slOpendoorApply.setUserName2(r.getData().getNickName());
|
|
|
- slOpendoorApply.setUserCode2(r.getData().getUserName());
|
|
|
- slOpendoorApply.setUserSex2(r.getData().getSex() == null ? 1 : Integer.valueOf(sysUser.getSex()));
|
|
|
- slOpendoorApply.setPhonenumber2(r.getData().getPhonenumber());
|
|
|
-
|
|
|
slOpendoorApply.setUserId(sysUser.getUserId());
|
|
|
slOpendoorApply.setUserName(sysUser.getNickName());
|
|
|
slOpendoorApply.setDeptId(sysUser.getDept().getDeptId());
|
|
|
@@ -211,8 +200,6 @@ public class SlOpendoorApplyServiceImpl implements ISlOpendoorApplyService {
|
|
|
log.info("========开始门锁授权===========");
|
|
|
//人员1 授权结果
|
|
|
Boolean auths1=false;
|
|
|
- //人员2授权结果
|
|
|
- Boolean auths2=false;
|
|
|
//返回值
|
|
|
String strMsg="ok";
|
|
|
try {
|
|
|
@@ -250,42 +237,9 @@ public class SlOpendoorApplyServiceImpl implements ISlOpendoorApplyService {
|
|
|
auths1=true;
|
|
|
}
|
|
|
|
|
|
- //人员1 备注详情
|
|
|
- detalisMap.put("人员1",opendoorApply.getUserName());
|
|
|
- detalisMap.put("锁编1号",listsubRla.get(0).getLockCode());
|
|
|
- detalisMap.put("人员1密码",map1.get("password"));
|
|
|
-
|
|
|
- //学号、工号
|
|
|
- user.setPersoncode(opendoorApply.getUserCode2());
|
|
|
- //姓名
|
|
|
- user.setPersonname(opendoorApply.getUserName2());
|
|
|
- //性别 (0=女,1=男)
|
|
|
- user.setPersonsex(opendoorApply.getUserSex2()==null?1+"":0+"");
|
|
|
- //人员类别(1=学生,2=教职工,3=临时人员)
|
|
|
- user.setPersontype("1");
|
|
|
- //电话
|
|
|
- user.setPersonmobile(opendoorApply.getPhonenumber2());
|
|
|
-
|
|
|
- log.info("=======人员2授权开始========");
|
|
|
- Map<String,Object> map2= SmartlockUtil.addUser(user,listsubRla.get(1).getLockRoomId());
|
|
|
-
|
|
|
- //人员2 备注详情
|
|
|
- detalisMap.put("人员2",opendoorApply.getUserName());
|
|
|
- detalisMap.put("锁编2号",listsubRla.get(1).getLockCode());
|
|
|
- detalisMap.put("人员2密码",map2.get("password"));
|
|
|
- if(!SmartlockUtil.resultMsg.equals(map2.get("resultMsg").toString())){
|
|
|
- log.info("人员2:"+opendoorApply.getUserName()+",授权失败,原因:"+map2.get("resultMsg")+",请联系管理员");
|
|
|
- strMsg="人员:"+opendoorApply.getUserName()+",授权失败,原因:"+map2.get("resultMsg")+",请联系管理员";
|
|
|
- return strMsg;
|
|
|
- }else {
|
|
|
- log.info("=======人员2授权成功========");
|
|
|
- auths2=true;
|
|
|
- }
|
|
|
-
|
|
|
- log.info("=======授权结束========人员1授权结果:"+auths1+" ,人员2授权结果:"+auths2);
|
|
|
+ log.info("=======授权结束========人员授权结果:"+auths1);
|
|
|
//人员入住办理成功,发送短信提示
|
|
|
- if(auths1 && auths2){
|
|
|
- log.info("=============双人授权成功,下发短信================");
|
|
|
+ if(auths1){
|
|
|
SlSubjectRelationVo relationVo = new SlSubjectRelationVo();
|
|
|
relationVo.setSubjectId(opendoorApply.getSubjectId());
|
|
|
List<SlSubjectRelationVo> relist = slSubjectRelationMapper.selectSlSubjectRelationList(relationVo);
|
|
|
@@ -294,30 +248,23 @@ public class SlOpendoorApplyServiceImpl implements ISlOpendoorApplyService {
|
|
|
throw new ServiceException("该实验室暂未关联双门锁。");
|
|
|
}
|
|
|
|
|
|
- if(StringUtils.isNotEmpty(relist.get(0).getSafeUserPhone())){
|
|
|
- R r1= remoteStockService.sendSydSms(
|
|
|
- "【实验室安全系统】" + opendoorApply.getUserName() + "申请" +
|
|
|
- opendoorApply.getSubjectName() +
|
|
|
- "-门禁远程授权,手机号:"+opendoorApply.getPhonenumber()+",授权码:"+map1.get("password")+
|
|
|
- "("+ SmartlockUtil.authsLength+"小时内有效),请勿泄露给他人。",
|
|
|
- 3, opendoorApply.getId(), relist.get(0).getSafeUserPhone());
|
|
|
- log.info("人员1短信发送结果:"+r1);
|
|
|
- }else {
|
|
|
- log.info("安全负责人电话为空:"+relist.get(0).getSafeUserName());
|
|
|
+ for (SlSubjectRelationVo rvo:relist) {
|
|
|
+ if(opendoorApply.getSafeUserId().equals(String.valueOf(rvo.getSubjectId())) ){
|
|
|
+ log.info("=============授权成功,下发短信================");
|
|
|
+ //人员1 备注详情
|
|
|
+ detalisMap.put("人员",opendoorApply.getUserName());
|
|
|
+ detalisMap.put("锁编号",rvo.getLockCode());
|
|
|
+ detalisMap.put("人员密码",map1.get("password"));
|
|
|
+
|
|
|
+ R r1= remoteStockService.sendSydSms(
|
|
|
+ "【实验室安全系统】" + opendoorApply.getUserName() + "申请" +
|
|
|
+ opendoorApply.getSubjectName() +
|
|
|
+ "-门禁远程授权,手机号:"+opendoorApply.getPhonenumber()+",授权码:"+map1.get("password")+
|
|
|
+ "("+ SmartlockUtil.authsLength+"小时内有效),请勿泄露给他人。",
|
|
|
+ 3, opendoorApply.getId(), rvo.getSafeUserPhone());
|
|
|
+ log.info("人员1短信发送结果:"+r1);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- if(StringUtils.isNotEmpty(relist.get(1).getSafeUserPhone())){
|
|
|
- R r2= remoteStockService.sendSydSms(
|
|
|
- "【实验室安全系统】" + opendoorApply.getUserName2() + "申请" +
|
|
|
- opendoorApply.getSubjectName() +
|
|
|
- "-门禁远程授权,手机号:"+opendoorApply.getPhonenumber2()+",授权码:"+map2.get("password")+
|
|
|
- "("+ SmartlockUtil.authsLength+"小时内有效),请勿泄露给他人。",
|
|
|
- 3, opendoorApply.getId(), relist.get(1).getSafeUserPhone());
|
|
|
- log.info("人员2短信发送结果:"+r2);
|
|
|
- }else{
|
|
|
- log.info("安全负责人电话为空:"+relist.get(1).getSafeUserName());
|
|
|
- }
|
|
|
-
|
|
|
}
|
|
|
opendoorApply.setIllustrate(detalisMap.toString());
|
|
|
slOpendoorApplyMapper.updateSlOpendoorApply(opendoorApply);
|