长庆项目10.24

This commit is contained in:
ovo 2024-10-24 14:05:57 +08:00
parent a861cad96f
commit 6fea9672af
9 changed files with 443 additions and 105 deletions

View File

@ -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.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; 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 lombok.extern.slf4j.Slf4j;
import net.shapelight.common.config.GlobalValue; import net.shapelight.common.config.GlobalValue;
import net.shapelight.common.config.MinioConfig;
import net.shapelight.common.utils.Constant; import net.shapelight.common.utils.Constant;
import net.shapelight.common.utils.UUIDUtil;
import net.shapelight.modules.face.dto.FaceRecognitionResDTO; import net.shapelight.modules.face.dto.FaceRecognitionResDTO;
import net.shapelight.modules.face.entity.UserCompareInfo; import net.shapelight.modules.face.entity.UserCompareInfo;
import net.shapelight.modules.face.enums.ErrorCodeEnum; import net.shapelight.modules.face.enums.ErrorCodeEnum;
@ -42,10 +47,10 @@ import org.springframework.web.multipart.MultipartFile;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream; import java.io.*;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -103,6 +108,11 @@ public class RtspFrameGrabber {
@Autowired @Autowired
private TenCellDao tenCellDao; private TenCellDao tenCellDao;
@Autowired
private MinioConfig minioConfig;
@Autowired
private MinioClient minioClient;
private void createGrabber() { private void createGrabber() {
try { try {
@ -145,7 +155,10 @@ public class RtspFrameGrabber {
log.error(e.getMessage()); log.error(e.getMessage());
} }
} }
public void startGrabber(String cellId) { public List<FaceVideoVo> startGrabber(String cellId) {
List<FaceVideoVo> faceVideoVos = new ArrayList<>();
avutil.av_log_set_level(AV_LOG_ERROR); avutil.av_log_set_level(AV_LOG_ERROR);
Java2DFrameConverter java2DFrameConverter = new Java2DFrameConverter(); Java2DFrameConverter java2DFrameConverter = new Java2DFrameConverter();
if (grabber == null) { if (grabber == null) {
@ -157,7 +170,21 @@ public class RtspFrameGrabber {
if (frame != null) { if (frame != null) {
// logger.info("处理帧............................................."); // logger.info("处理帧.............................................");
BufferedImage bi = java2DFrameConverter.getBufferedImage(frame); BufferedImage bi = java2DFrameConverter.getBufferedImage(frame);
byte[] bytes = imageToBytes(bi, "jpg"); 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")); BufferedImage image = ImageIO.read(new File("C:\\Users\\zhangbo\\OneDrive\\图片\\Camera Roll\\1寸相片.jpg"));
@ -169,7 +196,8 @@ public class RtspFrameGrabber {
// 转换为byte数组 // 转换为byte数组
byte[] imageBytes = baos.toByteArray();*/ byte[] imageBytes = baos.toByteArray();*/
imageRecognition(bytes,cellId); faceVideoVos = imageRecognition(bytes, cellId);
System.out.println("faceVideoVos = " + faceVideoVos);
} else { } else {
log.error("解码失败"); log.error("解码失败");
@ -196,6 +224,8 @@ public class RtspFrameGrabber {
} }
} }
} finally {
grabber = null;
} }
// try { // try {
// Thread.sleep(100); // Thread.sleep(100);
@ -203,7 +233,7 @@ public class RtspFrameGrabber {
// logger.error(e.getMessage()); // logger.error(e.getMessage());
// } // }
return faceVideoVos;
} }
public List<FaceVideoVo> recognition(MultipartFile file,String cellId) { public List<FaceVideoVo> recognition(MultipartFile file,String cellId) {
@ -262,6 +292,35 @@ public class RtspFrameGrabber {
faceVideoVo.setPersonId(userCompareInfo.getFaceId()).setName(userCompareInfo.getName()); 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); temp.add(faceVideoVo);
} }
if (!userCompareInfoList.isEmpty()) { if (!userCompareInfoList.isEmpty()) {

View File

@ -43,6 +43,7 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.io.*; import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
@ -293,6 +294,12 @@ public class HttpApiController {
tenPersonSyncService.removeAllDeletePersons(deviceEntity.getDeviceId(),deviceEntity.getTenantId()); tenPersonSyncService.removeAllDeletePersons(deviceEntity.getDeviceId(),deviceEntity.getTenantId());
Map<String,Object> allPersons = new HashMap<>(); Map<String,Object> allPersons = new HashMap<>();
allPersons.put("allPerson",resAll); allPersons.put("allPerson",resAll);
System.out.println("allPersons = " + allPersons);
//测试
return R.ok().put("data",allPersons); return R.ok().put("data",allPersons);
} }
@ -693,6 +700,10 @@ public class HttpApiController {
String appKey = jsonContent.getString("appKey"); String appKey = jsonContent.getString("appKey");
String timestamp = jsonContent.getString("timestamp"); String timestamp = jsonContent.getString("timestamp");
String sign = jsonContent.getString("sign"); String sign = jsonContent.getString("sign");
System.out.println("sign = " + sign);
//鉴权 //鉴权
R res = authService.auth(sn,appKey,timestamp,sign); R res = authService.auth(sn,appKey,timestamp,sign);
if((Integer) res.get("code") != 0){ 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_OWNER,"2");//内部人员
personnelTypeMap.put(Constant.PERSON_TYPE_MEMBER,"1");//承包商 personnelTypeMap.put(Constant.PERSON_TYPE_MEMBER,"1");//承包商
personnelTypeMap.put(Constant.PERSON_TYPE_TENANT,"3");//长期供应商 personnelTypeMap.put(Constant.PERSON_TYPE_TENANT,"3");//长期供应商
personnelTypeMap.put(Constant.PERSON_TYPE_GUEST,"4");//访客
Map<String,Object> params = new HashMap<>(); Map<String,Object> params = new HashMap<>();
params.put("pmEntryExitRecordId",""); params.put("pmEntryExitRecordId","");
params.put("orgId",memberEntity.getOrgId()); params.put("orgId",memberEntity.getOrgId());
params.put("orgName",memberEntity.getCellName()); params.put("orgName",memberEntity.getCellName());
params.put("personnelName",memberEntity.getName()); params.put("personnelName",memberEntity.getName());
//TODO 访客ID
params.put("personnelId",memberEntity.getOpenId()); params.put("personnelId",memberEntity.getOpenId());
params.put("personnelType",personnelTypeMap.get(memberEntity.getPersonType())); params.put("personnelCardId", memberEntity.getIdCard());
params.put("entryOrExit",String.valueOf(deviceEntity.getGateFlag()+1));
params.put("entryExitTime",new Date(unlockTime));
params.put("accessControlName",memberEntity.getOpenId()); params.put("personnelType",memberEntity.getPersonType());
params.put("state","");
params.put("failureReason",""); 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); /*cn.hutool.json.JSONObject jsonObject = cxFeignClient.savePmEntryExitRecord(params);
if(jsonObject.getBool("success")!=null && jsonObject.getBool("success")){ if(jsonObject.getBool("success")!=null && jsonObject.getBool("success")){
log.debug("同步进出场记录成功"); log.debug("同步进出场记录成功");
@ -2081,7 +2107,7 @@ public class HttpApiController {
return R.ok().put("data", page); return R.ok().put("data", page);
} }
@GetMapping("/role") @PostMapping("/role")
public R roleList(@Param(value = "sn")String sn) { public R roleList(@Param(value = "sn")String sn) {
return R.ok().put("data",cqEnterService.queryByCellId(sn)); return R.ok().put("data",cqEnterService.queryByCellId(sn));
} }

View File

@ -22,6 +22,7 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* 宣传片表 * 宣传片表
@ -38,6 +39,9 @@ public class CqSafeVideoController {
private RtspFrameGrabber rtspFrameGrabber; private RtspFrameGrabber rtspFrameGrabber;
private final List<FaceVideoVo> list = new ArrayList<>();
@GetMapping("/getCells") @GetMapping("/getCells")
@ApiOperation(value = "获取单位列表") @ApiOperation(value = "获取单位列表")
public R getCells() { public R getCells() {
@ -92,18 +96,49 @@ public class CqSafeVideoController {
@GetMapping("/camara") @GetMapping("/camara")
public R watchStart(String cellId) { public R watchStart(String cellId, Integer isEnd) {
rtspFrameGrabber.startGrabber(cellId);
return R.ok(); List<FaceVideoVo> 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<FaceVideoVo> listTemp = new ArrayList<>(list);
list.clear();
return R.ok().put("data", listTemp);
}
return R.ok().put("data", list);
}
@PostMapping("/face/recognition") @PostMapping("/face/recognition")
public R aWatchStart(@RequestParam("image") MultipartFile image, @RequestParam String cellId) { public R aWatchStart(@RequestParam("image") MultipartFile image, @RequestParam String cellId) {
List<FaceVideoVo> recognition = rtspFrameGrabber.recognition(image, cellId); List<FaceVideoVo> recognition = rtspFrameGrabber.recognition(image, cellId);
for (FaceVideoVo faceVideoVo : recognition) {
System.out.println(faceVideoVo.getImageUrl());
}
return R.ok().put("data", recognition); return R.ok().put("data", recognition);
} }
} }

View File

@ -25,5 +25,11 @@ public class FaceVideoVo {
private Integer isHeadOnView; //0否1是 private Integer isHeadOnView; //0否1是
/**
* 图片url
*/
private String imageUrl;
} }

View File

@ -114,14 +114,27 @@ public class CqEnterServiceImpl {
*/ */
@Transactional @Transactional
public boolean changeState(int ruleId) { public boolean changeState(int ruleId) {
TenEnterConfigCell id = cqEnterConfigCellMapper
.selectOne(new QueryWrapper<TenEnterConfigCell>().eq("id", ruleId));
System.out.println(id);
//多传递一个cellId
/* if(cellId == '1'){
ruleId = ruleId % 6 + 1;
}else{
ruleId = ruleId % 6 + 7;
}*/
return cqEnterConfigCellMapper.update( return cqEnterConfigCellMapper.update(
null, null,
new UpdateWrapper<TenEnterConfigCell>() new UpdateWrapper<TenEnterConfigCell>()
.eq("enter_config_id", cqEnterConfigCellMapper .eq("enter_config_id", cqEnterConfigCellMapper
.selectOne(new QueryWrapper<TenEnterConfigCell>().eq("id", ruleId)) .selectOne(new QueryWrapper<TenEnterConfigCell>().eq("id", (ruleId % 6) + 1))
.getEnterConfigId()) .getEnterConfigId())
.eq("cell_id", cqEnterConfigCellMapper .eq("cell_id", cqEnterConfigCellMapper
.selectOne(new QueryWrapper<TenEnterConfigCell>().eq("id", ruleId)).getCellId()) .selectOne(new QueryWrapper<TenEnterConfigCell>().eq("id", (ruleId % 6) + 1)).getCellId())
.set("operate_time", new Date())) > 0 .set("operate_time", new Date())) > 0
&& cqEnterConfigTypeMapper.update( && cqEnterConfigTypeMapper.update(
null, null,

View File

@ -10,6 +10,7 @@ import com.arcsoft.face.toolkit.ImageInfo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.minio.MinioClient; import io.minio.MinioClient;
import io.minio.PutObjectOptions; import io.minio.PutObjectOptions;
import io.minio.errors.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.shapelight.common.config.GlobalValue; import net.shapelight.common.config.GlobalValue;
import net.shapelight.common.config.MinioConfig; import net.shapelight.common.config.MinioConfig;
@ -32,6 +33,8 @@ import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.*; import java.io.*;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
@ -68,9 +71,27 @@ public class PersonSynchronousTask extends AbstractController implements ITask {
@Override @Override
public void run(String params) { public void run(String params) {
try {
getPmInternalPersonnelList("Person"); getPmInternalPersonnelList("Person");
} catch (Exception e) {
// 处理异常比如记录日志
System.err.println("Error while fetching personnel list for Person: " + e.getMessage());
}
try {
getPmInternalPersonnelList("Contractor"); getPmInternalPersonnelList("Contractor");
} catch (Exception e) {
// 处理异常比如记录日志
System.err.println("Error while fetching personnel list for Contractor: " + e.getMessage());
}
try {
getPmInternalPersonnelList("Supplier"); getPmInternalPersonnelList("Supplier");
} catch (Exception e) {
// 处理异常比如记录日志
System.err.println("Error while fetching personnel list for Supplier: " + e.getMessage());
}
} }
private void getPmInternalPersonnelList(String type) { private void getPmInternalPersonnelList(String type) {
@ -419,9 +440,17 @@ public class PersonSynchronousTask extends AbstractController implements ITask {
pmContractorCertDatas.forEach(contractorCert -> { pmContractorCertDatas.forEach(contractorCert -> {
TenPersonCert personCert = new TenPersonCert(); TenPersonCert personCert = new TenPersonCert();
personCert.setCertName(contractorCert.getStr("certName") != null ? contractorCert.getStr("certName") : null); personCert.setCertName(contractorCert.getStr("certName") != null ? contractorCert.getStr("certName") : null);
personCert.setPmContractorCertId(contractorCert.getStr("pmContractorCertId") != null ? contractorCert.getStr("pmContractorCertId") : null); personCert.setPmContractorCertId(contractorCert.getStr("pmContractorCertId") != null
personCert.setPerson(id); ? contractorCert.getStr("pmContractorCertId") : null);
personCert.setCertType(contractorCert.getStr("certType") != null ? contractorCert.getStr("certType") : 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) { if (contractorCert.getStr("certObtainDate") != null) {
try { try {
personCert.setCertObtainDate(sfm1.parse(contractorCert.getStr("certObtainDate"))); personCert.setCertObtainDate(sfm1.parse(contractorCert.getStr("certObtainDate")));
@ -436,16 +465,91 @@ public class PersonSynchronousTask extends AbstractController implements ITask {
throw new RuntimeException(e); 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"); certService.saveOrUpdateByField(personCert, "pm_contractor_cert_id");
}); });
} }
if (person.getJSONArray("certList") != null) {
List<JSONObject> 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) { if (person.getJSONArray("pmContractorTrainDatas") != null) {
List<JSONObject> pmContractorTrainDatas = person.getJSONArray("pmContractorTrainDatas").toList(JSONObject.class); List<JSONObject> pmContractorTrainDatas = person.getJSONArray("pmContractorTrainDatas").toList(JSONObject.class);
pmContractorTrainDatas.forEach(contractorTrain -> { pmContractorTrainDatas.forEach(contractorTrain -> {
TenPersonTrain personTrain = new TenPersonTrain(); 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.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) { if (contractorTrain.getStr("isQualified") != null) {
personTrain.setIsQualified(contractorTrain.getStr("isQualified").equals("") ? 1 : 0); personTrain.setIsQualified(contractorTrain.getStr("isQualified").equals("") ? 1 : 0);
} }
@ -464,10 +568,51 @@ public class PersonSynchronousTask extends AbstractController implements ITask {
throw new RuntimeException(e); 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"); trainService.saveOrUpdateByField(personTrain, "pm_contractor_train_id");
}); });
} }
if (person.getJSONArray("trainList") != null) {
List<JSONObject> 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) { if (person.getStr("attachment") != null) {
try { try {
//保存原始图片 //保存原始图片
@ -475,7 +620,8 @@ public class PersonSynchronousTask extends AbstractController implements ITask {
tenPerson.getCellId().toString() + "/" + tenPerson.getCellId().toString() + "/" +
tenPerson.getPersonId().toString() + "/"; tenPerson.getPersonId().toString() + "/";
String orgImageFileName = userFileUrl + "o_" + UUIDUtil.uuid() + ".jpg"; 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); ImageInfo rgbData = ImageFactory.getRGBData(b);
List<FaceInfo> faceInfoList = faceEngineService.detectFaces(rgbData); List<FaceInfo> faceInfoList = faceEngineService.detectFaces(rgbData);
if (CollectionUtil.isNotEmpty(faceInfoList)) { if (CollectionUtil.isNotEmpty(faceInfoList)) {

View File

@ -28,7 +28,7 @@ public class TenPersonCert implements Serializable {
*/ */
@NotNull(message="[人员ID]不能为空") @NotNull(message="[人员ID]不能为空")
@ApiModelProperty("人员ID") @ApiModelProperty("人员ID")
private Long person; private String person;
/** /**
* 证书ID * 证书ID
*/ */
@ -60,4 +60,15 @@ public class TenPersonCert implements Serializable {
@ApiModelProperty("证书类型") @ApiModelProperty("证书类型")
@Length(max= 255,message="编码长度不能超过255") @Length(max= 255,message="编码长度不能超过255")
private String certType; private String certType;
/**
* 学员类别
*/
private String category;
/**
* 附件
*/
private String attachment;
} }

View File

@ -29,7 +29,7 @@ public class TenPersonTrain implements Serializable {
*/ */
@NotNull(message="[人员ID]不能为空") @NotNull(message="[人员ID]不能为空")
@ApiModelProperty("人员ID") @ApiModelProperty("人员ID")
private Long personId; private String personId;
/** /**
* 培训记录ID * 培训记录ID
*/ */
@ -63,4 +63,26 @@ public class TenPersonTrain implements Serializable {
@Length(max= 2,message="编码长度不能超过2") @Length(max= 2,message="编码长度不能超过2")
private int isQualified; private int isQualified;
/**
* 理论成绩
*/
private String theoreticalScorel;
/**
* 实践成绩
*/
private String practiceScore;
/**
* 人员类型
*/
private String personnelType;
/**
* 培训班名称
*/
private String className;
} }

View File

@ -664,30 +664,30 @@ public class TenPersonServiceImpl extends ServiceImpl<TenPersonDao,TenPersonEnti
}*/ }*/
//发送设备通知 //发送设备通知
// List<TenDeviceVo> devList = tenDeviceService.findByCellId(entity.getCellId()); List<TenDeviceVo> devList = tenDeviceService.findByCellId(entity.getCellId());
// //状态是0正常发送推送 //状态是0正常发送推送
// if (entity.getStatus().intValue() == Constant.PESON_SUATUS_NOMOR) { if (entity.getStatus() == Constant.PESON_SUATUS_NOMOR) {
// for (TenDeviceVo dev : devList) { for (TenDeviceVo dev : devList) {
// //添加到同步表下发设备通知 //添加到同步表下发设备通知
// TenPersonSyncEntity syncEntity = new TenPersonSyncEntity(); TenPersonSyncEntity syncEntity = new TenPersonSyncEntity();
// syncEntity.setPersonId(entity.getPersonId()); syncEntity.setPersonId(entity.getPersonId());
// syncEntity.setTenantId(entity.getTenantId()); syncEntity.setTenantId(entity.getTenantId());
// syncEntity.setDeviceSn(dev.getSn()); syncEntity.setDeviceSn(dev.getSn());
// syncEntity.setDeviceId(dev.getDeviceId()); syncEntity.setDeviceId(dev.getDeviceId());
// syncEntity.setState(1); syncEntity.setState(1);
// syncEntity.setLastUpdateTime(entity.getLastUpdateTime()); syncEntity.setLastUpdateTime(entity.getLastUpdateTime());
// tenPersonSyncService.insert(syncEntity); tenPersonSyncService.insert(syncEntity);
//
// //下发通知 //下发通知
// List<TenPersonOperationVo> list = new ArrayList<>(); List<TenPersonOperationVo> list = new ArrayList<>();
// TenPersonOperationVo vo = new TenPersonOperationVo(); TenPersonOperationVo vo = new TenPersonOperationVo();
// vo.setUid(syncEntity.getPersonId()); vo.setUid(syncEntity.getPersonId());
// vo.setOperation(1); vo.setOperation(1);
// vo.setLast_update_stamp(syncEntity.getLastUpdateTime()); vo.setLast_update_stamp(syncEntity.getLastUpdateTime());
// list.add(vo); list.add(vo);
// serverApiService.personOperation(dev.getSn(), list); serverApiService.personOperation(dev.getSn(), list);
// } }
// } }
return 0; return 0;
} }
return 1; return 1;
@ -1046,41 +1046,41 @@ public class TenPersonServiceImpl extends ServiceImpl<TenPersonDao,TenPersonEnti
//配置同步信息并推送 //配置同步信息并推送
// List<Map<String, String>> snPersonsList = tenPersonSyncService.findGroupDevicePersons(personIds, tenantId); List<Map<String, String>> snPersonsList = tenPersonSyncService.findGroupDevicePersons(personIds, tenantId);
// for (Map<String, String> snPersons : snPersonsList) { for (Map<String, String> snPersons : snPersonsList) {
// String sn = snPersons.get("deviceSn"); String sn = snPersons.get("deviceSn");
// TenDeviceEntity deviceEntity = tenDeviceService.findBySn(sn); TenDeviceEntity deviceEntity = tenDeviceService.findBySn(sn);
// if(deviceEntity==null){ if(deviceEntity==null){
// continue; continue;
// } }
// String[] persons = snPersons.get("plist").split(","); String[] persons = snPersons.get("plist").split(",");
// List<TenPersonOperationVo> list = new ArrayList<>(); List<TenPersonOperationVo> list = new ArrayList<>();
// for (String personStr : persons) { for (String personStr : persons) {
// String[] personInfoStr = personStr.split("_"); String[] personInfoStr = personStr.split("_");
// Long personId = Long.parseLong(personInfoStr[0]); Long personId = Long.parseLong(personInfoStr[0]);
// Date lastUpdateTime = DateUtils.stringToDate(personInfoStr[1], DateUtils.DATE_TIME_PATTERN); Date lastUpdateTime = DateUtils.stringToDate(personInfoStr[1], DateUtils.DATE_TIME_PATTERN);
//
// TenPersonSyncEntity syncEntity = tenPersonSyncService.findByDeviceIdAndPersonId(deviceEntity.getDeviceId(), personId, tenantId); TenPersonSyncEntity syncEntity = tenPersonSyncService.findByDeviceIdAndPersonId(deviceEntity.getDeviceId(), personId, tenantId);
// syncEntity.setLastUpdateTime(lastUpdateTime); syncEntity.setLastUpdateTime(lastUpdateTime);
// syncEntity.setState(Constant.PERSON_SYNC_DELETE); syncEntity.setState(Constant.PERSON_SYNC_DELETE);
// tenPersonSyncService.updateById(syncEntity); tenPersonSyncService.updateById(syncEntity);
// } }
// //下发通知 //下发通知
// List<TenPersonSyncEntity> allDelete = tenPersonSyncService.findDeviceAllDeletePersons(deviceEntity.getDeviceId(), deviceEntity.getTenantId()); List<TenPersonSyncEntity> allDelete = tenPersonSyncService.findDeviceAllDeletePersons(deviceEntity.getDeviceId(), deviceEntity.getTenantId());
// for (TenPersonSyncEntity syncEntity : allDelete) { for (TenPersonSyncEntity syncEntity : allDelete) {
// TenPersonOperationVo vo = new TenPersonOperationVo(); TenPersonOperationVo vo = new TenPersonOperationVo();
// vo.setUid(syncEntity.getPersonId()); vo.setUid(syncEntity.getPersonId());
// vo.setOperation(Constant.PERSON_SYNC_DELETE); vo.setOperation(Constant.PERSON_SYNC_DELETE);
// vo.setLast_update_stamp(syncEntity.getLastUpdateTime()); vo.setLast_update_stamp(syncEntity.getLastUpdateTime());
// list.add(vo); list.add(vo);
// } }
//
// int flag = serverApiService.personOperation(sn, list); int flag = serverApiService.personOperation(sn, list);
// if (flag == 0) { if (flag == 0) {
// //下发成功删除状态为删除的同步人员 //下发成功删除状态为删除的同步人员
// tenPersonSyncService.removeAllDeletePersons(deviceEntity.getDeviceId(), tenantId); tenPersonSyncService.removeAllDeletePersons(deviceEntity.getDeviceId(), tenantId);
// } }
// } }
return true; return true;
} }
@ -1096,7 +1096,27 @@ public class TenPersonServiceImpl extends ServiceImpl<TenPersonDao,TenPersonEnti
TenPersonEntity entity = tenPersonDao.selectById(personId, cellId); TenPersonEntity entity = tenPersonDao.selectById(personId, cellId);
if(entity!=null) { if(entity!=null) {
entity.setLastUpdateTime(new Date()); entity.setLastUpdateTime(new Date());
tenPersonDao.updateById(entity); tenPersonDao.updateById(entity);
List<TenPersonSyncEntity> syncEntitys = tenPersonSyncService.findByPersonId(entity.getPersonId(), entity.getTenantId());
for (TenPersonSyncEntity syncEn : syncEntitys) {
syncEn.setLastUpdateTime(entity.getLastUpdateTime());
syncEn.setState(2);
tenPersonSyncService.updateById(syncEn);
//下发通知
List<TenPersonOperationVo> 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 { } else {
return false; return false;
} }
@ -1666,20 +1686,20 @@ public class TenPersonServiceImpl extends ServiceImpl<TenPersonDao,TenPersonEnti
log.debug("内存增加人员:"+entity.getPersonId()+" 姓名:"+entity.getName()); log.debug("内存增加人员:"+entity.getPersonId()+" 姓名:"+entity.getName());
//配置同步数据 //配置同步数据
// List<TenPersonSyncEntity> syncEntitys = tenPersonSyncService.findByPersonId(entity.getPersonId(), entity.getTenantId()); List<TenPersonSyncEntity> syncEntitys = tenPersonSyncService.findByPersonId(entity.getPersonId(), entity.getTenantId());
// for (TenPersonSyncEntity syncEn : syncEntitys) { for (TenPersonSyncEntity syncEn : syncEntitys) {
// syncEn.setLastUpdateTime(entity.getLastUpdateTime()); syncEn.setLastUpdateTime(entity.getLastUpdateTime());
// syncEn.setState(2); syncEn.setState(2);
// tenPersonSyncService.updateById(syncEn); tenPersonSyncService.updateById(syncEn);
// //下发通知 //下发通知
// List<TenPersonOperationVo> list = new ArrayList<>(); List<TenPersonOperationVo> list = new ArrayList<>();
// TenPersonOperationVo vo = new TenPersonOperationVo(); TenPersonOperationVo vo = new TenPersonOperationVo();
// vo.setUid(entity.getPersonId()); vo.setUid(entity.getPersonId());
// vo.setOperation(2); vo.setOperation(2);
// vo.setLast_update_stamp(entity.getLastUpdateTime()); vo.setLast_update_stamp(entity.getLastUpdateTime());
// list.add(vo); list.add(vo);
// serverApiService.personOperation(syncEn.getDeviceSn(), list); serverApiService.personOperation(syncEn.getDeviceSn(), list);
// } }
} }
tenPersonDao.updateById(entity); tenPersonDao.updateById(entity);