| | |
| | | * 每分钟拉取一次今日的访客预约数据 |
| | | * @throws Exception |
| | | */ |
| | | @Scheduled(fixedRate= 30*1000) |
| | | @Scheduled(fixedRate= 3*60*1000) |
| | | public void syncVistAppointData() throws Exception { |
| | | if(Constants.DEALING_FROM_HK_VISIT){ |
| | | return ; |
| | |
| | | @Service |
| | | public class ErpTool { |
| | | |
| | | @Autowired |
| | | private InterfaceLogService interfaceLogService; |
| | | @Autowired |
| | | private SqlSessionFactory sqlSessionFactory; |
| | | public static InterfaceLogService interfaceLogService; |
| | | public void saveInterfaceLog(Object param, String path,String result,Integer type) { |
| | | SqlSession sqlSession2 = sqlSessionFactory.openSession(true); |
| | | InterfaceLogMapper mapper2 = sqlSession2.getMapper(InterfaceLogMapper.class); |
| | | |
| | | InterfaceLog interfaceLog=new InterfaceLog(); |
| | | interfaceLog.setType(type); |
| | | interfaceLog.setCreateDate(new Date()); |
| | | interfaceLog.setIsdeleted(Constants.ZERO); |
| | | if(param!=null){ |
| | | interfaceLog.setRequest(JSONObject.toJSONString(param)); |
| | | if(interfaceLogService !=null) { |
| | | InterfaceLog interfaceLog = new InterfaceLog(); |
| | | interfaceLog.setType(type); |
| | | interfaceLog.setCreateDate(new Date()); |
| | | interfaceLog.setIsdeleted(Constants.ZERO); |
| | | if (param != null) { |
| | | interfaceLog.setRequest(JSONObject.toJSONString(param)); |
| | | } |
| | | interfaceLog.setPlat(Constants.ONE); |
| | | interfaceLog.setRepose(result); |
| | | interfaceLog.setName(path); |
| | | interfaceLog.setUrl(path); |
| | | interfaceLogService.create(interfaceLog); |
| | | } |
| | | interfaceLog.setPlat(Constants.ONE); |
| | | interfaceLog.setRepose(result); |
| | | interfaceLog.setName(path); |
| | | interfaceLog.setUrl(path); |
| | | mapper2.insert(interfaceLog); |
| | | sqlSession2.commit(); |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | throw e; |
| | | e.printStackTrace(); |
| | | }finally { |
| | | saveInterfaceLog(param,url,JSONArray.toJSONString(list),Constants.ZERO); |
| | | } |
| | |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | throw e; |
| | | e.printStackTrace(); |
| | | }finally { |
| | | saveInterfaceLog(param,url, JSONArray.toJSONString(list),Constants.ZERO); |
| | | } |
| | |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | throw e; |
| | | e.printStackTrace(); |
| | | }finally { |
| | | saveInterfaceLog(param,url,JSONObject.toJSONString(result),Constants.ZERO); |
| | | } |
| | |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | throw e; |
| | | e.printStackTrace(); |
| | | }finally { |
| | | saveInterfaceLog(param,url,JSONObject.toJSONString(result),Constants.ZERO); |
| | | } |
| | |
| | | } |
| | | public static InterfaceLogService interfaceLogService = null; |
| | | private static void saveInterfaceLog(String s, String result,Map<String, String> path) { |
| | | // InterfaceLogService bean = SpringContextUtil.getBean(InterfaceLogService.class); |
| | | if(interfaceLogService !=null){ |
| | | InterfaceLog hkMonitoryLogDO=new InterfaceLog(); |
| | | hkMonitoryLogDO.setType(0); |
| | | hkMonitoryLogDO.setCreateDate(new Date()); |
| | | hkMonitoryLogDO.setIsdeleted(0); |
| | | hkMonitoryLogDO.setRequest(s); |
| | | hkMonitoryLogDO.setRepose(result); |
| | | hkMonitoryLogDO.setName(path.get(HKConstants.https)); |
| | | hkMonitoryLogDO.setUrl(HKConstants.https + ArtemisConfig.host+path.get(HKConstants.https)); |
| | | interfaceLogService.create(hkMonitoryLogDO); |
| | | try { |
| | | if(interfaceLogService !=null){ |
| | | InterfaceLog hkMonitoryLogDO=new InterfaceLog(); |
| | | hkMonitoryLogDO.setType(0); |
| | | hkMonitoryLogDO.setCreateDate(new Date()); |
| | | hkMonitoryLogDO.setIsdeleted(0); |
| | | hkMonitoryLogDO.setRequest(s); |
| | | hkMonitoryLogDO.setRepose(result); |
| | | hkMonitoryLogDO.setName(path.get(HKConstants.https)); |
| | | hkMonitoryLogDO.setUrl(HKConstants.https + ArtemisConfig.host+path.get(HKConstants.https)); |
| | | interfaceLogService.create(hkMonitoryLogDO); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | |
| | | public static String addFace(String body) { |
| | | Map<String, String> path = getPath(HKConstants.InterfacePath.addFace); |
| | | String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, "application/json", null);// post请求application/json类型参数 |
| | | saveInterfaceLog(body,result,path); |
| | | saveInterfaceLog(null,result,path); |
| | | return result; |
| | | } |
| | | /** |
| | |
| | | public static String editFace(String body) { |
| | | Map<String, String> path = getPath(HKConstants.InterfacePath.editFace); |
| | | String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, "application/json", null);// post请求application/json类型参数 |
| | | saveInterfaceLog(body,result,path); |
| | | saveInterfaceLog(null,result,path); |
| | | return result; |
| | | } |
| | | /** |
| | |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | @Data |
| | | public class BaseResponse<T> { |
| | | public class BaseResponse<T> implements Serializable { |
| | | |
| | | private T data; |
| | | /** |
| | |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | @Data |
| | | public class FaceAddOrEditesponse { |
| | | public class FaceAddOrEditesponse implements Serializable { |
| | | |
| | | private String faceId;// string False 人脸Id |
| | | private String faceUrl;// string False 人脸图片Url |
| | |
| | | * @return |
| | | */ |
| | | public static BaseResponse<FaceAddOrEditesponse> addFace( FaceAddRequest param){ |
| | | log.info("【海康添加人脸信息】================开始===="+JSONObject.toJSONString(param)); |
| | | log.info("【海康添加人脸信息】================开始====" ); |
| | | try { |
| | | String res = HKTools.addFace(JSONObject.toJSONString(param)); |
| | | TypeReference typeReference = |
| | | new TypeReference< BaseResponse<FaceAddOrEditesponse>>(){}; |
| | | TypeReference typeReference = new TypeReference< BaseResponse<FaceAddOrEditesponse>>(){}; |
| | | BaseResponse<FaceAddOrEditesponse> result = JSONObject.parseObject(res, typeReference.getType()); |
| | | logResult(result,"海康添加人脸信息"); |
| | | logResult(res,"海康添加人脸信息"); |
| | | return result; |
| | | }catch (Exception e){ |
| | | log.error("【海康添加人脸信息】================失败====:\n"+ e.getMessage()); |
| | |
| | | * @return |
| | | */ |
| | | public static BaseResponse<FaceAddOrEditesponse> editFace( FaceEditRequest param){ |
| | | log.info("【海康编辑人脸信息】================开始===="+JSONObject.toJSONString(param)); |
| | | log.info("【海康编辑人脸信息】================开始====" ); |
| | | String res =null; |
| | | try { |
| | | String res = HKTools.editFace(JSONObject.toJSONString(param)); |
| | | res = HKTools.editFace(JSONObject.toJSONString(param)); |
| | | TypeReference typeReference = |
| | | new TypeReference< BaseResponse<FaceAddOrEditesponse>>(){}; |
| | | BaseResponse<FaceAddOrEditesponse> result = JSONObject.parseObject(res, typeReference.getType()); |
| | | logResult(result,"海康编辑人脸信息"); |
| | | logResult(res,"海康编辑人脸信息"); |
| | | return result; |
| | | }catch (Exception e){ |
| | | log.error("【海康编辑人脸信息】================失败====:\n"+ e.getMessage()); |
| | |
| | | log.error("【"+name+"】================失败====:\n"+ res); |
| | | } |
| | | } |
| | | private static void logResult(String res,String name) { |
| | | log.info("【"+name+"】================结果====\n"+res); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | package com.doumee.service.business.impl.hksync; |
| | | |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.core.erp.ErpTool; |
| | | import com.doumee.core.haikang.model.HKConstants; |
| | | import com.doumee.core.haikang.model.HKTools; |
| | | import com.doumee.core.utils.Constants; |
| | |
| | | ArtemisConfig.appSecret = systemDictDataBiz.queryByCode(Constants.HK_PARAM, Constants.HK_APPSECRET).getCode(); |
| | | HKConstants.https = systemDictDataBiz.queryByCode(Constants.HK_PARAM, Constants.HK_HTTPS).getCode(); |
| | | HKTools.interfaceLogService=interfaceLogService; |
| | | ErpTool.interfaceLogService=interfaceLogService; |
| | | return 0; |
| | | } |
| | | |
| | |
| | | //如果有人脸照片,处理人脸照片同步 |
| | | String faceid = dealMemberFace(c,path); |
| | | if(StringUtils.isBlank(faceid)){ |
| | | noticeErpFail(c,Constants.ZERO,"人脸信息更新失败,请检查人脸照片是否合法!"); |
| | | c.setHkStatus(Constants.TWO); |
| | | c.setFaceStatus(Constants.TWO); |
| | | c.setRemark("人脸信息更新失败,请检查人脸照片是否合法!!"+result.getMsg()); |
| | | noticeErpFail(c,Constants.ZERO,"人脸信息更新失败,请检查人脸照片是否合法!"); |
| | | }else{ |
| | | c.setFaceId(faceid); |
| | | c.setFaceStatus(Constants.ONE); |
| | |
| | | * @return |
| | | */ |
| | | public static String dealMemberFace(Member c,String path) { |
| | | if(StringUtils.isBlank(c.getFaceId())){ |
| | | BaseResponse<FaceAddOrEditesponse> response = HKService.addFace(getFaceAddModel(c,path)); |
| | | if(response !=null && StringUtils.equals(response.getCode(),HKConstants.RESPONSE_SUCCEE)&& response.getData()!=null ){ |
| | | return response.getData().getFaceId(); |
| | | } |
| | | }else{ |
| | | FaceEditRequest param =getFaceUpdateModel(c,path); |
| | | if(param !=null){ |
| | | BaseResponse response = HKService.editFace(param); |
| | | if(StringUtils.equals(response.getCode(),HKConstants.RESPONSE_SUCCEE) ){ |
| | | return c.getFaceId(); |
| | | try { |
| | | if(StringUtils.isBlank(c.getFaceId())){ |
| | | BaseResponse<FaceAddOrEditesponse> response = HKService.addFace(getFaceAddModel(c,path)); |
| | | if(response !=null && StringUtils.equals(response.getCode(),HKConstants.RESPONSE_SUCCEE)&& response.getData()!=null ){ |
| | | return response.getData().getFaceId(); |
| | | } |
| | | }else{ |
| | | FaceEditRequest param =getFaceUpdateModel(c,path); |
| | | if(param !=null){ |
| | | BaseResponse response = HKService.editFace(param); |
| | | if(response!=null && StringUtils.equals(response.getCode(),HKConstants.RESPONSE_SUCCEE) ){ |
| | | return c.getFaceId(); |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |