From 67dfeea84fcf92e11e07eaf2eb0e235387287813 Mon Sep 17 00:00:00 2001
From: nidapeng <jp@doumee.com>
Date: 星期一, 18 三月 2024 11:41:02 +0800
Subject: [PATCH] 整理
---
server/dmvisit_service/src/main/java/com/doumee/service/business/impl/VisitsServiceImpl.java | 59 ++++++++++++++++++++++++++++++++++++-----------------------
1 files changed, 36 insertions(+), 23 deletions(-)
diff --git a/server/dmvisit_service/src/main/java/com/doumee/service/business/impl/VisitsServiceImpl.java b/server/dmvisit_service/src/main/java/com/doumee/service/business/impl/VisitsServiceImpl.java
index 43d9931..d7a86bf 100644
--- a/server/dmvisit_service/src/main/java/com/doumee/service/business/impl/VisitsServiceImpl.java
+++ b/server/dmvisit_service/src/main/java/com/doumee/service/business/impl/VisitsServiceImpl.java
@@ -1,5 +1,6 @@
package com.doumee.service.business.impl;
+import cn.hutool.core.date.DateUnit;
import cn.hutool.core.util.IdcardUtil;
import com.alibaba.fastjson.JSONObject;
import com.doumee.biz.system.SystemDictDataBiz;
@@ -54,9 +55,11 @@
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.DigestUtils;
+import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.Collectors;
@@ -110,16 +113,16 @@
@Override
@Transactional(rollbackFor = {BusinessException.class,Exception.class})
public void createFKForErp(ErpVisitDTO erpVisitDTO){
- try {
-
if (Objects.isNull(erpVisitDTO)
|| StringUtils.isBlank(erpVisitDTO.getName())
|| StringUtils.isBlank(erpVisitDTO.getPhone())
+ || StringUtils.isBlank(erpVisitDTO.getCompanyName())
|| Objects.isNull(erpVisitDTO.getIdcardType())
|| StringUtils.isBlank(erpVisitDTO.getIdcardNo())
|| Objects.isNull(erpVisitDTO.getStarttime())
|| Objects.isNull(erpVisitDTO.getEndtime())
|| StringUtils.isBlank(erpVisitDTO.getFaceImg())
+ || StringUtils.isBlank(erpVisitDTO.getDoors())
|| Objects.isNull(erpVisitDTO.getReceptMemberId())
|| Objects.isNull(erpVisitDTO.getErpId())
) {
@@ -155,19 +158,17 @@
for (ErpWithVisitDTO erpWithVisitDTO : erpWithVisitDTOList) {
Visits withVisits = new Visits();
BeanUtils.copyProperties(erpWithVisitDTO, withVisits);
+ withVisits.setCompanyName(visits.getCompanyName());
+ withVisits.setReason(visits.getReason());
visitsList.add(withVisits);
}
visits.setWithUserList(visitsList);
}
- this.createFk(visits);
- }catch (BusinessException e){
- throw e;
- }finally {
- saveInterfaceLog(erpVisitDTO,"/visitBiz/resource/crateVisit",null,Constants.ZERO);
- }
+ this.createFk(visits,true);
}
- private void saveInterfaceLog(Object param, String path,String result,Integer type) {
+ @Transactional(propagation = Propagation.NOT_SUPPORTED)
+ void saveInterfaceLog(Object param, String path, String result, Integer type) {
InterfaceLog interfaceLog=new InterfaceLog();
interfaceLog.setType(type);
interfaceLog.setCreateDate(new Date());
@@ -190,12 +191,12 @@
*/
@Override
@Transactional(rollbackFor = {BusinessException.class,Exception.class})
- public Integer createFk(Visits visits) {
+ public Integer createFk(Visits visits,Boolean isERP) {
isValidBaseParam(visits);
//妫�鏌ユ槸鍚﹀繀椤荤瓟棰橈紝骞朵笖绗﹀悎绛旈瑕佹眰
ProblemLog problemLog = isValidProblemLog(visits);
//鑾峰彇鐢宠鐨勬捣搴疯闂棬绂佺粍淇℃伅
- getHkDeviceRoles(visits);
+ getHkDeviceRoles(visits,isERP);
//妫�楠屾嫓璁夸汉鏄惁鍚堟硶
Member visitMember = isValideVisitedUser(visits.getReceptMemberId());
if(Constants.equalsInteger(Constants.ZERO, visits.getIdcardType())&&visits.getIdcardNo().length()!=18
@@ -568,20 +569,30 @@
private void isValidBaseParam(Visits visits) {
if(visits.getEndtime() == null
|| visits.getStarttime() == null
-// || StringUtils.isBlank(visits.getReason())
+ || StringUtils.isBlank(visits.getReason())
|| StringUtils.isBlank( visits.getName())
|| StringUtils.isBlank( visits.getPhone())
+ || StringUtils.isBlank( visits.getCompanyName())
|| visits.getIdcardType() == null
// || StringUtils.isBlank( visits.getFaceImg() )
|| StringUtils.isBlank( visits.getIdcardNo() )
|| visits.getReceptMemberId() == null){
throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝淇℃伅濉啓涓嶆纭紒");
}
-// if(visits.getStarttime().getTime() < System.currentTimeMillis()){
-// throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝棰勭害寮�濮嬫椂闂村繀椤诲ぇ浜庡綋鍓嶆椂闂达紒");//
-// }
+ if(visits.getEndtime().getTime() < System.currentTimeMillis()){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝棰勭害缁撴潫鏃堕棿蹇呴』澶т簬褰撳墠鏃堕棿锛�");//
+ }
if(visits.getEndtime().getTime() <= visits.getStarttime().getTime()){
throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝棰勭害缁撴潫鏃堕棿蹇呴』澶т簬寮�濮嬫椂闂达紒");//
+ }
+ if(visits.getSourceType().equals(Constants.ZERO)){
+ String code = systemDictDataBiz.queryByCode(Constants.VISIT_CONFIG,Constants.VALIDATE_VISIT).getCode();
+ if(StringUtils.isNotBlank(code)&&!StringUtils.equals(code,"0")){
+ Integer betweenDays = Math.toIntExact(cn.hutool.core.date.DateUtil.between(visits.getEndtime(), visits.getStarttime(), DateUnit.DAY));
+ if(Integer.compare(betweenDays,Integer.valueOf(code))>0){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝棰勭害鎬诲ぉ鏁颁笉鑳借秴杩嘯"+code+"澶锛�");
+ }
+ }
}
}
private void isValidWithVisitParam(Visits visits, List<Member> addList, List<Member> updateList) {
@@ -847,6 +858,8 @@
if (visitsMapper.selectCount(new QueryWrapper<Visits>().lambda()
.notIn(Visits::getStatus,Constants.VisitStatus.cancel,Constants.VisitStatus.noPass,Constants.VisitStatus.xfFail,Constants.VisitStatus.signout,Constants.VisitStatus.invalid)
.eq(Visits::getIdcardDecode, Constants.getTuominStr(cardno))
+ .and(ms -> ms.eq(Visits::getPhone, visits.getPhone())
+ .or().eq(Visits::getIdcardDecode, Constants.getTuominStr(cardno)))
.and(ms -> ms.apply(" visits.STARTTIME <= '" + DateUtil.DateToStr(visits.getStarttime(),"yyyy-MM-dd HH:mm:ss") + "' and visits.ENDTIME >= '" + DateUtil.DateToStr(visits.getStarttime(),"yyyy-MM-dd HH:mm:ss") + "' ")
.or().apply(" visits.STARTTIME <= '" + DateUtil.DateToStr(visits.getEndtime(),"yyyy-MM-dd HH:mm:ss") + "' and visits.ENDTIME >= '" + DateUtil.DateToStr(visits.getEndtime(),"yyyy-MM-dd HH:mm:ss") + "' ")
)) > Constants.ZERO) {
@@ -917,6 +930,9 @@
if(!Constants.equalsInteger(Constants.ONE, member.getCanVisit())){
throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝璇ユ嫓璁夸汉鏆傛椂涓嶈兘鎺ュ彈鎮ㄧ殑鎷滆鐢宠~");
}
+ if(StringUtils.isBlank(member.getHkId())){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝璇ユ嫓璁夸汉鏈笅鍙戞殏鏃朵笉鑳芥帴鍙楁偍鐨勬嫓璁跨敵璇穨");
+ }
return member;
}
@@ -944,16 +960,13 @@
* @param visits
* @return
*/
- private String[] getHkDeviceRoles(Visits visits) {
+ private String[] getHkDeviceRoles(Visits visits,Boolean isERP) {
String mustSelectDoors = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.SELECT_DOORS_VISIT_REQUIRED).getCode();
+ if(isERP){
+ mustSelectDoors = Constants.ONE+"";
+ }
List<DeviceRole> roles = null;
if(StringUtils.equals(mustSelectDoors,Constants.ZERO+"")){
- //濡傛灉璁剧疆涓嶉�夋嫨闂ㄧ锛屽垯鎻愪緵榛樿闂ㄧ缁勪俊鎭�
- if(StringUtils.isBlank(visits.getDoors())){
- throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝璇烽�夋嫨璁块棶闂ㄧ锛�");
- }
- //鏍¢獙闂ㄧ缁勪俊鎭槸鍚︽纭�
- String[] dIds = visits.getDoors().split(",");
roles = deviceRoleMapper.selectList(new QueryWrapper<DeviceRole>().lambda()
.eq(DeviceRole::getIsDefault,Constants.ZERO)
.eq(DeviceRole::getIsdeleted,Constants.ZERO)
@@ -963,7 +976,7 @@
}
}else{
//濡傛灉蹇呴』閫夋嫨闂ㄧ锛屼絾鏈�夋嫨
- if(StringUtils.isNotBlank(visits.getDoors())){
+ if(StringUtils.isBlank(visits.getDoors())){
throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝璇烽�夋嫨鏈夋晥璁块棶闂ㄧ锛�");
}
String[] dIds = visits.getDoors().split(",");
--
Gitblit v1.9.3