| | |
| | | import cn.hutool.core.util.IdcardUtil; |
| | | 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.erp.ApproveAddRequest; |
| | | import com.doumee.core.erp.model.openapi.request.erp.UserInfoRequest; |
| | | 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.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import io.swagger.models.auth.In; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import org.springframework.util.DigestUtils; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 访客申请信息表Service实现 |
| | |
| | | //获取申请的海康访问门禁组信息 |
| | | String[] hkIds = getHkDeviceRoles(visits); |
| | | //检验拜访人是否合法 |
| | | isValideVisitedUser(visits.getReceptMemberId()); |
| | | Member visitMember = isValideVisitedUser(visits.getReceptMemberId()); |
| | | if(Constants.equalsInteger(Constants.ZERO, visits.getIdcardType()) &&!IdcardUtil.isValidCard(visits.getIdcardNo())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "对不起,身份证号码有误,请核实后重试!"); |
| | | } |
| | |
| | | //初始化访客信息 |
| | | initVisitInfo(visits,date); |
| | | //发起ERP审批申请 |
| | | String erpid = startSendErpCheck(visits); |
| | | if(StringUtils.isNotBlank(erpid)){ |
| | | visits.setErpId(erpid); |
| | | String erpId = startSendErpCheck(visits,visitMember); |
| | | if(StringUtils.isNotBlank(erpId)){ |
| | | visits.setErpId(erpId); |
| | | }else{ |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "对不起,发起拜访审批申请失败!"); |
| | | } |
| | |
| | | visits.setCreateDate(date); |
| | | } |
| | | |
| | | private String startSendErpCheck(Visits visits) { |
| | | //TODO ------------RK-------------- |
| | | // ErpTool.submitApprove() |
| | | private String startSendErpCheck(Visits visits,Member visitMember) { |
| | | ApproveAddRequest param = new ApproveAddRequest(); |
| | | List<Visits> withUserVisitsList = visits.getWithUserList(); |
| | | List<UserInfoRequest> withUserList = new ArrayList<>(); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(withUserVisitsList)){ |
| | | for (Visits v:withUserVisitsList) { |
| | | UserInfoRequest userInfoRequest = new UserInfoRequest(); |
| | | userInfoRequest.setName(v.getName()); |
| | | userInfoRequest.setIdNo(v.getIdcardNo()); |
| | | userInfoRequest.setSex(v.getSex()); |
| | | userInfoRequest.setPhone(v.getPhone()); |
| | | userInfoRequest.setFaceImg(v.getFaceImg()); |
| | | userInfoRequest.setHealthImg(v.getImgurl()); |
| | | withUserList.add(userInfoRequest); |
| | | } |
| | | 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")); |
| | | 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)){ |
| | | 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); |
| | | if(!Objects.isNull(response)){ |
| | | return response.getId().toString(); |
| | | } |
| | | return null; |
| | | } |
| | | |