From 9ef944f83e337193293807cdcc6e7bbc1c494c25 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期二, 20 八月 2024 15:09:27 +0800
Subject: [PATCH] 最新版本
---
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncVisitServiceImpl.java | 179 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 175 insertions(+), 4 deletions(-)
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncVisitServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncVisitServiceImpl.java
index 8a287bf..09e6a3f 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncVisitServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncVisitServiceImpl.java
@@ -52,7 +52,7 @@
@Autowired
private WxPlatNotice wxPlatNotice;
/**
- * 鍚屾娴峰悍璁垮淇℃伅,鏍规嵁erp鍚屾缁勭粐缁撴灉锛屽畾鏃舵鏌ラ渶瑕佷笅鍙戝埌娴峰悍鐨勭粍缁囦俊鎭�
+ * 鍚屾娴峰悍璁垮淇℃伅鏄惁宸茬绂荤姸鎬�
*/
@Override
public void getOutTimeVisitRecord(){
@@ -219,7 +219,8 @@
Date date = new Date();
for(Visits c : list) {
//鍙戣捣娴峰悍棰勭害鎺ュ彛锛堥渶瑕佺櫥璁帮級锛屾牴鎹绾﹁繑鍥炴帴鍙e皝瑁呯敵璇疯褰曟洿鏂板瓧娈�
- getUpdateModelByResponse(c,date,roleList,path);
+// getUpdateModelByResponse(c,date,roleList,path);
+ getUpdateModelByResponseIccm(c,date,roleList,path);
visitsMapper.updateById(c);
if(Objects.isNull(c.getParentId())){
wxPlatNotice.sendVisitAuditTemplateNotice(c,
@@ -266,7 +267,6 @@
* @param c
* @param date
* @param date
- * @param type 0闇�瑕佺櫥璁� 1鍏嶇櫥璁�
*/
private void getUpdateModelByResponse( Visits c,Date date, List<DeviceRole> roleList,String path ) {
String code = null;
@@ -315,7 +315,6 @@
}
reson = response!=null?JSONObject.toJSONString(response):"";
}
-
if (code!= null && id!=null) {
//娴峰悍涓嬪彂鎴愬姛
c.setHkId( id);//棰勭害鏍囪瘑
@@ -323,6 +322,67 @@
c.setRemark("涓嬪彂娴峰悍鎴愬姛锛�");
c.setStatus(Constants.VisitStatus.xfSuccess);//涓嬪彂娴峰悍鎴愬姛
} else {
+ //娴峰悍涓嬪彂澶辫触
+ c.setRemark("涓嬪彂娴峰悍澶辫触,鍘熷洜锛�"+ reson);
+ c.setStatus(Constants.VisitStatus.xfFail);//涓嬪彂娴峰悍澶辫触
+ }
+ c.setHkStatus(Constants.ONE);
+ c.setHkDate(date);
+ }
+ private void getUpdateModelByResponseIccm( Visits c,Date date, List<DeviceRole> roleList,String path ) {
+ String code = null;
+ String id = null;
+ String qrcode = null;
+ String reson = "";
+ //鍙戣捣娴峰悍棰勭害鎺ュ彛
+ if(Constants.equalsInteger(c.getVisitType(),Constants.ZERO)){
+ //锛堥渶瑕佺櫥璁帮級
+ c.setVisitType(Constants.ZERO);
+ IccmAppointmentRequest request = getHkRequestParaIccm(c,roleList,path);
+ if(request == null){
+ //娴峰悍涓嬪彂鎴愬姛
+ c.setStatus(Constants.VisitStatus.xfFail);//涓嬪彂娴峰悍澶辫触
+ c.setRemark("涓嬪彂娴峰悍鍙傛暟涓嶆纭紒");
+ c.setHkStatus(Constants.ONE);
+ c.setHkDate(date);
+ return;
+ }
+ BaseResponse<IccmAppointmentResponse> response = HKService.iccmAppointment(request);
+ code =response!=null ?response.getCode():null;
+ if((response!=null && response.getData()!=null
+ && response.getData().getAppointmentInfoList() !=null
+ && response.getData().getAppointmentInfoList().size()>0)){
+ id =response.getData().getOrderId();
+ qrcode =response.getData().getAppointmentInfoList().get(0).getQRCode();
+ }
+ reson = response!=null?JSONObject.toJSONString(response):"";
+ }else{
+ //鍏嶇櫥璁�
+ c.setVisitType(Constants.ONE);
+ IccmAppointmentMDJRequest request =getHkMDJRequestParamIccm(c,roleList,path);
+ if(request == null){
+ //娴峰悍涓嬪彂鎴愬姛
+ c.setStatus(Constants.VisitStatus.xfFail);//涓嬪彂娴峰悍澶辫触
+ c.setRemark("涓嬪彂娴峰悍鍏嶇櫥璁板弬鏁颁笉姝g‘锛�");
+ c.setHkStatus(Constants.ONE);
+ c.setHkDate(date);
+ return;
+ }
+ BaseResponse<IccmAppointmentMDJResponse> response = HKService.iccmAppiontmentMDJ(request );
+ code =response!=null ?response.getCode():null;
+ if(response!=null && response.getData()!=null){
+ id = response.getData().getOrderId();
+ qrcode =response.getData().getQRCode();
+ }
+ reson = response!=null?JSONObject.toJSONString(response):"";
+ }
+ if (code!= null && id!=null) {
+ //娴峰悍涓嬪彂鎴愬姛
+ c.setHkId( id);//棰勭害鏍囪瘑
+ c.setQrcode(qrcode);
+ c.setRemark("涓嬪彂娴峰悍鎴愬姛锛�");
+ c.setStatus(Constants.VisitStatus.xfSuccess);//涓嬪彂娴峰悍鎴愬姛
+ }else {
//娴峰悍涓嬪彂澶辫触
c.setRemark("涓嬪彂娴峰悍澶辫触,鍘熷洜锛�"+ reson);
c.setStatus(Constants.VisitStatus.xfFail);//涓嬪彂娴峰悍澶辫触
@@ -359,6 +419,29 @@
request.setVisitorPermissionSet(getVisitPermissonRequest(roleList,c));
return request;
}
+ private IccmAppointmentMDJRequest getHkMDJRequestParamIccm(Visits c,List<DeviceRole> roleList,String path) {
+ IccmAppointmentMDJRequest request = new IccmAppointmentMDJRequest();
+ IccmAppointmentVistorRequest info =getRequestInfoByVisitIccm(c,path);
+ if(info == null ){
+ //浜鸿劯涓虹┖锛屼笉鑳借繘琛屾帹閫�
+ return null;
+ }
+ request.setVisitStartTime(DateUtil.getISO8601Timestamp2(c.getStarttime()));
+ request.setVisitEndTime(DateUtil.getISO8601Timestamp2(c.getEndtime()));
+ request.setReceptionistId(c.getReceptMemberHkId());//琚浜烘捣搴风紪鐮�
+ if(StringUtils.isNotBlank(c.getReason())){
+ char[] charArray = c.getReason().toCharArray();
+ int length = charArray.length;
+ if(length>32){
+ request.setVisitPurpose(c.getReason().substring(0,32));
+ }else{
+ request.setVisitPurpose(c.getReason());
+ }
+ }
+ request.setVisitorInfo(info);
+ request.setVisitorPermissionSet(getVisitPermissonRequestIccm(roleList,c));
+ return request;
+ }
/**
* 璁垮鏉冮檺缁�
@@ -368,6 +451,20 @@
*/
private VisitAppointmentPermissonRequest getVisitPermissonRequest(List<DeviceRole> roleList, Visits c) {
VisitAppointmentPermissonRequest p = new VisitAppointmentPermissonRequest();
+ //鑾峰彇鏉冮檺缁勯泦鍚�
+ String[] roles = getHkRoles(c.getDoors(),roleList);
+ if(roles==null || roles.length ==0){
+ //浣跨敤榛樿璁垮鏉冮檺缁�
+ p.setDefaultPrivilegeGroupFlag(Constants.ONE+"");
+ }else{
+ //鎸囧畾鏈夋晥娴峰悍璁垮鏉冮檺缁勬暟鎹�
+ p.setDefaultPrivilegeGroupFlag(Constants.ZERO+"");
+ p.setPrivilegeGroupIds(roles);
+ }
+ return p;
+ }
+ private IccmPermissionSetRequest getVisitPermissonRequestIccm(List<DeviceRole> roleList, Visits c) {
+ IccmPermissionSetRequest p = new IccmPermissionSetRequest();
//鑾峰彇鏉冮檺缁勯泦鍚�
String[] roles = getHkRoles(c.getDoors(),roleList);
if(roles==null || roles.length ==0){
@@ -409,6 +506,34 @@
request.setVisitorInfoList(infolist);
return request;
}
+ private IccmAppointmentRequest getHkRequestParaIccm(Visits c,List<DeviceRole> roleList,String path ) {
+ IccmAppointmentRequest request = new IccmAppointmentRequest();
+ //鐢宠浜轰俊鎭�
+ IccmAppointmentVistorRequest info =getRequestInfoByVisitIccm(c,path);
+ if(info == null ){
+ //浜鸿劯涓虹┖锛屼笉鑳借繘琛屾帹閫�
+ return null;
+ }
+ request.setVisitStartTime(DateUtil.getISO8601Timestamp(c.getStarttime()));
+ request.setVisitEndTime(DateUtil.getISO8601Timestamp(c.getEndtime()));
+ request.setReceptionistId(c.getReceptMemberHkId());//琚浜烘捣搴风紪鐮�
+
+ if(StringUtils.isNotBlank(c.getReason())){
+ char[] charArray = c.getReason().toCharArray();
+ int length = charArray.length;
+ if(length>32){
+ request.setVisitPurpose(c.getReason().substring(0,32));
+ }else{
+ request.setVisitPurpose(c.getReason());
+ }
+ }
+ //鑾峰彇鏉冮檺缁勯泦鍚�
+ request.setVisitorPermissionSet(getVisitPermissonRequestIccm(roleList,c));
+ List<IccmAppointmentVistorRequest> infolist = new ArrayList<>();
+ infolist.add(info);
+ request.setVisitorInfoList(infolist);
+ return request;
+ }
private VisitAppointmentVistorRequest getRequestInfoByVisit(Visits c,String path) {
VisitAppointmentVistorRequest info = new VisitAppointmentVistorRequest();
@@ -456,6 +581,52 @@
return info;
}
+ private IccmAppointmentVistorRequest getRequestInfoByVisitIccm(Visits c,String path) {
+ IccmAppointmentVistorRequest info = new IccmAppointmentVistorRequest();
+ //浜鸿劯鏁版嵁
+ if(StringUtils.isBlank(c.getName())
+ ||StringUtils.isBlank(c.getPhone())
+ || StringUtils.isBlank(c.getFaceImg()) ){
+ return null;
+ }
+ if(StringUtils.isNotBlank(c.getFaceImg())){
+ info.setVisitorPhoto(ImageBase64Util.Image2Base64(path+c.getFaceImg()));
+ }
+ if(info.getVisitorPhoto() == null){
+ return null;
+ }
+ if(StringUtils.isNotBlank(c.getName())){
+ char[] charArray = c.getName().toCharArray();
+ int length = charArray.length;
+ if(length>32){
+ info.setVisitorName(c.getName().substring(0,32));
+ }else{
+ info.setVisitorName(c.getName());
+ }
+ }
+
+ if(StringUtils.isNotBlank(c.getCompanyName())){
+ char[] charArray = c.getCompanyName().toCharArray();
+ int length = charArray.length;
+ if(length>32){
+ info.setVisitorWorkUnit(c.getCompanyName().substring(0,32));
+ }else{
+ info.setVisitorWorkUnit(c.getCompanyName());
+ }
+ }
+ info.setPhoneNo(c.getPhone());
+ info.setPlateNo(c.getCarNos());
+ info.setGender(c.getSex()+"");
+ if(Constants.equalsInteger(c.getIdcardType(),Constants.ZERO)){
+ info.setCertificateType(HKConstants.CertificateType.SHENFENZHENG.getKey()+"");
+ info.setCertificateNo(DESUtil.decrypt(Constants.EDS_PWD, c.getIdcardNo()));
+ } else if(Constants.equalsInteger(c.getIdcardType(),Constants.TWO)){
+ info.setCertificateType(HKConstants.CertificateType.HUZHAO.getKey()+"");
+ info.setCertificateNo(DESUtil.decrypt(Constants.EDS_PWD, c.getIdcardNo()));
+ }
+
+ return info;
+ }
private String[] getHkRoles(String doors, List<DeviceRole> roleList) {
if(StringUtils.isBlank(doors) || roleList.size()==0|| roleList.size()==0){
--
Gitblit v1.9.3