diff --git a/shapelight-admin/Dockerfile b/shapelight-admin/Dockerfile index 0786a7c..0401696 100644 --- a/shapelight-admin/Dockerfile +++ b/shapelight-admin/Dockerfile @@ -14,7 +14,7 @@ ADD target/shapelight-admin.jar app.jar EXPOSE 8018 # 定义环境变量 -ENV JAVA_OPTS="" +ENV JAVA_OPTS="-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8095" # 在容器启动时运行jar包 ENTRYPOINT exec java $JAVA_OPTS -Djava.security.egd=file:/dev/./cell -jar /app.jar \ No newline at end of file diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/face/FaceEngineAutoRun.java b/shapelight-admin/src/main/java/net/shapelight/modules/face/FaceEngineAutoRun.java index f68757c..3933e0d 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/face/FaceEngineAutoRun.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/face/FaceEngineAutoRun.java @@ -83,7 +83,7 @@ public class FaceEngineAutoRun extends AbstractController implements Application // } - List cellList = tenCellService.list(new QueryWrapper() + /*List cellList = tenCellService.list(new QueryWrapper() .eq("tenant_id","1298283126102949890") .eq("delete_flag",0)); for(TenCellEntity cellEntity: cellList){ @@ -112,6 +112,6 @@ public class FaceEngineAutoRun extends AbstractController implements Application } } log.debug(cellEntity.getName()+":初始化人脸库完成,共 "+faceCount+" 人"); - } + }*/ } } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/job/task/PersonProcessTask.java b/shapelight-admin/src/main/java/net/shapelight/modules/job/task/PersonProcessTask.java index 311fe2e..240ad14 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/job/task/PersonProcessTask.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/job/task/PersonProcessTask.java @@ -50,7 +50,7 @@ public class PersonProcessTask implements ITask { //修改人员表 tenPersonService.updateStatusById(guest); //特征保存到内存 - UserRamGroup.removeUser(guest.getPersonId()+"",guest.getCellId()+""); + //UserRamGroup.removeUser(guest.getPersonId()+"",guest.getCellId()+""); // UserRamCache.removeUser(guest.getPersonId()+""); log.debug("内存删除人员:"+guest.getPersonId()+" 姓名:"+guest.getName()); //修改同步表 diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/sys/service/impl/SysUserServiceImpl.java b/shapelight-admin/src/main/java/net/shapelight/modules/sys/service/impl/SysUserServiceImpl.java index 84a2cab..38d7d8e 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/sys/service/impl/SysUserServiceImpl.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/sys/service/impl/SysUserServiceImpl.java @@ -215,7 +215,7 @@ public class SysUserServiceImpl extends ServiceImpl i userScopeEntity.setUserId(user.getUserId()); - //小区管理员 + /* //小区管理员 if (user.getRoleIdList().get(0).longValue() == Constant.ROLE_TEN_CELL) { TenCellEntity cell = tenCellService.getById(user.getCellId()); userScopeEntity.setAreaId(cell.getAreaId()); @@ -251,7 +251,7 @@ public class SysUserServiceImpl extends ServiceImpl i appUser.setCurrentScopeId(appScope.getUserScopeId()); appUserService.updateById(appUser); - } + }*/ } @Override diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenParentController.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenParentController.java index 4df107e..db0b501 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenParentController.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenParentController.java @@ -84,7 +84,7 @@ public class TenParentController { appUserService.removeById(tenParent.getUserId()); appUserScopeService.remove(new LambdaQueryWrapper() .eq(AppUserScopeEntity::getUserId,tenParent.getUserId())); - relationService.remove(new LambdaQueryWrapper().eq(TenRelation::getParentId,item.get("id"))); + relationService.remove(new LambdaQueryWrapper().eq(TenRelation::getParentId,tenParent.getUserId())); }); opParams.put("dataInfo",dataInfo); JSONObject jsonObject = opFeignClient.submitData(opParams); diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenPersonController.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenPersonController.java index e41df50..58ae7ef 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenPersonController.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenPersonController.java @@ -397,22 +397,23 @@ public class TenPersonController extends AbstractController { } - TenPersonEntity tenPersonEntity = tenPersonService.findByName(tenPerson.getName(), - tenPerson.getRoomId(),tenPerson.getCellId()); - if(tenPersonEntity!=null){ - return R.error("当前学生已存在"); + /*TenPersonEntity tenPersonEntity = tenPersonService.findByName(tenPerson.getName(), + tenPerson.getRoomId(),tenPerson.getCellId());*/ + Integer count = tenPersonService.findByRyId(tenPerson.getRyid()); + if(count!=null&&count>=1){ + return R.error("当前学号已存在"); } if(tenPerson.getIdCard()!=null){ -// TenPersonEntity tenPersonIdcard = tenPersonService.findByIdCard(tenPerson.getIdCard(), -// tenPerson.getRoomId(),tenPerson.getCellId()); -// if(tenPersonIdcard!=null){ -// return R.error("身份证在此房间已存在"); -// } +/* TenPersonEntity tenPersonIdcard = tenPersonService.findByIdCard(tenPerson.getIdCard(), + tenPerson.getRoomId(),tenPerson.getCellId()); + if(tenPersonIdcard!=null){ + return R.error("身份证在此班级已存在"); + }*/ List list = tenPersonService.findByIdCardAndDept(tenPerson.getIdCard(),tenPerson.getDeptId()); if(list.size()>0){ - return R.error("身份证在此组织已存在"); + return R.error("身份证已存在"); } } @@ -449,6 +450,10 @@ public class TenPersonController extends AbstractController { tenPerson.setLastUpdateBy(getUser().getUsername()); tenPerson.setLastUpdateTime(new Date()); tenPerson.setFaceFailure(Constant.FACE_FAILURE_OK); + Integer count = tenPersonService.findByRyId(tenPerson.getRyid()); + if(count!=null&&count>=2){ + return R.error("当前学号已存在"); + } if(tenPerson.getIdCard()!=null){ if(tenPerson.getIdCard().length() == 15){ @@ -690,8 +695,21 @@ public class TenPersonController extends AbstractController { if(params.size()>20){ return R.error("最多选择20条数据"); } - tenPersonService.removeByIdList(params); - return R.ok(); + List> list = new ArrayList<>(); + //params.stream().filter(item -> !relationService.list(new LambdaQueryWrapper().eq(TenRelation::getStudentId,item.get("personId"))).isEmpty()).collect(Collectors.toList()); + Iterator> iterator = params.iterator(); + while (iterator.hasNext()) { + Map item = iterator.next(); + List tenRelations = relationService.list(new LambdaQueryWrapper().eq(TenRelation::getStudentId,item.get("personId")).ne(TenRelation::getStatus,0)); + if(!tenRelations.isEmpty()) { + iterator.remove(); + list.add(item); + } + } + if (!params.isEmpty()) { + tenPersonService.removeByIdList(params); + } + return R.ok().put("data",list); } // public R delete(@RequestBody Map params){ // //tenRoomService.removeByIds(Arrays.asList(roomIds)); diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenRelationController.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenRelationController.java index 7eebae0..984e50f 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenRelationController.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenRelationController.java @@ -64,28 +64,38 @@ public class TenRelationController extends AbstractController { tenRelation.setApprovalTime(new Date()); tenRelation.setApproval(getUser().getRealName()); AppUserEntity appUser = appUserService.getById(tenRelation.getParentId()); - Map opParams = new HashMap<>(); - opParams.put("operation","editUserContactData"); - opParams.put("accountNumber",globalValue.accountNumber); - opParams.put("passKey", KeysEntity.passKey); - opParams.put("empowerText",KeysEntity.empowerText); - List> dataInfo = new ArrayList<>(); - Map info = new HashMap<>(); - info.put("objectUuid",tenRelation.getParentId().toString()); - info.put("userUuid",tenRelation.getStudentId().toString()); - info.put("salutation",tenRelation.getRelation()); - info.put("phoneNumber",appUser.getMobile()); - info.put("orderNumber",1); - dataInfo.add(info); - opParams.put("dataInfo",dataInfo); - JSONObject jsonObject = opFeignClient.submitData(opParams); - if(jsonObject.getString("shrgStatus").equals("S")) { - if(jsonObject.getJSONArray("errInfo").isEmpty()) { - relationService.updateById(tenRelation); + if(tenRelation.getStatus().equals(1)) { + Map opParams = new HashMap<>(); + opParams.put("operation","editUserContactData"); + opParams.put("accountNumber",globalValue.accountNumber); + opParams.put("passKey", KeysEntity.passKey); + opParams.put("empowerText",KeysEntity.empowerText); + List> dataInfo = new ArrayList<>(); + Map info = new HashMap<>(); + info.put("objectUuid",tenRelation.getParentId().toString()); + info.put("userUuid",tenRelation.getStudentId().toString()); + info.put("salutation",tenRelation.getRelation()); + info.put("phoneNumber",appUser.getMobile()); + info.put("orderNumber",1); + dataInfo.add(info); + opParams.put("dataInfo",dataInfo); + JSONObject jsonObject = opFeignClient.submitData(opParams); + if(jsonObject.getString("shrgStatus").equals("S")) { + if(jsonObject.getJSONArray("errInfo").isEmpty()) { + relationService.updateById(tenRelation); + } + }else { + errMsg.add(item.get("id").toString()); } + } else { + relationService.updateById(tenRelation); } }); + if (errMsg.isEmpty()) { + return R.ok(); + } else { + return R.error(errMsg.toString()+"不存在"); + } - return R.ok(); } } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenPersonDao.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenPersonDao.java index 27ccef9..2612637 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenPersonDao.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/dao/TenPersonDao.java @@ -122,6 +122,8 @@ public interface TenPersonDao { TenPersonEntity findByRyId(@Param("ryId")String ryId, @Param("cellId")Long cellId,@Param("idCard") String idCard); + Integer getCountByRyId(String ryId); + IPage getByPersonIds(Page page,@Param("personIds")List personIds, @Param("cellId")Long cellId); List listPage(@Param("start")int start, @Param("count")int count, @Param("cellId")String cellId); diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenPersonService.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenPersonService.java index 29b1104..cdda19b 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenPersonService.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenPersonService.java @@ -156,5 +156,7 @@ public interface TenPersonService { List listPage(int start, int count, String cellId); + Integer findByRyId(String ryId); + } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPersonServiceImpl.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPersonServiceImpl.java index 06e9da4..349ad21 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPersonServiceImpl.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPersonServiceImpl.java @@ -9,6 +9,7 @@ import com.arcsoft.face.FaceInfo; import com.arcsoft.face.enums.ExtractType; import com.arcsoft.face.toolkit.ImageFactory; import com.arcsoft.face.toolkit.ImageInfo; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.minio.MinioClient; import io.minio.PutObjectOptions; @@ -32,6 +33,7 @@ import net.shapelight.modules.job.entity.KeysEntity; import net.shapelight.modules.nettyapi.service.ServerApiService; import net.shapelight.modules.sys.entity.SysDictEntity; import net.shapelight.modules.sys.service.impl.SysDictServiceImpl; +import net.shapelight.modules.ten.dao.TenRelationMapper; import net.shapelight.modules.ten.entity.*; import net.shapelight.modules.ten.service.*; import net.shapelight.modules.tripartitePlatform.operatorPlatform.OpFeignClient; @@ -115,6 +117,8 @@ public class TenPersonServiceImpl implements TenPersonService { private String bucketName; @Autowired private FaceEngineService faceEngineService; + @Autowired + private TenRelationMapper tenRelationMapper; @Override @@ -474,7 +478,7 @@ public class TenPersonServiceImpl implements TenPersonService { appUserService.updateById(appUser); } - /*//发送设备通知 + //发送设备通知 List devList = tenDeviceService.findByCellId(entity.getCellId()); //状态是0正常,发送推送 if (entity.getStatus().intValue() == Constant.PESON_SUATUS_NOMOR) { @@ -489,17 +493,17 @@ public class TenPersonServiceImpl implements TenPersonService { syncEntity.setLastUpdateTime(entity.getLastUpdateTime()); tenPersonSyncService.insert(syncEntity); - //下发通知 + /* //下发通知 List list = new ArrayList<>(); TenPersonOperationVo vo = new TenPersonOperationVo(); vo.setUid(syncEntity.getPersonId()); vo.setOperation(1); vo.setLast_update_stamp(syncEntity.getLastUpdateTime()); list.add(vo); - serverApiService.personOperation(dev.getSn(), list); + serverApiService.personOperation(dev.getSn(), list);*/ } - }*/ - if(entity.getPersonType()!=Constant.PERSON_TYPE_GUEST) { + } + if(entity.getPersonType()==Constant.PERSON_TYPE_OWNER) { List dictList = sysDictService.queryByType("optype"); Map optypeMap = new HashMap<>(); dictList.forEach(dict -> { @@ -527,10 +531,12 @@ public class TenPersonServiceImpl implements TenPersonService { JSONObject jsonObject = opFeignClient.submitData(personParams); if(!jsonObject.getString("shrgStatus").equals("S")) { log.error(jsonObject.toJSONString()); + new SyncFailedException(entity.getPersonId()+","+entity.getName()+"青桔同步失败"); return jsonObject.getString("shrgMsg"); } if(!jsonObject.getJSONArray("errInfo").isEmpty()) { log.error(jsonObject.toJSONString()); + new SyncFailedException(entity.getPersonId()+","+entity.getName()+"青桔同步失败"); return jsonObject.getJSONArray("errInfo").toJSONString(); } } @@ -820,14 +826,14 @@ public class TenPersonServiceImpl implements TenPersonService { syncEntity.setLastUpdateTime(entity.getLastUpdateTime()); tenPersonSyncService.insert(syncEntity); - //下发通知 + /* //下发通知 List list = new ArrayList<>(); TenPersonOperationVo vo = new TenPersonOperationVo(); vo.setUid(syncEntity.getPersonId()); vo.setOperation(1); vo.setLast_update_stamp(syncEntity.getLastUpdateTime()); list.add(vo); - serverApiService.personOperation(dev.getSn(), list); + serverApiService.personOperation(dev.getSn(), list);*/ } } return true; @@ -887,10 +893,28 @@ public class TenPersonServiceImpl implements TenPersonService { //删除人员 - tenPersonDao.logicDeleteById(personId, cellId); + //记录所有人员id - personIds.add(personId); + + Map personParams = new HashMap<>(); + personParams.put("operation","delUserData"); + personParams.put("accountNumber",globalValue.accountNumber); + personParams.put("passKey", KeysEntity.passKey); + personParams.put("empowerText",KeysEntity.empowerText); + JSONArray jsonArray = new JSONArray(); + Map student = new HashMap<>(); + student.put("objectUuid",String.valueOf(entity.getPersonId())); + jsonArray.add(student); + personParams.put("dataInfo",jsonArray); + JSONObject jsonObject = opFeignClient.submitData(personParams); + if(jsonObject.getString("shrgStatus").equals("S")) { + if(jsonObject.getJSONArray("errInfo").isEmpty()) { + tenPersonDao.logicDeleteById(personId, cellId); + tenRelationMapper.delete(new LambdaQueryWrapper().eq(TenRelation::getStudentId,personId)); + personIds.add(personId); + } + } } //配置同步信息并推送 @@ -914,7 +938,7 @@ public class TenPersonServiceImpl implements TenPersonService { syncEntity.setState(Constant.PERSON_SYNC_DELETE); tenPersonSyncService.updateById(syncEntity); } - //下发通知 + /*//下发通知 List allDelete = tenPersonSyncService.findDeviceAllDeletePersons(deviceEntity.getDeviceId(), deviceEntity.getTenantId()); for (TenPersonSyncEntity syncEntity : allDelete) { TenPersonOperationVo vo = new TenPersonOperationVo(); @@ -922,13 +946,12 @@ public class TenPersonServiceImpl implements TenPersonService { vo.setOperation(Constant.PERSON_SYNC_DELETE); vo.setLast_update_stamp(syncEntity.getLastUpdateTime()); list.add(vo); - } + }*/ - int flag = serverApiService.personOperation(sn, list); - if (flag == 0) { - //下发成功,删除状态为删除的同步人员 - tenPersonSyncService.removeAllDeletePersons(deviceEntity.getDeviceId(), tenantId); - } + //int flag = serverApiService.personOperation(sn, list); + + //下发成功,删除状态为删除的同步人员 + tenPersonSyncService.removeAllDeletePersons(deviceEntity.getDeviceId(), tenantId); } return true; } @@ -1440,39 +1463,39 @@ public class TenPersonServiceImpl implements TenPersonService { // for (TenDeviceVo dev : devList) { // CmdProcess.publishPersonChange(dev.getSn()); // } - List dictList = sysDictService.queryByType("optype"); - Map optypeMap = new HashMap<>(); - dictList.forEach(dict -> { - optypeMap.put(dict.getValue(),dict.getCode()); - }); - Map personParams = new HashMap<>(); - personParams.put("operation","editUserData"); - personParams.put("accountNumber",globalValue.accountNumber); - personParams.put("passKey", KeysEntity.passKey); - personParams.put("empowerText",KeysEntity.empowerText); - JSONArray jsonArray = new JSONArray(); - Map student = new HashMap<>(); - student.put("objectUuid",String.valueOf(entity.getPersonId())); - student.put("userCode",entity.getRyid()); - student.put("userName",entity.getName()); - student.put("userType",optypeMap.get(entity.getLabelName())); - student.put("studentType","0"+entity.getPersonType()); - student.put("gender",entity.getGender()==0?"WOMAN":"MAN"); - student.put("cardNumber",""); - student.put("idCard",entity.getIdCard()); - student.put("fileUrl",imagBaseUrl+"/"+bucketName+"/"+entity.getOrgImage()); - student.put("fileName",entity.getOrgImage().substring(entity.getOrgImage().lastIndexOf("//"))); - jsonArray.add(student); - personParams.put("dataInfo",jsonArray); - JSONObject jsonObject = opFeignClient.submitData(personParams); - if(!jsonObject.getString("shrgStatus").equals("S")) { - new SyncFailedException(entity.getPersonId()+","+entity.getName()+"青桔同步失败"); + if(entity.getPersonType() == Constant.PERSON_TYPE_OWNER) { + List dictList = sysDictService.queryByType("optype"); + Map optypeMap = new HashMap<>(); + dictList.forEach(dict -> { + optypeMap.put(dict.getValue(),dict.getCode()); + }); + Map personParams = new HashMap<>(); + personParams.put("operation","editUserData"); + personParams.put("accountNumber",globalValue.accountNumber); + personParams.put("passKey", KeysEntity.passKey); + personParams.put("empowerText",KeysEntity.empowerText); + JSONArray jsonArray = new JSONArray(); + Map student = new HashMap<>(); + student.put("objectUuid",String.valueOf(entity.getPersonId())); + student.put("userCode",entity.getRyid()); + student.put("userName",entity.getName()); + student.put("userType",optypeMap.get(entity.getLabelName())); + student.put("studentType","0"+entity.getLabelId()); + student.put("gender",entity.getGender()==0?"WOMAN":"MAN"); + student.put("cardNumber",""); + student.put("idCard",entity.getIdCard()); + student.put("fileUrl",imagBaseUrl+"/"+bucketName+"/"+entity.getOrgImage()); + student.put("fileName",entity.getOrgImage().substring(entity.getOrgImage().lastIndexOf("/")+1)); + jsonArray.add(student); + personParams.put("dataInfo",jsonArray); + JSONObject jsonObject = opFeignClient.submitData(personParams); + if(!jsonObject.getString("shrgStatus").equals("S")) { + throw new SyncFailedException(entity.getPersonId()+","+entity.getName()+"青桔同步失败"); + } + if(jsonObject.getJSONArray("errInfo")!=null && !jsonObject.getJSONArray("errInfo").isEmpty()) { + throw new SyncFailedException(entity.getPersonId()+","+entity.getName()+"青桔同步失败"); + } } - if(jsonObject.getJSONArray("errInfo")!=null && !jsonObject.getJSONArray("errInfo").isEmpty()) { - new SyncFailedException(entity.getPersonId()+","+entity.getName()+"青桔同步失败"); - } - - return "OK"; } @@ -2543,4 +2566,9 @@ public class TenPersonServiceImpl implements TenPersonService { public List listPage(int start, int count, String cellId) { return tenPersonDao.listPage(start, count, cellId); } + + @Override + public Integer findByRyId(String ryId) { + return tenPersonDao.getCountByRyId(ryId); + } } diff --git a/shapelight-admin/src/main/resources/application-prod.yml b/shapelight-admin/src/main/resources/application-prod.yml index a7f8727..f9f75e6 100644 --- a/shapelight-admin/src/main/resources/application-prod.yml +++ b/shapelight-admin/src/main/resources/application-prod.yml @@ -6,9 +6,9 @@ spring: # url: jdbc:mysql://localhost:3306/site_db_1.3?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # username: rootuser # password: zy_db@C501 - url: jdbc:mysql://localhost:3306/cell_db?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai - username: user - password: user@server001 + url: jdbc:mysql://192.168.10.62:3306/smartschool?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai + username: smartschool + password: jaGXddQFnsxcTJSd initial-size: 10 max-active: 100 min-idle: 10 diff --git a/shapelight-admin/src/main/resources/mapper/ten/TenPersonDao.xml b/shapelight-admin/src/main/resources/mapper/ten/TenPersonDao.xml index 85d86f7..58a0f14 100644 --- a/shapelight-admin/src/main/resources/mapper/ten/TenPersonDao.xml +++ b/shapelight-admin/src/main/resources/mapper/ten/TenPersonDao.xml @@ -1321,7 +1321,12 @@ + +