diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/task/KitchenStaffInfoFaceTask.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/task/KitchenStaffInfoFaceTask.java index 38173aa..789a733 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/task/KitchenStaffInfoFaceTask.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/cook/task/KitchenStaffInfoFaceTask.java @@ -10,6 +10,7 @@ import com.bonus.canteen.core.kitchen.utils.NetSDK.FaceManage; import com.bonus.canteen.core.kitchen.utils.NetSDK.UserManage; import com.bonus.canteen.core.kitchen.utils.initServer; import com.bonus.canteen.core.kitchen.vo.KitchenDeviceListVO; +import com.bonus.canteen.core.utils.BnsUtils; import com.bonus.common.houqin.constant.DeviceTypeEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -18,8 +19,11 @@ import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import org.springframework.transaction.support.TransactionTemplate; +import java.io.File; +import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.util.ArrayList; +import java.util.Date; import java.util.List; @Component @@ -35,13 +39,15 @@ public class KitchenStaffInfoFaceTask { // private TransactionTemplate transactionTemplate; //@XxlJob("cookRecipeHandler") - @Scheduled(fixedDelay = 10*60*1000) + @Scheduled(fixedDelay = 1*60*1000) public void KitchenStaffInfoFaceHandler() { - if(1==1){ - return; - } logger.info("[定时修复发送门禁人脸信息]开始:{},{}", "0", LocalDateTime.now()); + SimpleDateFormat sdf =new SimpleDateFormat("HH"); try{ + String hour=sdf.format(new Date()); + if(!"23".equals(hour)){ + return; + } List list=this.kitchenStaffInfoService.selectKitchenStaffInfoList(new KitchenStaffInfo()); int userl=-1; String ip="192.168.20.51"; @@ -71,7 +77,9 @@ public class KitchenStaffInfoFaceTask { logger.info(info.getStaffNo()); logger.info(info.getFaceUrl()); UserManage.addUserInfo(userl,info.getStaffNo(),info.getStaffName()); - int faceres=FaceManage.AddFaceByBinary(userl,info.getStaffNo(),info.getFaceUrl().replace("http://192.168.0.14:9090/lnyst/","")); + File file = BnsUtils.getFile(info.getFaceUrl(),info.getFaceUrl().substring(info.getFaceUrl().indexOf("/"))); + System.out.println(file.getAbsolutePath()); + int faceres=FaceManage.AddFaceByBinaryFile(userl,info.getStaffNo(),file); if(faceres==1){ info.setFaceFlage("1"); kitchenStaffInfoService.updateKitchenStaffInfoFaceFlage(info); diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/kitchen/service/impl/KitchenStaffInfoServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/kitchen/service/impl/KitchenStaffInfoServiceImpl.java index 841638c..7662f97 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/kitchen/service/impl/KitchenStaffInfoServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/kitchen/service/impl/KitchenStaffInfoServiceImpl.java @@ -287,8 +287,8 @@ public class KitchenStaffInfoServiceImpl implements IKitchenStaffInfoService { UserManage.addUserInfo(initServer.lUserID,kitchenStaffInfo.getStaffNo(),kitchenStaffInfo.getStaffName()); System.out.println(kitchenStaffInfo.getFaceUrl()); File file = BnsUtils.getFile(kitchenStaffInfo.getFaceUrl(),kitchenStaffInfo.getFaceUrl().substring(kitchenStaffInfo.getFaceUrl().indexOf("/"))); - System.out.println(file.getAbsolutePath().replace("\\","/")); - int numd=FaceManage.addFaceByUrl(initServer.lUserID,kitchenStaffInfo.getStaffNo(),kitchenStaffInfo.getFaceUrl()); + System.out.println(file.getAbsolutePath()); + int numd=FaceManage.AddFaceByBinaryFile(initServer.lUserID,kitchenStaffInfo.getStaffNo(),file); if(numd>0){ System.out.println(kitchenStaffInfo.getStaffNo()+" "+kitchenStaffInfo.getStaffName()+" "+"门禁人脸下发成功!"+kitchenStaffInfo.getFaceUrl()); kitchenStaffInfo.setFaceFlage("1"); @@ -301,6 +301,8 @@ public class KitchenStaffInfoServiceImpl implements IKitchenStaffInfoService { }catch (Exception e){ e.printStackTrace(); } + }else{ + System.err.println(kitchenStaffInfo.getStaffNo()+" "+kitchenStaffInfo.getStaffName()+" 人员权限不足 "+kitchenStaffInfo.getFaceUrl()); } } kitchenStaffDevicePrivilegeService.insertKitchenStaffDevicePrivilege(kitchenStaffDevicePrivilegeList); diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/utils/BnsUtils.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/utils/BnsUtils.java index f9e4dc3..059f33a 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/utils/BnsUtils.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/utils/BnsUtils.java @@ -58,7 +58,7 @@ public class BnsUtils { InputStream inStream = null; OutputStream os = null; try { - file = new File( System.getProperty("user.dir") +"\\newImg"+suffix); + file = new File( System.getProperty("user.dir") +"\\newImg"+".jpg"); //下载 urlfile = new URL(url); inStream = urlfile.openStream();