rev:修改了日志获取IP和登录端

This commit is contained in:
2023-08-21 15:24:18 +08:00
parent 4a0e519617
commit 1240aae17b
12 changed files with 84 additions and 12 deletions

View File

@@ -146,11 +146,6 @@ public class StringUtils {
* 获取ip地址
*/
public static String getIp(HttpServletRequest request) {
// TODO 不解析IP地址
if(true){
return "127.0.0.1";
}
String ip = request.getHeader("x-forwarded-for");
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");

View File

@@ -15,6 +15,7 @@
*/
package org.nl.modules.logging.aspect;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
@@ -90,7 +91,8 @@ public class LogAspect {
//是否把日志存到日志表
if (logInfo.isAddLogTable()) {
Log log = new Log("INFO", System.currentTimeMillis() - comming);
logService.save(getUsername(), StringUtils.getBrowser(request), requestIp, joinPoint, log);
String loginDevice = StpUtil.getLoginDevice();
logService.save(getUsername(), StringUtils.getBrowser(request)+"---"+loginDevice, requestIp, joinPoint, log);
}
if (logInfo.isInterfaceLog()) {
try {

View File

@@ -15,6 +15,7 @@
*/
package org.nl.modules.logging.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Dict;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
@@ -42,6 +43,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -103,6 +105,7 @@ public class LogServiceImpl implements LogService {
logDto.setUsername(username);
logDto.setParams(getParameter(method, joinPoint.getArgs()));
logDto.setBrowser(browser);
logDto.setCreateTime(Timestamp.valueOf(DateUtil.now()));
logRepository.save(logDto);
}

View File

@@ -100,6 +100,9 @@ public class DeviceStatusServiceImpl implements DeviceStatusService {
try {
if (!jo.containsKey("need_update_flag")){
JSONArray rows = jo.getJSONArray("upload_user");
if (ObjectUtil.isEmpty(rows)){
rows = new JSONArray();
}
HashMap<String,String> map = new HashMap<>();
String msg = "";
for (int i = 0; i < rows.size(); i++) {

View File

@@ -808,6 +808,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
@Override
public JSONObject sendDeviceStatus(JSONObject whereJson) {
log.info("sendDeviceStatus--------------输入为:"+whereJson.toString());
WQLObject wo = WQLObject.getWQLObject("em_bi_devicestatus");
String device_code = whereJson.getString("device_code");
String device_name = whereJson.getString("device_name");

View File

@@ -0,0 +1,32 @@
package org.nl.wms.ext.szls.rest;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.modules.logging.annotation.Log;
import org.nl.wms.ext.szls.service.LmsToBigScreenService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequiredArgsConstructor
@Api(tags = "lms发送数字孪生")
@RequestMapping("/api/szls")
@Slf4j
public class LmsToBigScreenController {
private final LmsToBigScreenService LmsToBigScreenService;
@PostMapping("/getDeviceInfo")
@Log("数字孪生请求LMS获取设备信息")
@ApiOperation("数字孪生请求LMS获取设备信息")
public ResponseEntity<Object> getDeviceInfo(@RequestBody JSONObject jo) {
return new ResponseEntity<>(LmsToBigScreenService.getDeviceInfo(jo), HttpStatus.OK);
}
}

View File

@@ -0,0 +1,8 @@
package org.nl.wms.ext.szls.service;
import com.alibaba.fastjson.JSONObject;
public interface LmsToBigScreenService {
JSONObject getDeviceInfo(JSONObject jo);
}

View File

@@ -0,0 +1,27 @@
package org.nl.wms.ext.szls.service.impl;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.wql.util.SpringContextHolder;
import org.nl.system.service.param.impl.SysParamServiceImpl;
import org.nl.wms.ext.szls.service.LmsToBigScreenService;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
@Slf4j
public class LmsToBigScreenServiceImpl implements LmsToBigScreenService {
@Override
public JSONObject getDeviceInfo(JSONObject jo) {
return null;
}
}

View File

@@ -25,9 +25,9 @@ public class AutoQueryBillInfo {
String nofity_day = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("NOFITY_DAY").getValue();
JSONArray send_rows = new JSONArray();
if (Integer.parseInt(nofity_day) == 0) {
send_rows = wo.query("bill_type = '1001' AND bill_status = '99' AND stor_code = 'CP01' AND upload_sap = '0' AND is_delete = '0' AND (IFNULL(carno,'') = '' OR IFNULL(trans_code,'') = '' OR IFNULL(estimated_freight,'') = '' OR IFNULL(order_number,'') = '' OR IFNULL(car_type,'') = '')").getResultJSONArray(0);
send_rows = wo.query("bill_type = '1001' AND bill_status = '99' AND stor_code = 'AC01' AND upload_sap = '0' AND is_delete = '0' AND (IFNULL(carno,'') = '' OR IFNULL(trans_code,'') = '' OR IFNULL(estimated_freight,'') = '' OR IFNULL(order_number,'') = '' OR IFNULL(car_type,'') = '')").getResultJSONArray(0);
} else {
send_rows = wo.query("bill_type = '1001' AND bill_status = '99' AND stor_code = 'CP01' AND upload_sap = '0' AND is_delete = '0' AND (IFNULL(carno,'') = '' OR IFNULL(trans_code,'') = '' OR IFNULL(estimated_freight,'') = '' OR IFNULL(order_number,'') = '' OR IFNULL(car_type,'') = '') AND TIMESTAMPDIFF(DAY,confirm_time,NOW()) = " + nofity_day).getResultJSONArray(0);
send_rows = wo.query("bill_type = '1001' AND bill_status = '99' AND stor_code = 'AC01' AND upload_sap = '0' AND is_delete = '0' AND (IFNULL(carno,'') = '' OR IFNULL(trans_code,'') = '' OR IFNULL(estimated_freight,'') = '' OR IFNULL(order_number,'') = '' OR IFNULL(car_type,'') = '') AND TIMESTAMPDIFF(DAY,confirm_time,NOW()) = " + nofity_day).getResultJSONArray(0);
}
this.sendInfo(send_rows);
}

View File

@@ -22,7 +22,7 @@ public class AutoQueryUpload {
public void run() {
//查询已经处于分配中、分配完但还未回传给MES的销售出库单
WQLObject wo = WQLObject.getWQLObject("st_ivt_iostorinv");
JSONArray send_rows = wo.query("mst.bill_type = '1001' AND mst.bill_status IN ( '30', '40' ) AND mst.stor_code = 'CP01' AND upload_mes = '0' AND is_delete = '0'").getResultJSONArray(0);
JSONArray send_rows = wo.query("bill_type = '1001' AND bill_status IN ( '30', '40' ) AND stor_code = 'AC01' AND upload_mes = '0' AND is_delete = '0'").getResultJSONArray(0);
this.sendInfo(send_rows);
}
@@ -64,7 +64,7 @@ public class AutoQueryUpload {
String resultMsg = HttpRequest.post(url)
.body(String.valueOf(jo))
.execute().body();
log.info("飞书输入参数为:-------------------" + jo);
log.info(" " + jo);
log.info("飞书输出参数为:-------------------" + resultMsg);
HashMap<String, String> map = new HashMap<>();
map.put("is_upload", "1");

View File

@@ -85,7 +85,7 @@
find_in_set( task.task_status, 输入.task_status)
ENDOPTION
OPTION 输入.vehicle_code <> ""
(task.vehicle_code like 输入.vehicle_code)
(task.vehicle_code like 输入.vehicle_code OR task.material_code like 输入.vehicle_code OR task.vehicle_code2 like 输入.vehicle_code)
ENDOPTION
OPTION 输入.task_code <> ""
(task.task_code like 输入.task_code)

View File

@@ -83,6 +83,7 @@ spring:
singleServerConfig:
connectionMinimumIdleSize: 8
connectionPoolSize: 8
database: 14
address: redis://127.0.0.1:6379
idleConnectionTimeout: 10000
timeout: 3000
@@ -169,7 +170,7 @@ sa-token:
# token 临时有效期 (指定时间内无操作就视为token过期) 单位: 秒
activity-timeout: -1
# 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录)
is-concurrent: true
is-concurrent: false
# 在多人登录同一账号时是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token)
is-share: false
# token风格