diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/face/rtsp/RtspFrameGrabber.java b/shapelight-admin/src/main/java/net/shapelight/modules/face/rtsp/RtspFrameGrabber.java index 0772f07..753d3e5 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/face/rtsp/RtspFrameGrabber.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/face/rtsp/RtspFrameGrabber.java @@ -12,9 +12,14 @@ import com.arcsoft.face.toolkit.ImageInfo; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import io.minio.MinioClient; +import io.minio.PutObjectOptions; +import io.minio.errors.*; import lombok.extern.slf4j.Slf4j; import net.shapelight.common.config.GlobalValue; +import net.shapelight.common.config.MinioConfig; import net.shapelight.common.utils.Constant; +import net.shapelight.common.utils.UUIDUtil; import net.shapelight.modules.face.dto.FaceRecognitionResDTO; import net.shapelight.modules.face.entity.UserCompareInfo; import net.shapelight.modules.face.enums.ErrorCodeEnum; @@ -42,10 +47,10 @@ import org.springframework.web.multipart.MultipartFile; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; +import java.io.*; import java.nio.charset.StandardCharsets; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.ConcurrentHashMap; @@ -103,6 +108,11 @@ public class RtspFrameGrabber { @Autowired private TenCellDao tenCellDao; + @Autowired + private MinioConfig minioConfig; + @Autowired + private MinioClient minioClient; + private void createGrabber() { try { @@ -145,7 +155,10 @@ public class RtspFrameGrabber { log.error(e.getMessage()); } } - public void startGrabber(String cellId) { + public List startGrabber(String cellId) { + + List faceVideoVos = new ArrayList<>(); + avutil.av_log_set_level(AV_LOG_ERROR); Java2DFrameConverter java2DFrameConverter = new Java2DFrameConverter(); if (grabber == null) { @@ -157,7 +170,21 @@ public class RtspFrameGrabber { if (frame != null) { // logger.info("处理帧............................................."); BufferedImage bi = java2DFrameConverter.getBufferedImage(frame); + byte[] bytes = imageToBytes(bi, "jpg"); + + /* InputStream frameInputStream = new ByteArrayInputStream(bytes); + String frameFileName = "temp/" + "frame_" + UUIDUtil.uuid() + + ".jpg"; + + PutObjectOptions framePutObjectOptions = new PutObjectOptions(bytes.length, -1); + framePutObjectOptions.setContentType("image/jpeg"); + + minioClient.putObject( + minioConfig.getBucketName(), frameFileName, frameInputStream, framePutObjectOptions); + + System.out.println("文件名 = " + globalValue.getMinioEndpoint() + "/" + + globalValue.getMinioBucketName() + "/" + frameFileName);*/ /* // 读取图片 BufferedImage image = ImageIO.read(new File("C:\\Users\\zhangbo\\OneDrive\\图片\\Camera Roll\\1寸相片.jpg")); @@ -169,7 +196,8 @@ public class RtspFrameGrabber { // 转换为byte数组 byte[] imageBytes = baos.toByteArray();*/ - imageRecognition(bytes,cellId); + faceVideoVos = imageRecognition(bytes, cellId); + System.out.println("faceVideoVos = " + faceVideoVos); } else { log.error("解码失败"); @@ -196,6 +224,8 @@ public class RtspFrameGrabber { } } + } finally { + grabber = null; } // try { // Thread.sleep(100); @@ -203,7 +233,7 @@ public class RtspFrameGrabber { // logger.error(e.getMessage()); // } - + return faceVideoVos; } public List recognition(MultipartFile file,String cellId) { @@ -262,6 +292,35 @@ public class RtspFrameGrabber { faceVideoVo.setPersonId(userCompareInfo.getFaceId()).setName(userCompareInfo.getName()); + + + InputStream frameInputStream = new ByteArrayInputStream(bytes); + String frameFileName = "temp/" + "frame_" + UUIDUtil.uuid() + + ".jpg"; + + PutObjectOptions framePutObjectOptions = new PutObjectOptions(bytes.length, -1); + framePutObjectOptions.setContentType("image/jpeg"); + + try { + frameInputStream.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + + try { + minioClient.putObject( + minioConfig.getBucketName(), frameFileName, frameInputStream, framePutObjectOptions); + } catch (Exception e) { + throw new RuntimeException(e); + } + + System.out.println("文件名 = " + globalValue.getMinioEndpoint() + "/" + + globalValue.getMinioBucketName() + "/" + frameFileName); + + + + faceVideoVo.setImageUrl(frameFileName); + temp.add(faceVideoVo); } if (!userCompareInfoList.isEmpty()) { diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/httpapi/controler/HttpApiController.java b/shapelight-admin/src/main/java/net/shapelight/modules/httpapi/controler/HttpApiController.java index 34683d2..83a7cc6 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/httpapi/controler/HttpApiController.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/httpapi/controler/HttpApiController.java @@ -43,6 +43,7 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import java.io.*; +import java.text.SimpleDateFormat; import java.util.*; @@ -293,6 +294,12 @@ public class HttpApiController { tenPersonSyncService.removeAllDeletePersons(deviceEntity.getDeviceId(),deviceEntity.getTenantId()); Map allPersons = new HashMap<>(); allPersons.put("allPerson",resAll); + + + System.out.println("allPersons = " + allPersons); + + + //测试 return R.ok().put("data",allPersons); } @@ -693,6 +700,10 @@ public class HttpApiController { String appKey = jsonContent.getString("appKey"); String timestamp = jsonContent.getString("timestamp"); String sign = jsonContent.getString("sign"); + + + System.out.println("sign = " + sign); + //鉴权 R res = authService.auth(sn,appKey,timestamp,sign); if((Integer) res.get("code") != 0){ @@ -831,18 +842,33 @@ public class HttpApiController { personnelTypeMap.put(Constant.PERSON_TYPE_OWNER,"2");//内部人员 personnelTypeMap.put(Constant.PERSON_TYPE_MEMBER,"1");//承包商 personnelTypeMap.put(Constant.PERSON_TYPE_TENANT,"3");//长期供应商 + personnelTypeMap.put(Constant.PERSON_TYPE_GUEST,"4");//访客 + Map params = new HashMap<>(); params.put("pmEntryExitRecordId",""); params.put("orgId",memberEntity.getOrgId()); params.put("orgName",memberEntity.getCellName()); params.put("personnelName",memberEntity.getName()); + //TODO 访客ID + + params.put("personnelId",memberEntity.getOpenId()); - params.put("personnelType",personnelTypeMap.get(memberEntity.getPersonType())); - params.put("entryOrExit",String.valueOf(deviceEntity.getGateFlag()+1)); - params.put("entryExitTime",new Date(unlockTime)); - params.put("accessControlName",memberEntity.getOpenId()); - params.put("state",""); - params.put("failureReason",""); + params.put("personnelCardId", memberEntity.getIdCard()); + + + params.put("personnelType",memberEntity.getPersonType()); + + params.put("entryOrExit",(deviceEntity.getGateFlag()+1) == 1); //1进2出 + + SimpleDateFormat sfm = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); + + params.put("entryExitTime", sfm.format(new Date(unlockTime))); + params.put("accessControlName",deviceEntity.getName()); + params.put("state",failureReason.isEmpty() ? "1" : "0"); + params.put("failureReason",failureReason); + + System.out.println("params = " + params); + /*cn.hutool.json.JSONObject jsonObject = cxFeignClient.savePmEntryExitRecord(params); if(jsonObject.getBool("success")!=null && jsonObject.getBool("success")){ log.debug("同步进出场记录成功"); @@ -2081,7 +2107,7 @@ public class HttpApiController { return R.ok().put("data", page); } - @GetMapping("/role") + @PostMapping("/role") public R roleList(@Param(value = "sn")String sn) { return R.ok().put("data",cqEnterService.queryByCellId(sn)); } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/video/CqSafeVideoController.java b/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/video/CqSafeVideoController.java index 34f72bc..c38bca3 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/video/CqSafeVideoController.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/video/CqSafeVideoController.java @@ -22,6 +22,7 @@ import org.springframework.web.multipart.MultipartFile; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.Objects; /** * 宣传片表 @@ -38,6 +39,9 @@ public class CqSafeVideoController { private RtspFrameGrabber rtspFrameGrabber; + private final List list = new ArrayList<>(); + + @GetMapping("/getCells") @ApiOperation(value = "获取单位列表") public R getCells() { @@ -92,18 +96,49 @@ public class CqSafeVideoController { @GetMapping("/camara") - public R watchStart(String cellId) { - rtspFrameGrabber.startGrabber(cellId); - return R.ok(); + public R watchStart(String cellId, Integer isEnd) { + + List faceVideoVos = rtspFrameGrabber.startGrabber(cellId); + System.out.println("faceVideoVos = " + faceVideoVos); + for (FaceVideoVo faceVideoVo : faceVideoVos) { + boolean exists = false; + for (FaceVideoVo videoVo : list) { + if (Objects.equals(videoVo.getPersonId(), faceVideoVo.getPersonId())) { + exists = true; + if (faceVideoVo.getIsHeadOnView() == 0) { + list.remove(videoVo); + list.add(faceVideoVo); + } + break; + } + } + if (!exists) { + list.add(faceVideoVo); + } + } + System.out.println("list = " + list); + + if (isEnd == 1){ + List listTemp = new ArrayList<>(list); + list.clear(); + return R.ok().put("data", listTemp); + } + return R.ok().put("data", list); + } + + + + @PostMapping("/face/recognition") public R aWatchStart(@RequestParam("image") MultipartFile image, @RequestParam String cellId) { List recognition = rtspFrameGrabber.recognition(image, cellId); + for (FaceVideoVo faceVideoVo : recognition) { + System.out.println(faceVideoVo.getImageUrl()); + } return R.ok().put("data", recognition); } - - } \ No newline at end of file diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/video/vo/FaceVideoVo.java b/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/video/vo/FaceVideoVo.java index c86e28d..7c38215 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/video/vo/FaceVideoVo.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/video/vo/FaceVideoVo.java @@ -25,5 +25,11 @@ public class FaceVideoVo { private Integer isHeadOnView; //0否1是 + /** + * 图片url + */ + private String imageUrl; + + } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/iCq/service/enter/CqEnterServiceImpl.java b/shapelight-admin/src/main/java/net/shapelight/modules/iCq/service/enter/CqEnterServiceImpl.java index 735f011..4048aba 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/iCq/service/enter/CqEnterServiceImpl.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/iCq/service/enter/CqEnterServiceImpl.java @@ -114,14 +114,27 @@ public class CqEnterServiceImpl { */ @Transactional public boolean changeState(int ruleId) { - return cqEnterConfigCellMapper.update( + + TenEnterConfigCell id = cqEnterConfigCellMapper + .selectOne(new QueryWrapper().eq("id", ruleId)); + System.out.println(id); + + + //多传递一个cellId + /* if(cellId == '1'){ + ruleId = ruleId % 6 + 1; + }else{ + ruleId = ruleId % 6 + 7; + }*/ + + return cqEnterConfigCellMapper.update( null, new UpdateWrapper() .eq("enter_config_id", cqEnterConfigCellMapper - .selectOne(new QueryWrapper().eq("id", ruleId)) + .selectOne(new QueryWrapper().eq("id", (ruleId % 6) + 1)) .getEnterConfigId()) .eq("cell_id", cqEnterConfigCellMapper - .selectOne(new QueryWrapper().eq("id", ruleId)).getCellId()) + .selectOne(new QueryWrapper().eq("id", (ruleId % 6) + 1)).getCellId()) .set("operate_time", new Date())) > 0 && cqEnterConfigTypeMapper.update( null, diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/job/task/PersonSynchronousTask.java b/shapelight-admin/src/main/java/net/shapelight/modules/job/task/PersonSynchronousTask.java index fba46eb..ff5d352 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/job/task/PersonSynchronousTask.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/job/task/PersonSynchronousTask.java @@ -10,6 +10,7 @@ import com.arcsoft.face.toolkit.ImageInfo; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import io.minio.MinioClient; import io.minio.PutObjectOptions; +import io.minio.errors.*; import lombok.extern.slf4j.Slf4j; import net.shapelight.common.config.GlobalValue; import net.shapelight.common.config.MinioConfig; @@ -32,6 +33,8 @@ import org.springframework.stereotype.Component; import javax.annotation.Resource; import java.io.*; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; @@ -68,9 +71,27 @@ public class PersonSynchronousTask extends AbstractController implements ITask { @Override public void run(String params) { - getPmInternalPersonnelList("Person"); - getPmInternalPersonnelList("Contractor"); - getPmInternalPersonnelList("Supplier"); + try { + getPmInternalPersonnelList("Person"); + } catch (Exception e) { + // 处理异常,比如记录日志 + System.err.println("Error while fetching personnel list for Person: " + e.getMessage()); + } + + try { + getPmInternalPersonnelList("Contractor"); + } catch (Exception e) { + // 处理异常,比如记录日志 + System.err.println("Error while fetching personnel list for Contractor: " + e.getMessage()); + } + + try { + getPmInternalPersonnelList("Supplier"); + } catch (Exception e) { + // 处理异常,比如记录日志 + System.err.println("Error while fetching personnel list for Supplier: " + e.getMessage()); + } + } private void getPmInternalPersonnelList(String type) { @@ -419,9 +440,17 @@ public class PersonSynchronousTask extends AbstractController implements ITask { pmContractorCertDatas.forEach(contractorCert -> { TenPersonCert personCert = new TenPersonCert(); personCert.setCertName(contractorCert.getStr("certName") != null ? contractorCert.getStr("certName") : null); - personCert.setPmContractorCertId(contractorCert.getStr("pmContractorCertId") != null ? contractorCert.getStr("pmContractorCertId") : null); - personCert.setPerson(id); - personCert.setCertType(contractorCert.getStr("certType") != null ? contractorCert.getStr("certType") : null); + personCert.setPmContractorCertId(contractorCert.getStr("pmContractorCertId") != null + ? contractorCert.getStr("pmContractorCertId") : null); + /*personCert.setPerson(id);*/ + + + personCert.setPerson(contractorCert.getStr("pmContractorId") != null ? + contractorCert.getStr("pmContractorId") : null) ; + + personCert.setCertType(contractorCert.getStr("certType") != null + ? contractorCert.getStr("certType") : null); + if (contractorCert.getStr("certObtainDate") != null) { try { personCert.setCertObtainDate(sfm1.parse(contractorCert.getStr("certObtainDate"))); @@ -436,16 +465,91 @@ public class PersonSynchronousTask extends AbstractController implements ITask { throw new RuntimeException(e); } } + + personCert.setCategory(contractorCert.getStr("category") != null + ? contractorCert.getStr("category") : null); + + if (contractorCert.getStr("attachment") != null) { + try { + + String personId = (contractorCert.getStr("pmContractorId") != null ? + contractorCert.getStr("pmContractorId") : null); + + + //保存原始图片 + String userFileUrl = globalValue.getImagesDir() + "/" + + personId + "/" ; + String orgImageFileName = userFileUrl + "o_" + UUIDUtil.uuid() + ".jpg"; + byte[] b = Base64.getDecoder().decode(person.getStr("attachment") + .replace("\n", "")); + InputStream inputStream = new ByteArrayInputStream(b); + PutObjectOptions putObjectOptions = new PutObjectOptions(inputStream.available(), + -1); + putObjectOptions.setContentType("image/jpeg"); + minioClient.putObject( + minioConfig.getBucketName(), orgImageFileName, inputStream, putObjectOptions); + inputStream.close(); + + personCert.setAttachment(globalValue.getMinioEndpoint() + "/" + + globalValue.getMinioBucketName() + "/" + + orgImageFileName); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + certService.saveOrUpdateByField(personCert, "pm_contractor_cert_id"); }); } + + if (person.getJSONArray("certList") != null) { + List pmContractorCertDatas = person.getJSONArray("certList").toList(JSONObject.class); + pmContractorCertDatas.forEach(contractorCert -> { + TenPersonCert personCert = new TenPersonCert(); + personCert.setCertName(contractorCert.getStr("qualificationCertificateName") != null + ? contractorCert.getStr("qualificationCertificateName") : null); + personCert.setPmContractorCertId(contractorCert.getStr("qualificationCertificateId") != null + ? contractorCert.getStr("qualificationCertificateId") : null); + + /* personCert.setPerson(id);*/ + + personCert.setPerson(contractorCert.getStr("pmPersonnelId") != null ? + contractorCert.getStr("pmPersonnelId") : null) ; + + personCert.setCertType(contractorCert.getStr("type") != null + ? contractorCert.getStr("type") : null); + if (contractorCert.getStr("evidenceCollectionDate") != null) { + try { + personCert.setCertObtainDate(sfm1.parse(contractorCert.getStr("evidenceCollectionDate"))); + } catch (ParseException e) { + throw new RuntimeException(e); + } + } + if (contractorCert.getStr("expirationDateCertificate") != null) { + try { + personCert.setEffectiveDate(sfm1.parse(contractorCert.getStr("expirationDateCertificate"))); + } catch (ParseException e) { + throw new RuntimeException(e); + } + } + certService.saveOrUpdateByField(personCert, "pm_contractor_cert_id"); + }); + } + if (person.getJSONArray("pmContractorTrainDatas") != null) { List pmContractorTrainDatas = person.getJSONArray("pmContractorTrainDatas").toList(JSONObject.class); pmContractorTrainDatas.forEach(contractorTrain -> { TenPersonTrain personTrain = new TenPersonTrain(); - personTrain.setTrainContent(contractorTrain.getStr("trainContent") != null ? contractorTrain.getStr("trainContent") : null); + personTrain.setTrainContent(contractorTrain.getStr("trainContent") != null + ? contractorTrain.getStr("trainContent") : null); personTrain.setPmContractorTrainId(contractorTrain.getStr("pmContractorTrainId") != null ? contractorTrain.getStr("pmContractorTrainId") : null); - personTrain.setPersonId(id); + + /*personTrain.setPersonId(id);*/ + personTrain.setPersonId(contractorTrain.getStr("pmContractorId") != null ? + contractorTrain.getStr("pmContractorId") : null) ; + + if (contractorTrain.getStr("isQualified") != null) { personTrain.setIsQualified(contractorTrain.getStr("isQualified").equals("是") ? 1 : 0); } @@ -464,10 +568,51 @@ public class PersonSynchronousTask extends AbstractController implements ITask { throw new RuntimeException(e); } } + + personTrain.setTheoreticalScorel(contractorTrain.getStr("theoreticalScore") != null + ? contractorTrain.getStr("theoreticalScore") : null); + + personTrain.setPracticeScore(contractorTrain.getStr("practiceScore") != null + ? contractorTrain.getStr("practiceScore") : null); + + personTrain.setPersonnelType(contractorTrain.getStr("personnelType") != null + ? contractorTrain.getStr("personnelType") : null); trainService.saveOrUpdateByField(personTrain, "pm_contractor_train_id"); }); } + + + if (person.getJSONArray("trainList") != null) { + List pmContractorTrainDatas = person.getJSONArray("trainList").toList(JSONObject.class); + pmContractorTrainDatas.forEach(contractorTrain -> { + TenPersonTrain personTrain = new TenPersonTrain(); + // personTrain.setPersonId(id); + + personTrain.setPersonId(contractorTrain.getStr("pmPersonnelId") != null + ? contractorTrain.getStr("pmPersonnelId") : null); + personTrain.setPmContractorTrainId(contractorTrain.getStr("trainRecordsId") != null + ? contractorTrain.getStr("trainRecordsId") : null); + + + personTrain.setClassName(contractorTrain.getStr("className") != null + ? contractorTrain.getStr("className") : null); + + personTrain.setPersonnelType(contractorTrain.getStr("userType") != null + ? contractorTrain.getStr("userType") : null); + + + if (contractorTrain.getStr("isQualified") != null) { + personTrain.setIsQualified(contractorTrain.getStr("isQualified").equals("是") ? 1 : 0); + } + + + trainService.saveOrUpdateByField(personTrain, "pm_contractor_train_id"); + }); + } + + + if (person.getStr("attachment") != null) { try { //保存原始图片 @@ -475,7 +620,8 @@ public class PersonSynchronousTask extends AbstractController implements ITask { tenPerson.getCellId().toString() + "/" + tenPerson.getPersonId().toString() + "/"; String orgImageFileName = userFileUrl + "o_" + UUIDUtil.uuid() + ".jpg"; - byte[] b = Base64.getDecoder().decode(person.getStr("attachment").replace("\n", "")); + byte[] b = Base64.getDecoder().decode(person.getStr("attachment") + .replace("\n", "")); ImageInfo rgbData = ImageFactory.getRGBData(b); List faceInfoList = faceEngineService.detectFaces(rgbData); if (CollectionUtil.isNotEmpty(faceInfoList)) { diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenPersonCert.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenPersonCert.java index 05ec359..ee08d4c 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenPersonCert.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenPersonCert.java @@ -28,7 +28,7 @@ public class TenPersonCert implements Serializable { */ @NotNull(message="[人员ID]不能为空") @ApiModelProperty("人员ID") - private Long person; + private String person; /** * 证书ID */ @@ -60,4 +60,15 @@ public class TenPersonCert implements Serializable { @ApiModelProperty("证书类型") @Length(max= 255,message="编码长度不能超过255") private String certType; + + /** + * 学员类别 + */ + private String category; + /** + * 附件 + */ + private String attachment; + + } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenPersonTrain.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenPersonTrain.java index 4ce1b63..630a272 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenPersonTrain.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenPersonTrain.java @@ -29,7 +29,7 @@ public class TenPersonTrain implements Serializable { */ @NotNull(message="[人员ID]不能为空") @ApiModelProperty("人员ID") - private Long personId; + private String personId; /** * 培训记录ID */ @@ -63,4 +63,26 @@ public class TenPersonTrain implements Serializable { @Length(max= 2,message="编码长度不能超过2") private int isQualified; + + /** + * 理论成绩 + */ + private String theoreticalScorel; + + /** + * 实践成绩 + */ + private String practiceScore; + + /** + * 人员类型 + */ + private String personnelType; + + /** + * 培训班名称 + */ + private String className; + + } 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 100617a..6b55dc0 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 @@ -664,30 +664,30 @@ public class TenPersonServiceImpl extends ServiceImpl devList = tenDeviceService.findByCellId(entity.getCellId()); -// //状态是0正常,发送推送 -// if (entity.getStatus().intValue() == Constant.PESON_SUATUS_NOMOR) { -// for (TenDeviceVo dev : devList) { -// //添加到同步表,下发设备通知 -// TenPersonSyncEntity syncEntity = new TenPersonSyncEntity(); -// syncEntity.setPersonId(entity.getPersonId()); -// syncEntity.setTenantId(entity.getTenantId()); -// syncEntity.setDeviceSn(dev.getSn()); -// syncEntity.setDeviceId(dev.getDeviceId()); -// syncEntity.setState(1); -// 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); -// } -// } + List devList = tenDeviceService.findByCellId(entity.getCellId()); + //状态是0正常,发送推送 + if (entity.getStatus() == Constant.PESON_SUATUS_NOMOR) { + for (TenDeviceVo dev : devList) { + //添加到同步表,下发设备通知 + TenPersonSyncEntity syncEntity = new TenPersonSyncEntity(); + syncEntity.setPersonId(entity.getPersonId()); + syncEntity.setTenantId(entity.getTenantId()); + syncEntity.setDeviceSn(dev.getSn()); + syncEntity.setDeviceId(dev.getDeviceId()); + syncEntity.setState(1); + 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); + } + } return 0; } return 1; @@ -1046,41 +1046,41 @@ public class TenPersonServiceImpl extends ServiceImpl> snPersonsList = tenPersonSyncService.findGroupDevicePersons(personIds, tenantId); -// for (Map snPersons : snPersonsList) { -// String sn = snPersons.get("deviceSn"); -// TenDeviceEntity deviceEntity = tenDeviceService.findBySn(sn); -// if(deviceEntity==null){ -// continue; -// } -// String[] persons = snPersons.get("plist").split(","); -// List list = new ArrayList<>(); -// for (String personStr : persons) { -// String[] personInfoStr = personStr.split("_"); -// Long personId = Long.parseLong(personInfoStr[0]); -// Date lastUpdateTime = DateUtils.stringToDate(personInfoStr[1], DateUtils.DATE_TIME_PATTERN); -// -// TenPersonSyncEntity syncEntity = tenPersonSyncService.findByDeviceIdAndPersonId(deviceEntity.getDeviceId(), personId, tenantId); -// syncEntity.setLastUpdateTime(lastUpdateTime); -// 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(); -// vo.setUid(syncEntity.getPersonId()); -// 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); -// } -// } + List> snPersonsList = tenPersonSyncService.findGroupDevicePersons(personIds, tenantId); + for (Map snPersons : snPersonsList) { + String sn = snPersons.get("deviceSn"); + TenDeviceEntity deviceEntity = tenDeviceService.findBySn(sn); + if(deviceEntity==null){ + continue; + } + String[] persons = snPersons.get("plist").split(","); + List list = new ArrayList<>(); + for (String personStr : persons) { + String[] personInfoStr = personStr.split("_"); + Long personId = Long.parseLong(personInfoStr[0]); + Date lastUpdateTime = DateUtils.stringToDate(personInfoStr[1], DateUtils.DATE_TIME_PATTERN); + + TenPersonSyncEntity syncEntity = tenPersonSyncService.findByDeviceIdAndPersonId(deviceEntity.getDeviceId(), personId, tenantId); + syncEntity.setLastUpdateTime(lastUpdateTime); + 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(); + vo.setUid(syncEntity.getPersonId()); + 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); + } + } return true; } @@ -1096,7 +1096,27 @@ public class TenPersonServiceImpl extends ServiceImpl syncEntitys = tenPersonSyncService.findByPersonId(entity.getPersonId(), entity.getTenantId()); + for (TenPersonSyncEntity syncEn : syncEntitys) { + syncEn.setLastUpdateTime(entity.getLastUpdateTime()); + syncEn.setState(2); + tenPersonSyncService.updateById(syncEn); + //下发通知 + List list = new ArrayList<>(); + TenPersonOperationVo vo = new TenPersonOperationVo(); + vo.setUid(entity.getPersonId()); + vo.setOperation(2); + vo.setLast_update_stamp(entity.getLastUpdateTime()); + list.add(vo); + serverApiService.personOperation(syncEn.getDeviceSn(), list); + } + + + + } else { return false; } @@ -1666,20 +1686,20 @@ public class TenPersonServiceImpl extends ServiceImpl syncEntitys = tenPersonSyncService.findByPersonId(entity.getPersonId(), entity.getTenantId()); -// for (TenPersonSyncEntity syncEn : syncEntitys) { -// syncEn.setLastUpdateTime(entity.getLastUpdateTime()); -// syncEn.setState(2); -// tenPersonSyncService.updateById(syncEn); -// //下发通知 -// List list = new ArrayList<>(); -// TenPersonOperationVo vo = new TenPersonOperationVo(); -// vo.setUid(entity.getPersonId()); -// vo.setOperation(2); -// vo.setLast_update_stamp(entity.getLastUpdateTime()); -// list.add(vo); -// serverApiService.personOperation(syncEn.getDeviceSn(), list); -// } + List syncEntitys = tenPersonSyncService.findByPersonId(entity.getPersonId(), entity.getTenantId()); + for (TenPersonSyncEntity syncEn : syncEntitys) { + syncEn.setLastUpdateTime(entity.getLastUpdateTime()); + syncEn.setState(2); + tenPersonSyncService.updateById(syncEn); + //下发通知 + List list = new ArrayList<>(); + TenPersonOperationVo vo = new TenPersonOperationVo(); + vo.setUid(entity.getPersonId()); + vo.setOperation(2); + vo.setLast_update_stamp(entity.getLastUpdateTime()); + list.add(vo); + serverApiService.personOperation(syncEn.getDeviceSn(), list); + } } tenPersonDao.updateById(entity);