¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.service.business.impl.hksync; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.haikang.model.HKConstants; |
| | | import com.doumee.core.haikang.model.param.BaseResponse; |
| | | import com.doumee.core.haikang.model.param.request.AcsDeviceListRequest; |
| | | import com.doumee.core.haikang.model.param.respose.AcsDeviceInfoResponse; |
| | | import com.doumee.core.haikang.model.param.respose.AcsDeviceListResponse; |
| | | import com.doumee.core.haikang.service.HKService; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.dao.business.*; |
| | | import com.doumee.dao.business.model.CarEvent; |
| | | import com.doumee.dao.business.model.Device; |
| | | import com.doumee.dao.business.model.DeviceEvent; |
| | | import com.doumee.dao.business.model.VisitEvent; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 设å¤ä¿¡æ¯è¡¨Serviceå®ç° |
| | | * @author æ±è¹è¹ |
| | | * @date 2023/11/30 15:33 |
| | | */ |
| | | @Service |
| | | public class HkSyncImgServiceImpl extends HkSyncBaseServiceImpl { |
| | | |
| | | @Autowired |
| | | private CarEventMapper carEventMapper; |
| | | @Autowired |
| | | private DeviceEventMapper deviceEventMapper; |
| | | @Autowired |
| | | private VisitEventMapper visitEventMapper; |
| | | @Override |
| | | public String downHKImgs(int type){ |
| | | if(Constants.DEALING_HK_IMG){ |
| | | return null ; |
| | | } |
| | | Constants.DEALING_HK_IMG =true; |
| | | try { |
| | | //æ¥è¯¢ææè®¿å®¢äºä»¶è®°å½ä¸ææä¸è½½ç海康端 ææç
§ç å ç
§ç |
| | | startDealVisitImg(); |
| | | |
| | | //æ¥è¯¢ææå车åºäºä»¶è®°å½ä¸ææä¸è½½ç海康端 车çå¾ç å 车è¾å¾ç |
| | | startDealCarImg(); |
| | | //æ¥è¯¢ææé¨ç¦äºä»¶è®°å½ä¸ææä¸è½½ç海康端 ææç
§ç å 身份è¯å¾çURL |
| | | startDealDeviceImg(); |
| | | }catch (Exception e){ |
| | | |
| | | }finally { |
| | | Constants.DEALING_HK_IMG =false; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private void startDealDeviceImg() { |
| | | List<DeviceEvent> deviceEventList = deviceEventMapper.selectList(new QueryWrapper<DeviceEvent>().lambda() |
| | | .eq(DeviceEvent::getIsdeleted,Constants.ZERO) |
| | | .and(wrapper ->{wrapper.likeLeft(DeviceEvent::getExtEventPictureURL,HKConstants.IMG_INDEX) |
| | | .or() |
| | | .likeLeft(DeviceEvent::getExtEventIDCardPictureURL,HKConstants.IMG_INDEX) ;})); |
| | | Date date= new Date(); |
| | | if(deviceEventList !=null && deviceEventList.size()>0){ |
| | | for(DeviceEvent model:deviceEventList){ |
| | | String img1 = model.getExtEventPictureURL(); |
| | | String img2 = model.getExtEventIDCardPictureURL(); |
| | | String serverIndex = model.getSvrIndexCode();//æå¡å¨ç¼ç |
| | | String rs1 = downHkImgToFtp(img1,serverIndex,Constants.DEVICE_EVENT_IMG); |
| | | String rs2 = downHkImgToFtp(img2,serverIndex,Constants.DEVICE_EVENT_IMG); |
| | | DeviceEvent event = new DeviceEvent(); |
| | | event.setId(model.getId()); |
| | | event.setEditDate(date); |
| | | if(StringUtils.isNotBlank(rs1)){ |
| | | event.setExtEventPictureURL(rs1); |
| | | }else{ |
| | | event.setExtEventPictureURL(img1.replace(HKConstants.IMG_INDEX, HKConstants.IMG_INDEX_ERROR)); |
| | | } |
| | | if(StringUtils.isNotBlank(rs2)){ |
| | | event.setExtEventIDCardPictureURL(rs2); |
| | | }else{ |
| | | event.setExtEventIDCardPictureURL(img2.replace(HKConstants.IMG_INDEX, HKConstants.IMG_INDEX_ERROR)); |
| | | } |
| | | deviceEventMapper.updateById(event); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | private void startDealCarImg() { |
| | | List<CarEvent> carEventList = carEventMapper.selectList(new QueryWrapper<CarEvent>().lambda() |
| | | .eq(CarEvent::getIsdeleted,Constants.ZERO) |
| | | .and(wrapper ->{wrapper.likeLeft(CarEvent::getPlatePicUrl,HKConstants.IMG_INDEX) |
| | | .or() |
| | | .likeLeft(CarEvent::getVehiclePicUrl,HKConstants.IMG_INDEX) ;})); |
| | | Date date= new Date(); |
| | | if(carEventList !=null && carEventList.size()>0){ |
| | | for(CarEvent model:carEventList){ |
| | | String img1 = model.getPlatePicUrl(); |
| | | String img2 = model.getVehiclePicUrl(); |
| | | String serverIndex = model.getSvrIndex();//æå¡å¨ç¼ç |
| | | String rs1 = downHkImgToFtp(img1,serverIndex,Constants.CAR_EVENT_IMG); |
| | | String rs2 = downHkImgToFtp(img2,serverIndex,Constants.CAR_EVENT_IMG); |
| | | CarEvent event = new CarEvent(); |
| | | event.setId(model.getId()); |
| | | event.setEditDate(date); |
| | | if(StringUtils.isNotBlank(rs1)){ |
| | | event.setPlatePicUrl(rs1); |
| | | }else{ |
| | | event.setPlatePicUrl(img1.replace(HKConstants.IMG_INDEX, HKConstants.IMG_INDEX_ERROR)); |
| | | } |
| | | if(StringUtils.isNotBlank(rs2)){ |
| | | event.setVehiclePicUrl(rs2); |
| | | }else{ |
| | | event.setVehiclePicUrl(img2.replace(HKConstants.IMG_INDEX, HKConstants.IMG_INDEX_ERROR)); |
| | | } |
| | | carEventMapper.updateById(event); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | private void startDealVisitImg() { |
| | | List<VisitEvent> visitEventList = visitEventMapper.selectList(new QueryWrapper<VisitEvent>().lambda() |
| | | .eq(VisitEvent::getIsdeleted,Constants.ZERO) |
| | | .and(wrapper ->{wrapper.likeLeft(VisitEvent::getCaptureUrl,HKConstants.IMG_INDEX) |
| | | .or() |
| | | .likeLeft(VisitEvent::getPhotoUrl,HKConstants.IMG_INDEX) ;})); |
| | | |
| | | Date date= new Date(); |
| | | if(visitEventList !=null && visitEventList.size()>0){ |
| | | for(VisitEvent model:visitEventList){ |
| | | String img1 = model.getCaptureUrl(); |
| | | String img2 = model.getPhotoUrl(); |
| | | String serverIndex = model.getSvrIndexCode();//æå¡å¨ç¼ç |
| | | String rs1 = downHkImgToFtp(img1,serverIndex,Constants.VISIT_EVENT_IMG); |
| | | String rs2 = downHkImgToFtp(img2,serverIndex,Constants.VISIT_EVENT_IMG); |
| | | VisitEvent event = new VisitEvent(); |
| | | event.setId(model.getId()); |
| | | event.setEditDate(date); |
| | | if(StringUtils.isNotBlank(rs1)){ |
| | | event.setCaptureUrl(rs1); |
| | | }else{ |
| | | event.setCaptureUrl(img1.replace(HKConstants.IMG_INDEX, HKConstants.IMG_INDEX_ERROR)); |
| | | } |
| | | if(StringUtils.isNotBlank(rs2)){ |
| | | event.setPhotoUrl(rs2); |
| | | }else{ |
| | | event.setPhotoUrl(img2.replace(HKConstants.IMG_INDEX, HKConstants.IMG_INDEX_ERROR)); |
| | | } |
| | | visitEventMapper.updateById(event); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | private String downHkImgToFtp(String img1, String serverIndex, String visitEventImg) { |
| | | // |
| | | |
| | | return null; |
| | | } |
| | | } |