From 2d95605efd098e1b1c80f80021b259314b10f204 Mon Sep 17 00:00:00 2001 From: k94314517 <8417338+k94314517@user.noreply.gitee.com> Date: 星期五, 01 三月 2024 10:41:14 +0800 Subject: [PATCH] ERP接口 --- server/dmvisit_service/src/main/java/com/doumee/service/business/impl/VisitsServiceImpl.java | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 101 insertions(+), 12 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 b98b25a..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 @@ -34,6 +34,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; @@ -94,11 +96,92 @@ @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){ + 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); + } + /** * 鏅�氳瀹㈢敵璇� @@ -135,22 +218,27 @@ initVisitInfo(visits,date); visitsMapper.insert(visits); //鍙戣捣ERP瀹℃壒鐢宠 - String erpId = startSendErpCheck(visits,visitMember); - if(StringUtils.isNotBlank(erpId)){ - visits.setErpId(erpId); - visits.setStatus(Constants.VisitStatus.submitCheck); - 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(); } @@ -554,7 +642,8 @@ v.setDoors(visits.getDoors()); v.setType(visits.getType()); v.setVisitType(visits.getVisitType()); - v.setStatus(Constants.VisitStatus.submitCheck); + v.setStatus(visits.getStatus()); + v.setSourceType(visits.getSourceType()); } //鎵归噺鎻掑叆鏁版嵁 visitsMapper.insertBatchSomeColumn(visits.getWithUserList()); @@ -833,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(), "瀵逛笉璧凤紝璇峰厛鎸夎姹傝繘琛屽畨鍏ㄧ煡璇嗙瓟棰橈紒"); -- Gitblit v1.9.3