From 89610234a2bdc56f60e0998045892ef2672edccc Mon Sep 17 00:00:00 2001 From: nidapeng <jp@doumee.com> Date: 星期五, 19 四月 2024 14:18:31 +0800 Subject: [PATCH] 最新版本 --- server/dmvisit_service/src/main/java/com/doumee/service/business/impl/VisitsServiceImpl.java | 319 ++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 253 insertions(+), 66 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 2009aaa..cd3eed5 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; @@ -16,6 +17,7 @@ import com.doumee.core.haikang.model.HKTools; import com.doumee.core.haikang.model.param.BaseResponse; import com.doumee.core.haikang.model.param.request.VisitAppointmentCancelRequest; +import com.doumee.core.haikang.model.param.request.VisitAppointmentOutRequest; import com.doumee.core.haikang.model.param.request.VisitAppointmentRequest; import com.doumee.core.haikang.model.param.respose.VisitAppointmentResponse; import com.doumee.core.haikang.service.HKService; @@ -33,6 +35,8 @@ import com.doumee.dao.business.join.VisitsJoinMapper; import com.doumee.dao.business.model.*; import com.doumee.dao.web.reqeust.AuditApproveDTO; +import com.doumee.dao.web.reqeust.ErpVisitDTO; +import com.doumee.dao.web.reqeust.ErpWithVisitDTO; import com.doumee.dao.web.reqeust.VisitRecordDTO; import com.doumee.dao.web.response.InternalHomeVO; import com.doumee.dao.web.response.VisitDetailVO; @@ -51,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; @@ -65,6 +71,8 @@ @Service public class VisitsServiceImpl implements VisitsService { + @Autowired + private RetentionMapper retentionMapper; @Autowired private VisitsMapper visitsMapper; @Autowired @@ -91,11 +99,90 @@ @Autowired private WxPlatNotice wxPlatNotice; + @Autowired + private InterfaceLogService interfaceLogService; + + @Override public Integer create(Visits visits) { visitsMapper.insert(visits); return visits.getId(); } + + + @Override + @Transactional(rollbackFor = {BusinessException.class,Exception.class}) + public void createFKForErp(ErpVisitDTO erpVisitDTO){ + 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()) + ) { + throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝淇℃伅濉啓涓嶆纭紒"); + } + if (erpVisitDTO.getEndtime().getTime() <= erpVisitDTO.getStarttime().getTime()) { + throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝棰勭害缁撴潫鏃堕棿蹇呴』澶т簬寮�濮嬫椂闂达紒"); + } + if (Constants.equalsInteger(Constants.ZERO, erpVisitDTO.getIdcardType()) && erpVisitDTO.getIdcardNo().length() != 18 + //&&!IdcardUtil.isValidCard(visits.getIdcardNo()) + ) { + throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝韬唤璇佸彿鐮佹湁璇紝璇锋牳瀹炲悗閲嶈瘯锛�"); + } + + Visits visits = new Visits(); + //鏍规嵁琚闂汉ERP涓婚敭鏌ヨ绯荤粺鍐呬汉鍛樹富閿俊鎭� + Member member = memberMapper.selectOne(new QueryWrapper<Member>().lambda() + .eq(Member::getIsdeleted, Constants.ZERO).eq(Member::getType, Constants.memberType.internal) + .eq(Member::getErpId, erpVisitDTO.getReceptMemberId()).last("limit 1")); + if (Objects.isNull(member)) { + throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "鏈煡璇㈠埌琚闂汉淇℃伅"); + } + if (Objects.isNull(member.getCanVisit()) || member.getCanVisit().equals(Constants.ZERO)) { + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "褰撳墠琚闂汉鏃犳硶琚闂�"); + } + BeanUtils.copyProperties(erpVisitDTO, visits); + //璁剧疆鍐呴儴绯荤粺浜哄憳涓婚敭 + visits.setReceptMemberId(member.getId()); + visits.setSourceType(Constants.ONE); + List<ErpWithVisitDTO> erpWithVisitDTOList = erpVisitDTO.getErpWithVisitDTOList(); + if (CollectionUtils.isNotEmpty(erpWithVisitDTOList)) { + List<Visits> visitsList = new ArrayList<>(); + 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,true); + } + + @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()); + interfaceLog.setIsdeleted(Constants.ZERO); + if(param!=null){ + interfaceLog.setRequest(JSONObject.toJSONString(param)); + } + interfaceLog.setPlat(Constants.ONE); + interfaceLog.setRepose(result); + interfaceLog.setName(path); + interfaceLog.setUrl(path); + interfaceLogService.create(interfaceLog); + } + /** * 鏅�氳瀹㈢敵璇� @@ -104,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 @@ -127,25 +214,32 @@ //璁垮淇℃伅(浣跨敤韬唤璇佸彿鏌ヨ鏄惁宸插瓨鍦ㄦ敼鏅�氳瀹紝娌℃湁鍒欐柊澧烇紝瀛樺湪鍒欐洿鏂皁penid绛変俊鎭�),鍖呮嫭闅忚浜哄憳鏍¢獙鍜屽鐞� Member member =dealMemberAndVisits(visits); visits.setMemberId(member.getId()); + visits.setVisitType(Integer.valueOf(systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.MDJ_VISIT_REQUIRED).getCode())); //鍒濆鍖栬瀹俊鎭� initVisitInfo(visits,date); visitsMapper.insert(visits); //鍙戣捣ERP瀹℃壒鐢宠 - String erpId = startSendErpCheck(visits,visitMember); - if(StringUtils.isNotBlank(erpId)){ - visits.setErpId(erpId); - visitsMapper.updateById(visits); + if(visits.getSourceType().equals(Constants.ZERO)){ + String erpId = startSendErpCheck(visits,visitMember); + if(StringUtils.isNotBlank(erpId)){ + visits.setErpId(erpId); + visits.setStatus(Constants.VisitStatus.submitCheck); + visitsMapper.updateById(visits); + }else{ + throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "瀵逛笉璧凤紝鍙戣捣鎷滆瀹℃壒鐢宠澶辫触锛�"); + } + //鍙戦�佸井淇″叕浼楀彿閫氱煡 + wxPlatNotice.sendVisitAuditTemplateNotice(visits, + systemDictDataBiz.queryByCode(Constants.WX_PLATFORM,Constants.WX_PLATFORM_PREFIX).getCode(), + systemDictDataBiz.queryByCode(Constants.WX_PLATFORM,Constants.WX_PLATFORM_AUDIT_VISIT).getCode()); }else{ - throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "瀵逛笉璧凤紝鍙戣捣鎷滆瀹℃壒鐢宠澶辫触锛�"); + visits.setStatus(Constants.VisitStatus.pass); + visitsMapper.updateById(visits); } initWithVisitInfo(visits); updateProblemLog(visits,problemLog,member); //鍒涘缓瀹℃壒璁板綍 // createApprove(visits,visitMember); - //鍙戦�佸井淇″叕浼楀彿閫氱煡 - wxPlatNotice.sendVisitAuditTemplateNotice(visits, - systemDictDataBiz.queryByCode(Constants.WX_PLATFORM,Constants.WX_PLATFORM_PREFIX).getCode(), - systemDictDataBiz.queryByCode(Constants.WX_PLATFORM,Constants.WX_PLATFORM_AUDIT_VISIT).getCode()); return visits.getId(); } @@ -478,17 +572,34 @@ || 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(); + int codenum =0; + try { + codenum = Integer.parseInt(code); + }catch (Exception e){ + + } + if(StringUtils.isNotBlank(code)&&!StringUtils.equals(code,"0")){ +// Integer betweenDays = Math.toIntExact(cn.hutool.core.date.DateUtil.between(visits.getEndtime(), visits.getStarttime(), DateUnit.DAY)); + int betweenDays = DateUtil.daysBetweenDates11(visits.getEndtime(), visits.getStarttime())+1; + if( betweenDays > codenum){ + throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝棰勭害鎬诲ぉ鏁颁笉鑳借秴杩嘯"+code+"澶锛�"); + } + } } } private void isValidWithVisitParam(Visits visits, List<Member> addList, List<Member> updateList) { @@ -500,9 +611,9 @@ ){ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝淇℃伅濉啓涓嶆纭紒"); } - if(visits.getStarttime().getTime() < System.currentTimeMillis()){ - throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝棰勭害寮�濮嬫椂闂村繀椤诲ぇ浜庡綋鍓嶆椂闂达紒");// - } +// if(visits.getStarttime().getTime() < System.currentTimeMillis()){ +// throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝棰勭害寮�濮嬫椂闂村繀椤诲ぇ浜庡綋鍓嶆椂闂达紒");// +// } if(visits.getEndtime().getTime() <= visits.getStarttime().getTime()){ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝棰勭害缁撴潫鏃堕棿蹇呴』澶т簬寮�濮嬫椂闂达紒");// } @@ -532,6 +643,7 @@ private void initWithVisitInfo(Visits visits) { if(CollectionUtils.isNotEmpty(visits.getWithUserList())){ for(Visits v :visits.getWithUserList()){ + v.setBirthday(Constants.getBirthdyByCardNo(v.getIdcardNo())); v.setParentId(visits.getId()); v.setStarttime(visits.getStarttime()); v.setEndtime(visits.getEndtime()); @@ -541,8 +653,15 @@ v.setIdcardDecode(Constants.getTuominStr(v.getIdcardNo()));//鑴辨晱韬唤璇佸彿 v.setIdcardNo(DESUtil.encrypt(Constants.EDS_PWD, v.getIdcardNo()));//韬唤璇佸彿鍔犲瘑 v.setErpId(visits.getErpId()); + v.setReceptMemberId(visits.getReceptMemberId()); + v.setMemberNum(Constants.ZERO); v.setHkStatus(Constants.ZERO); - v.setStatus(Constants.ZERO); + v.setReason(visits.getReason()); + v.setDoors(visits.getDoors()); + v.setType(visits.getType()); + v.setVisitType(visits.getVisitType()); + v.setStatus(visits.getStatus()); + v.setSourceType(visits.getSourceType()); } //鎵归噺鎻掑叆鏁版嵁 visitsMapper.insertBatchSomeColumn(visits.getWithUserList()); @@ -652,31 +771,40 @@ //闅忚浜哄憳淇℃伅澶勭悊 if(visits.getWithUserList()!= null && visits.getWithUserList().size()>0){ for(Visits model:visits.getWithUserList()){ + model.setBirthday(Constants.getBirthdyByCardNo(model.getIdcardNo())); model.setStarttime(visits.getStarttime()); model.setEndtime(visits.getEndtime()); //鏍¢獙闅忚浜哄憳濉姤鏁版嵁鍚堟硶鎬� isValidWithVisitParam(model,addList,editList); model.setCreateDate(visits.getCreateDate()); - getMemberListParam(model.getIdcardNo(),model,addList,editList); + Member visitsMember = getMemberListParam(model.getIdcardNo(),model,addList,editList); + model.setMemberId(visitsMember.getId()); } } - if(CollectionUtils.isNotEmpty(addList)){ - memberMapper.insertBatchSomeColumn(addList); - } - if(CollectionUtils.isNotEmpty(editList)){ - editList.forEach(i->{ - memberMapper.updateById(i); - }); - - } +// if(CollectionUtils.isNotEmpty(addList)){ +// memberMapper.insertBatchSomeColumn(addList); +// } +// if(CollectionUtils.isNotEmpty(editList)){ +// editList.forEach(i->{ +// memberMapper.updateById(i); +// }); +// +// } return m; } private Member getMemberListParam(String cardno, Visits visits, List<Member> addList, List<Member> editList) { - if(StringUtils.isNotBlank(visits.getCarNos())&&!Constants.checkCarNo(visits.getCarNos())){ + if(StringUtils.isNotBlank(visits.getCarNos()) + &&Objects.isNull(Constants.getVehiclePlateNo(visits.getCarNos())) + ){ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝杞︾墝鍙枫��"+visits.getCarNos()+"銆戜笉鍚堟硶锛岃鏍稿疄鍚庨噸璇晘"); + } + if(Constants.equalsInteger(Constants.ZERO, visits.getIdcardType())&&cardno.length()!=18 + //&&!IdcardUtil.isValidCard(cardno) + ){ + throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝韬唤璇併��"+cardno+"銆戝彿鐮佹湁璇紝璇锋牳瀹炲悗閲嶈瘯锛�"); } Member member = memberMapper.selectOne(new QueryWrapper<Member>().lambda() .eq(Member::getType,Constants.memberType.visitor) @@ -689,6 +817,7 @@ member.setCreateDate(visits.getCreateDate()); member.setIsdeleted(Constants.ZERO); member.setIdcardNo(visits.getIdcardNo()); + member.setBirthday(Constants.getBirthdyByCardNo(cardno)); member.setIdcardDecode(visits.getIdcardDecode()); member.setIdcardNo(DESUtil.encrypt(Constants.EDS_PWD, cardno));//韬唤璇佸彿鍔犲瘑 member.setIdcardDecode(Constants.getTuominStr(cardno));//鑴辨晱鎵嬫満鍙� @@ -704,15 +833,18 @@ member.setSex(Constants.getSexByCardNo(cardno)); member.setHkStatus(Constants.ZERO); member.setErpStatus(Constants.ZERO); - // 鏂板璁垮璁板綍 - addList.add(member); + member.setVisitCompanyName(visits.getCompanyName()); + memberMapper.insert(member); + // 鏂板璁垮 +// addList.add(member); }else{ if(!Constants.equalsInteger(Constants.ZERO,member.getStatus() )){ //濡傛灉鐢ㄦ埛鐘舵�佸紓甯革紝鍒欐彁绀� - throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "瀵逛笉璧凤紝璇ヨ韩浠借瘉鍙疯绂佹璁块棶鐢宠锛屽鏈夌枒闂紝璇疯仈绯绘偍鐨勬嫓璁夸汉杩涜鏍稿疄"); + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "瀵逛笉璧凤紝韬唤璇佸彿銆�"+cardno+"銆戣绂佹璁块棶鐢宠锛屽鏈夌枒闂紝璇疯仈绯绘偍鐨勬嫓璁夸汉杩涜鏍稿疄"); } //鏍告煡棰勭害鐢ㄦ埛鏄惁瀛樺湪鏈绂荤殑棰勭害璁板綍 - isExsitNoOutVisisRecord(member); +// isExsitNoOutVisisRecord(member); + member.setFaceImg(visits.getFaceImg()); member.setImgurl(StringUtils.isNotBlank(visits.getImgurl())?visits.getImgurl():null); member.setEditDate(visits.getCreateDate()); @@ -726,11 +858,13 @@ member.setSex(Constants.getSexByCardNo(cardno)); member.setHkStatus(Constants.ZERO); member.setErpStatus(Constants.ZERO); - // 鏇存柊璁垮淇℃伅, - editList.add(member); + member.setVisitCompanyName(visits.getCompanyName()); + memberMapper.updateById(member); } //鏍规嵁鎵嬫満鍙峰拰韬唤璇佸彿鐮佹煡璇� 褰撳墠棰勭害鐨勬椂闂存槸鍚︿笌鍏朵粬棰勭害璁板綍鏈夊啿绐� 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") + "' ") @@ -803,12 +937,15 @@ 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; } private ProblemLog isValidProblemLog(Visits visits) { String required = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.PROBLEM_VISIT_REQUIRED).getCode(); - if(StringUtils.equals(required,Constants.ONE+"")){ + if(StringUtils.equals(required,Constants.ONE+"")&&visits.getSourceType()==Constants.ZERO){ //濡傛灉蹇呴』绛旈锛屾煡鎵剧瓟棰樿褰� if(visits.getUserAnswerId() == null){ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝璇峰厛鎸夎姹傝繘琛屽畨鍏ㄧ煡璇嗙瓟棰橈紒"); @@ -830,17 +967,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) @@ -848,9 +981,11 @@ if(roles.size() ==0){ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝鏆備笉瀛樺湪鍙闂殑璁垮闂ㄧ锛屾棤娉曡繘琛岀敵璇锋搷浣滐紒"); } - }else{ //濡傛灉蹇呴』閫夋嫨闂ㄧ锛屼絾鏈�夋嫨 + 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::getIsdeleted,Constants.ZERO) @@ -909,7 +1044,7 @@ queryWrapper.selectAs(Member::getName,Visits::getReceptMemberName); queryWrapper.selectAs(Company::getName,Visits::getReceptMemberDepartment); queryWrapper.leftJoin(Member.class,Member::getId,Visits::getReceptMemberId); - queryWrapper.leftJoin(Company.class,Company::getId,Member::getCompanyId); + queryWrapper.leftJoin(Company.class,Company::getErpId,Member::getErpOrgId); queryWrapper.eq(Visits::getId,id); Visits result = visitsJoinMapper.selectJoinOne(Visits.class,queryWrapper); @@ -917,10 +1052,10 @@ if(result!=null){ if(StringUtils.isNotBlank(result.getDoors())){ String[] doorList=result.getDoors().split(","); - MPJLambdaWrapper<Device> deviceQuery = new MPJLambdaWrapper<>(); - deviceQuery.in(Device::getId,doorList); - List<Device> deviceList= deviceJoinMapper.selectList(deviceQuery); - result.setDeviceList(deviceList); + MPJLambdaWrapper<DeviceRole> deviceQuery = new MPJLambdaWrapper<>(); + deviceQuery.in(DeviceRole::getId,doorList); + List<DeviceRole> deviceRoleList= deviceRoleMapper.selectList(deviceQuery); + result.setDeviceRoleList(deviceRoleList); } } @@ -957,6 +1092,7 @@ MPJLambdaWrapper<Visits> queryWrapper = new MPJLambdaWrapper<>(); queryWrapper.selectAll(Visits.class); + queryWrapper.select(" ( select count(distinct(v.CAR_NOS)) from visits v where v.PARENT_ID = t.ID and v.CAR_NOS is not null and v.CAR_NOS != '' and v.CAR_NOS != t.CAR_NOS ) as carNum "); queryWrapper.selectAs(Member::getName,Visits::getReceptMemberName); queryWrapper.selectAs(Company::getName,Visits::getReceptMemberDepartment); queryWrapper.leftJoin(Member.class,Member::getId,Visits::getReceptMemberId); @@ -972,6 +1108,12 @@ queryWrapper.isNull(Visits::getParentId); queryWrapper.orderByDesc(Visits::getCreateDate); IPage<Visits> result = visitsJoinMapper.selectJoinPage(page, Visits.class,queryWrapper); + + for (Visits visits:result.getRecords()) { + if(StringUtils.isNotBlank(visits.getCarNos())){ + visits.setCarNum(visits.getCarNum() + Constants.ONE); + } + } return PageData.from(result); } @@ -984,40 +1126,42 @@ @Override public PageData<Visits> retentionPage(PageWrap<Visits> pageWrap) { + String code= systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.TIMEOUT_WARNING).getCode(); IPage<Visits> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); MPJLambdaWrapper<Visits> queryWrapper = new MPJLambdaWrapper<>(); - queryWrapper.selectAll(Visits.class); queryWrapper.selectAs(Member::getName,Visits::getReceptMemberName); - queryWrapper.select("TIMESTAMPDIFF(MINUTE,t.ENDTIME , NOW()) AS timeOut"); + queryWrapper.select("TIMESTAMPDIFF( MINUTE, NOW(), t.OUT_DATE) AS timeOut"); queryWrapper.selectAs(Member::getType,Visits::getMemberType); queryWrapper.selectAs(Company::getName,Visits::getReceptMemberDepartment); queryWrapper.leftJoin(Member.class,Member::getId,Visits::getReceptMemberId); queryWrapper.leftJoin(Company.class,Company::getId,Member::getCompanyId); - queryWrapper.leftJoin(" member m on m.id=t.MEMBER_ID"); + queryWrapper.leftJoin(" member m on m.id= t.MEMBER_ID"); + + queryWrapper.eq(Objects.nonNull(pageWrap.getModel().getLevelStatus()),Visits::getStatus,Constants.VisitStatus.signin); + + queryWrapper.apply(Objects.nonNull(pageWrap.getModel().getLevelStatus())," TIMESTAMPDIFF( MINUTE, NOW(), t.OUT_DATE) <= "+code+" "); queryWrapper.ne("m.type ",Constants.TWO); queryWrapper.eq(Visits::getIsdeleted,Constants.ZERO); queryWrapper.eq(Objects.nonNull(pageWrap.getModel().getType()),Visits::getType,pageWrap.getModel().getType()); queryWrapper.and(StringUtils.isNotBlank(pageWrap.getModel().getName()),ms->ms.like(Visits::getPhone,pageWrap.getModel().getName()) - .or().like(Visits::getPhone,pageWrap.getModel().getName())) - .eq(StringUtils.isNotBlank(pageWrap.getModel().getIdcardNo()),Visits::getIdcardNo,StringUtils.isNotBlank(pageWrap.getModel().getIdcardNo())) - .eq(StringUtils.isNotBlank(pageWrap.getModel().getCompanyName()),Visits::getCompanyName,pageWrap.getModel().getCompanyName()) - .eq(Objects.nonNull(pageWrap.getModel().getStatus()),Visits::getStatus,pageWrap.getModel().getStatus()); - queryWrapper.isNull(Visits::getOutDate); + .or().like(Visits::getName,pageWrap.getModel().getName())); + queryWrapper.eq(StringUtils.isNotBlank(pageWrap.getModel().getIdcardNo()),Visits::getIdcardNo,StringUtils.isNotBlank(pageWrap.getModel().getIdcardNo())); + queryWrapper.eq(StringUtils.isNotBlank(pageWrap.getModel().getCompanyName()),Visits::getCompanyName,pageWrap.getModel().getCompanyName()); queryWrapper.orderByDesc(Visits::getEditDate); - String code= systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.TIMEOUT_FREEZE).getCode(); IPage<Visits> result = visitsJoinMapper.selectJoinPage(page, Visits.class,queryWrapper); if(result!=null&&result.getRecords()!=null){ result.getRecords().stream().forEach(s ->{ - if(s.getTimeOut()>=Constants.ZERO){ - s.setOutStatus(Constants.ONE); - }else if(s.getTimeOut()<=Integer.valueOf(code)&&s.getTimeOut()>0){ - s.setOutStatus(Constants.TWO); - }else{ - s.setOutStatus(Constants.ZERO); + if(s.getStatus().equals(Constants.VisitStatus.signin)){ + if(s.getTimeOut()<=Integer.valueOf(code)&&s.getTimeOut()>=0){ + s.setOutStatus(Constants.TWO); + }else if(s.getTimeOut()>Constants.ZERO){ + s.setOutStatus(Constants.ZERO); + }else{ + s.setOutStatus(Constants.ONE); + } } - }); } @@ -1039,8 +1183,10 @@ VisitDetailVO visitDetailVO = new VisitDetailVO(); visitDetailVO.setStatus(visits.getStatus()); visitDetailVO.setCarNos(visits.getCarNos()); + visitDetailVO.setPhone(visits.getPhone()); visitDetailVO.setVisitUserName(member.getName()); visitDetailVO.setVisitReason(visits.getReason()); + visitDetailVO.setQrcode(visits.getQrcode()); visitDetailVO.setVisitTime(DateUtil.DateToStr(visits.getStarttime(),"yyyy-MM-dd HH:mm") + " 鑷� " + DateUtil.DateToStr(visits.getEndtime(),"yyyy-MM-dd HH:mm") ); //琚浜哄憳閮ㄩ棬 Company company = companyMapper.selectById(member.getCompanyId()); @@ -1067,7 +1213,7 @@ } visitDetailVO.setWithVisitsList( visitsMapper.selectList(new QueryWrapper<Visits>().lambda() - .select(Visits::getName,Visits::getPhone,Visits::getFaceImg,Visits::getImgurl,Visits::getIdcardDecode) + .select(Visits::getName,Visits::getPhone,Visits::getQrcode,Visits::getFaceImg,Visits::getImgurl,Visits::getIdcardDecode,Visits::getStatus) .eq(Visits::getParentId,id))); return visitDetailVO; } @@ -1110,4 +1256,45 @@ + @Override + public void visitLevel(Integer visitId){ + Visits visits = visitsMapper.selectById(visitId); + if(Objects.isNull(visits)){ + throw new BusinessException(ResponseStatus.DATA_EMPTY); + } + if(!visits.getStatus().equals(Constants.VisitStatus.signin)){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"璁垮璁板綍鐘舵�侀敊璇紝璇峰埛鏂伴噸璇�"); + } + VisitAppointmentOutRequest request = new VisitAppointmentOutRequest(); + request.setOrderId(visits.getHkId()); + //璋冪敤娴峰悍寮哄埗绛剧 + BaseResponse response = HKService.outVisitAppiontment(request); + visitsMapper.update(null,new UpdateWrapper<Visits>().lambda().set(Visits::getStatus,Constants.VisitStatus.signout) + .eq(Visits::getId,visitId)); + //浜у嚭鍦ㄥ満浜哄憳淇℃伅 + retentionMapper.delete(new UpdateWrapper<Retention>().lambda() + .eq(Retention::getType,Constants.memberType.visitor) + .eq(Retention::getMemberId,visits.getMemberId())); + } + @Override + public void visitCancel(Integer visitId){ + Visits visits = visitsMapper.selectById(visitId); + if(Objects.isNull(visits)){ + throw new BusinessException(ResponseStatus.DATA_EMPTY); + } + if(!visits.getStatus().equals(Constants.VisitStatus.xfSuccess)){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"璁垮璁板綍鐘舵�侀敊璇紝璇峰埛鏂伴噸璇�"); + } + VisitAppointmentOutRequest request = new VisitAppointmentOutRequest(); + request.setOrderId(visits.getHkId()); + //璋冪敤娴峰悍寮哄埗绛剧 + BaseResponse response = HKService.outVisitAppiontment(request); + visitsMapper.update(null,new UpdateWrapper<Visits>().lambda().set(Visits::getStatus,Constants.VisitStatus.signout) + .eq(Visits::getId,visitId)); + //浜у嚭鍦ㄥ満浜哄憳淇℃伅 + retentionMapper.delete(new UpdateWrapper<Retention>().lambda() + .eq(Retention::getType,Constants.memberType.visitor) + .eq(Retention::getMemberId,visits.getMemberId())); + } + } -- Gitblit v1.9.3