|  |  |  | 
|---|
|  |  |  | import com.github.yulichang.wrapper.MPJLambdaWrapper; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.apache.commons.lang3.StringUtils; | 
|---|
|  |  |  | import org.apache.http.HttpEntity; | 
|---|
|  |  |  | import org.apache.http.HttpResponse; | 
|---|
|  |  |  | import org.apache.http.client.HttpClient; | 
|---|
|  |  |  | import org.apache.http.client.methods.HttpGet; | 
|---|
|  |  |  | import org.apache.http.impl.client.HttpClientBuilder; | 
|---|
|  |  |  | import org.apache.http.util.EntityUtils; | 
|---|
|  |  |  | import org.checkerframework.checker.units.qual.C; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | 
|---|
|  |  |  | import org.springframework.util.CollectionUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.servlet.http.HttpServletResponse; | 
|---|
|  |  |  | import java.io.IOException; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  | import java.util.stream.Collectors; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | private PlatformLogMapper platformLogMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private PlatformWarnEventServiceImpl platformWarnEventService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 海康门禁事件推送 | 
|---|
|  |  |  | * @param param | 
|---|
|  |  |  | 
|---|
|  |  |  | event.setPlatePicUrl(getHkImgUrl(request.getData().getPicUrl().getPlatePicUrl())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(StringUtils.isNotBlank(event.getPlateNos())){ | 
|---|
|  |  |  | Cars carModel = carsMapper.selectJoinOne(Cars.class,new MPJLambdaWrapper<Cars>() | 
|---|
|  |  |  | .selectAll(Cars.class ) | 
|---|
|  |  |  | .selectAs(Company::getType,Cars::getCompanyType) | 
|---|
|  |  |  | .leftJoin(Company.class,Company::getId,Cars::getGroupId) | 
|---|
|  |  |  | .eq(Cars::getCode,event.getPlateNos()) | 
|---|
|  |  |  | .eq(Cars::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .last(" limit 1")); | 
|---|
|  |  |  | if(carModel!=null){ | 
|---|
|  |  |  | //0安泰公务车 1安泰自有物流车 2其它 | 
|---|
|  |  |  | event.setMemberId(carModel.getMemberId()); | 
|---|
|  |  |  | event.setCompanyId(carModel.getGroupId()); | 
|---|
|  |  |  | if(Constants.equalsInteger(carModel.getType(),Constants.ONE)){ | 
|---|
|  |  |  | event.setCarType(Constants.RetentionCarType.selfTruck); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | if(Constants.equalsInteger(carModel.getCompanyType(),Constants.ONE)){ | 
|---|
|  |  |  | event.setCarType(Constants.RetentionCarType.internal);//内部车辆 | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | event.setCarType(Constants.RetentionCarType.relation);//相关方车辆 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | PlatformJob carTypeJob = platformJobMapper.selectOne(new QueryWrapper<PlatformJob>().lambda() | 
|---|
|  |  |  | .eq(PlatformJob::getCarCodeFront,event.getPlateNos()) | 
|---|
|  |  |  | .eq(PlatformJob::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .orderByAsc(PlatformJob::getCreateDate) | 
|---|
|  |  |  | .last(" limit 1")); | 
|---|
|  |  |  | if(carTypeJob!=null){ | 
|---|
|  |  |  | //作业类型 0自有车卸货 1自有车装货 2外协车卸货 3外协车装货 4市公司外协车卸货 | 
|---|
|  |  |  | if(Constants.equalsInteger(carTypeJob.getType(),Constants.FOUR)){ | 
|---|
|  |  |  | event.setCarType(Constants.RetentionCarType.cityComTruck);//市公司车辆 | 
|---|
|  |  |  | }else if(Constants.equalsInteger(carTypeJob.getType(),Constants.TWO) | 
|---|
|  |  |  | || Constants.equalsInteger(carTypeJob.getType(),Constants.THREE)){ | 
|---|
|  |  |  | event.setCarType(Constants.RetentionCarType.outTruck);//外协车 | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | event.setCarType(Constants.RetentionCarType.selfTruck);//自有车 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ParkBook cars = parkBookMapper.selectOne(new QueryWrapper<ParkBook>().lambda() | 
|---|
|  |  |  | .eq(ParkBook::getCarCode,event.getPlateNos()) | 
|---|
|  |  |  | .eq(ParkBook::getIsdeleted,Constants.ZERO ) | 
|---|
|  |  |  | 
|---|
|  |  |  | Constants.PlatformJobStatus.IN_WAIT.getKey(), | 
|---|
|  |  |  | Constants.PlatformJobStatus.CALLED.getKey(), | 
|---|
|  |  |  | Constants.PlatformJobStatus.WORKING.getKey(), | 
|---|
|  |  |  | Constants.PlatformJobStatus.DONE.getKey(), | 
|---|
|  |  |  | Constants.PlatformJobStatus.TRANSFERING.getKey(), | 
|---|
|  |  |  | Constants.PlatformJobStatus.EXCEPTION.getKey(), | 
|---|
|  |  |  | Constants.PlatformJobStatus.AUTHED_LEAVE.getKey() | 
|---|
|  |  |  | Constants.PlatformJobStatus.EXCEPTION.getKey() | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | )==Constants.ZERO){ | 
|---|
|  |  |  | PlatformJob platformJob = platformJobMapper.selectOne(new QueryWrapper<PlatformJob>().lambda() | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | Visits visits =  visitsMapper.selectOne(new QueryWrapper<Visits>().lambda() | 
|---|
|  |  |  | .eq(Visits::getCarNos,event.getPlateNos()) | 
|---|
|  |  |  | 
|---|
|  |  |  | if(visits!=null){ | 
|---|
|  |  |  | //最近使用该车的申请人(已到达) | 
|---|
|  |  |  | event.setMemberId(visits.getMemberId()); | 
|---|
|  |  |  | event.setCarType(Constants.RetentionCarType.visitor); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(Constants.formatIntegerNum(request.getEventType()) == HKConstants.EventTypes.PARK_PASS_IN.getKey()){ | 
|---|
|  |  |  | //如果是入厂放行 | 
|---|
|  |  |  | delRetentionList.add(event.getPlateNos()); | 
|---|
|  |  |  | retentionList.add(getRetentionModelByParkRequest(request)); | 
|---|
|  |  |  | retentionList.add(getRetentionModelByParkRequest(request,event)); | 
|---|
|  |  |  | inoutDayCount.setInCarNum(Constants.formatIntegerNum(inoutDayCount.getInCarNum())+1); | 
|---|
|  |  |  | }else if(Constants.formatIntegerNum(request.getEventType()) == HKConstants.EventTypes.PARK_PASS_OUT.getKey()){ | 
|---|
|  |  |  | //如果是出场放行 | 
|---|
|  |  |  | 
|---|
|  |  |  | return event; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private Retention getRetentionModelByParkRequest(EventParkInfoRequest request) { | 
|---|
|  |  |  | private Retention getRetentionModelByParkRequest(EventParkInfoRequest request,CarEvent event) { | 
|---|
|  |  |  | Retention retention = new Retention(); | 
|---|
|  |  |  | retention.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | retention.setCreateDate(DateUtil.getISO8601DateByStr(request.getHappenTime())); | 
|---|
|  |  |  | retention.setCarNo(request.getData().getPlateNo()); | 
|---|
|  |  |  | retention.setType(Constants.THREE); | 
|---|
|  |  |  | retention.setMemberId(event.getMemberId()); | 
|---|
|  |  |  | retention.setCarType(event.getCarType()); | 
|---|
|  |  |  | retention.setCompanyId(event.getCompanyId()); | 
|---|
|  |  |  | //        retention.setDeviceName(request.getSrcName()); | 
|---|
|  |  |  | //        retention.setDeviceIndex(request.getSrcIndex()); | 
|---|
|  |  |  | return retention; | 
|---|
|  |  |  | 
|---|
|  |  |  | if(StringUtils.isBlank(device.getHkId())){ | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(Constants.equalsInteger(device.getType(),Constants.ZERO)){ | 
|---|
|  |  |  | /*if(Constants.equalsInteger(device.getType(),Constants.ZERO)){ | 
|---|
|  |  |  | //如果是LED | 
|---|
|  |  |  | PlatformBroadcastLog log = dealLedContentBiz(model.getId(),device.getHkNo(),device.getName(),content,speed,1); | 
|---|
|  |  |  | logList.add(log); | 
|---|
|  |  |  | ledList.add(device.getHkId()); | 
|---|
|  |  |  | }else  if(Constants.equalsInteger(device.getType(),Constants.TWO)){ | 
|---|
|  |  |  | }else  */if(Constants.equalsInteger(device.getType(),Constants.TWO)){ | 
|---|
|  |  |  | //如果是广播点 | 
|---|
|  |  |  | bNames += device.getName()+";"; | 
|---|
|  |  |  | broadcastList.add(device.getHkId()); | 
|---|