代码说明

This commit is contained in:
lijiazhuo
2026-01-19 14:39:01 +08:00
parent a96e7d64c5
commit edcec0eade
5 changed files with 45 additions and 559 deletions

View File

@ -54,6 +54,12 @@
<artifactId>fastjson</artifactId> <artifactId>fastjson</artifactId>
<version>1.2.45</version> <version>1.2.45</version>
</dependency> </dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -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<String, Object> driver = (HashMap<String, Object>) 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();
}
}
}

View File

@ -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";
}
}

View File

@ -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;
}
}

View File

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property name="LOG_PATH" value="./logs" />
<property name="LOG_FILE" value="app" />
<property name="MAX_HISTORY" value="30" />
<!-- 控制台输出 -->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<!-- 按天滚动的文件输出 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 当前日志文件 -->
<file>${LOG_PATH}/${LOG_FILE}.log</file>
<!-- 滚动策略 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 每天0点生成新文件 -->
<fileNamePattern>${LOG_PATH}/${LOG_FILE}.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 保留30天 -->
<maxHistory>${MAX_HISTORY}</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
<!-- 关键:立即刷新,确保启动时有日志就立即创建文件 -->
<immediateFlush>true</immediateFlush>
</appender>
<root level="INFO">
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</root>
</configuration>