|  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONObject; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | import com.doumee.biz.system.SystemDictDataBiz; | 
|---|
|  |  |  | import com.doumee.config.DataSyncConfig; | 
|---|
|  |  |  | import com.doumee.core.constants.ResponseStatus; | 
|---|
|  |  |  | import com.doumee.core.exception.BusinessException; | 
|---|
|  |  |  | import com.doumee.core.haikang.model.HKConstants; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.doumee.core.utils.DateUtil; | 
|---|
|  |  |  | import com.doumee.core.utils.FtpUtil; | 
|---|
|  |  |  | 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 com.doumee.dao.business.model.*; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.apache.commons.lang3.StringUtils; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.scheduling.annotation.Async; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.io.File; | 
|---|
|  |  |  | import java.io.IOException; | 
|---|
|  |  |  | import java.io.InputStream; | 
|---|
|  |  |  | import java.io.*; | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private CarEventMapper carEventMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private MemberMapper memberMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private DeviceEventMapper deviceEventMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | 
|---|
|  |  |  | startDealCarImg(); | 
|---|
|  |  |  | //查询所有门禁事件记录中所有下载的海康端 抓拍照片 和   身份证图片URL | 
|---|
|  |  |  | startDealDeviceImg(); | 
|---|
|  |  |  | //查询所有人员人脸照片 | 
|---|
|  |  |  | startDealMemberImg(); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | }finally { | 
|---|
|  |  |  | 
|---|
|  |  |  | return  null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private void startDealMemberImg() { | 
|---|
|  |  |  | List<Member> list = memberMapper.selectList(new QueryWrapper<Member>().lambda() | 
|---|
|  |  |  | .eq(Member::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .likeRight(Member::getFaceImg,HKConstants.IMG_INDEX)); | 
|---|
|  |  |  | Date date= new Date(); | 
|---|
|  |  |  | if(list !=null && list.size()>0){ | 
|---|
|  |  |  | for(Member model:list){ | 
|---|
|  |  |  | String serverIndex = model.getFaceServerIndexCode();//服务器编码 | 
|---|
|  |  |  | if(StringUtils.isBlank(serverIndex)){ | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String rs1 = null; | 
|---|
|  |  |  | Member event = new Member(); | 
|---|
|  |  |  | event.setId(model.getId()); | 
|---|
|  |  |  | event.setEditDate(date); | 
|---|
|  |  |  | if(StringUtils.isNotBlank(model.getFaceImg())){ | 
|---|
|  |  |  | String img1 = model.getFaceImg().replace(HKConstants.IMG_INDEX_ERROR, "").replace(HKConstants.IMG_INDEX, ""); | 
|---|
|  |  |  | rs1 = downHkImgToFtp(img1,serverIndex,Constants.MEMBER_IMG); | 
|---|
|  |  |  | if(StringUtils.isNotBlank(rs1)){ | 
|---|
|  |  |  | event.setFaceImg(rs1); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | event.setFaceImg(model.getFaceImg().replace(HKConstants.IMG_INDEX, HKConstants.IMG_INDEX_ERROR)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | memberMapper.updateById(event); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | private void startDealDeviceImg() { | 
|---|
|  |  |  | List<DeviceEvent> deviceEventList = deviceEventMapper.selectList(new QueryWrapper<DeviceEvent>().lambda() | 
|---|
|  |  |  | .eq(DeviceEvent::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | 
|---|
|  |  |  | param.setPicUri(img1.replace(HKConstants.IMG_INDEX_ERROR,"").replace(HKConstants.IMG_INDEX,"")); | 
|---|
|  |  |  | param.setSvrIndexCode(serverIndex); | 
|---|
|  |  |  | is = HKService.getVisitPicture(param); | 
|---|
|  |  |  | }else if(StringUtils.equals(folder_code,Constants.MEMBER_IMG)){ | 
|---|
|  |  |  | //访客事件图片 | 
|---|
|  |  |  | FacePictureRequest param = new FacePictureRequest(); | 
|---|
|  |  |  | param.setPicUri(img1.replace(HKConstants.IMG_INDEX_ERROR,"").replace(HKConstants.IMG_INDEX,"")); | 
|---|
|  |  |  | param.setServerIndexCode(serverIndex); | 
|---|
|  |  |  | is = HKService.getFaceInputStream(param); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(is ==null){ | 
|---|
|  |  |  | return  null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //TODO------jiangping--------- | 
|---|
|  |  |  |  | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | if(ftp == null){ | 
|---|
|  |  |  | ftp = new FtpUtil(systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_HOST).getCode(), | 
|---|
|  |  |  | 
|---|
|  |  |  | ftp.connect(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String date = DateUtil.getNowShortDate(); | 
|---|
|  |  |  | String fName =  date+"/"+ UUID.randomUUID().toString()+".jpg"; | 
|---|
|  |  |  | String fName =  date+"/"+ UUID.randomUUID().toString()+".png"; | 
|---|
|  |  |  | String fileName = folder+fName; | 
|---|
|  |  |  | boolean r = ftp.uploadInputstream(is,fileName);//上传 | 
|---|
|  |  |  | if(r){ | 
|---|