| | |
| | | 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; |
| | | |
| | |
| | | @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()) |
| | | ) { |
| | |
| | | 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); |
| | | this.createFk(visits,true); |
| | | }catch (BusinessException e){ |
| | | throw e; |
| | | }finally { |
| | | saveInterfaceLog(erpVisitDTO,"/visitBiz/resource/crateVisit",null,Constants.ZERO); |
| | | saveInterfaceLog(erpVisitDTO,"/visitBiz/resource/createVisit",null,Constants.ZERO); |
| | | } |
| | | } |
| | | |
| | | 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()); |
| | |
| | | */ |
| | | @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 |
| | |
| | | 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(!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; |
| | | } |
| | | |
| | |
| | | * @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) |
| | |
| | | } |
| | | }else{ |
| | | //如果必须选择门禁,但未选择 |
| | | if(StringUtils.isNotBlank(visits.getDoors())){ |
| | | if(StringUtils.isBlank(visits.getDoors())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "对不起,请选择有效访问门禁!"); |
| | | } |
| | | String[] dIds = visits.getDoors().split(","); |