| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.api.business; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.fastjson.TypeReference; |
| | | import com.doumee.api.BaseController; |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.config.annotation.LoginNoRequired; |
| | | import com.doumee.core.annotation.pr.PreventRepeat; |
| | | import com.doumee.core.annotation.trace.Trace; |
| | | 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.FacePictureCheckRequest; |
| | | import com.doumee.core.haikang.model.param.respose.FacePictureCheckResponse; |
| | | import com.doumee.core.haikang.service.HKService; |
| | | import com.doumee.core.jiandaoyun.model.request.BasePushRequest; |
| | | import com.doumee.core.jiandaoyun.model.request.MemberPushData; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.core.utils.FtpUtil; |
| | | import com.doumee.core.utils.HttpsUtil; |
| | | import com.doumee.core.utils.aliyun.ALiYunUtil; |
| | | import com.doumee.core.wms.model.response.WmsBaseDataResponse; |
| | | import com.doumee.core.wms.model.response.WmsBaseResponse; |
| | | import com.doumee.dao.business.model.CarUseBook; |
| | | import com.doumee.dao.business.model.Cars; |
| | | import com.doumee.dao.business.model.JkCabinetLog; |
| | | import com.doumee.dao.web.reqeust.VisitRecordDTO; |
| | | import com.doumee.dao.web.response.VisitRecordVO; |
| | | import com.doumee.service.business.CarUseBookService; |
| | | import com.doumee.service.business.CarsService; |
| | | import com.doumee.service.business.MemberService; |
| | | import com.doumee.service.business.third.model.ApiResponse; |
| | | import com.doumee.service.business.third.model.PageData; |
| | | import com.doumee.service.business.third.model.PageWrap; |
| | | import com.sun.net.httpserver.HttpExchange; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.codec.digest.DigestUtils; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import org.springframework.web.multipart.MultipartHttpServletRequest; |
| | | import org.springframework.web.multipart.commons.CommonsMultipartResolver; |
| | | |
| | | import javax.imageio.ImageIO; |
| | | import javax.imageio.stream.ImageOutputStream; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.awt.*; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.*; |
| | | import java.net.URI; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @author Eva.Caesar Liu |
| | | * @date 2023/02/14 11:14 |
| | | */ |
| | | |
| | | @Api(tags = "ãç®éäºãä¸å¡æ¥å£") |
| | | @RestController |
| | | @RequestMapping(Constants.CLOUD_SERVICE_URL_INDEX+"/web/jiandaoyun") |
| | | @Slf4j |
| | | public class JiandaoyunCloudController extends BaseController { |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | |
| | | @Autowired |
| | | private MemberService memberService; |
| | | |
| | | public static final String SECRET ="yKSKuO0LoFf06jWGrwwuGudK"; |
| | | |
| | | @LoginNoRequired |
| | | @ApiOperation("ç®éäºæ¨éç¨æ·ä¿¡æ¯") |
| | | @PostMapping("/pushMemberData") |
| | | @PreventRepeat |
| | | public ApiResponse pushMemberData (HttpServletRequest request, HttpServletResponse response) { |
| | | BasePushRequest<MemberPushData> o = checkParamterValid(request,response,new TypeReference<BasePushRequest<MemberPushData>>(){}); |
| | | if(o == null || o.getData() ==null){ |
| | | return ApiResponse.failed(401,"error"); |
| | | } |
| | | int status =0; |
| | | String info ="忥æå"; |
| | | try { |
| | | memberService.dealJdyMemberInfo(o.getData());//å¤çç®éäºä¿¡æ¯ |
| | | }catch (BusinessException e){ |
| | | status =1; |
| | | info =e.getMessage(); |
| | | return ApiResponse.failed(e.getCode(),e.getMessage()); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | status =1; |
| | | info="忥åéå¼å¸¸"; |
| | | return ApiResponse.failed(ResponseStatus.SERVER_ERROR.getCode(),e.getMessage()); |
| | | }finally { |
| | | memberService.sendMemberInfoResult(o.getData().getUsername(),info,status); |
| | | } |
| | | |
| | | return ApiResponse.success("success"); |
| | | } |
| | | |
| | | private <T> BasePushRequest<T> checkParamterValid(HttpServletRequest request, HttpServletResponse response,TypeReference<BasePushRequest<T>> typeReference) { |
| | | |
| | | log.error("ãç®éäºã ç¨è½¦ç³è¯· =========getRequestURIï¼{}",request.getRequestURI()); |
| | | try { |
| | | String jdy = request.getHeader("x-jdy-signature"); |
| | | StringBuilder json = new StringBuilder(); |
| | | String line; |
| | | BufferedReader reader = new BufferedReader(new InputStreamReader(request.getInputStream())); |
| | | while ((line = reader.readLine()) != null) { |
| | | json.append(line); |
| | | } |
| | | String payload = json.toString(); |
| | | Map<String, String> parameterMap = parseParameter(request.getQueryString()); |
| | | String nonce = parameterMap.get("nonce"); |
| | | String timestamp = parameterMap.get("timestamp"); |
| | | String signature = getSignature(nonce, payload, |
| | | systemDictDataBiz.queryByCode(Constants.JDY_CONFIG,Constants.JDY_SECRET).getCode(), timestamp); |
| | | log.error("ãç®éäºãæ°æ®æ¨é =========getRequestURIï¼{}\nï¼queryParamï¼{}\n,payload:{}\n,ç¾åï¼{}\n,æ£ç¡®ç¾å:{}\n",request.getRequestURI(),request.getQueryString(),payload,jdy,signature); |
| | | if (!signature.equals(jdy)) { |
| | | return null; |
| | | } |
| | | BasePushRequest<T> t = JSONObject.parseObject(payload, typeReference.getType()); |
| | | return t; |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | log.error("ãç®éäºã ç¨è½¦ç³è¯· =========å¼å¸¸ï¼{}",e.getMessage()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | @ApiOperation("ç®éäºæäº¤é¥ååè¿ä¿¡æ¯") |
| | | @PostMapping("/submitKeyRecord") |
| | | public ApiResponse<JkCabinetLog> submitKeyRecord (HttpServletRequest request, HttpServletResponse response) { |
| | | JkCabinetLog log = new JkCabinetLog(); |
| | | log.setKeyId(1); |
| | | log.setCreateDate(new Date()); |
| | | log.setMemberName("å¼ ä¸"); |
| | | return ApiResponse.success(log); |
| | | } |
| | | |
| | | private static String getSignature(String nonce, String payload, String secret, String timestamp) { |
| | | return DigestUtils.sha1Hex(nonce + ":" + payload + ":" + secret + ":" + timestamp); |
| | | } |
| | | |
| | | private static Map<String, String> parseParameter(String query) { |
| | | Map<String, String> paramMap = new HashMap<String, String>(); |
| | | String[] params = query.split("&"); |
| | | for (String param : params) { |
| | | String[] keyValue = param.split("="); |
| | | paramMap.put(keyValue[0], keyValue[1]); |
| | | } |
| | | return paramMap; |
| | | } |
| | | public static void main(String[] args) { |
| | | /* |
| | | */ |
| | | String url = "https://lcdp.ahyc.com.cn:30443/api/v1/automation/tenant/61b6fb6080e9de2aa1df94d7/hooks/6954aca3cdf86954d2657433fb470ca1aabd108246925eca"; |
| | | JSONObject object = new JSONObject(); |
| | | object.put("status",0); |
| | | object.put("username","20251104160000" ); |
| | | object.put("info", "è¿æ¯å¤æ³¨"); |
| | | String result = HttpsUtil.postJson(url,JSONObject.toJSONString(object)); |
| | | System.out.println(result); |
| | | } |
| | | } |