| | |
| | | import com.doumee.core.haikang.model.param.BaseListPageResponse; |
| | | import com.doumee.core.haikang.model.param.BaseResponse; |
| | | import com.doumee.core.haikang.model.param.request.AppointmentListRequest; |
| | | import com.doumee.core.haikang.model.param.request.OrgUserListRequest; |
| | | import com.doumee.core.haikang.model.param.respose.AppointmentInfoResponse; |
| | | import com.doumee.core.haikang.model.param.respose.OrgInfoResponse; |
| | | import com.doumee.core.haikang.model.param.respose.UserInfoResponse; |
| | | import com.doumee.core.haikang.service.HKService; |
| | | import com.doumee.core.model.LoginUserInfo; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.DESUtil; |
| | | import com.doumee.core.utils.DateUtil; |
| | |
| | | import com.doumee.dao.business.CompanyMapper; |
| | | import com.doumee.dao.business.MemberMapper; |
| | | import com.doumee.dao.business.VisitsMapper; |
| | | import com.doumee.dao.business.model.Company; |
| | | import com.doumee.dao.business.model.Member; |
| | | import com.doumee.dao.business.model.Visits; |
| | | import com.doumee.service.business.impl.hksync.HkSyncBaseServiceImpl; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class HkSyncVistFromHKServiceImpl extends HkSyncBaseServiceImpl { |
| | | public class HkSyncVisitFromHKServiceImpl extends HkSyncBaseServiceImpl { |
| | | @Autowired |
| | | private CompanyMapper companyMapper; |
| | | @Autowired |
| | |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public void syncVistAppointData(){ |
| | | if(Constants.DEALING_FROM_HK_VISIT){ |
| | | return ; |
| | | } |
| | | Constants.DEALING_FROM_HK_VISIT =true; |
| | | public void syncVistAppointData(Date date){ |
| | | try { |
| | | if( Constants.formatIntegerNum(dataSyncConfig.getVisitorDataOrigin()) != DataSyncConfig.origin.hk){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,当前不支持海康数据同步操作~"); |
| | |
| | | int curTotal = 0; |
| | | int curPage = 1; |
| | | //查询今天的 |
| | | param.setVisitStartTimeBegin(DateUtil.getISO8601Timestamp( Utils.Date.getStart(new Date()))); |
| | | Date start =Utils.Date.getStart(date); |
| | | Date end = new Date(); |
| | | if(DateUtil.daysBetweenDates(end,start) >1){ |
| | | end = Utils.Date.getEnd(date); |
| | | } |
| | | param.setVisitStartTimeBegin(DateUtil.getISO8601Timestamp2( start)); |
| | | param.setVisitStartTimeEnd(DateUtil.getISO8601Timestamp2( end)); |
| | | |
| | | List<Visits> allHkList = new ArrayList<>(); |
| | | while (hasNext){ |
| | |
| | | param.setPageNo(curPage); |
| | | param.setPageSize(100); |
| | | BaseResponse<BaseListPageResponse<AppointmentInfoResponse>> response = HKService.appointmentRecords(param); |
| | | if(response == null || !StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE)){ |
| | | if(response == null || !StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE) ){ |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "对不起,海康同步数据失败~"); |
| | | } |
| | | if(response.getData() == null || response.getData().getTotal() ==0){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未同步到任何信息!"); |
| | | } |
| | | BaseListPageResponse<AppointmentInfoResponse> r = response.getData(); |
| | | curTotal += 100; |
| | |
| | | if(allHkList .size() == 0){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未同步到任何组织信息!"); |
| | | } |
| | | //清空原有数据 |
| | | visitsMapper.delete(new UpdateWrapper<Visits>().lambda().apply("to_days(create_date)=to_days(now())" )); |
| | | //清空原有当天的数据 |
| | | visitsMapper.delete(new UpdateWrapper<Visits>().lambda() |
| | | .ge(Visits::getStarttime,start) |
| | | .eq(Visits::getType,Constants.ONE) |
| | | .le(Visits::getStarttime,end)); |
| | | visitsMapper.insertBatchSomeColumn(allHkList);//插入新数据 |
| | | }catch (BusinessException e){ |
| | | throw e; |
| | | }catch (Exception e){ |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "对不起,海康同步数据失败~"); |
| | | }finally { |
| | | Constants.DEALING_FROM_HK_VISIT =false; |
| | | } |
| | | } |
| | | |
| | |
| | | c.setHkDate(new Date()); |
| | | c.setIsdeleted(Constants.ZERO); |
| | | c.setCreateDate(c.getHkDate()); |
| | | c.setStarttime(DateUtil.getISO8601DateByStr(model.getVisitStartTime())); |
| | | c.setEndtime(DateUtil.getISO8601DateByStr(model.getVisitEndTime())); |
| | | c.setStarttime(DateUtil.getISO8601DateByStr2(model.getVisitStartTime())); |
| | | c.setEndtime(DateUtil.getISO8601DateByStr2(model.getVisitEndTime())); |
| | | c.setReason(model.getVisitPurpose()); |
| | | c.setStatus(model.getVisitorStatus()); |
| | | c.setType(Constants.ONE); |