From 139718fc346918375b406f8a253732de264b929b Mon Sep 17 00:00:00 2001 From: ovo Date: Wed, 30 Oct 2024 15:42:36 +0800 Subject: [PATCH] =?UTF-8?q?=E9=95=BF=E5=BA=86=E9=A1=B9=E7=9B=AE10.30?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shapelight/common/config/ShiroConfig.java | 1 + .../modules/face/rtsp/RtspFrameGrabber.java | 104 ++++++++--------- .../httpapi/controler/HttpApiController.java | 2 +- .../iCq/controller/DemoController.java | 104 ++++++++++++++++- .../controller/enter/CqEnterController.java | 10 +- .../enter/dto/ChangeTypeStatesDto.java | 16 +++ .../video/CqSafeVideoController.java | 6 +- .../iCq/controller/video/vo/FaceVideoVo.java | 6 + .../iCq/service/enter/CqEnterServiceImpl.java | 25 +--- .../job/task/PersonSynchronousTask.java | 108 ++++++++++++++++-- .../ten/controller/TenPersonController.java | 7 +- .../service/impl/TenPersonServiceImpl.java | 8 ++ .../resources/mapper/ten/TenPersonDao.xml | 12 +- 13 files changed, 313 insertions(+), 96 deletions(-) create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/enter/dto/ChangeTypeStatesDto.java diff --git a/shapelight-admin/src/main/java/net/shapelight/common/config/ShiroConfig.java b/shapelight-admin/src/main/java/net/shapelight/common/config/ShiroConfig.java index 35357b2..310f36f 100644 --- a/shapelight-admin/src/main/java/net/shapelight/common/config/ShiroConfig.java +++ b/shapelight-admin/src/main/java/net/shapelight/common/config/ShiroConfig.java @@ -127,6 +127,7 @@ public class ShiroConfig { filterMap.put("/swagger-ui.html", "anon"); filterMap.put("/swagger-resources/**", "anon"); filterMap.put("/captcha.jpg", "anon"); + filterMap.put("/cq/demo/**", "anon"); // filterMap.put("/aaa.txt", "anon"); filterMap.put("/**", "oauth2"); 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 753d3e5..c4e9c0c 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 @@ -2,10 +2,7 @@ package net.shapelight.modules.face.rtsp; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.json.JSONObject; -import com.arcsoft.face.FaceEngine; -import com.arcsoft.face.FaceFeature; import com.arcsoft.face.FaceInfo; -import com.arcsoft.face.FaceSimilar; import com.arcsoft.face.enums.ExtractType; import com.arcsoft.face.toolkit.ImageFactory; import com.arcsoft.face.toolkit.ImageInfo; @@ -14,19 +11,13 @@ 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; -import net.shapelight.modules.face.face.FacePreviewInfo; -import net.shapelight.modules.face.rpc.BusinessException; import net.shapelight.modules.face.service.FaceEngineService; -import net.shapelight.modules.face.service.impl.FaceEngineServiceImpl; import net.shapelight.modules.face.util.UserInfo; import net.shapelight.modules.face.util.UserRamGroup; import net.shapelight.modules.feignClient.CxFeignClient; @@ -36,23 +27,27 @@ import net.shapelight.modules.ten.entity.TenCellEntity; import net.shapelight.modules.ten.entity.TenPersonEntity; import net.shapelight.modules.ten.service.TenPersonService; import net.shapelight.modules.ten.service.impl.TenPersonServiceImpl; -import org.apache.commons.pool2.impl.GenericObjectPool; import org.bytedeco.javacpp.avutil; -import org.bytedeco.javacv.*; +import org.bytedeco.javacv.FFmpegFrameGrabber; +import org.bytedeco.javacv.Frame; +import org.bytedeco.javacv.FrameGrabber; +import org.bytedeco.javacv.Java2DFrameConverter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.cloud.openfeign.FeignClient; import org.springframework.stereotype.Component; import org.springframework.web.multipart.MultipartFile; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; -import java.io.*; -import java.nio.charset.StandardCharsets; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; import java.text.SimpleDateFormat; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import static org.bytedeco.javacpp.avutil.AV_LOG_ERROR; @@ -253,17 +248,6 @@ public class RtspFrameGrabber { List faceInfoList = faceEngineService.detectFaces(imageInfo); - /* for (FaceInfo faceInfo : faceInfoList) { - System.out.println(faceInfo.getFace3DAngle()); - //Yaw上下 Pitch左右 - if (faceInfo.getFace3DAngle().getYaw() > 20 || faceInfo.getFace3DAngle().getYaw() < -20) { - System.out.println("没在好好看!!!"); - // faceInfoList.remove(faceInfo); - } - if (faceInfo.getFace3DAngle().getPitch() > 20 || faceInfo.getFace3DAngle().getPitch() < -20) { - System.out.println("没在好好看!!!"); - } - }*/ if (CollectionUtil.isNotEmpty(faceInfoList)) { @@ -282,6 +266,11 @@ public class RtspFrameGrabber { for (UserCompareInfo userCompareInfo : userCompareInfoList) { FaceVideoVo faceVideoVo = new FaceVideoVo(); + + //System.out.println("faceInfo = " + faceInfo.getRect()); + + faceVideoVo.setRect(faceInfo.getRect()); + if (faceInfo.getFace3DAngle().getYaw() > 20 || faceInfo.getFace3DAngle().getYaw() < -20) { faceVideoVo.setIsHeadOnView(0); }else if (faceInfo.getFace3DAngle().getPitch() > 20 || faceInfo.getFace3DAngle().getPitch() < -20) { @@ -322,45 +311,48 @@ public class RtspFrameGrabber { faceVideoVo.setImageUrl(frameFileName); temp.add(faceVideoVo); - } - if (!userCompareInfoList.isEmpty()) { - for (UserCompareInfo userCompareInfo : userCompareInfoList) { - TenPersonEntity tenPerson = personService.getOne(new LambdaQueryWrapper() - .eq(TenPersonEntity::getPersonId, userCompareInfo.getFaceId())); - Map personnelTypeMap = new HashMap<>(); - 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("pmWatchVideoRecordId", ""); - params.put("orgId", tenPerson.getOrgId()); - params.put("orgName", tenCellDao.selectOne(new QueryWrapper().eq("cell_id", tenPerson.getCellId()))); - params.put("personnelName", tenPerson.getName()); - params.put("personnelId", tenPerson.getOpenId()); - params.put("personnelCardId", tenPerson.getIdCard()); - params.put("personnelType", personnelTypeMap.get(tenPerson.getPersonType())); - params.put("dictSex", tenPerson.getGender() == 0 ? "女" : "男"); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); - params.put("watchVideoTime", sdf.format(System.currentTimeMillis())); - tenPerson.setIsWatchSafeVideo(1); - tenPersonService.updateById(tenPerson); - System.out.println("params = " + params); + TenPersonEntity tenPerson = personService.getOne(new LambdaQueryWrapper() + .eq(TenPersonEntity::getPersonId, userCompareInfo.getFaceId())); + Map personnelTypeMap = new HashMap<>(); + 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");//访客 - /* JSONObject jsonObject = feignClient.savePmWatchVideoRecord(params); + // + Map params = new HashMap<>(); + params.put("pmWatchVideoRecordId", ""); + params.put("orgId", tenPerson.getOrgId()); + params.put("orgName", tenCellDao.selectOne(new QueryWrapper().eq("cell_id", tenPerson.getCellId())).getName()); + params.put("personnelName", tenPerson.getName()); + params.put("personnelId", tenPerson.getOpenId()); + params.put("personnelCardId", tenPerson.getIdCard()); + params.put("personnelType", personnelTypeMap.get(tenPerson.getPersonType())); + params.put("dictSex", tenPerson.getGender() == 0 ? "女" : "男"); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); + params.put("watchVideoTime", sdf.format(System.currentTimeMillis())); + + + tenPerson.setIsWatchSafeVideo(faceVideoVo.getIsHeadOnView() == 0 ? 2 : 1); + + + tenPersonService.updateById(tenPerson); + + System.out.println("params = " + params); + + if(faceVideoVo.getIsHeadOnView() == 1){ + /* JSONObject jsonObject = feignClient.savePmWatchVideoRecord(params); if (jsonObject.getBool("success") != null && jsonObject.getBool("success")) { personService.update(new LambdaUpdateWrapper() .set(TenPersonEntity::getIsWatchSafeVideo, 1) .eq(TenPersonEntity::getPersonId, userCompareInfo.getFaceId())); }*/ } - - } + } else { log.error("图片不合格,未检测到人脸"); } 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 65736fe..87b1c1c 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 @@ -890,7 +890,7 @@ public class HttpApiController { 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")){ log.debug("同步进出场记录成功"); }else { diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/DemoController.java b/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/DemoController.java index 2b91eea..362cb3a 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/DemoController.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/DemoController.java @@ -1,10 +1,15 @@ package net.shapelight.modules.iCq.controller; import cn.hutool.json.JSONObject; +import com.arcsoft.face.ActiveDeviceInfo; +import com.arcsoft.face.FaceEngine; +import com.arcsoft.face.enums.ErrorInfo; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import io.minio.MinioClient; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; +import net.shapelight.common.config.GlobalValue; import net.shapelight.common.utils.R; import net.shapelight.modules.iCq.dal.mysql.enter.CqEnterConfigCellMapper; import net.shapelight.modules.iCq.dal.mysql.enter.CqEnterConfigMapper; @@ -16,6 +21,9 @@ import net.shapelight.modules.ten.entity.TenCellEntity; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import net.shapelight.modules.face.factory.FaceEngineFactory; + +import java.util.regex.Pattern; @RestController @RequestMapping("cq/demo") @@ -32,8 +40,11 @@ public class DemoController { @Autowired private TenCellDao tenCellDao; + @Autowired + private GlobalValue globalValue; + @GetMapping("/save1") - public void saveSupplier(){ + public void saveSupplier(String type){ /* System.out.println("测试开始"); TenCellEntity tenCellEntity = tenCellDao.selectOne(new QueryWrapper().eq("cell_id", "1255898969448382468")); @@ -75,9 +86,98 @@ public class DemoController { task.save(jsonObject, tenCellEntity);*/ - task.getPmInternalPersonnelList2(); + task.getPmInternalPersonnelList2(type); + } + + + @GetMapping("/offline") + public R activeOffline() { + FaceEngine faceEngine; + String USER_HOME = System.getProperty("user.home"); + System.out.println(USER_HOME); + String jvmName = System.getProperty("java.vm.name", "").toLowerCase(); + String osName = System.getProperty("os.name", "").toLowerCase(); + String osArch = System.getProperty("os.arch", "").toLowerCase(); + String abiType = System.getProperty("sun.arch.abi", "").toLowerCase(); + String libPath = System.getProperty("sun.boot.library.path", "").toLowerCase(); + USER_HOME = System.getProperty("user.home"); + if (jvmName.startsWith("dalvik") && osName.startsWith("linux")) { + osName = "android"; + } else if (jvmName.startsWith("robovm") && osName.startsWith("darwin")) { + osName = "ios"; + osArch = "arm"; + } else if (osName.startsWith("mac os x") || osName.startsWith("darwin")) { + osName = "macosx"; + } else { + int spaceIndex = osName.indexOf(' '); + if (spaceIndex > 0) { + osName = osName.substring(0, spaceIndex); + } + } + if (osArch.equals("i386") || osArch.equals("i486") || osArch.equals("i586") || osArch.equals("i686")) { + osArch = "x86"; + } else if (osArch.equals("amd64") || osArch.equals("x86-64") || osArch.equals("x64")) { + osArch = "x86_64"; + } else if (osArch.startsWith("aarch64") || osArch.startsWith("armv8") || osArch.startsWith("arm64")) { + osArch = "arm64"; + } else if ((osArch.startsWith("arm")) && ((abiType.equals("gnueabihf")) || (libPath.contains("openjdk-armhf")))) { + osArch = "armhf"; + } else if (osArch.startsWith("arm")) { + osArch = "arm"; + } + String PLATFORM = osName + "-" + osArch; + + System.out.println("PLATFORM = " + PLATFORM); + + String CACHE_LIB_FOLDER = USER_HOME + "/.arcface/cache/" + "4.1" + "/" + PLATFORM + "/"; + + System.out.println("CACHE_LIB_FOLDER = " + CACHE_LIB_FOLDER); + + if (Pattern.matches("windows.*", osName)) { + + System.out.println("osName = " + osName); + faceEngine = new FaceEngine(CACHE_LIB_FOLDER); + }else{ + // faceEngine = new FaceEngine("D:\\00_桌面\\ArcSoft_ArcFacePro_windows_x64_java_V4.1\\libs\\WIN64"); + faceEngine = new FaceEngine(CACHE_LIB_FOLDER); + } + + + ActiveDeviceInfo activeDeviceInfo = new ActiveDeviceInfo(); + int code = faceEngine.getActiveDeviceInfo(activeDeviceInfo); + +// System.out.println("\n设备信息:" + activeDeviceInfo.toString() + "\n"); // 这个(com.arcsoft.face.model.ActiveDeviceInfo@4ad9b7b)并不是设备信息 + System.out.println("设备信息:" + activeDeviceInfo.getDeviceInfo() + "\n"); // 这个的结果才是设备信息 + + + return R.ok().put("data", activeDeviceInfo.getDeviceInfo()); + + + } + + + @PostMapping("/changeBucketPolicy") + public R changeBucketPolicy() { + String info; + try { + MinioClient minioClient = new MinioClient( + globalValue.getMinioEndpoint(), // MinIO 服务器的 URL + globalValue.getMinioAccessKey(), // 访问密钥 + globalValue.getMinioSecretKey() // 密钥 + ); + + String bucketName = "cell"; // 替换为你的桶名 + String policy = "{ \"Version\": \"2012-10-17\", \"Statement\": [ { \"Effect\": \"Allow\", \"Principal\": { \"AWS\": [ \"*\" ] }, \"Action\": [ \"s3:GetObject\", \"s3:ListBucket\" ], \"Resource\": [ \"arn:aws:s3:::" + bucketName + "\", \"arn:aws:s3:::" + bucketName + "/*\" ] } ] }"; + // 设置桶策略 + minioClient.setBucketPolicy(bucketName, policy); + info = "Bucket policy set successfully"; + } catch (Exception e) { + info = "Error occurred"; + } + return R.ok().put("data", info); } + } \ No newline at end of file diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/enter/CqEnterController.java b/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/enter/CqEnterController.java index e74049a..93c10a6 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/enter/CqEnterController.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/enter/CqEnterController.java @@ -4,13 +4,17 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import net.shapelight.common.utils.R; +import net.shapelight.modules.iCq.controller.enter.dto.ChangeTypeStatesDto; import net.shapelight.modules.iCq.dal.mysql.enter.CqEnterConfigCellMapper; import net.shapelight.modules.iCq.dal.mysql.enter.CqEnterConfigMapper; import net.shapelight.modules.iCq.dal.mysql.enter.CqEnterConfigTypeMapper; import net.shapelight.modules.iCq.service.enter.CqEnterServiceImpl; import net.shapelight.modules.job.task.PersonSynchronousTask; +import oracle.jdbc.proxy.annotation.Post; import org.springframework.web.bind.annotation.*; +import java.util.Map; + @RestController @RequestMapping("cq/enterConfig") @@ -45,10 +49,10 @@ public class CqEnterController { return R.ok().put("data", cqEnterService.rulesByType(typeId, cellId)); } - @PutMapping("/changeState/{ruleId}") + @PostMapping("/changeState") @ApiOperation(value = "改变配置状态") - public R changeState(@PathVariable int ruleId){ - if (cqEnterService.changeState(ruleId)){ + public R changeState(@RequestBody ChangeTypeStatesDto data){ + if (cqEnterService.changeState(data.getRuleId(), data.getCellId(), data.getTypeId())){ return R.ok(); }else { return R.error(); diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/enter/dto/ChangeTypeStatesDto.java b/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/enter/dto/ChangeTypeStatesDto.java new file mode 100644 index 0000000..d62b45c --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/iCq/controller/enter/dto/ChangeTypeStatesDto.java @@ -0,0 +1,16 @@ +package net.shapelight.modules.iCq.controller.enter.dto; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Accessors(chain = true) +public class ChangeTypeStatesDto { + private Integer ruleId; + private String cellId; + private Integer typeId; +} 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 962bd15..d647558 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 @@ -86,7 +86,11 @@ public class CqSafeVideoController { @PutMapping("/update") @ApiOperation(value = "更新视频接口") - public R update(@RequestBody UpdateVideoDto updateVideoDto) { + public R update(@RequestBody UpdateVideoDto updateVideoDto, + @RequestHeader(value = "X-HTTP-Method-Override", required = false) String methodOverride) { + + System.out.println("methodOverride = " + methodOverride); + if (cqSafeVideoService.update(updateVideoDto) == 1) { return R.ok(); } else { 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 7c38215..e0f2a12 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 @@ -1,6 +1,7 @@ package net.shapelight.modules.iCq.controller.video.vo; +import com.arcsoft.face.Rect; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -30,6 +31,11 @@ public class FaceVideoVo { */ private String imageUrl; + /** + * 人员头像坐标 + */ + private Rect rect; + } 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 3b32b2c..2a6a3dd 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 @@ -113,33 +113,20 @@ public class CqEnterServiceImpl { * @return */ @Transactional - public boolean changeState(int ruleId) { - - 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; - }*/ + public boolean changeState(int ruleId, String cellId, int typeId) { return cqEnterConfigCellMapper.update( null, new UpdateWrapper() - .eq("enter_config_id", cqEnterConfigCellMapper - .selectOne(new QueryWrapper().eq("id", (ruleId % 6) + 1)) - .getEnterConfigId()) - .eq("cell_id", cqEnterConfigCellMapper - .selectOne(new QueryWrapper().eq("id", (ruleId % 6) + 1)).getCellId()) + .eq("enter_config_id", ruleId) + .eq("cell_id", cellId) .set("operate_time", new Date())) > 0 && cqEnterConfigTypeMapper.update( null, new UpdateWrapper() - .eq("id", ruleId) + .eq("enter_config_id", ruleId) + .eq("type_id", typeId) + .eq("cell_id", cellId) .setSql("state = 1 - state")) > 0; } 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 904e5d2..5ebdcc2 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 @@ -3,6 +3,7 @@ package net.shapelight.modules.job.task; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.json.JSONArray; import cn.hutool.json.JSONObject; +import com.arcsoft.face.FaceEngine; import com.arcsoft.face.FaceInfo; import com.arcsoft.face.enums.ExtractType; import com.arcsoft.face.toolkit.ImageFactory; @@ -39,6 +40,7 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; import java.util.logging.SimpleFormatter; +import java.util.regex.Pattern; @Component("personSynchronousTask") @Slf4j @@ -149,8 +151,16 @@ public class PersonSynchronousTask extends AbstractController implements ITask { System.out.println("cssssssssssssssssssssss" + data); JSONArray dataList = data.getJSONArray("list"); List list1 = dataList.toList(JSONObject.class); - String filePath = "C:\\zhihuiyuanqu\\firePerson.txt"; + + String osName = System.getProperty("os.name", "").toLowerCase(); + // 创建一个File对象 + String filePath; + if (Pattern.matches("windows.*", osName)) { + filePath = "C:\\zhihuiyuanqu\\firePerson.txt"; + }else{ + filePath = "zhihuiyuanqu/firePerson.txt"; + } File file = new File(filePath); // 确保父目录存在 if (file.getParentFile() != null) { @@ -159,7 +169,7 @@ public class PersonSynchronousTask extends AbstractController implements ITask { try (FileWriter writer = new FileWriter(file)) { // 写入数据 list1.forEach(person -> { - String msg = save(person, item); + String msg = save(person, item, type); System.out.println("msg = " + msg); if (!msg.isEmpty()) { try { @@ -186,7 +196,7 @@ public class PersonSynchronousTask extends AbstractController implements ITask { - public void getPmInternalPersonnelList2() { + public void getPmInternalPersonnelList2(String type) { List list = tenCellService.list(); list.forEach(item -> { int pageIndex = 1; @@ -262,7 +272,7 @@ public class PersonSynchronousTask extends AbstractController implements ITask { "}\n";*/ - String jsonString = "{\n" + + /*String jsonString = "{\n" + " \"data\": {\n" + " \"list\": [\n" + " {\n" + @@ -289,7 +299,74 @@ public class PersonSynchronousTask extends AbstractController implements ITask { " \"errCode\": \"0\",\n" + " \"resCode\": 1,\n" + " \"timestamp\": 1729497503\n" + - "}"; + "}";*/ + + + String jsonString = "{\n" + + " \"success\": true,\n" + + " \"message\": null,\n" + + " \"errCode\": \"0\",\n" + + " \"resCode\": 1,\n" + + " \"apiVersion\": \"1\",\n" + + " \"timestamp\": 1726651433,\n" + + " \"data\": {\n" + + " \"apiVersion\": null,\n" + + " \"list\": [\n" + + " {\n" + + " \"pmContractorId\": \"73e92ad1ec104074a791540f65db99af\", \n" + + " \"orgId\": \"ORGACQ100008461\", \n" + + " \"orgName\": \"第二采油厂\\\\城壕采油作业区\", \n" + + " \"contractorName\": \"赵刚\", \n" + + " \"contractorCardId\": \"610501198910191210\", \n" + + " \"dictSex\": \"0\", \n" + + " \"dictSexName\": \"男\", \n" + + " \"validPeriodSta\": \"2024-09-03 00:00:00\",\n" + + " \"validPeriodEnd\": \"2024-10-31 00:00:00\",\n" + + " \"dictNation\": \"01\", \n" + + " \"dicPolitical\": \"1\",\n" + + " \"dictNationName\": \"汉族\",\n" + + " \"dicPoliticalName\": \"中共党员\",\n" + + " \"mobile\": \"13772488873\", \n" + + " \"belongContractor\": \"21C0E54714D20F1DE06344A44E0ADD89\", \n" + + " \"belongTeam\": \"十多个的防火防盗\",\n" + + " \"certificateType\": \"特种作业人员\",\n" + + " \"isEnterSulfurArea\": \"是\", \n" + + " \"isProtectDevice\": \"否\",\n" + + " \"isBlacklistPersonnel\": \"否\",\n" + + " \"isWatchSafeVideo\": \"未观看\",\n" + + " \"belongContractorName\": \"测试承包商\", \n" + + " \"attachment\": null, \n" + + " \"pmContractorCertDatas\": [ \n" + + " {\n" + + " \"pmContractorId\": \"73e92ad1ec104074a791540f65db99af\",\n" + + " \"pmContractorCertId\":\"c4316aba1e9c49cca03d7cd95832bf6a\",\n" + + " \t\t\t\t\t \"category\": null, \n" + + " \"certName\": \"333\", \n" + + " \"issueUnit\": \"3333\",\n" + + " \"certObtainDate\": \"2024-09-03\",\n" + + " \"effectiveDate\": \"2024-09-27\",\n" + + " \"certType\": \"特种作业人员\" ,\n" + + "\"attachment\": null \n" + + " }\n" + + " ],\n" + + " \"pmContractorTrainDatas\": [ \n" + + " {\n" + + " \"pmContractorId\": \"73e92ad1ec104074a791540f65db99af\",\n" + + " \"pmContractorTrainId\": \"75b9b3e6d16944ff8297e5fa04890c39\",\n" + + " \"trainContent\": \"问题而光伏发电\", \n" + + " \"trainStartDate\": \"2024-09-03\",\n" + + "\"trainEndDate\": \"2024-09-30\",\n" + + "\"theoreticalScore\": \"null\",\n" + + "\"practiceScore\": \"null\",\n" + + " \"personnelType\": \"特种作业人员\",\n" + + " \"isQualified\": \"是\" \n" + + " }\n" + + " ]\n" + + " }\n" + + " ],\n" + + " \"total\": 1\n" + + " }\n" + + "}\n"; JSONObject jsonOne = new JSONObject(jsonString); @@ -328,7 +405,7 @@ public class PersonSynchronousTask extends AbstractController implements ITask { // 写入数据 list1.forEach(person -> { System.out.println("开始保存"); - String msg = save(person, item); + String msg = save(person, item, type); if (!msg.isEmpty()) { try { writer.write(msg); @@ -354,7 +431,7 @@ public class PersonSynchronousTask extends AbstractController implements ITask { - public String save(JSONObject person, TenCellEntity cellEntity) { + public String save(JSONObject person, TenCellEntity cellEntity, String type) { /*System.out.println("personcscscs= " + person);*/ @@ -371,6 +448,16 @@ public class PersonSynchronousTask extends AbstractController implements ITask { tenPerson.setCreateTime(now); tenPerson.setLastUpdateTime(now); + //type + if (type.equals("Person")) { + tenPerson.setPersonType(5000); + } else if (type.equals("Contractor")) {//承包商 + tenPerson.setPersonType(5001); + } else { + tenPerson.setPersonType(5002); + } + + //tenPerson.setCellId(person.getStr("orgId") != null ? Long.parseLong(UserRamGroup.getOrgCellMap(person.getStr("orgId"))) : null); /* tenPerson.setCellId(person.getStr("orgId") != null ? tenCellService.getOne(new QueryWrapper().eq("org_id", person.getStr("orgId"))).getCellId() : null);*/ @@ -381,7 +468,6 @@ public class PersonSynchronousTask extends AbstractController implements ITask { tenPerson.setCellId(1L); - /* System.out.println("id = " + id);*/ tenPerson.setOrgId(cellEntity.getOrgId()); @@ -393,9 +479,6 @@ public class PersonSynchronousTask extends AbstractController implements ITask { } if (person.getStr("personnelName") != null){ - /* if(person.getStr("personnelName").equals("邢严")){ - System.out.println("person水水水水水水水水水水水水水水水水水" + person); - }*/ tenPerson.setName(person.getStr("personnelName")); } @@ -721,8 +804,9 @@ public class PersonSynchronousTask extends AbstractController implements ITask { if(tenPersonService.getOne(new QueryWrapper() .eq("open_id", tenPerson.getOpenId())) != null) { + //MyBatis-Plus会优先使用 personId 作为主键,因为它更具体地定义了主键的生成策略。 tenPersonService.removeById(tenPersonService.getOne(new QueryWrapper() - .eq("open_id", tenPerson.getOpenId())).getMemberId()); + .eq("open_id", tenPerson.getOpenId())).getPersonId()); } tenPersonService.saveTenPerson(tenPerson); System.out.println("新增成功" + tenPerson); 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 684cd18..f4c3263 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 @@ -50,6 +50,7 @@ import net.shapelight.modules.ten.service.*; import net.shapelight.modules.ten.vo.PersonExcelModel; import net.shapelight.modules.vo.TenDeviceVo; import net.shapelight.modules.vo.TenPersonOperationVo; +import net.shapelight.modules.vo.TenPersonVo; import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; import org.apache.poi.ss.usermodel.HorizontalAlignment; @@ -346,6 +347,10 @@ public class TenPersonController extends AbstractController { } params.put("isBlacklistPersonnel", 1); PageUtils page = tenPersonService.queryPage(params); + + + + return R.ok().put("data", page); } @@ -581,7 +586,7 @@ public class TenPersonController extends AbstractController { params.put("attachment", "data:image/jpeg;base64," + base64); System.out.println("params = " + params); - //cxFeignClient.savePmVisitorPersonnel(params); + // cxFeignClient.savePmVisitorPersonnel(params); } return R.ok(); } 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 6b55dc0..a9849ca 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 @@ -113,6 +113,10 @@ public class TenPersonServiceImpl extends ServiceImpl params) { + + + System.out.println("params = " + params); + List cellIds = new ArrayList<>(); // cellIds.add(709832651506188289L); @@ -369,6 +373,8 @@ public class TenPersonServiceImpl extends ServiceImpl faceInfoList = faceEngineService.detectFaces(rgbData); + System.out.println("--测试打印--"); if (CollectionUtil.isNotEmpty(faceInfoList)) { FaceInfo faceInfo = faceInfoList.get(0); FaceRecognitionResDTO faceRecognitionResDTO = new FaceRecognitionResDTO(); diff --git a/shapelight-admin/src/main/resources/mapper/ten/TenPersonDao.xml b/shapelight-admin/src/main/resources/mapper/ten/TenPersonDao.xml index 6ecd3ea..68abe14 100644 --- a/shapelight-admin/src/main/resources/mapper/ten/TenPersonDao.xml +++ b/shapelight-admin/src/main/resources/mapper/ten/TenPersonDao.xml @@ -143,7 +143,7 @@ - + insert into ten_person @@ -335,6 +335,10 @@ is_check_cert, + + belong_contractor_name, + + @@ -527,6 +531,9 @@ #{isCheckCert}, + + #{belongContractorName}, + @@ -902,6 +909,9 @@ and p.live_end < #{params.liveEnd} + + and p.is_blacklist_personnel = #{params.isBlacklistPersonnel} + order by p.create_time desc