| | |
| | | |
| | | import com.doumee.api.BaseController; |
| | | import com.doumee.core.annotation.pr.PreventRepeat; |
| | | import com.doumee.core.erp.model.openapi.request.erp.OrgListRequest; |
| | | import com.doumee.core.erp.model.openapi.request.erp.UserFailRequest; |
| | | import com.doumee.core.erp.model.openapi.request.erp.UserListRequest; |
| | | import com.doumee.core.haikang.model.param.request.AcsDeviceListRequest; |
| | | import com.doumee.core.haikang.model.param.request.ParkListRequest; |
| | | import com.doumee.core.model.ApiResponse; |
| | | import com.doumee.service.business.ERPSyncService; |
| | | import com.doumee.service.business.impl.hksync.HkSyncDeviceServiceImpl; |
| | | import com.doumee.service.business.impl.hksync.HkSyncParkServiceImpl; |
| | | import com.doumee.service.business.impl.hksync.HkSyncPrivilegeServiceImpl; |
| | |
| | | @RestController |
| | | @RequestMapping("/business/erpsync") |
| | | public class ERPSyncController extends BaseController { |
| | | |
| | | @Autowired |
| | | private HkSyncDeviceServiceImpl hkSyncDeviceService; |
| | | @Autowired |
| | | private HkSyncParkServiceImpl hkSyncParkService; |
| | | @Autowired |
| | | private HkSyncPrivilegeServiceImpl hkSyncPrivilegeService; |
| | | private ERPSyncService erpSyncService; |
| | | |
| | | @PreventRepeat |
| | | @ApiOperation("【ERP】全量同步门禁设备接口") |
| | | @PostMapping("/syncDevices") |
| | | //@RequiresPermissions("business:erpsync:device") |
| | | public ApiResponse getDevices(@RequestBody AcsDeviceListRequest param) { |
| | | String result = hkSyncDeviceService.syncHkDevices(param); |
| | | @ApiOperation("【ERP】全量同步ERP组织接口") |
| | | @PostMapping("/getCompanies") |
| | | //@RequiresPermissions("business:erpsync:company") |
| | | public ApiResponse getCompanies(@RequestBody OrgListRequest param) { |
| | | String result = erpSyncService.syncCompany(param); |
| | | return ApiResponse.success(result); |
| | | } |
| | | @PreventRepeat |
| | | @ApiOperation("【海康】全量同步停车库接口") |
| | | @PostMapping("/getParks") |
| | | // @RequiresPermissions("business:hksync:park") |
| | | public ApiResponse getParks(@RequestBody ParkListRequest param) { |
| | | String result = hkSyncParkService.syncHkParks(param); |
| | | return ApiResponse.success(result); |
| | | } |
| | | @PreventRepeat |
| | | @ApiOperation("【海康】全量同步停车库接口") |
| | | @PostMapping("/getPrivilege") |
| | | // @RequiresPermissions("business:hksync:privilege") |
| | | public ApiResponse getPrivilege(@RequestBody ParkListRequest param) { |
| | | String result = hkSyncPrivilegeService.syncHkParks(param); |
| | | @ApiOperation("【ERP】全量同步ERP人员接口") |
| | | @PostMapping("/getUsers") |
| | | // @RequiresPermissions("business:erpsync:users") |
| | | public ApiResponse getUsers(@RequestBody UserListRequest param) { |
| | | String result = erpSyncService.syncUsers(param); |
| | | return ApiResponse.success(result); |
| | | } |
| | | } |
| | |
| | | |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.core.haikang.model.HKConstants; |
| | | import com.doumee.core.haikang.model.HKTools; |
| | | import com.doumee.core.haikang.model.param.BaseResponse; |
| | | import com.doumee.core.haikang.model.param.request.EventSubRequest; |
| | | import com.doumee.core.haikang.model.param.respose.OrgListResponse; |
| | | import com.doumee.core.haikang.service.HKService; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.dao.system.model.SystemDictData; |
| | | import com.doumee.service.business.InterfaceLogService; |
| | | import com.doumee.service.business.impl.hksync.HkSyncBaseServiceImpl; |
| | | import com.hikvision.artemis.sdk.config.ArtemisConfig; |
| | | import org.apache.commons.lang3.StringUtils; |
| | |
| | | |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | @Autowired |
| | | private InterfaceLogService interfaceLogService; |
| | | |
| | | @PostConstruct |
| | | public int initHkConfig(){ |
| | |
| | | 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; |
| | | //获取根组织编码 |
| | | getRootOrgCode(); |
| | | //开始订阅门禁事件、访客事件、和停车场事件 |
| | |
| | | import com.doumee.core.erp.model.openapi.response.erp.ERPApiResponse; |
| | | import com.doumee.core.erp.model.openapi.response.erp.ErpOrgListResponse; |
| | | import com.doumee.core.erp.model.openapi.response.erp.ErpUserListResponse; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.HttpsUtil; |
| | | import com.doumee.dao.business.model.Member; |
| | | import com.github.pagehelper.PageInfo; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | public class ErpTool { |
| | |
| | | * @return |
| | | */ |
| | | public static List<ErpOrgListResponse> getErpOrgList(String url, OrgListRequest param){ |
| | | String result = HttpsUtil.postJson(url, JSONObject.toJSONString(param)); |
| | | if(StringUtils.isNotBlank(result)){ |
| | | TypeReference typeReference = |
| | | new TypeReference<ERPApiResponse<List<ErpOrgListResponse>>>(){}; |
| | | ERPApiResponse<List<ErpOrgListResponse>> response = JSONObject.parseObject(result, typeReference.getType()); |
| | | if(response!=null){ |
| | | return response.getData(); |
| | | } |
| | | } |
| | | return null; |
| | | |
| | | List<ErpOrgListResponse> list = new ArrayList<>(); |
| | | int page =1; |
| | | int pageSize = 100; |
| | | boolean hasLast = true; |
| | | while (hasLast){ |
| | | hasLast = false; |
| | | PageWrap<OrgListRequest> pageWrap = new PageWrap<>(); |
| | | pageWrap.setModel(param); |
| | | pageWrap.setPage(page); |
| | | pageWrap.setCapacity(pageSize); |
| | | String result = HttpsUtil.postJson(url, JSONObject.toJSONString(pageWrap)); |
| | | if(StringUtils.isNotBlank(result)){ |
| | | TypeReference typeReference = |
| | | new TypeReference<ERPApiResponse<PageData<ErpOrgListResponse>>>(){}; |
| | | ERPApiResponse<PageData<ErpOrgListResponse>> response = JSONObject.parseObject(result, typeReference.getType()); |
| | | if(response!=null && response.getData()!=null&& response.getData().getRecords()!=null){ |
| | | list.addAll(response.getData().getRecords()); |
| | | if(100*pageSize < response.getData().getTotal() ){ |
| | | hasLast =true;//还有下一页 |
| | | } |
| | | page++; |
| | | } |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return |
| | | */ |
| | | public static List<ErpUserListResponse> getErpUserList(String url, UserListRequest param){ |
| | | String result = HttpsUtil.postJson(url, JSONObject.toJSONString(param)); |
| | | if(StringUtils.isNotBlank(result)){ |
| | | TypeReference typeReference = |
| | | new TypeReference<ERPApiResponse<List<ErpUserListResponse>>>(){}; |
| | | ERPApiResponse<List<ErpUserListResponse>> response = JSONObject.parseObject(result, typeReference.getType()); |
| | | if(response!=null){ |
| | | return response.getData(); |
| | | |
| | | List<ErpUserListResponse> list = new ArrayList<>(); |
| | | int page =1; |
| | | int pageSize = 100; |
| | | boolean hasLast = true; |
| | | while (hasLast){ |
| | | hasLast = false; |
| | | PageWrap<UserListRequest> pageWrap = new PageWrap<>(); |
| | | pageWrap.setModel(param); |
| | | pageWrap.setPage(page); |
| | | pageWrap.setCapacity(pageSize); |
| | | String result = HttpsUtil.postJson(url, JSONObject.toJSONString(pageWrap)); |
| | | if(StringUtils.isNotBlank(result)){ |
| | | TypeReference typeReference = |
| | | new TypeReference<ERPApiResponse<PageData<ErpUserListResponse>>>(){}; |
| | | ERPApiResponse<PageData <ErpUserListResponse>> response = JSONObject.parseObject(result, typeReference.getType()); |
| | | if(response!=null && response.getData()!=null && response.getData().getRecords()!=null){ |
| | | list.addAll(response.getData().getRecords()); |
| | | if(100*pageSize < response.getData().getTotal() ){ |
| | | hasLast =true;//还有下一页 |
| | | } |
| | | page++; |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | return list; |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | System.out.println(content.toString()); |
| | | |
| | | } |
| | | public static InterfaceLogService interfaceLogService = null; |
| | | private static void saveInterfaceLog(String s, String result,Map<String, String> path) { |
| | | InterfaceLogService bean = SpringContextUtil.getBean(InterfaceLogService.class); |
| | | if(bean !=null){ |
| | | // InterfaceLogService bean = SpringContextUtil.getBean(InterfaceLogService.class); |
| | | if(interfaceLogService !=null){ |
| | | InterfaceLog hkMonitoryLogDO=new InterfaceLog(); |
| | | hkMonitoryLogDO.setType(0); |
| | | hkMonitoryLogDO.setCreateDate(new Date()); |
| | |
| | | hkMonitoryLogDO.setRepose(result); |
| | | hkMonitoryLogDO.setName(path.get(HKConstants.https)); |
| | | hkMonitoryLogDO.setUrl(HKConstants.https + ArtemisConfig.host+path.get(HKConstants.https)); |
| | | bean.create(hkMonitoryLogDO); |
| | | interfaceLogService.create(hkMonitoryLogDO); |
| | | } |
| | | } |
| | | |
| | |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.InputStream; |
| | | import java.io.OutputStream; |
| | | import java.net.HttpURLConnection; |
| | | import java.net.URL; |
| | | import java.security.KeyManagementException; |
| | | import java.security.NoSuchAlgorithmException; |
| | |
| | | return connection(url, "POST", data, contentType, ignoreSSL); |
| | | } |
| | | public static String postJson(String url, String data) { |
| | | return connection(url, "POST", data, "application/json", false); |
| | | if(url.startsWith("https://")){ |
| | | return connection(url, "POST", data, "application/json", true); |
| | | }else{ |
| | | return connectionHttp(url, "POST", data, "application/json"); |
| | | } |
| | | } |
| | | |
| | | public static String connection(String url,String method,String data,String contentType,boolean ignoreSSL){ |
| | |
| | | } |
| | | return null; |
| | | } |
| | | public static String connectionHttp(String url,String method,String data,String contentType ){ |
| | | HttpURLConnection connection = null; |
| | | try { |
| | | URL _url = new URL(url); |
| | | connection = (HttpURLConnection) _url.openConnection(); |
| | | connection.setRequestMethod(method); |
| | | connection.setDoOutput(true); |
| | | connection.setDoInput(true); |
| | | connection.setUseCaches(false); |
| | | if(contentType != null){ |
| | | connection.setRequestProperty("Content-Type", contentType); |
| | | } |
| | | |
| | | connection.connect(); |
| | | |
| | | if(data != null){ |
| | | OutputStream outputStream = connection.getOutputStream(); |
| | | outputStream.write(data.getBytes("utf-8")); |
| | | outputStream.close(); |
| | | } |
| | | |
| | | int responseCode = connection.getResponseCode(); |
| | | if (responseCode == HttpsURLConnection.HTTP_OK) { |
| | | InputStream is = connection.getInputStream(); |
| | | byte[] b = new byte[4096]; |
| | | ByteArrayOutputStream baos = new ByteArrayOutputStream(b.length); |
| | | int len; |
| | | while ((len = is.read(b)) != -1) { |
| | | baos.write(b, 0, len); |
| | | } |
| | | is.close(); |
| | | return baos.toString("utf-8"); |
| | | } |
| | | return connection.getResponseMessage(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | if(connection != null){ |
| | | connection.disconnect(); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | public static void main(String[] args) { |
| | |
| | | @TableField(exist = false) |
| | | private String createrName; |
| | | |
| | | @ApiModelProperty(value = "下发状态 0待下发 1已下发 2下发成功 3已取消 4下发失败 ", example = "1") |
| | | @ExcelColumn(name="下发状态",index= 8,valueMapping ="0=待下发;1=已下发;2=下发成功;3=已取消;4=下发失败" ) |
| | | @ApiModelProperty(value = "一卡通授权下发状态 0待下发 1任务执行 2下发成功 3已取消 4下发失败 5任务下载已结束 ", example = "1") |
| | | @ExcelColumn(name="下发状态",index= 8,valueMapping ="0=待下发;1=已下发;2=下发成功;3=已取消;4=下发失败;5=任务下载已结束" ) |
| | | private Integer sendStatus; |
| | | |
| | | @ApiModelProperty(value = "下发类型 0实时 1定时 ", example = "1") |
| | |
| | | company.setName(respone.getName()); |
| | | company.setErpId(respone.getId()); |
| | | company.setCreateDate(date); |
| | | company.setType(Constants.ONE); |
| | | company.setCode(respone.getCode()); |
| | | company.setErpParentId(respone.getParentOrgId()); |
| | | company.setErpDate(date); |
| | |
| | | OrgDelRequest request = new OrgDelRequest(); |
| | | request.setIndexCodes( delHkIds.toArray(new String[]{})); |
| | | BaseResponse<List<OrgUpdateFailureResponse>> result = HKService.delBatchOrg(request); |
| | | if(StringUtils.equals(result.getCode(),HKConstants.RESPONSE_SUCCEE)){ |
| | | if(result !=null && StringUtils.equals(result.getCode(),HKConstants.RESPONSE_SUCCEE)){ |
| | | List<String> fIds = new ArrayList<>(); |
| | | if(result.getData()!=null){ |
| | | for(OrgUpdateFailureResponse r : result.getData()){ |
| | |
| | | List<ErpOrgListResponse> list = new ArrayList<>(); |
| | | String[] ids = new String[]{"","001","002","003"}; |
| | | String[] names = new String[]{"","组织1","组织2","组织3"}; |
| | | for(int i=1;i<=4;i++){ |
| | | for(int i=1;i<4;i++){ |
| | | ErpOrgListResponse r = new ErpOrgListResponse(); |
| | | r.setParentOrgId(ids[i-1]); |
| | | r.setId(ids[i]); |
| | | r.setCreateDate(new Date()); |
| | | r.setCode(UUID.randomUUID().toString()); |
| | | r.setCode(ids[i]); |
| | | r.setStatus(Constants.ZERO); |
| | | r.setName(names[i]); |
| | | list.add(r); |
| | | } |
| | | IPage<ErpOrgListResponse> pageInfo = new Page<>(1,10,3); |
| | | pageInfo.setTotal(3); |
| | | pageInfo.setRecords(list); |
| | | PageData<ErpOrgListResponse> r = PageData.from( pageInfo); |
| | | return ERPApiResponse.success(r); |
| | |
| | | String[] ids = new String[]{"","1001","1002","1003"}; |
| | | String[] names = new String[]{"","人员1","人员2","人员3"}; |
| | | String[] orgs = new String[]{"","001","002","003"}; |
| | | for(int i=1;i<=4;i++){ |
| | | for(int i=1;i<4;i++){ |
| | | ErpUserListResponse r = new ErpUserListResponse(); |
| | | r.setOrgId(orgs[i]); |
| | | r.setId(ids[i]); |
| | | r.setName(names[i-1]); |
| | | r.setCode( ids[i]); |
| | | r.setIsdeleted(Constants.ONE); |
| | | r.setName(names[i]); |
| | | r.setFaceImg("/20223402/"+r.getId()+".png"); |
| | | list.add(r); |
| | | } |
| | | IPage<ErpUserListResponse> pageInfo = new Page<>(1,10,3); |
| | | pageInfo.setRecords(list); |
| | | pageInfo.setTotal(3); |
| | | PageData<ErpUserListResponse> r = PageData.from( pageInfo); |
| | | return ERPApiResponse.success(r); |
| | | } |
| | |
| | | # application: |
| | | # name: doumeemes |
| | | profiles: |
| | | active: test |
| | | active: dev |
| | | |
| | | # JSON返回配置 |
| | | jackson: |