From f6c2b63e7c992b17ea7750e7c20ee3bcdd9428fb Mon Sep 17 00:00:00 2001 From: jiangping <jp@doumee.com> Date: 星期五, 01 三月 2024 15:57:15 +0800 Subject: [PATCH] 整理 --- server/dmvisit_service/src/main/java/com/doumee/service/business/impl/VisitsServiceImpl.java | 806 +++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 719 insertions(+), 87 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 b6e3f46..7dd65c1 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,18 +1,22 @@ package com.doumee.service.business.impl; import cn.hutool.core.util.IdcardUtil; +import com.alibaba.fastjson.JSONObject; import com.doumee.biz.system.SystemDictDataBiz; import com.doumee.core.constants.ResponseStatus; import com.doumee.core.erp.ErpConstants; import com.doumee.core.erp.ErpTool; +import com.doumee.core.erp.model.openapi.request.VisitListRequest; import com.doumee.core.erp.model.openapi.request.erp.ApproveAddRequest; import com.doumee.core.erp.model.openapi.request.erp.UserInfoRequest; +import com.doumee.core.erp.model.openapi.response.VisitEventListResponse; import com.doumee.core.erp.model.openapi.response.erp.ApproveInfoResponse; import com.doumee.core.exception.BusinessException; import com.doumee.core.haikang.model.HKConstants; 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; @@ -22,19 +26,28 @@ import com.doumee.core.utils.DESUtil; import com.doumee.core.utils.DateUtil; import com.doumee.core.utils.Utils; +import com.doumee.core.wx.wxPlat.WxPlatNotice; import com.doumee.dao.admin.response.MemberInfoDTO; -import com.doumee.dao.business.DeviceRoleMapper; -import com.doumee.dao.business.MemberMapper; -import com.doumee.dao.business.ProblemLogMapper; -import com.doumee.dao.business.VisitsMapper; +import com.doumee.dao.business.*; import com.doumee.dao.business.join.DeviceJoinMapper; +import com.doumee.dao.business.join.VisitEventJoinMapper; 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; +import com.doumee.dao.web.response.VisitRecordVO; +import com.doumee.service.business.ApproveService; +import com.doumee.service.business.InterfaceLogService; import com.doumee.service.business.VisitsService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.github.xiaoymin.knife4j.core.util.CollectionUtils; import com.github.yulichang.wrapper.MPJLambdaWrapper; import io.swagger.models.auth.In; import org.apache.commons.lang3.StringUtils; @@ -42,7 +55,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.CollectionUtils; import org.springframework.util.DigestUtils; import java.util.*; @@ -57,7 +69,13 @@ public class VisitsServiceImpl implements VisitsService { @Autowired + private RetentionMapper retentionMapper; + @Autowired private VisitsMapper visitsMapper; + @Autowired + private ApproveMapper approveMapper; + @Autowired + private ApproveParamMapper approveParamMapper; @Autowired private DeviceRoleMapper deviceRoleMapper; @Autowired @@ -66,11 +84,20 @@ private MemberMapper memberMapper ; @Autowired private VisitsJoinMapper visitsJoinMapper; - + @Autowired + private CompanyMapper companyMapper; @Autowired private SystemDictDataBiz systemDictDataBiz; @Autowired private DeviceJoinMapper deviceJoinMapper; + @Autowired + private ErpTool erpTool; + + @Autowired + private WxPlatNotice wxPlatNotice; + + @Autowired + private InterfaceLogService interfaceLogService; @Override @@ -78,6 +105,83 @@ visitsMapper.insert(visits); return visits.getId(); } + + + @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()) + || Objects.isNull(erpVisitDTO.getIdcardType()) + || StringUtils.isBlank(erpVisitDTO.getIdcardNo()) + || Objects.isNull(erpVisitDTO.getStarttime()) + || Objects.isNull(erpVisitDTO.getEndtime()) + || StringUtils.isBlank(erpVisitDTO.getFaceImg()) + || 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); + visitsList.add(withVisits); + } + visits.setWithUserList(visitsList); + } + this.createFk(visits); + }catch (BusinessException e){ + throw e; + }finally { + saveInterfaceLog(erpVisitDTO,"/visitBiz/resource/crateVisit",null,Constants.ZERO); + } + } + + private 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); + } + /** * 鏅�氳瀹㈢敵璇� @@ -91,49 +195,391 @@ //妫�鏌ユ槸鍚﹀繀椤荤瓟棰橈紝骞朵笖绗﹀悎绛旈瑕佹眰 ProblemLog problemLog = isValidProblemLog(visits); //鑾峰彇鐢宠鐨勬捣搴疯闂棬绂佺粍淇℃伅 - String[] hkIds = getHkDeviceRoles(visits); + getHkDeviceRoles(visits); //妫�楠屾嫓璁夸汉鏄惁鍚堟硶 Member visitMember = isValideVisitedUser(visits.getReceptMemberId()); - if(Constants.equalsInteger(Constants.ZERO, visits.getIdcardType()) &&!IdcardUtil.isValidCard(visits.getIdcardNo())){ + if(Constants.equalsInteger(Constants.ZERO, visits.getIdcardType())&&visits.getIdcardNo().length()!=18 + //&&!IdcardUtil.isValidCard(visits.getIdcardNo()) + ){ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝韬唤璇佸彿鐮佹湁璇紝璇锋牳瀹炲悗閲嶈瘯锛�"); } Date date = new Date(); + //鍒涘缓鏃堕棿 + visits.setCreateDate(date); + //鏅�氳瀹� + visits.setType(Constants.ONE); + //闅忚浜哄憳鏁伴噺 + visits.setMemberNum(CollectionUtils.isNotEmpty(visits.getWithUserList())?visits.getWithUserList().size():0); //璁垮淇℃伅(浣跨敤韬唤璇佸彿鏌ヨ鏄惁宸插瓨鍦ㄦ敼鏅�氳瀹紝娌℃湁鍒欐柊澧烇紝瀛樺湪鍒欐洿鏂皁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); - //鍙戣捣ERP瀹℃壒鐢宠 - String erpId = startSendErpCheck(visits,visitMember); - if(StringUtils.isNotBlank(erpId)){ - visits.setErpId(erpId); - }else{ - throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "瀵逛笉璧凤紝鍙戣捣鎷滆瀹℃壒鐢宠澶辫触锛�"); - } visitsMapper.insert(visits); + //鍙戣捣ERP瀹℃壒鐢宠 + 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{ + visits.setStatus(Constants.VisitStatus.pass); + visitsMapper.updateById(visits); + } initWithVisitInfo(visits); updateProblemLog(visits,problemLog,member); + //鍒涘缓瀹℃壒璁板綍 +// createApprove(visits,visitMember); + return visits.getId(); } + + + /** + * 鍒涘缓瀹℃壒璁板綍 + * @param visits + * @param visitMember + */ + public void createApprove(Visits visits,Member visitMember){ + List<Integer> approveIds = new ArrayList<>(); + ApproveParam approveParam = null;//this.getApproveIds(1,visitMember,approveIds); + //鍒涘缓寰呭鎵硅褰� + //鑾峰彇瀹℃壒閰嶇疆涓婚敭 + Integer firstApproveId = this.checkFirstAudit(); + //鍐呴儴浜哄憳鍒涘缓 涓斿垱寤轰汉涓庤璁块棶浜虹浉鍚� + if(!Objects.isNull(visits.getCreateMemberId())//鍐呴儴浜哄憳鍙戝竷 + &&visits.getCreateMemberId().equals(visitMember.getId())//鍒涘缓浜哄憳涓庤璁块棶浜哄憳鏄惁鏄悓涓�浜� + &&!Objects.isNull(firstApproveId)//瀹℃壒閰嶇疆绗竴绾т负 琚闂汉瀹℃壒 + ){ + approveParam = this.getApproveIds(2,visitMember,approveIds); + Approve approve = new Approve(); + approve.setCreateDate(new Date()); + approve.setIsdeleted(Constants.ZERO); + approve.setCheckInfo("鑷姩瀹℃壒"); + approve.setTemplatId(firstApproveId); + approve.setIsEndCheck(Constants.ZERO); + approve.setType(Constants.ZERO); + approve.setLevel(Constants.ONE); + approve.setVisitId(visits.getId()); + approveMapper.insert(approve); + if(!CollectionUtils.isNotEmpty(approveIds)){ + approve.setIsEndCheck(Constants.ONE); + visits.setStatus(Constants.TWO); + visitsMapper.updateById(visits); + //瀛樺偍鎶勯�佽褰� + this.saveCopyFor(visits.getId()); + } + }else{ + approveParam = this.getApproveIds(null,visitMember,approveIds); + if(!CollectionUtils.isNotEmpty(approveIds)){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏃犳湁鏁堢殑瀹℃壒閰嶇疆锛岃鑱旂郴绠$悊鍛�"); + } + } + if(!Objects.isNull(approveIds)){ + //鍒涘缓涓嬩竴绾у鎵硅褰� + this.saveAuditRecord(visits.getId(),approveIds,approveParam); + } + } + + + /** + * 瀹℃壒 瀹℃壒璁板綍 鎴栫 瀹℃壒閫氳繃杩涘叆涓嬩竴姝� 浼氱 妫�娴嬫槸鍚︽槸鏈�鍚庝竴鏉″緟瀹℃壒 + * @param auditApproveDTO + */ + @Override + public void auditApprove(AuditApproveDTO auditApproveDTO){ + Approve approve = approveMapper.selectById(auditApproveDTO.getId()); + if(Objects.isNull(approve)){ + throw new BusinessException(ResponseStatus.DATA_EMPTY); + } + if(approve.getStatus().equals(Constants.approveStatus.wait)){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀹℃壒璁板綍宸插鐞�!"); + } + Visits visits = visitsMapper.selectById(approve.getVisitId()); + if(Objects.isNull(visits)){ + throw new BusinessException(ResponseStatus.DATA_EMPTY); + } + if(!auditApproveDTO.getMemberId().equals(approve.getChekorId())){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"浜哄憳淇℃伅鍖归厤閿欒!"); + } + //琚浜� + Member visitMember = memberMapper.selectById(visits.getReceptMemberId()); + List<Integer> approveIds = new ArrayList<>(); + ApproveParam approveParam = this.getApproveIds(approve.getLevel()+1,visitMember,approveIds); + + approve.setStatus(auditApproveDTO.getStatus()); + approve.setEditDate(new Date()); + approve.setChekorId(auditApproveDTO.getMemberId()); + approve.setCheckInfo(auditApproveDTO.getCheckInfo()); + approveMapper.updateById(approve); + + if(auditApproveDTO.getStatus().equals(Constants.approveStatus.pass)){ + if(approve.getApproveType().equals(Constants.ONE)){ + //浼氱 鏌ヨ鏄惁鏄渶鍚庝竴鏉¤褰� 濡傛灉鏄渶鍚庝竴鏉¤褰� 鍒欑敓鎴愪笅绾у鎵硅褰� 濡傛灉鏄渶鍚庝竴绾э紝鍒欒繘琛屽鎵圭‘璁� + if(approveMapper.selectCount(new QueryWrapper<Approve>().lambda() + .eq(Approve::getVisitId,visits.getId()) + .eq(Approve::getLevel,approve.getLevel()) + .ne(Approve::getId,approve.getId()) + )<=Constants.ZERO){ + //褰撳墠瀹℃壒绾у埆 鏈�鍚庝竴鏉″緟瀹℃壒璁板綍 + if(!CollectionUtils.isNotEmpty(approveIds)){ + //娌℃湁涓嬬骇瀹℃壒娴佸垯 淇敼璁垮璁板綍涓婚敭 + visits.setStatus(auditApproveDTO.getStatus()); + visits.setCheckDate(new Date()); + visits.setCheckorId(auditApproveDTO.getMemberId()); + visitsMapper.updateById(visits); + }else{ + this.saveAuditRecord(visits.getId(),approveIds,approveParam); + } + } + }else{ + //鎴栫 + approveMapper.update(null,new UpdateWrapper<Approve>().lambda() + .set(Approve::getStatus,Constants.approveStatus.otherDeal) + .set(Approve::getEditDate,new Date()) + .set(Approve::getCheorId,auditApproveDTO.getMemberId()) + .eq(Approve::getVisitId,visits.getId()) + .eq(Approve::getStatus,Constants.approveStatus.wait) + .ne(Approve::getId,approve.getId()) + .eq(Approve::getLevel,approve.getLevel()) + ); + + if(!CollectionUtils.isNotEmpty(approveIds)){ + //娌℃湁涓嬬骇瀹℃壒娴佸垯 淇敼璁垮璁板綍涓婚敭 + visits.setStatus(auditApproveDTO.getStatus()); + visits.setCheckDate(new Date()); + visits.setCheckorId(auditApproveDTO.getMemberId()); + visitsMapper.updateById(visits); + }else{ + this.saveAuditRecord(visits.getId(),approveIds,approveParam); + } + + } + }else if(auditApproveDTO.getStatus().equals(Constants.approveStatus.unPass)){ + visits.setStatus(auditApproveDTO.getStatus()); + visits.setCheckDate(new Date()); + visits.setCheckorId(auditApproveDTO.getMemberId()); + visitsMapper.updateById(visits); + + approveMapper.update(null,new UpdateWrapper<Approve>().lambda() + .set(Approve::getStatus,Constants.approveStatus.otherDeal) + .set(Approve::getEditDate,new Date()) + .set(Approve::getCheorId,auditApproveDTO.getMemberId()) + .eq(Approve::getVisitId,visits.getId()) + .eq(Approve::getStatus,Constants.approveStatus.wait) + .ne(Approve::getId,approve.getId()) + .eq(Approve::getLevel,approve.getLevel()) + ); + + }else{ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀹℃壒鐘舵�侀敊璇�!"); + } + } + + + + + /** + * 瀛樺偍鎶勯�佽褰� + * @param visitId + */ + public void saveCopyFor(Integer visitId){ + ApproveParam approveParam = approveParamMapper.selectOne(new QueryWrapper<ApproveParam>().lambda() + .eq(ApproveParam::getIsdeleted,Constants.ZERO) + .eq(ApproveParam::getType,Constants.ONE) + .eq(ApproveParam::getLevel,Constants.ONE) + .last("limit 1")); + if(Objects.isNull(approveParam)){ + return; + } + if(StringUtils.isNotBlank(approveParam.getObjIds())){ + String [] ids = approveParam.getObjIds().split(","); + List<Approve> approveList = new ArrayList<>(); + for (String id:ids) { + Approve approve = new Approve(); + approve.setCreateDate(new Date()); + approve.setIsdeleted(Constants.ZERO); + approve.setCheckInfo("鎶勯�佽褰�"); + approve.setTemplatId(approveParam.getId()); + approve.setChekorId(Integer.valueOf(id)); + approve.setType(Constants.ONE); + approve.setVisitId(visitId); + approveList.add(approve); + } + approveMapper.insertBatchSomeColumn(approveList); + } + } + + /** + * 瀛樺偍涓嬬骇瀹℃壒璁板綍 + * @param visitId + * @param ids + * @param approveParam + */ + public void saveAuditRecord(Integer visitId,List<Integer> ids,ApproveParam approveParam){ + if(CollectionUtils.isNotEmpty(ids)) { + List<Approve> approveList = new ArrayList<>(); + for (Integer id:ids) { + Approve approve = new Approve(); + approve.setCreateDate(new Date()); + approve.setIsdeleted(Constants.ZERO); + approve.setStatus(Constants.ZERO); + approve.setCheckInfo("鎶勯�佽褰�"); + approve.setTemplatId(approveParam.getId()); + approve.setLevel(approveParam.getLevel()); + approve.setApproveType(approveParam.getApproveType()); + approve.setChekorId(id); + approve.setType(Constants.ONE); + approve.setVisitId(visitId); + approveList.add(approve); + } + approveMapper.insertBatchSomeColumn(approveList); + } + } + + /** + * 鍒ゆ柇涓�绾у鎵逛汉鏄惁鏄垱寤轰汉 + * @return + */ + public Integer checkFirstAudit(){ + ApproveParam approveParam = approveParamMapper.selectOne(new QueryWrapper<ApproveParam>().lambda() + .eq(ApproveParam::getIsdeleted,Constants.ZERO) + .eq(ApproveParam::getType,Constants.ZERO) + .eq(ApproveParam::getLevel,Constants.ONE) + .eq(ApproveParam::getMemberType,Constants.ZERO) + .last("limit 1")); + return Objects.isNull(approveParam)?null:approveParam.getId(); + + } + + + /** + * 鍒涘缓瀹℃壒浜哄憳淇℃伅 鑻ヨ繑鍥炲緟瀹℃壒浜哄憳涓婚敭鍒楄〃涓虹┖锛屽垯鏃犲鎵逛汉鍛� 鎶涘嚭瀵瑰簲寮傚父 + * @param level 澶勭悊绾у埆 + * @param visitMember 琚浜� + */ + public ApproveParam getApproveIds(Integer level,Member visitMember,List<Integer> ids){ + //鏌ヨ瀹℃壒閰嶇疆椤� + List<ApproveParam> allParam = approveParamMapper.selectList(new QueryWrapper<ApproveParam>().lambda() + .eq(ApproveParam::getIsdeleted,Constants.ZERO) + .eq(ApproveParam::getType,Constants.ZERO) + .ge(!Objects.isNull(level),ApproveParam::getLevel,level) + .orderByAsc(ApproveParam::getLevel)); + ApproveParam approveParam = new ApproveParam(); + //鍙戦�佸鎵�/鎶勯�佽褰曠殑鐢ㄦ埛涓婚敭闆嗗悎 + ids.clear(); + if(!CollectionUtils.isNotEmpty(allParam)){ + if(Objects.isNull(level)){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏈厤缃瀹㈠鎵规祦锛岃鑱旂郴绠$悊鍛�"); + } + }else{ + approveParam = allParam.get(0); + if(approveParam.getMemberType().equals(Constants.ZERO)){ + //琚浜哄鎵� + //娣诲姞瀹℃壒浜� + ids.add(visitMember.getId()); + }else if(approveParam.getMemberType().equals(Constants.ONE)){ + //鎸囧畾浜哄憳瀹℃壒 + String [] objIds = approveParam.getObjIds().split(","); + for (String id:objIds) { + //娣诲姞瀹℃壒浜� + ids.add(Integer.valueOf(id)); + } + }else if(approveParam.getMemberType().equals(Constants.TWO)){ + //閮ㄩ棬涓荤瀹℃壒 + //瀹℃壒閮ㄩ棬 + Company auditCompany = this.getAuditCompanyHead(visitMember.getCompanyId(),approveParam.getObjLevel()); + if(Objects.isNull(auditCompany)){ + //瀹℃壒閮ㄩ棬涓虹┖ 鑷姩娴佽浆涓嬩竴绾у鎵归厤缃� + level = level + 1; + return this.getApproveIds(level,visitMember,ids); + }else{ + //鏌ヨ閮ㄩ棬璐熻矗浜� + Member headMember = memberMapper.selectById(auditCompany.getHeadId()); + if(Objects.isNull(headMember)){ + //鏈煡璇㈠埌閮ㄩ棬璐熻矗浜� + if(approveParam.getNoleaderOpt().equals(Constants.ONE)&&!Objects.isNull(auditCompany.getParentId())){ + //鐢变笂绾т富绠′唬鏇垮鏍� + auditCompany = companyMapper.selectOne(new QueryWrapper<Company>().lambda().eq(Company::getId,auditCompany.getParentId())); + if(Objects.isNull(auditCompany)){ + //瀹℃壒閮ㄩ棬涓虹┖ 鑷姩娴佽浆涓嬩竴绾у鎵归厤缃� + level = level + 1; + this.getApproveIds(level,visitMember,ids); + }else{ + headMember = memberMapper.selectById(auditCompany.getHeadId()); + if(Objects.isNull(headMember)){ + //鏌ヨ閮ㄩ棬璐熻矗浜� 涓虹┖ 鑷姩娴佽浆涓嬩竴绾у鎵归厤缃� + level = level + 1; + return this.getApproveIds(level,visitMember,ids); + }else{ + //娣诲姞瀹℃壒浜� + ids.add(headMember.getId()); + } + } + }else{ + level = level + 1; + return this.getApproveIds(level,visitMember,ids); + } + }else{ + //娣诲姞瀹℃壒浜� + ids.add(headMember.getId()); + } + + } + } + } + + return approveParam; + } + + /** + * 鏍规嵁閰嶇疆鏌ヨ涓婄骇鏁版嵁 + * @param companyId 鐩存帴閮ㄩ棬 + * @param objLevel 鏌ヨ绾у埆 + */ + public Company getAuditCompanyHead(Integer companyId,Integer objLevel){ + Integer queryLevel = Constants.ONE; + Integer nextCompanyId = companyId; + Company auditCompany = new Company(); + while(queryLevel.equals(objLevel)){ + auditCompany = companyMapper.selectById(nextCompanyId); + if(Objects.isNull(auditCompany)){ + return null; + } + nextCompanyId = auditCompany.getParentId(); + } + return auditCompany; + } + /** * 鏍¢獙蹇呭~椤规暟鎹槸鍚﹀悎娉� * @param visits */ private void isValidBaseParam(Visits visits) { - if(visits.getStarttime() == null - || visits.getEndtime() == null - || StringUtils.isBlank(visits.getReason()) + if(visits.getEndtime() == null + || visits.getStarttime() == null +// || StringUtils.isBlank(visits.getReason()) || StringUtils.isBlank( visits.getName()) || StringUtils.isBlank( visits.getPhone()) || visits.getIdcardType() == null - || StringUtils.isBlank( visits.getFaceImg() ) +// || 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.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(), "瀵逛笉璧凤紝棰勭害缁撴潫鏃堕棿蹇呴』澶т簬寮�濮嬫椂闂达紒");// } @@ -177,16 +623,27 @@ } private void initWithVisitInfo(Visits visits) { - if(visits.getWithUserList()!=null && visits.getLwWithUserList().size()>0){ + 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()); v.setIsdeleted(Constants.ZERO); v.setCreateDate(visits.getCreateDate()); + v.setSex(Constants.getSexByCardNo(v.getIdcardNo())); + 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()); @@ -197,9 +654,10 @@ visits.setHkStatus(Constants.ZERO);//鏈悓姝� visits.setBirthday(Constants.getBirthdyByCardNo(visits.getIdcardNo())); visits.setStatus(Constants.ZERO);//寰呭鎵� + visits.setSex(Constants.getSexByCardNo(visits.getIdcardNo())); + visits.setIdcardDecode(Constants.getTuominStr(visits.getIdcardNo()));//鑴辨晱韬唤璇佸彿 visits.setIdcardNo(DESUtil.encrypt(Constants.EDS_PWD, visits.getIdcardNo()));//韬唤璇佸彿鍔犲瘑 - //韬唤璇佸彿瀛樺偍瀵嗘枃 - visits.setIdcardDecode(Constants.getTuominStr(visits.getIdcardNo()));//鑴辨晱鎵嬫満鍙� + visits.setIsdeleted(Constants.ZERO); visits.setCreateDate(date); } @@ -207,7 +665,16 @@ ApproveAddRequest param = new ApproveAddRequest(); List<Visits> withUserVisitsList = visits.getWithUserList(); List<UserInfoRequest> withUserList = new ArrayList<>(); - if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(withUserVisitsList)){ + UserInfoRequest mainUser = new UserInfoRequest(); + mainUser.setName(visits.getName()); + mainUser.setIdNo(DESUtil.decrypt(Constants.EDS_PWD, visits.getIdcardNo())); + mainUser.setSex(visits.getSex()); + mainUser.setPhone(visits.getPhone()); + mainUser.setFaceImg(visits.getFaceImg()); + mainUser.setHealthImg(visits.getImgurl()); + withUserList.add(mainUser); + + if(CollectionUtils.isNotEmpty(withUserVisitsList)){ for (Visits v:withUserVisitsList) { UserInfoRequest userInfoRequest = new UserInfoRequest(); userInfoRequest.setName(v.getName()); @@ -218,30 +685,35 @@ userInfoRequest.setHealthImg(v.getImgurl()); withUserList.add(userInfoRequest); } - param.setWithUserList(withUserList); } + param.setWithUserList(withUserList); + param.setId(visits.getId()); param.setBeVisitedUserId(visitMember.getErpId()); param.setVisitorWorkUint(visits.getCompanyName()); param.setPurpose(visits.getReason()); - param.setStartTime(DateUtil.getDate(visits.getStarttime(),"yyyy-MM-dd HH:mm:ss")); - param.setEndTime(DateUtil.getDate(visits.getEndtime(),"yyyy-MM-dd HH:mm:ss")); + param.setStartTime(DateUtil.DateToStr(visits.getStarttime(),"yyyy-MM-dd HH:mm:ss")); + param.setEndTime(DateUtil.DateToStr(visits.getEndtime(),"yyyy-MM-dd HH:mm:ss")); + param.setBeVisitedOrgId(visitMember.getErpOrgId()); if(StringUtils.isNotBlank(visits.getCarNos())){ param.setCarNo(Arrays.asList(visits.getCarNos().split(","))); } if(StringUtils.isNotBlank(visits.getDoors())){ List<DeviceRole> deviceRoleList = deviceRoleMapper.selectList(new QueryWrapper<DeviceRole>().lambda().in(DeviceRole::getId,Arrays.asList(visits.getDoors().split(",")))); - if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(deviceRoleList)){ + if(CollectionUtils.isNotEmpty(deviceRoleList)){ param.setRoleIds(deviceRoleList.stream().map(m->m.getId()).collect(Collectors.toList())); param.setRoleNames(deviceRoleList.stream().map(m->m.getName()).collect(Collectors.toList())); } } - ApproveInfoResponse response = ErpTool.submitApprove(ErpConstants.approveUrl,param); + ApproveInfoResponse response = erpTool.submitApprove(ErpConstants.approveUrl,param); if(!Objects.isNull(response)){ - return response.getId().toString(); + return visits.getId().toString(); } + return null; } + + private String visitAppiontment(Visits visits) { VisitAppointmentRequest param = new VisitAppointmentRequest(); @@ -281,65 +753,102 @@ //闅忚浜哄憳淇℃伅澶勭悊 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(),visits,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); +// }); +// +// } + return m; } private Member getMemberListParam(String cardno, Visits visits, List<Member> addList, List<Member> editList) { - if(!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) .eq(Member::getIdcardType,visits.getIdcardType()) - .eq(Member::getIdcardNo,visits.getIdcardNo()).last("limit 1" ) + .eq(Member::getIdcardNo,DESUtil.encrypt(Constants.EDS_PWD, cardno)).last("limit 1" ) ); if(member == null){ + member = new Member(); //濡傛灉鐢ㄦ埛涓嶅瓨鍦紝鍒欐柊澧� 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));//鑴辨晱鎵嬫満鍙� + member.setFaceImg(visits.getFaceImg()); + member.setSex(Constants.getSexByCardNo(cardno)); + member.setImgurl(StringUtils.isNotBlank(visits.getImgurl())?visits.getImgurl():null); + member.setIdcardType(visits.getIdcardType()); member.setName(visits.getName()); member.setPhone(visits.getPhone()); member.setOpenid(visits.getOpenid()); member.setType(Constants.memberType.visitor); member.setStatus(Constants.ZERO); member.setSex(Constants.getSexByCardNo(cardno)); - // 鏂板璁垮璁板綍 - addList.add(member); + member.setHkStatus(Constants.ZERO); + member.setErpStatus(Constants.ZERO); + 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()); member.setIsdeleted(Constants.ZERO); - member.setIdcardNo(visits.getIdcardNo()); - member.setIdcardDecode(visits.getIdcardDecode()); + member.setSex(Constants.getSexByCardNo(cardno)); + member.setIdcardNo(DESUtil.encrypt(Constants.EDS_PWD, cardno));//韬唤璇佸彿鍔犲瘑 + member.setIdcardDecode(Constants.getTuominStr(cardno));//鑴辨晱韬唤璇佸彿 member.setName(visits.getName()); member.setPhone(visits.getPhone()); member.setOpenid(visits.getOpenid()); member.setSex(Constants.getSexByCardNo(cardno)); - // 鏇存柊璁垮淇℃伅, - editList.add(member); + member.setHkStatus(Constants.ZERO); + member.setErpStatus(Constants.ZERO); + member.setVisitCompanyName(visits.getCompanyName()); + memberMapper.updateById(member); } //鏍规嵁鎵嬫満鍙峰拰韬唤璇佸彿鐮佹煡璇� 褰撳墠棰勭害鐨勬椂闂存槸鍚︿笌鍏朵粬棰勭害璁板綍鏈夊啿绐� if (visitsMapper.selectCount(new QueryWrapper<Visits>().lambda() - .eq(Visits::getPhone, member.getPhone()) - .and(ms -> ms.eq(Visits::getPhone, member.getPhone()) - .or().eq(Visits::getIdcardDecode, member.getIdcardDecode())) - .and(ms -> ms.apply(" visits.STARTTIME <= '" + visits.getStarttime() + "' and visits.ENDTIME >= '" + visits.getStarttime() + "' ") - .or().apply(" visits.STARTTIME <= '" + visits.getEndtime() + "' and visits.ENDTIME >= '" + visits.getEndtime() + "' ") + .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.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) { throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "瀵逛笉璧凤紝鎵嬫満鍙枫��"+member.getPhone()+"銆戞垨韬唤璇併��"+ member.getIdcardDecode() +"銆戝瓨鍦ㄩ绾︽椂闂村啿绐侊紝鏃犳硶鐢宠鍝︼紒"); } @@ -384,6 +893,7 @@ private void updateProblemLog(Visits visits, ProblemLog problemLog,Member member) { if(problemLog!=null){ problemLog.setEditDate(visits.getCreateDate()); + problemLog.setStatus(Constants.ONE); problemLog.setName(visits.getName()); problemLog.setUserId(member.getId()); problemLog.setPhone(member.getPhone()); @@ -398,7 +908,7 @@ */ private Member isValideVisitedUser(Integer receptMemberId) { Member member = memberMapper.selectById(receptMemberId); - if(member == null || Constants.equalsInteger(Constants.ZERO,member.getIsdeleted())){ + if(member == null || !Constants.equalsInteger(Constants.ZERO,member.getIsdeleted())){ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝璇ユ嫓璁夸汉鏆傛椂涓嶈兘鎺ュ彈鎮ㄧ殑鎷滆鐢宠锛�"); } if(!Constants.equalsInteger(member.getStatus(), Constants.ZERO)){ @@ -412,7 +922,7 @@ 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(), "瀵逛笉璧凤紝璇峰厛鎸夎姹傝繘琛屽畨鍏ㄧ煡璇嗙瓟棰橈紒"); @@ -421,7 +931,7 @@ if(log == null){ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝璇峰厛鎸夎姹傝繘琛屽畨鍏ㄧ煡璇嗙瓟棰�."); } - if(log.getLogId() !=null){ + if(log.getLogId() !=null&&log.getStatus().equals(Constants.ZERO)){ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝璇峰厛鎸夎姹傝繘琛屽畨鍏ㄧ煡璇嗙瓟棰榽"); } return log; @@ -438,11 +948,23 @@ String mustSelectDoors = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.SELECT_DOORS_VISIT_REQUIRED).getCode(); 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) + .eq(DeviceRole::getType,Constants.DeviceRoleType.fk)); + if(roles.size() ==0){ + throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝鏆備笉瀛樺湪鍙闂殑璁垮闂ㄧ锛屾棤娉曡繘琛岀敵璇锋搷浣滐紒"); + } + + }else{ + //濡傛灉蹇呴』閫夋嫨闂ㄧ锛屼絾鏈�夋嫨 String[] dIds = visits.getDoors().split(","); roles = deviceRoleMapper.selectList(new QueryWrapper<DeviceRole>().lambda() .eq(DeviceRole::getIsdeleted,Constants.ZERO) @@ -450,17 +972,6 @@ .in(DeviceRole::getId, Arrays.asList(dIds))); if(roles == null || roles.size()==0 || roles.size() != dIds.length){ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝璇烽�夋嫨鏈夋晥璁块棶闂ㄧ锛�"); - } - }else{ - //濡傛灉璁剧疆涓嶉�夋嫨闂ㄧ锛屽垯鎻愪緵榛樿闂ㄧ缁勪俊鎭� - String[] dIds = visits.getDoors().split(","); - roles = deviceRoleMapper.selectList(new QueryWrapper<DeviceRole>().lambda() - .eq(DeviceRole::getIsdeleted,Constants.ZERO) - .eq(DeviceRole::getIsDefault,Constants.ZERO) - .eq(DeviceRole::getType,Constants.DeviceRoleType.fk)); - if(roles.size() ==0){ - - throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝鏆備笉瀛樺湪鍙闂殑璁垮闂ㄧ锛屾棤娉曡繘琛岀敵璇锋搷浣滐紒"); } } String[] ids =new String[roles.size()]; @@ -512,7 +1023,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); @@ -520,10 +1031,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); } } @@ -537,6 +1048,8 @@ BeanUtils.copyProperties(result,v); visitsList.add(0,v); result.setWithUserList(visitsList); + result.setPrefixUrl(systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode() + + systemDictDataBiz.queryByCode(Constants.FTP,Constants.MEMBER_IMG).getCode()); return result; } @@ -558,6 +1071,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); @@ -565,14 +1079,20 @@ 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()) + queryWrapper.and(StringUtils.isNotBlank(pageWrap.getModel().getName()),ms->ms.like(Visits::getName,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().getIdcardNo()),Visits::getIdcardNo,DESUtil.encrypt(Constants.EDS_PWD, 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::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); } @@ -585,43 +1105,155 @@ @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.ne(Member::getType,Constants.TWO); + 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); + } } - }); } return PageData.from(result); } + + + @Override + public VisitDetailVO getVisitDetail(Integer id){ + Visits visits = visitsMapper.selectById(id); + if(Objects.isNull(visits)){ + throw new BusinessException(ResponseStatus.DATA_EMPTY); + } + Member member = memberMapper.selectById(visits.getReceptMemberId()); + if(Objects.isNull(member)){ + throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌琚鍛樺伐淇℃伅"); + } + 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()); + if(!Objects.isNull(company)){ + visitDetailVO.setVisitUserCompany(company.getName()); + } + visitDetailVO.setName(visits.getName()); + visitDetailVO.setCompanyName(visits.getCompanyName()); + visitDetailVO.setFaceImg(visits.getFaceImg()); + visitDetailVO.setImgUrl(visits.getImgurl()); + visitDetailVO.setIdCardDecode(visits.getIdcardDecode()); + visitDetailVO.setPrefix(systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode() + + systemDictDataBiz.queryByCode(Constants.FTP,Constants.MEMBER_IMG).getCode()); + if(StringUtils.isNotBlank(visits.getDoors())){ + List<DeviceRole> deviceRoleList = deviceRoleMapper.selectList(new QueryWrapper<DeviceRole>().lambda() + .select(DeviceRole::getName) + .eq(DeviceRole::getIsdeleted,Constants.ZERO) + .in(DeviceRole::getId,visits.getDoors().split(","))); + if(CollectionUtils.isNotEmpty(deviceRoleList)){ + visitDetailVO.setDoorGroupName( + deviceRoleList.stream().map(m->m.getName()).collect(Collectors.toList()) + ); + } + } + visitDetailVO.setWithVisitsList( + visitsMapper.selectList(new QueryWrapper<Visits>().lambda() + .select(Visits::getName,Visits::getPhone,Visits::getQrcode,Visits::getFaceImg,Visits::getImgurl,Visits::getIdcardDecode,Visits::getStatus) + .eq(Visits::getParentId,id))); + return visitDetailVO; + } + + + + + @Override + public PageData<VisitRecordVO> taskCenter(PageWrap<VisitRecordDTO> param) { + VisitRecordDTO visitRecordDTO = param.getModel(); + IPage<Visits> page = new Page<>(param.getPage(), param.getCapacity()); + MPJLambdaWrapper<Visits> queryWrapper = new MPJLambdaWrapper<>(); + Utils.MP.blankToNull(visitRecordDTO); + + queryWrapper.selectAs(Visits::getId,VisitRecordVO::getId); + queryWrapper.selectAs(Visits::getName,VisitRecordVO::getName); + queryWrapper.selectAs(Visits::getStarttime,VisitRecordVO::getStartTime); + queryWrapper.selectAs(Visits::getEndtime,VisitRecordVO::getEndTime); + queryWrapper.selectAs(Visits::getReason,VisitRecordVO::getReason); + queryWrapper.selectAs(Visits::getMemberNum,VisitRecordVO::getInNum); + queryWrapper.selectAs(Visits::getCreateDate,VisitRecordVO::getCreateDate); + queryWrapper.leftJoin(Approve.class,Approve::getId,Visits::getId); + if(!Objects.isNull(visitRecordDTO)){ + queryWrapper.like(StringUtils.isNotBlank(visitRecordDTO.getName()),Visits::getName,visitRecordDTO.getName()); + queryWrapper.le(!Objects.isNull(visitRecordDTO.getCreateTimeS()),Visits::getCreateDate,visitRecordDTO.getCreateTimeS()); + queryWrapper.ge(!Objects.isNull(visitRecordDTO.getCreateTimeE()),Visits::getCreateDate,visitRecordDTO.getCreateTimeE()); + queryWrapper.eq(!Objects.isNull(visitRecordDTO.getType()),Visits::getType,visitRecordDTO.getType()); + if(!Objects.isNull(visitRecordDTO.getState())&&visitRecordDTO.getState()<Constants.TWO){ + queryWrapper.eq(Approve::getStatus,visitRecordDTO.getState()); + queryWrapper.eq(Approve::getChekorId,visitRecordDTO.getMemberId()); + }else if(!Objects.isNull(visitRecordDTO.getState())&&visitRecordDTO.getState()==Constants.TWO){ + queryWrapper.eq(Visits::getMemberId,visitRecordDTO.getMemberId()); + } + } + queryWrapper.orderByDesc(Visits::getCreateDate); + IPage<VisitRecordVO> result = visitsJoinMapper.selectJoinPage(page, VisitRecordVO.class,queryWrapper); + + return PageData.from(result); + } + + + + @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())); + } + } -- Gitblit v1.9.3