diff --git a/pom.xml b/pom.xml index 62ae4bf..afb16de 100644 --- a/pom.xml +++ b/pom.xml @@ -54,6 +54,12 @@ fastjson 1.2.45 + + + org.projectlombok + lombok + true + diff --git a/src/main/java/com/example/sso/controller/BeiSenController.java b/src/main/java/com/example/sso/controller/BeiSenController.java deleted file mode 100644 index a6625ba..0000000 --- a/src/main/java/com/example/sso/controller/BeiSenController.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.example.sso.controller; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.example.sso.config.SSOConfig; -import com.example.sso.dao.J9051Dao; -import com.example.sso.dao.J9052Dao; -import com.example.sso.dao.J9053Dao; -import com.example.sso.dao.J905Dao; -import com.example.sso.service.JDYAuthService; -import com.example.sso.service.SSOService; -import com.example.sso.util.BeiSenTest; -import com.example.sso.util.J905Util; -import com.example.sso.util.JDYUtil; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; - -import javax.servlet.http.HttpServletRequest; -import java.security.KeyManagementException; -import java.security.NoSuchAlgorithmException; -import java.util.Date; -import java.util.HashMap; -@RestController -@NoArgsConstructor -@AllArgsConstructor -class BeiSenController { - @Getter @Setter @Autowired private SSOConfig ssoConfig; - private JSONObject limitIpInfo_dep1 = new JSONObject(); - private JSONObject limitIpInfo_dep2 = new JSONObject(); - private JSONObject limitIpInfo_dep3 = new JSONObject(); - private JSONObject limitIpInfo_dep4 = new JSONObject(); - private JSONObject limitIpInfo_dep5 = new JSONObject(); - private JSONObject limitIpInfo_dep6 = new JSONObject(); - @Getter @Setter @Autowired private SSOService ssoService; - @Getter @Setter @Autowired private JDYAuthService jdyAuthService; - Logger logger = LoggerFactory.getLogger(getClass()); - - /** - * 创建人员信息 - a */ - @GetMapping("/createPerson") - public void yxMes() throws KeyManagementException, NoSuchAlgorithmException { - try { - JSONArray drivers=JDYUtil.getAllDrivers();//查询 - for (Object o:drivers){ - JSONObject driver=(JSONObject)o; - JSONObject orgNos=JDYUtil.getOrgNos(); - BeiSenTest.createUser(driver,orgNos,""); - } - }catch (Exception e) { - e.printStackTrace(); - } - } - - /** - * 接收简道云新增的人员数据 - */ - @PostMapping("/createPerson_jdy") - public void yxMes3(@RequestBody JSONObject driver){ - try { - logger.info(driver.toJSONString()); - if (driver.getJSONObject("data").getString("status").equals("已择车") || - driver.getJSONObject("data").getString("status").equals("运营")){ - //if (driver.getJSONObject("data").getString("status").equals("运营")){ - //这个情况说明上车,创建账户 - JSONObject orgNos=JDYUtil.getOrgNos(); - JSONObject data=driver.getJSONObject("data"); - BeiSenTest.createUser(data,orgNos,driver.getJSONObject("data").getString("_id")); - }else if (driver.getJSONObject("data").getString("status").equals("已下车")){ - //}else if (driver.getJSONObject("data").getString("status").equals("已下车")|| - //driver.getJSONObject("data").getString("status").equals("休医疗期")){ - BeiSenTest.deleteUser(driver.getJSONObject("data").getInteger("beisen_id")); - } - }catch (Exception e) { - e.printStackTrace(); - } - } - - - /** - * 更新人员数据信息,修护职务、身份证号码信息 - */ - @GetMapping("/updatePersonData") - public void yxMes2(){ - //修改职工基础信息数据 - try { - JSONArray beiSens = JDYUtil.getAllDriversBeiSen();//查询 - JSONArray drivers = JDYUtil.getAllDrivers();//查询 - JSONObject orgNos=JDYUtil.getOrgNos(); - JSONObject jsonObject = new JSONObject(); - for (Object o : drivers) { - HashMap driver = (HashMap) o; - jsonObject.put((String) driver.get("shjh") + "@yinjian.com", driver); - } - for (Object o : beiSens) { - JSONObject driver = (JSONObject) o; - if (jsonObject.getJSONObject(driver.getString("zhanghao"))!=null){ -// BeiSenTest.updateUser(driver,driver.getString("oid"),orgNos); -// System.out.println(jsonObject.getJSONObject(driver.getString("zhanghao"))); - } - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - -} diff --git a/src/main/java/com/example/sso/controller/GongZiController.java b/src/main/java/com/example/sso/controller/GongZiController.java deleted file mode 100644 index 3ea5b69..0000000 --- a/src/main/java/com/example/sso/controller/GongZiController.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.example.sso.controller; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.example.sso.dao.GongZiFaFang; -import com.example.sso.dao.UpDataYes; -import com.example.sso.util.GongZiUtil; -import com.example.sso.util.V5utils; -import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@Slf4j -public class GongZiController { - @PostMapping("/gongzi") - public String gongzi(@RequestBody JSONObject driver){ - log.info(driver.toJSONString()); - log.info("------------------------------------------------------------"); - - JSONObject jsonObject = new JSONObject(); - jsonObject.put("app_id", "667cc6dbaa923599ad735201"); - jsonObject.put("entry_id", "62f4913c82654a00085de9e4"); - jsonObject.put("limit",10000); - JSONArray fields = new JSONArray(); - fields.add("yuefen"); - fields.add("status_jiaoyan"); - fields.add("sijishenfenzhenghao"); - fields.add("jine"); - fields.add("yinhangkahao"); - fields.add("status_yinhang"); - - JSONObject filter = new JSONObject(); - filter.put("rel","and"); - JSONArray jsonArray = new JSONArray(); - JSONObject jsonObject1 = new JSONObject(); - jsonObject1.put("field","status_jiaoyan"); - jsonObject1.put("method","empty"); - jsonArray.add(jsonObject1); - filter.put("cond",jsonArray); - jsonObject.put("fields",fields); - jsonObject.put("filter",filter); - String jsonString = jsonObject.toJSONString(); - String list = V5utils.list(jsonString); - JSONObject jsonObject2 = JSON.parseObject(list); - JSONArray jsonArray1 = jsonObject2.getJSONArray("data"); - String yuefen = GongZiUtil.yuefen(); - for (Object o : jsonArray1){ - JSONObject test = (JSONObject) o; - String yuefen1 = test.getString("yuefen"); - String sijishenfenzhenghao = test.getString("sijishenfenzhenghao"); - Integer jine = test.getInteger("jine"); - String yinhangkahao = test.getString("yinhangkahao"); - String status_yinhang = test.getString("status_yinhang"); - String id = test.getString("_id"); - - if (yuefen.equals(yuefen1)){ - String fafang = GongZiFaFang.fafang(yuefen1, sijishenfenzhenghao, jine, yinhangkahao, status_yinhang); - log.info(fafang); - UpDataYes.updata(id); - - } - } - - return "Success"; - } - - - - - - - - -} diff --git a/src/main/java/com/example/sso/controller/SSOController.java b/src/main/java/com/example/sso/controller/SSOController.java deleted file mode 100644 index 257e4c3..0000000 --- a/src/main/java/com/example/sso/controller/SSOController.java +++ /dev/null @@ -1,365 +0,0 @@ -package com.example.sso.controller; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.example.sso.config.SSOConfig; -import com.example.sso.dao.J9051Dao; -import com.example.sso.dao.J9052Dao; -import com.example.sso.dao.J9053Dao; -import com.example.sso.dao.J905Dao; -import com.example.sso.service.*; -import com.example.sso.util.J905Util; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; -import javax.servlet.http.HttpServletRequest; -import java.security.KeyManagementException; -import java.security.NoSuchAlgorithmException; -import java.util.Date; -@RestController -@NoArgsConstructor -@AllArgsConstructor -class SSOController { - @Getter @Setter @Autowired private SSOConfig ssoConfig; - private JSONObject limitIpInfo_dep1 = new JSONObject(); - private JSONObject limitIpInfo_dep2 = new JSONObject(); - private JSONObject limitIpInfo_dep3 = new JSONObject(); - private JSONObject limitIpInfo_dep4 = new JSONObject(); - private JSONObject limitIpInfo_dep5 = new JSONObject(); - private JSONObject limitIpInfo_dep6 = new JSONObject(); - @Getter @Setter @Autowired private SSOService ssoService; - @Getter @Setter @Autowired private JDYAuthService jdyAuthService; - Logger logger = LoggerFactory.getLogger(getClass()); - /** - * 查询SIM卡号,车牌号和终端号的对应关系 - * @param jsonMes - * @param httpServletRequest - * @return - * @throws KeyManagementException - * @throws NoSuchAlgorithmException - */ - @PostMapping("/mdnVcn/getPageList") - public JSONObject yxMes(@RequestBody JSONObject jsonMes,HttpServletRequest httpServletRequest) throws KeyManagementException, NoSuchAlgorithmException { - try { - String ip = httpServletRequest.getRemoteAddr(); - if (limitIpInfo_dep1.getJSONObject(ip) == null) { - limitIpInfo_dep1.put(ip, initializationIP()); - try { - String key=jsonMes.getString("key"); - if (key.equals("5fff9123eadbae0007b9ce3e")){ - JSONArray jsonArray=J905Dao.getAllSims(); - return J905Util.returnOK(jsonArray); - }else{ - return J905Util.returnLoser(400,"秘钥错误");//秘钥错误 - } - } catch (Exception e) { - e.printStackTrace(); - } - } else { - JSONObject limitInfo = limitIpInfo_dep1.getJSONObject(ip); - Long time = (new Date().getTime() - limitInfo.getLong("time")) / 1000;//秒 - //logger.info(ip+":还需等待"+time); - if (time>=60) { - limitIpInfo_dep1.put(ip, initializationIP()); - try { - String key=jsonMes.getString("key"); - if (key.equals("5fff9123eadbae0007b9ce3e")){ - JSONArray jsonArray=J905Dao.getAllSims(); - return J905Util.returnOK(jsonArray); - }else{ - return J905Util.returnLoser(400,"秘钥错误");//秘钥错误 - } - } catch (Exception e) { - e.printStackTrace(); - } - } - } - return J905Util.returnLoser(402,"接口频率超出限制,1分钟内允许调取一次,请稍后再试");//秘钥错误 - }catch (Exception e){ - e.printStackTrace(); - return J905Util.returnLoser(401,"系统查询异常,请联系开发人员"); - } - } - /** - * 查询车队 - * @param jsonMes - * @param httpServletRequest - * @return - * @throws KeyManagementException - * @throws NoSuchAlgorithmException - */ - @PostMapping("/vDwnoFzr/getPageList") - public JSONObject vDwnoFzr(@RequestBody JSONObject jsonMes,HttpServletRequest httpServletRequest) throws KeyManagementException, NoSuchAlgorithmException { - try { - String ip = httpServletRequest.getRemoteAddr(); - if (limitIpInfo_dep2.getJSONObject(ip) == null) { - limitIpInfo_dep2.put(ip, initializationIP()); - try { - String key=jsonMes.getString("key"); - if (key.equals("5fff9123eadbae0007b9ce3e")){ - JSONArray jsonArray=J905Dao.getAllSims(); - return J905Util.returnOK(jsonArray); - }else{ - return J905Util.returnLoser(400,"秘钥错误");//秘钥错误 - } - } catch (Exception e) { - e.printStackTrace(); - } - } else { - JSONObject limitInfo = limitIpInfo_dep2.getJSONObject(ip); - Long time = (new Date().getTime() - limitInfo.getLong("time")) / 1000;//秒 - //logger.info(ip+":还需等待"+time); - if (time>=60) { - limitIpInfo_dep2.put(ip, initializationIP()); - try { - String key=jsonMes.getString("key"); - if (key.equals("5fff9123eadbae0007b9ce3e")){ - JSONArray jsonArray=J905Dao.getAllSims(); - return J905Util.returnOK(jsonArray); - }else{ - return J905Util.returnLoser(400,"秘钥错误");//秘钥错误 - } - } catch (Exception e) { - e.printStackTrace(); - } - } - } - return J905Util.returnLoser(402,"接口频率超出限制,1分钟内允许调取一次,请稍后再试");//秘钥错误 - }catch (Exception e){ - e.printStackTrace(); - return J905Util.returnLoser(401,"系统查询异常,请联系开发人员"); - } - } - - - - - /** - * 查询车辆 - * @param jsonMes - * @param httpServletRequest - * @return - * @throws KeyManagementException - * @throws NoSuchAlgorithmException - */ - @PostMapping("/VGpsCheliang/getPageList") - public JSONObject VGpsCheliang(@RequestBody JSONObject jsonMes,HttpServletRequest httpServletRequest) throws KeyManagementException, NoSuchAlgorithmException { - try { - String ip = httpServletRequest.getRemoteAddr(); - if (limitIpInfo_dep3.getJSONObject(ip) == null) { - limitIpInfo_dep3.put(ip, initializationIP()); - try { - String key=jsonMes.getString("key"); - if (key.equals("5fff9123eadbae0007b9ce3e")){ - JSONArray jsonArray=J905Dao.getVGpsCheliangs(); - return J905Util.returnOK(jsonArray); - }else{ - return J905Util.returnLoser(400,"秘钥错误");//秘钥错误 - } - } catch (Exception e) { - e.printStackTrace(); - } - } else { - JSONObject limitInfo = limitIpInfo_dep3.getJSONObject(ip); - Long time = (new Date().getTime() - limitInfo.getLong("time")) / 1000;//秒 - //logger.info(ip+":还需等待"+time); - if (time>=60) { - limitIpInfo_dep3.put(ip, initializationIP()); - try { - String key=jsonMes.getString("key"); - if (key.equals("5fff9123eadbae0007b9ce3e")){ - JSONArray jsonArray=J905Dao.getVGpsCheliangs(); - return J905Util.returnOK(jsonArray); - }else{ - return J905Util.returnLoser(400,"秘钥错误");//秘钥错误 - } - } catch (Exception e) { - e.printStackTrace(); - } - } - } - return J905Util.returnLoser(402,"接口频率超出限制,1分钟内允许调取一次,请稍后再试");//秘钥错误 - }catch (Exception e){ - e.printStackTrace(); - return J905Util.returnLoser(401,"系统查询异常,请联系开发人员"); - } - } - - - - - /** - * 查询驾驶员 - * @param jsonMes - * @param httpServletRequest - * @return - * @throws KeyManagementException - * @throws NoSuchAlgorithmException - */ - @PostMapping("/vGpsJiashiyuan/getPageList") - public JSONObject vGpsJiashiyuan(@RequestBody JSONObject jsonMes,HttpServletRequest httpServletRequest) throws KeyManagementException, NoSuchAlgorithmException { - try { - String ip = httpServletRequest.getRemoteAddr(); - if (limitIpInfo_dep4.getJSONObject(ip) == null) { - limitIpInfo_dep4.put(ip, initializationIP()); - try { - String key=jsonMes.getString("key"); - if (key.equals("5fff9123eadbae0007b9ce3e")){ - JSONArray jsonArray= J9051Dao.getAllJiashiyuans(); - return J905Util.returnOK(jsonArray); - }else{ - return J905Util.returnLoser(400,"秘钥错误");//秘钥错误 - } - } catch (Exception e) { - e.printStackTrace(); - } - } else { - JSONObject limitInfo = limitIpInfo_dep4.getJSONObject(ip); - Long time = (new Date().getTime() - limitInfo.getLong("time")) / 1000;//秒 - //logger.info(ip+":还需等待"+time); - if (time>=60) { - limitIpInfo_dep4.put(ip, initializationIP()); - try { - String key=jsonMes.getString("key"); - if (key.equals("5fff9123eadbae0007b9ce3e")){ - JSONArray jsonArray=J9051Dao.getAllJiashiyuans(); - return J905Util.returnOK(jsonArray); - }else{ - return J905Util.returnLoser(400,"秘钥错误");//秘钥错误 - } - } catch (Exception e) { - e.printStackTrace(); - } - } - } - return J905Util.returnLoser(402,"接口频率超出限制,1分钟内允许调取一次,请稍后再试");//秘钥错误 - }catch (Exception e){ - e.printStackTrace(); - return J905Util.returnLoser(401,"系统查询异常,请联系开发人员"); - } - } - - - /** - * 查询驾驶员和车辆关系 - * @param jsonMes - * @param httpServletRequest - * @return - * @throws KeyManagementException - * @throws NoSuchAlgorithmException - */ - @PostMapping("/vGpsHetong/getPageList") - public JSONObject vGpsHetong(@RequestBody JSONObject jsonMes,HttpServletRequest httpServletRequest) throws KeyManagementException, NoSuchAlgorithmException { - try { - String ip = httpServletRequest.getRemoteAddr(); - if (limitIpInfo_dep5.getJSONObject(ip) == null) { - limitIpInfo_dep5.put(ip, initializationIP()); - try { - String key=jsonMes.getString("key"); - if (key.equals("5fff9123eadbae0007b9ce3e")){ - JSONArray jsonArray= J9052Dao.getAllvGpsHetongs(); - for (Object o:jsonArray){ - JSONObject jsonObject=(JSONObject)o; - String hphm=jsonObject.getString("hphm"); - if (hphm.contains("")){ - System.out.println(""); - } - } - return J905Util.returnOK(jsonArray); - }else{ - return J905Util.returnLoser(400,"秘钥错误");//秘钥错误 - } - } catch (Exception e) { - e.printStackTrace(); - } - } else { - JSONObject limitInfo = limitIpInfo_dep5.getJSONObject(ip); - Long time = (new Date().getTime() - limitInfo.getLong("time")) / 1000;//秒 - //logger.info(ip+":还需等待"+time); - if (time>=60) { - limitIpInfo_dep5.put(ip, initializationIP()); - try { - String key=jsonMes.getString("key"); - if (key.equals("5fff9123eadbae0007b9ce3e")){ - JSONArray jsonArray=J9052Dao.getAllvGpsHetongs(); - return J905Util.returnOK(jsonArray); - }else{ - return J905Util.returnLoser(400,"秘钥错误");//秘钥错误 - } - } catch (Exception e) { - e.printStackTrace(); - } - } - } - return J905Util.returnLoser(402,"接口频率超出限制,1分钟内允许调取一次,请稍后再试");//秘钥错误 - }catch (Exception e){ - e.printStackTrace(); - return J905Util.returnLoser(401,"系统查询异常,请联系开发人员"); - } - } - - - - /** - * 查询历史人车对应关系 - * @param jsonMes - * @param httpServletRequest - * @return - * @throws KeyManagementException - * @throws NoSuchAlgorithmException - */ - @PostMapping("/vGpsLiShiHeTong/getPageList") - public JSONObject vGpsLiShiHeTong(@RequestBody JSONObject jsonMes,HttpServletRequest httpServletRequest) throws KeyManagementException, NoSuchAlgorithmException { - try { - String ip = httpServletRequest.getRemoteAddr(); - if (limitIpInfo_dep6.getJSONObject(ip) == null) { - limitIpInfo_dep6.put(ip, initializationIP()); - try { - String key=jsonMes.getString("key"); - if (key.equals("5fff9123eadbae0007b9ce3e")){ - JSONArray jsonArray= J9053Dao.getAllvGpsLiShiHeTong(); - return J905Util.returnOK(jsonArray); - }else{ - return J905Util.returnLoser(400,"秘钥错误");//秘钥错误 - } - } catch (Exception e) { - e.printStackTrace(); - } - } else { - JSONObject limitInfo = limitIpInfo_dep6.getJSONObject(ip); - Long time = (new Date().getTime() - limitInfo.getLong("time")) / 1000;//秒 - //logger.info(ip+":还需等待"+time); - if (time>=180) { - limitIpInfo_dep6.put(ip, initializationIP()); - try { - String key=jsonMes.getString("key"); - if (key.equals("5fff9123eadbae0007b9ce3e")){ - JSONArray jsonArray=J9053Dao.getAllvGpsLiShiHeTong(); - return J905Util.returnOK(jsonArray); - }else{ - return J905Util.returnLoser(400,"秘钥错误");//秘钥错误 - } - } catch (Exception e) { - e.printStackTrace(); - } - } - } - return J905Util.returnLoser(402,"接口频率超出限制,3分钟内允许调取一次,请稍后再试");//秘钥错误 - }catch (Exception e){ - e.printStackTrace(); - return J905Util.returnLoser(401,"系统查询异常,请联系开发人员"); - } - } - - - private JSONObject initializationIP() { - JSONObject info = new JSONObject(); - info.put("time", new Date().getTime()); - info.put("num", 1); - return info; - } -} diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..c57a06f --- /dev/null +++ b/src/main/resources/logback-spring.xml @@ -0,0 +1,39 @@ + + + + + + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + ${LOG_PATH}/${LOG_FILE}.log + + + + + ${LOG_PATH}/${LOG_FILE}.%d{yyyy-MM-dd}.log + + ${MAX_HISTORY} + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + true + + + + + + + \ No newline at end of file