From eea92f23bf8ead897f346ae6ccc8603ac039e566 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期二, 30 七月 2024 09:48:47 +0800
Subject: [PATCH] 修复bug
---
server/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncVisitServiceImpl.java | 190 +++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 167 insertions(+), 23 deletions(-)
diff --git a/server/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncVisitServiceImpl.java b/server/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncVisitServiceImpl.java
index 4c5b975..5bdeaf0 100644
--- a/server/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncVisitServiceImpl.java
+++ b/server/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncVisitServiceImpl.java
@@ -1,8 +1,10 @@
package com.doumee.service.business.impl.hksync;
+import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.doumee.biz.system.SystemDictDataBiz;
+import com.doumee.config.DataSyncConfig;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
import com.doumee.core.haikang.model.HKConstants;
@@ -12,25 +14,22 @@
import com.doumee.core.haikang.model.param.request.event.visit.EventVisitInfoRequest;
import com.doumee.core.haikang.model.param.respose.*;
import com.doumee.core.haikang.service.HKService;
-import com.doumee.core.utils.Constants;
-import com.doumee.core.utils.DESUtil;
-import com.doumee.core.utils.DateUtil;
-import com.doumee.core.utils.ImageBase64Util;
+import com.doumee.core.utils.*;
import com.doumee.core.wx.wxPlat.WxPlatNotice;
import com.doumee.dao.business.DeviceRoleMapper;
import com.doumee.dao.business.RetentionMapper;
+import com.doumee.dao.business.VisitEventMapper;
import com.doumee.dao.business.join.VisitsJoinMapper;
-import com.doumee.dao.business.model.DeviceRole;
-import com.doumee.dao.business.model.Member;
-import com.doumee.dao.business.model.Retention;
-import com.doumee.dao.business.model.Visits;
+import com.doumee.dao.business.model.*;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
import java.util.*;
+import java.util.Date;
/**
* 娴峰悍璁垮涓氬姟Service瀹炵幇
@@ -40,8 +39,13 @@
@Service
@Slf4j
public class HkSyncVisitServiceImpl extends HkSyncBaseServiceImpl {
+
+ @Autowired
+ private DataSyncConfig dataSyncConfig;
@Autowired
private VisitsJoinMapper visitsMapper;
+ @Autowired
+ private VisitEventMapper visitEventMapper;
@Autowired
private RetentionMapper retentionMapper;
@Autowired
@@ -71,14 +75,15 @@
//鍙戣捣娴峰悍棰勭害鎺ュ彛锛堥渶瑕佺櫥璁帮級锛屾牴鎹绾﹁繑鍥炴帴鍙e皝瑁呯敵璇疯褰曟洿鏂板瓧娈�
AppointmentInfoResponse model = getVisitRecord(c.getHkId());
if(model == null){
- Visits update = new Visits();
+ continue;
+ /* Visits update = new Visits();
//宸插け鏁�
update.setStatus(Constants.VisitStatus.invalid);
update.setEditDate(date);
update.setId(c.getId());
update.setRemark("棰勭害宸茶娓呴櫎");
visitsMapper.updateById(update);
- continue;
+ continue;*/
}
/**
* * 0锛氬緟瀹℃牳锛堥绾﹀緟瀹℃壒锛夈��
@@ -111,7 +116,7 @@
if(!Constants.equalsInteger(c.getStatus(),Constants.VisitStatus.signout)){
Visits update = new Visits();
//宸插け鏁�
- update.setStatus(Constants.VisitStatus.invalid);
+ update.setStatus(Constants.VisitStatus.signout);
update.setEditDate(date);
update.setId(c.getId());
update.setInDate(DateUtil.getISO8601DateByStr2(model.getVisitStartTime()));
@@ -204,8 +209,8 @@
List<DeviceRole> roleList = deviceRoleMapper.selectList(new QueryWrapper<DeviceRole>().lambda()
.eq(DeviceRole::getType, Constants.ONE));
//鏍囪鏄惁璧板厤鐧昏棰勭害
- String applyType =systemDictDataBiz.queryByCode(Constants.HK_PARAM,Constants.MDJ_VISIT_REQUIRED).getCode();
- String applyLwType =systemDictDataBiz.queryByCode(Constants.HK_PARAM,Constants.MDJ_LW_REQUIRED).getCode();
+// String applyType =systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.MDJ_VISIT_REQUIRED).getCode();
+// String applyLwType =systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.MDJ_LW_REQUIRED).getCode();
try {
//鏌ヨ鎵�鏈夐渶瑕佸悓姝ョ殑鏁版嵁
List<Visits> list = getVisitList();
@@ -217,8 +222,7 @@
Date date = new Date();
for(Visits c : list) {
//鍙戣捣娴峰悍棰勭害鎺ュ彛锛堥渶瑕佺櫥璁帮級锛屾牴鎹绾﹁繑鍥炴帴鍙e皝瑁呯敵璇疯褰曟洿鏂板瓧娈�
- String type = Constants.equalsInteger(c.getType(),Constants.ONE)?applyType:applyLwType;
- getUpdateModelByResponse(c,date,type,roleList,path);
+ getUpdateModelByResponse(c,date,roleList,path);
visitsMapper.updateById(c);
if(Objects.isNull(c.getParentId())){
wxPlatNotice.sendVisitAuditTemplateNotice(c,
@@ -267,13 +271,15 @@
* @param date
* @param type 0闇�瑕佺櫥璁� 1鍏嶇櫥璁�
*/
- private void getUpdateModelByResponse( Visits c,Date date,String type,List<DeviceRole> roleList,String path ) {
+ private void getUpdateModelByResponse( Visits c,Date date, List<DeviceRole> roleList,String path ) {
String code = null;
String id = null;
String qrcode = null;
+ String reson = "";
//鍙戣捣娴峰悍棰勭害鎺ュ彛
- if(StringUtils.equals(type,"0")){
+ if(Constants.equalsInteger(c.getVisitType(),Constants.ZERO)){
//锛堥渶瑕佺櫥璁帮級
+ c.setVisitType(Constants.ZERO);
VisitAppointmentRequest request = getHkRequestPara(c,roleList,path);
if(request == null){
//娴峰悍涓嬪彂鎴愬姛
@@ -291,8 +297,10 @@
id =response.getData().getAppointmentInfoList().get(0).getOrderId();
qrcode =response.getData().getAppointmentInfoList().get(0).getQRCode();
}
+ reson = response!=null?JSONObject.toJSONString(response):"";
}else{
//鍏嶇櫥璁�
+ c.setVisitType(Constants.ONE);
VisitAppointmentMDJRequest request =getHkMDJRequestPara(c,roleList,path);
if(request == null){
//娴峰悍涓嬪彂鎴愬姛
@@ -308,17 +316,18 @@
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("涓嬪彂娴峰悍鎴愬姛锛併��"+type+"銆�");
+ c.setRemark("涓嬪彂娴峰悍鎴愬姛锛�");
c.setStatus(Constants.VisitStatus.xfSuccess);//涓嬪彂娴峰悍鎴愬姛
} else {
//娴峰悍涓嬪彂澶辫触
- c.setRemark("涓嬪彂娴峰悍澶辫触锛併��"+type+"銆�");
+ c.setRemark("涓嬪彂娴峰悍澶辫触,鍘熷洜锛�"+ reson);
c.setStatus(Constants.VisitStatus.xfFail);//涓嬪彂娴峰悍澶辫触
}
c.setHkStatus(Constants.ONE);
@@ -340,7 +349,15 @@
request.setVisitStartTime(DateUtil.getISO8601Timestamp2(c.getStarttime()));
request.setVisitEndTime(DateUtil.getISO8601Timestamp2(c.getEndtime()));
request.setReceptionistId(c.getReceptMemberHkId());//琚浜烘捣搴风紪鐮�
- request.setVisitPurpose(c.getReason());
+ 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(getVisitPermissonRequest(roleList,c));
return request;
@@ -378,7 +395,16 @@
request.setVisitStartTime(DateUtil.getISO8601Timestamp(c.getStarttime()));
request.setVisitEndTime(DateUtil.getISO8601Timestamp(c.getEndtime()));
request.setReceptionistId(c.getReceptMemberHkId());//琚浜烘捣搴风紪鐮�
- request.setVisitPurpose(c.getReason());
+
+ 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(getVisitPermissonRequest(roleList,c));
List<VisitAppointmentVistorRequest> infolist = new ArrayList<>();
@@ -401,8 +427,25 @@
if(info.getVisitorPhoto() == null){
return null;
}
- info.setVisitorName(c.getName());
- info.setVisitorWorkUnit(c.getCompanyName());
+ 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()+"");
@@ -458,6 +501,107 @@
List<Visits> list = visitsMapper.selectJoinList(Visits.class,queryWrapper);
return list;
}
+ @Override
+ @Transactional
+ public void syncParkRecords(Date date){
+ try {
+ if( Constants.formatIntegerNum(dataSyncConfig.getVisitorDataOrigin()) != DataSyncConfig.origin.hk){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "瀵逛笉璧凤紝褰撳墠涓嶆敮鎸佹捣搴锋暟鎹悓姝ユ搷浣渵");
+ }
+ AppointmentEventListRequest param = new AppointmentEventListRequest();
+ //锛堝叏閲忓悓姝ワ級
+ boolean hasNext = true;
+ int curTotal = 0;
+ int curPage = 1;
+ //鏌ヨ浠婂ぉ鐨�
+ Date start = Utils.Date.getStart(date);
+ Date end = new Date();
+ if(DateUtil.daysBetweenDates(end,start) >1){
+ end = Utils.Date.getEnd(date);
+ }
+ param.setEventTimeBegin(DateUtil.getISO8601Timestamp2( start));
+ param.setEventTimeBegin(DateUtil.getISO8601Timestamp2( end));
+ List<VisitEvent> allHkList = new ArrayList<>();
+ while (hasNext){
+ //鍒嗛〉閬嶅巻寰幆鏌ヨ鎵�鏈夐棬绂佽澶囨暟鎹�
+ param.setPageNo(curPage);
+ param.setPageSize(100);
+ BaseResponse<BaseListPageResponse<AppointmentEventInfoResponse>> response = HKService.appointmentEventQuery(param);
+ if(response == null || !StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE) ){
+ throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "瀵逛笉璧凤紝娴峰悍鍚屾鏁版嵁澶辫触~");
+ }
+ if(response.getData() == null || response.getData().getTotal() ==0){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈悓姝ュ埌浠讳綍淇℃伅锛�");
+ }
+ BaseListPageResponse<AppointmentEventInfoResponse> r = response.getData();
+ curTotal += 100;
+ if(curTotal >= r.getTotal()){
+ hasNext = false;
+ }
+ if(r.getList() == null || r.getList().size()==0){
+ hasNext =false;
+ }else{
+ allHkList.addAll(getNewCarEventModelBYList(r.getList()));
+ }
+ curPage++;
+ }
+ if(allHkList .size() == 0){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈悓姝ュ埌浠讳綍淇℃伅锛�");
+ }
+ //娓呯┖鍘熸湁褰撳ぉ鐨勬暟鎹�
+ visitEventMapper.delete(new UpdateWrapper<VisitEvent>().lambda()
+ .ge(VisitEvent::getCreateDate,start)
+ .le(VisitEvent::getCreateDate,end));
+ if(allHkList.size()>0){
+ int sublistSize = 500;
+
+ int startIndex = 0;
+ int endIndex = sublistSize;
+
+ while (startIndex < allHkList.size()) {
+ if (endIndex > allHkList.size()) {
+ endIndex = allHkList.size();
+ }
+
+ List<VisitEvent> sublist = allHkList.subList(startIndex, endIndex);
+ if(sublist.size()>0){
+ visitEventMapper.insertBatchSomeColumn(sublist);//鎻掑叆鏂版暟鎹�
+ }
+ startIndex = endIndex;
+ endIndex += sublistSize;
+ }
+ }
+
+ }catch (BusinessException e){
+ throw e;
+ }
+ }
+
+ private List<VisitEvent> getNewCarEventModelBYList(List<AppointmentEventInfoResponse> list ) {
+ List<VisitEvent> newList = new ArrayList<>();
+ if(list == null || list.size()==0){
+ return newList;
+ }
+ for(AppointmentEventInfoResponse model :list){
+ VisitEvent c = new VisitEvent();
+ c.setHappenTime(model.getEventTime());
+ c.setCreateDate(DateUtil.getISO8601DateByStr2(model.getEventTime()));
+ c.setPersonName(model.getVisitorName());
+ c.setSex(Integer.parseInt(model.getVisitorSex()));
+ c.setCarNo(model.getCarNumber());
+ c.setIdNo(model.getIdentityNum());
+ c.setIdType(Integer.parseInt(model.getIdentityId()));
+ c.setPhone(model.getPhoneNum());
+ c.setRemark(model.getCardNum());
+ c.setPhotoUrl(model.getIdentityPhotoUri());
+ c.setVisitorId(model.getVisitorId());
+ c.setIsdeleted(Constants.ZERO);
+ c.setEventTypeName(model.getEventName());
+
+ newList.add(c);
+ }
+ return newList;
+ }
}
--
Gitblit v1.9.3