add: 添加操作日志,添加PDF加载系统
This commit is contained in:
@@ -28,4 +28,28 @@ import java.lang.annotation.Target;
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Log {
|
||||
String value() default "";
|
||||
|
||||
|
||||
/**
|
||||
* 是否打印到日志文件
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isPrintToLogFile() default false;
|
||||
|
||||
|
||||
/**
|
||||
* 是否插入操作日志表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isAddLogTable() default true;
|
||||
|
||||
/**
|
||||
* 是否接口日志
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isInterfaceLog() default false;
|
||||
|
||||
}
|
||||
|
||||
@@ -12,12 +12,14 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*//*
|
||||
*/
|
||||
|
||||
package org.nl.common.logging.aspect;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
@@ -31,6 +33,10 @@ import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.common.utils.StringUtils;
|
||||
import org.nl.common.utils.ThrowableUtil;
|
||||
import org.nl.common.logging.domain.Log;
|
||||
import org.nl.config.IdUtil;
|
||||
import org.nl.system.service.logging.ISysLogService;
|
||||
import org.nl.system.service.logging.dao.SysLog;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@@ -41,79 +47,67 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Parameter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
*/
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-11-24
|
||||
*//*
|
||||
|
||||
@Component
|
||||
@Aspect
|
||||
@Slf4j
|
||||
public class LogAspect {
|
||||
public class LogOperate {
|
||||
|
||||
private final LogService logService;
|
||||
@Autowired
|
||||
private ISysLogService logService;
|
||||
|
||||
ThreadLocal<Long> currentTime = new ThreadLocal<>();
|
||||
|
||||
public LogAspect(LogService logService) {
|
||||
public LogOperate(ISysLogService logService) {
|
||||
this.logService = logService;
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
* 配置切入点
|
||||
*//*
|
||||
|
||||
|
||||
@Pointcut("@annotation(org.nl.common.logging.annotation.Log)")
|
||||
public void logPointcut() {
|
||||
// 该方法无方法体,主要为了让同类中其他方法使用此切入点
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
* 配置环绕通知,使用在方法logPointcut()上注册的切入点
|
||||
*
|
||||
* @param joinPoint join point for advice
|
||||
*//*
|
||||
|
||||
@Around("logPointcut()")
|
||||
public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
HttpServletRequest request = attributes.getRequest();
|
||||
HttpServletResponse response = attributes.getResponse();
|
||||
// HttpServletRequest request = RequestHolder.getHttpServletRequest();
|
||||
|
||||
|
||||
String trackId = UUID.randomUUID().toString();
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
Method method = signature.getMethod();
|
||||
// 方法路径
|
||||
String methodName = joinPoint.getTarget().getClass().getName() + "." + signature.getName() + "()";
|
||||
String params=getParameter(method, joinPoint.getArgs());
|
||||
String params = getParameter(method, joinPoint.getArgs());
|
||||
|
||||
log.info("请求uri:{}", request.getRequestURI());
|
||||
log.info("请求方法:{}",methodName);
|
||||
log.info("请求方法参数:{}",params);
|
||||
org.nl.common.logging.annotation.Log logInfo = method.getAnnotation(org.nl.common.logging.annotation.Log.class);
|
||||
|
||||
//是否输出到日志文件
|
||||
if (logInfo.isPrintToLogFile()) {
|
||||
log.info("track_id:{},请求方法:{},请求方法参数:{}", trackId, methodName, params);
|
||||
}
|
||||
HttpServletRequest request = RequestHolder.getHttpServletRequest();
|
||||
String requestIp = StringUtils.getIp(request);
|
||||
Object result;
|
||||
currentTime.set(System.currentTimeMillis());
|
||||
result = joinPoint.proceed();
|
||||
Log log = new Log("INFO",System.currentTimeMillis() - currentTime.get());
|
||||
currentTime.remove();
|
||||
|
||||
logService.save(getUsername(), StringUtils.getBrowser(request), StringUtils.getIp(request),joinPoint, log);
|
||||
long startTime = System.currentTimeMillis();
|
||||
try {
|
||||
result = joinPoint.proceed();
|
||||
//是否把日志存到日志表
|
||||
if (logInfo.isAddLogTable()) {
|
||||
SysLog log = new SysLog("INFO", System.currentTimeMillis() - startTime);
|
||||
logService.save(getUsername(), StringUtils.getBrowser(request), requestIp, joinPoint, log);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
log.error("track_id:{},error:{}", trackId, ex.getMessage());
|
||||
SysLog log = new SysLog("ERROR", System.currentTimeMillis() - startTime);
|
||||
log.setException_detail(ThrowableUtil.getStackTrace(ex).getBytes());
|
||||
logService.save(getUsername(), StringUtils.getBrowser(request), StringUtils.getIp(request), (ProceedingJoinPoint) joinPoint, log);
|
||||
throw ex;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
* 根据方法和传入的参数获取请求参数
|
||||
*//*
|
||||
|
||||
|
||||
private String getParameter(Method method, Object[] args) {
|
||||
List<Object> argList = new ArrayList<>();
|
||||
@@ -142,29 +136,13 @@ public class LogAspect {
|
||||
return argList.size() == 1 ? JSONUtil.toJsonStr(argList.get(0)) : JSONUtil.toJsonStr(argList);
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
* 配置异常通知
|
||||
*
|
||||
* @param joinPoint join point for advice
|
||||
* @param e exception
|
||||
*//*
|
||||
|
||||
@AfterThrowing(pointcut = "logPointcut()", throwing = "e")
|
||||
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
|
||||
Log log = new Log("ERROR",System.currentTimeMillis() - currentTime.get());
|
||||
currentTime.remove();
|
||||
log.setExceptionDetail(ThrowableUtil.getStackTrace(e).getBytes());
|
||||
HttpServletRequest request = RequestHolder.getHttpServletRequest();
|
||||
logService.save(getUsername(), StringUtils.getBrowser(request), StringUtils.getIp(request), (ProceedingJoinPoint)joinPoint, log);
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
try {
|
||||
return SecurityUtils.getCurrentUsername();
|
||||
return SecurityUtils.getCurrentNickName();
|
||||
}catch (Exception e){
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -2,8 +2,10 @@ package org.nl.system.service.logging;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.system.service.logging.dao.SysLog;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -25,6 +27,9 @@ public interface ISysLogService extends IService<SysLog> {
|
||||
*/
|
||||
IPage<SysLog> queryAll(Map criteria, PageQuery pageable);
|
||||
|
||||
@Async
|
||||
void save(String username, String browser, String ip, ProceedingJoinPoint joinPoint, SysLog log);
|
||||
|
||||
/**
|
||||
* 查询异常详情
|
||||
* @param id 日志ID
|
||||
|
||||
@@ -4,8 +4,11 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.time.LocalDateTime;
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -18,6 +21,8 @@ import lombok.EqualsAndHashCode;
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("sys_log")
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SysLog implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -52,4 +57,8 @@ public class SysLog implements Serializable {
|
||||
private String create_time;
|
||||
|
||||
|
||||
public SysLog(String logType, Long time) {
|
||||
this.log_type = logType;
|
||||
this.time = time;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,35 @@
|
||||
package org.nl.system.service.logging.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.common.utils.StringUtils;
|
||||
import org.nl.common.utils.ValidationUtil;
|
||||
import org.nl.system.service.logging.ISysLogService;
|
||||
import org.nl.system.service.logging.dao.SysLog;
|
||||
import org.nl.system.service.logging.dao.mapper.SysLogMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Parameter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -36,12 +51,10 @@ public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> impleme
|
||||
public IPage<SysLog> queryAll(Map whereJson, PageQuery pageable) {
|
||||
String blurry = ObjectUtil.isNotEmpty(whereJson.get("blurry"))?whereJson.get("blurry").toString():null;
|
||||
String log_type = ObjectUtil.isNotEmpty(whereJson.get("log_type"))?whereJson.get("log_type").toString():null;
|
||||
String username = ObjectUtil.isNotEmpty(whereJson.get("username"))?whereJson.get("username").toString():null;
|
||||
String begin_time = ObjectUtil.isNotEmpty(whereJson.get("begin_time"))?whereJson.get("begin_time").toString():null;
|
||||
String end_time = ObjectUtil.isNotEmpty(whereJson.get("end_time"))?whereJson.get("end_time").toString():null;
|
||||
LambdaQueryWrapper<SysLog> lam = new LambdaQueryWrapper<>();
|
||||
lam.eq(ObjectUtil.isNotEmpty(log_type), SysLog::getLog_type, log_type)
|
||||
.eq(ObjectUtil.isNotEmpty(username), SysLog::getUsername, username)
|
||||
.like(ObjectUtil.isNotEmpty(blurry), SysLog::getDescription, blurry)
|
||||
.le(ObjectUtil.isNotEmpty(end_time), SysLog::getCreate_time, end_time)
|
||||
.ge(ObjectUtil.isNotEmpty(begin_time), SysLog::getCreate_time, begin_time)
|
||||
@@ -51,6 +64,60 @@ public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> impleme
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(String username, String browser, String ip, ProceedingJoinPoint joinPoint, SysLog logDto) {
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
Method method = signature.getMethod();
|
||||
Log aopLog = method.getAnnotation(Log.class);
|
||||
|
||||
// 方法路径
|
||||
String methodName = joinPoint.getTarget().getClass().getName() + "." + signature.getName() + "()";
|
||||
|
||||
// 描述
|
||||
if (logDto != null) {
|
||||
logDto.setDescription(aopLog.value());
|
||||
}
|
||||
assert logDto != null;
|
||||
logDto.setRequest_ip(ip);
|
||||
logDto.setLog_id(RandomUtil.randomString(5));
|
||||
logDto.setAddress(StringUtils.getCityInfo(logDto.getRequest_ip()));
|
||||
logDto.setMethod(methodName);
|
||||
logDto.setUsername(username);
|
||||
logDto.setParams(getParameter(method, joinPoint.getArgs()));
|
||||
logDto.setBrowser(browser);
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
String dateString = DateUtil.date(currentTimeMillis).toString();
|
||||
logDto.setCreate_time(dateString);
|
||||
logMapper.insert(logDto);
|
||||
}
|
||||
|
||||
private String getParameter(Method method, Object[] args) {
|
||||
List<Object> argList = new ArrayList<>();
|
||||
Parameter[] parameters = method.getParameters();
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
//将RequestBody注解修饰的参数作为请求参数
|
||||
RequestBody requestBody = parameters[i].getAnnotation(RequestBody.class);
|
||||
if (requestBody != null) {
|
||||
argList.add(args[i]);
|
||||
}
|
||||
//将RequestParam注解修饰的参数作为请求参数
|
||||
RequestParam requestParam = parameters[i].getAnnotation(RequestParam.class);
|
||||
if (requestParam != null) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
String key = parameters[i].getName();
|
||||
if (!StrUtil.isEmpty(requestParam.value())) {
|
||||
key = requestParam.value();
|
||||
}
|
||||
map.put(key, args[i]);
|
||||
argList.add(map);
|
||||
}
|
||||
}
|
||||
if (argList.size() == 0) {
|
||||
return "";
|
||||
}
|
||||
return argList.size() == 1 ? JSONUtil.toJsonStr(argList.get(0)) : JSONUtil.toJsonStr(argList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object findByErrDetail(String id) {
|
||||
SysLog sysLog = logMapper.selectById(id);
|
||||
|
||||
@@ -84,9 +84,9 @@ public class FabServiceImpl {
|
||||
Assert.noNullElements(new Object[]{form.getString("device_code"), form.getString("vehicle_code")}, "参数不能为空!");
|
||||
CallMaterVo callMaterVo = form.toJavaObject(CallMaterVo.class);
|
||||
SchBasePoint schBasePoint2 = iSchBasePointService.selectByPointCode(callMaterVo.getDevice_code());
|
||||
if (schBasePoint2.getPoint_status().equals(GoodsEnum.IN_STOCK.getValue())) {
|
||||
/*if (schBasePoint2.getPoint_status().equals(GoodsEnum.IN_STOCK.getValue()) || StrUtil.isNotEmpty(schBasePoint2.getVehicle_code())) {
|
||||
throw new BadRequestException("该点位已存在物料!");
|
||||
}
|
||||
}*/
|
||||
param.put("device_code", callMaterVo.getDevice_code());
|
||||
param.put("config_code", "PcOperationCMTask");
|
||||
param.put("region_code", callMaterVo.getRegion_code());
|
||||
@@ -155,7 +155,6 @@ public class FabServiceImpl {
|
||||
pcOperationSNTTask.apply(param);
|
||||
iSchBasePointService.update(Wrappers.lambdaUpdate(SchBasePoint.class)
|
||||
.eq(SchBasePoint::getPoint_code, sendVehicleVo.getDevice_code())
|
||||
.set(SchBasePoint::getPoint_status, GoodsEnum.OUT_OF_STOCK.getValue())
|
||||
.set(SchBasePoint::getIs_lock, true));
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -172,7 +172,7 @@ public class HandheldServiceImpl implements HandheldService {
|
||||
vehicle_list = new String[]{vehicle};
|
||||
}
|
||||
MdBaseVehicle mdBaseVehicle = iMdBaseVehicleService.selectByVehicleCode(vehicle_list[0]);
|
||||
if(ObjectUtil.isEmpty(mdBaseVehicle)) throw new BadRequestException("托盘不存在!");
|
||||
if (ObjectUtil.isEmpty(mdBaseVehicle)) throw new BadRequestException("托盘不存在!");
|
||||
verifyNumber(vehicle_list, mdBaseVehicle.getVehicle_type());
|
||||
SchBasePoint schBasePoint = iSchBasePointService.selectByPointCode(device_code);
|
||||
if (ObjectUtil.isEmpty(schBasePoint)) throw new BadRequestException("设备点位不存在!");
|
||||
@@ -191,12 +191,12 @@ public class HandheldServiceImpl implements HandheldService {
|
||||
/**
|
||||
* 验证托盘数量和类型
|
||||
*
|
||||
* @param vehicles 回库托盘号
|
||||
* @param number 托盘数
|
||||
* @param vehicles 回库托盘号
|
||||
* @param number 托盘数
|
||||
* @param vehicleType 托盘类型
|
||||
*/
|
||||
private void verifyNumber(String[] vehicles, String vehicleType) {
|
||||
switch(vehicleType){
|
||||
switch (vehicleType) {
|
||||
case "R01":
|
||||
if (vehicles.length != 2) {
|
||||
throw new BadRequestException("托盘数量不匹配");
|
||||
@@ -221,8 +221,8 @@ public class HandheldServiceImpl implements HandheldService {
|
||||
}
|
||||
verifyVehicleType(vehicles, "S06");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -253,7 +253,7 @@ public class HandheldServiceImpl implements HandheldService {
|
||||
.eq(SchBasePoint::getVehicle_code, param.getString("vehicle_code"))
|
||||
.ne(SchBasePoint::getPoint_code, param.getString("device_code")));
|
||||
Assert.isNull(one, "载具号已存在别的点位,请确认再下发");
|
||||
String region_code = param.getString("region_code");
|
||||
String region_code = param.getString("regionCode");
|
||||
String device_code = param.getString("device_code");
|
||||
String vehicle_code = param.getString("vehicle_code");
|
||||
String type = param.getString("type");
|
||||
@@ -303,6 +303,7 @@ public class HandheldServiceImpl implements HandheldService {
|
||||
*/
|
||||
private void goShelves(SchBasePoint schBasePoint, JSONObject param, String region_code, String device_code, String vehicle_code, AbstractTask connectorTask) {
|
||||
Assert.noNullElements(param.getJSONArray("material"), "参数不能为空!");
|
||||
Assert.notNull(region_code,"下道区域不能为空!");
|
||||
JSONArray materials = param.getJSONArray("material");
|
||||
JSONObject jo = new JSONObject();
|
||||
//冲床人工入库使用
|
||||
@@ -315,7 +316,7 @@ public class HandheldServiceImpl implements HandheldService {
|
||||
connectorTask.apply(jo);
|
||||
} else {
|
||||
if (StrUtil.isBlank(region_code)) {
|
||||
JSONObject json = new JSONObject();
|
||||
/*JSONObject json = new JSONObject();
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
materials.forEach(material2 -> {
|
||||
boolean material_code = ObjectUtil.isEmpty(((LinkedHashMap) material2).get("material_code"));
|
||||
@@ -329,7 +330,7 @@ public class HandheldServiceImpl implements HandheldService {
|
||||
jsonArray.add(map);
|
||||
});
|
||||
json.put("vehicle_code", vehicle_code);
|
||||
json.put("region_code", schBasePoint.getRegion_code());
|
||||
json.put("region_code", StrUtil.isNotEmpty(param.getString("regionCode")) ? param.getString("regionCode") : schBasePoint.getRegion_code());
|
||||
json.put("materials", jsonArray);
|
||||
JSONObject json1 = wmsToConnectorService.applyRegionAndDueDate(json);
|
||||
if (ObjectUtil.isNotEmpty(json1) && json1.getInteger("status") == HttpStatus.OK.value()) {
|
||||
@@ -353,7 +354,7 @@ public class HandheldServiceImpl implements HandheldService {
|
||||
jo.put("region_code", region_code);
|
||||
} else if (ObjectUtil.isNotEmpty(json1)) {
|
||||
throw new BadRequestException(json1.getString("msg"));
|
||||
}
|
||||
}*/
|
||||
} else {
|
||||
jo.put("region_code", region_code);
|
||||
}
|
||||
@@ -388,9 +389,9 @@ public class HandheldServiceImpl implements HandheldService {
|
||||
jo.put("create_mode", GeneralDefinition.AUTO_CREATION);
|
||||
jo.put("vehicle_code", vehicle_code);
|
||||
jo.put("region_code", region_code);
|
||||
jo.put("ext_data", param);
|
||||
param.put("region_code", region_code);
|
||||
param.put("target_region_code", region_code);
|
||||
jo.put("ext_data", param);
|
||||
connectorTask.apply(jo);
|
||||
iSchBasePointService.update(Wrappers.lambdaUpdate(SchBasePoint.class)
|
||||
.eq(SchBasePoint::getPoint_code, device_code)
|
||||
@@ -413,8 +414,9 @@ public class HandheldServiceImpl implements HandheldService {
|
||||
if (param.getJSONArray("pointCodes").size() > 0) {
|
||||
param.getJSONArray("pointCodes").forEach(pointCode -> {
|
||||
cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(pointCode);
|
||||
SchBasePoint schBasePoint = iSchBasePointService.selectByPointCode(jsonObject.getStr("point_code"));
|
||||
iSchBaseVehiclematerialgroupService.remove(Wrappers.lambdaQuery(SchBaseVehiclematerialgroup.class)
|
||||
.eq(SchBaseVehiclematerialgroup::getVehicle_code, jsonObject.get("vehicle_code")));
|
||||
.eq(SchBaseVehiclematerialgroup::getVehicle_code, schBasePoint.getVehicle_code()));
|
||||
iSchBasePointService.update(Wrappers.lambdaUpdate(SchBasePoint.class)
|
||||
.eq(SchBasePoint::getPoint_code, jsonObject.get("point_code"))
|
||||
.set(SchBasePoint::getPoint_status, GoodsEnum.OUT_OF_STOCK.getValue())
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
ROW_NUMBER() OVER (PARTITION BY vg.vehicle_code ORDER BY vg.due_date) AS rn
|
||||
FROM
|
||||
sch_base_vehiclematerialgroup vg
|
||||
where vg.is_delete = 0
|
||||
where 0 = 0
|
||||
<if test="query.vehicle_code != null">
|
||||
AND vg.vehicle_code like CONCAT('%', #{query.vehicle_code}, '%')
|
||||
</if>
|
||||
@@ -97,7 +97,7 @@
|
||||
<if test="query.material_id != null">
|
||||
AND vg.material_id like CONCAT('%', #{query.material_id}, '%')
|
||||
</if>
|
||||
order by vg.region_code desc
|
||||
order by vg.create_time desc
|
||||
)
|
||||
SELECT *
|
||||
FROM RankedVehicles
|
||||
|
||||
@@ -117,7 +117,6 @@ public class SchBaseVehiclematerialgroupServiceImpl extends ServiceImpl<SchBaseV
|
||||
item.setBetween(daysBetween + "");
|
||||
item.setHas_work(true);
|
||||
});
|
||||
schBaseVehiclematerialgroupIPage.getRecords().sort(Comparator.comparingLong(group -> Long.parseLong(group.getBetween())));
|
||||
return schBaseVehiclematerialgroupIPage;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package org.nl.wms.sch.task.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -18,10 +16,8 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import sun.security.krb5.internal.PAData;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
/**
|
||||
@@ -99,4 +95,11 @@ public class SchBaseTaskController {
|
||||
schBaseTaskService.downTask(schBaseTaskService.queryAll(whereJson),response);
|
||||
}
|
||||
|
||||
@PostMapping("/selectCacheTask")
|
||||
@Log("查询缓存任务")
|
||||
@ApiOperation("查询缓存任务")
|
||||
@SaIgnore
|
||||
public ResponseEntity<JSONObject> selectCacheTask(@RequestBody JSONObject jsonObject) {
|
||||
return new ResponseEntity<>(schBaseTaskService.selectCacheTask(jsonObject),HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,4 +141,11 @@ public interface ISchBaseTaskService extends IService<SchBaseTask> {
|
||||
* @return
|
||||
*/
|
||||
List<SchBaseTask> selectNoFinishTaskByPointCode(String taskCode,String pointCode);
|
||||
|
||||
/**
|
||||
* 根据点位查询缓存的任务
|
||||
* @param jsonObject
|
||||
* @return
|
||||
*/
|
||||
JSONObject selectCacheTask(JSONObject jsonObject);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ import org.apache.poi.xssf.streaming.SXSSFSheet;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService;
|
||||
import org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup;
|
||||
import org.nl.wms.sch.task.service.ISchBaseTaskService;
|
||||
import org.nl.wms.sch.task.service.dao.SchBaseTask;
|
||||
import org.nl.wms.sch.task.service.dao.mapper.SchBaseTaskMapper;
|
||||
@@ -59,6 +61,8 @@ public class SchBaseTaskServiceImpl extends ServiceImpl<SchBaseTaskMapper, SchBa
|
||||
private SchBaseTaskMapper schBaseTaskMapper;
|
||||
@Autowired
|
||||
private SchBaseTaskconfigMapper schBaseTaskconfigMapper;
|
||||
@Autowired
|
||||
private ISchBaseVehiclematerialgroupService schBaseVehiclematerialgroupServiceImpl;
|
||||
|
||||
@Autowired
|
||||
private TaskFactory taskFactory;
|
||||
@@ -402,6 +406,31 @@ public class SchBaseTaskServiceImpl extends ServiceImpl<SchBaseTaskMapper, SchBa
|
||||
.eq(SchBaseTask::getPoint_code2, pointCode));
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject selectCacheTask(JSONObject jsonObject) {
|
||||
Assert.notNull(jsonObject.getString("deviceCode"), "点位参数不能为空!");
|
||||
List<SchBaseTask> schBaseTasks = schBaseTaskMapper.selectList(Wrappers.lambdaQuery(SchBaseTask.class)
|
||||
.eq(SchBaseTask::getPoint_code2, jsonObject.getString("deviceCode"))
|
||||
.eq(SchBaseTask::getTask_status, TaskStatus.CREATED.getCode()));
|
||||
if(CollUtil.isNotEmpty(schBaseTasks)){
|
||||
String vehicle_code = schBaseTasks.get(0).getVehicle_code();
|
||||
List<SchBaseVehiclematerialgroup> list = schBaseVehiclematerialgroupServiceImpl.list(Wrappers.lambdaQuery(SchBaseVehiclematerialgroup.class)
|
||||
.eq(SchBaseVehiclematerialgroup::getVehicle_code, vehicle_code));
|
||||
JSONObject jsonObject2 = new JSONObject();
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
for (SchBaseVehiclematerialgroup schBaseVehiclematerialgroup : list) {
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("order_code", schBaseVehiclematerialgroup.getOrder_code());
|
||||
jsonObject1.put("material_id", schBaseVehiclematerialgroup.getMaterial_id());
|
||||
jsonArray.add(jsonObject1);
|
||||
}
|
||||
jsonObject2.put("vehicleCode", vehicle_code);
|
||||
jsonObject2.put("materialList", jsonArray);
|
||||
return jsonObject2;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static byte[] writeExcelAfterToBytes(String[] headers, ArrayList<List> cellList) {
|
||||
ExcelWriter writer = null;
|
||||
ByteArrayOutputStream outputStream = null;
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.nl.wms.sch.task_manage.enums.TaskDirectionEnum;
|
||||
import org.nl.wms.sch.task_manage.enums.WorkOrderStatusEnum;
|
||||
import org.nl.wms.sch.task_manage.task.AcsUtil;
|
||||
import org.nl.wms.sch.task_manage.task.core.TaskStatus;
|
||||
import org.nl.wms.sch.task_manage.task.tasks.pcoperation.PcOperationCMTask;
|
||||
import org.nl.wms.util.TaskUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -92,6 +93,9 @@ public abstract class AbstractTask {
|
||||
//2、根据任务配置补全任务
|
||||
//3、下发
|
||||
for (SchBaseTask task : taskList) {
|
||||
if("PcOperationCMTask".equals(task.getConfig_code())){
|
||||
continue;
|
||||
}
|
||||
List<AcsTaskDto> list = new ArrayList<>();
|
||||
AcsTaskDto taskDto = new AcsTaskDto();
|
||||
taskDto.setTask_id(task.getTask_id());
|
||||
@@ -120,7 +124,7 @@ public abstract class AbstractTask {
|
||||
}
|
||||
}
|
||||
|
||||
private AcsTaskDto setTask(String config_code, AcsTaskDto taskDto, SchBaseTask task) {
|
||||
protected AcsTaskDto setTask(String config_code, AcsTaskDto taskDto, SchBaseTask task) {
|
||||
SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper<SchBaseTaskconfig>()
|
||||
.eq(SchBaseTaskconfig::getConfig_code, config_code));
|
||||
taskDto.setPriority(StrUtil.isNotEmpty(task.getAcs_trace_id()) ? task.getAcs_trace_id() : taskConfig.getPriority());
|
||||
@@ -233,7 +237,7 @@ public abstract class AbstractTask {
|
||||
// 校验同个点位,同种任务是否多次请求创建任务(固定只能1个任务)
|
||||
List<SchBaseTask> applyPointTask = taskService.findUnFinishTasksByTaskConfig(
|
||||
taskConfig.getConfig_code(), apply_point_code, taskConfig.getTask_direction());
|
||||
if (applyPointTask.size() == 1) {
|
||||
if (!"PcOperationCMTask".equals(config_code) && applyPointTask.size() == 1) {
|
||||
throw new BadRequestException("已创建相同点位任务,不可重复创建!");
|
||||
}
|
||||
// 获取对接位点位对象
|
||||
|
||||
@@ -169,7 +169,7 @@ public class BlankingTask extends AbstractTask {
|
||||
schBaseVehiclematerialgroup.setDue_date(jsonObject.getStr("due_date"));
|
||||
schBaseVehiclematerialgroup.setCreate_name(SecurityUtils.getCurrentNickName());
|
||||
schBaseVehiclematerialgroup.setPriority(jsonObject.getStr("priority"));
|
||||
schBaseVehiclematerialgroup.setRegion_code(StrUtil.isBlank(finalRegion_code) ? jsonObject.getStr("region_code") : finalRegion_code);
|
||||
schBaseVehiclematerialgroup.setRegion_code(StrUtil.isBlank(finalRegion_code) ? taskObj.getRegion_code() : finalRegion_code);
|
||||
schBaseVehiclematerialgroupService.create(schBaseVehiclematerialgroup);
|
||||
});
|
||||
// 任务完成
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.nl.wms.sch.task_manage.task.tasks.pcoperation;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
@@ -21,16 +22,21 @@ import org.nl.wms.sch.task.service.ISchBaseTaskService;
|
||||
import org.nl.wms.sch.task.service.ISchBaseTaskconfigService;
|
||||
import org.nl.wms.sch.task.service.dao.SchBaseTask;
|
||||
import org.nl.wms.sch.task_manage.AbstractTask;
|
||||
import org.nl.wms.sch.task_manage.AcsTaskDto;
|
||||
import org.nl.wms.sch.task_manage.GeneralDefinition;
|
||||
import org.nl.wms.sch.task_manage.enums.NoticeTypeEnum;
|
||||
import org.nl.wms.sch.task_manage.enums.TaskFinishedTypeEnum;
|
||||
import org.nl.wms.sch.task_manage.task.AcsUtil;
|
||||
import org.nl.wms.sch.task_manage.task.core.TaskStatus;
|
||||
import org.nl.wms.util.PointUtils;
|
||||
import org.nl.wms.util.TaskUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* sorting呼叫满料
|
||||
@@ -86,6 +92,58 @@ public class PcOperationCMTask extends AbstractTask {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renotifyAcs(List<SchBaseTask> taskList) {
|
||||
taskList = taskList.stream().filter(task -> task.getConfig_code().equals(TASK_CONFIG_CODE)).collect(Collectors.toList());
|
||||
for (SchBaseTask schBaseTask : taskList) {
|
||||
List<SchBaseTask> schBaseTasks = taskService.list(Wrappers.lambdaQuery(SchBaseTask.class)
|
||||
.eq(SchBaseTask::getConfig_code, TASK_CONFIG_CODE)
|
||||
.gt(SchBaseTask::getTask_status, TaskStatus.CREATED.getCode())
|
||||
.lt(SchBaseTask::getTask_status, TaskStatus.FINISHED.getCode())
|
||||
.ne(SchBaseTask::getPoint_code1,schBaseTask.getPoint_code1())
|
||||
.eq(SchBaseTask::getPoint_code2,schBaseTask.getPoint_code2())
|
||||
);
|
||||
SchBasePoint schBasePoint = pointService.selectByPointCode(schBaseTask.getPoint_code2());
|
||||
if(ObjectUtil.isEmpty(schBasePoint)){
|
||||
log.info("{}点位不存在!!!",schBasePoint.getPoint_code());
|
||||
throw new BadRequestException("点位不存在!");
|
||||
}
|
||||
if(CollUtil.isNotEmpty(schBaseTasks) || schBasePoint.getPoint_status().equals(GoodsEnum.IN_STOCK.getValue())){
|
||||
log.info("{}点位被占用!!!",schBasePoint.getPoint_code());
|
||||
continue;
|
||||
}
|
||||
issuedAcsTask(schBaseTask);
|
||||
}
|
||||
}
|
||||
|
||||
private void issuedAcsTask(SchBaseTask schBaseTask) {
|
||||
List<AcsTaskDto> list = new ArrayList<>();
|
||||
AcsTaskDto taskDto = new AcsTaskDto();
|
||||
taskDto.setTask_id(schBaseTask.getTask_id());
|
||||
taskDto.setTask_code(schBaseTask.getTask_code());
|
||||
|
||||
taskDto.setRoute_plan_code("normal");
|
||||
taskDto.setStart_device_code(schBaseTask.getPoint_code1());
|
||||
//如果存在等待点,任务下发目标点给等待点
|
||||
if (ObjectUtil.isEmpty(schBaseTask.getPoint_code2())) {
|
||||
taskDto.setNext_device_code(schBaseTask.getNext_wait_point());
|
||||
} else {
|
||||
taskDto.setNext_device_code(schBaseTask.getPoint_code2());
|
||||
}
|
||||
taskDto.setVehicle_code(schBaseTask.getVehicle_code());
|
||||
setTask(schBaseTask.getConfig_code(), taskDto, schBaseTask);
|
||||
list.add(taskDto);
|
||||
JSONObject result = AcsUtil.notifyAcs("api/wms/task", list);
|
||||
if (HttpStatus.OK.value() == result.getInteger("status")) {
|
||||
schBaseTask.setTask_status(TaskStatus.ISSUED.getCode());
|
||||
schBaseTask.setRemark(" ");
|
||||
taskService.update(schBaseTask);
|
||||
} else if (HttpStatus.BAD_REQUEST.value() == result.getInteger("status")) {
|
||||
schBaseTask.setRemark(result.getString("message"));
|
||||
taskService.update(schBaseTask);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateStatus(String task_code, TaskStatus status) {
|
||||
//TODO:完成任务的时候将int_task_code的清除
|
||||
@@ -170,4 +228,7 @@ public class PcOperationCMTask extends AbstractTask {
|
||||
taskService.updateById(taskObj);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -91,8 +91,9 @@ public class ProcessingSMTTask extends AbstractTask {
|
||||
|
||||
for (SchBaseTask task : tasks) {
|
||||
SendMaterVo sendMaterVo = JSONObject.parseObject(task.getRequest_param(), SendMaterVo.class);
|
||||
JSONObject jsonObject = JSONObject.parseObject(task.getRequest_param());
|
||||
//判断是否指定到外协区
|
||||
String targetRegionCode = sendMaterVo.getRegion_code();
|
||||
String targetRegionCode = jsonObject.getString("region_code");
|
||||
if (StringUtils.isBlank(targetRegionCode)) {
|
||||
task.setRemark("未指定区域!");
|
||||
taskService.updateById(task);
|
||||
@@ -253,20 +254,24 @@ public class ProcessingSMTTask extends AbstractTask {
|
||||
* @param sendVehicleVos
|
||||
*/
|
||||
private void interiorTemplate(SchBaseTask taskObj, List<SendVehicleVo> sendVehicleVos) {
|
||||
JSONObject jsonObject3 = new JSONObject();
|
||||
jsonObject3.put("vehicle_code", taskObj.getVehicle_code());
|
||||
jsonObject3.put("id", taskObj.getTask_code());
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
sendVehicleVos.forEach(sendVehicleVo -> {
|
||||
JSONObject jsonObject4 = new JSONObject();
|
||||
jsonObject4.put("product_id", sendVehicleVo.getMaterial_code());
|
||||
jsonObject4.put("current_qty", sendVehicleVo.getMaterial_qty());
|
||||
jsonObject4.put("production_order", sendVehicleVo.getOrder_code());
|
||||
jsonObject4.put("due_date", sendVehicleVo.getDue_date());
|
||||
jsonArray.add(jsonObject4);
|
||||
});
|
||||
jsonObject3.put("materials", jsonArray);
|
||||
lmsToWmsService.feedbackMaterialStatus(jsonObject3);
|
||||
Param isPrint = sysParamService.findByCode(GeneralDefinition.IS_PRINT);
|
||||
if (ObjectUtil.isNotEmpty(isPrint) && "1".equals(isPrint.getValue())) {
|
||||
} else {
|
||||
JSONObject jsonObject3 = new JSONObject();
|
||||
jsonObject3.put("vehicle_code", taskObj.getVehicle_code());
|
||||
jsonObject3.put("id", taskObj.getTask_code());
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
sendVehicleVos.forEach(sendVehicleVo -> {
|
||||
JSONObject jsonObject4 = new JSONObject();
|
||||
jsonObject4.put("product_id", sendVehicleVo.getMaterial_code());
|
||||
jsonObject4.put("current_qty", sendVehicleVo.getMaterial_qty());
|
||||
jsonObject4.put("production_order", sendVehicleVo.getOrder_code());
|
||||
jsonObject4.put("due_date", sendVehicleVo.getDue_date());
|
||||
jsonArray.add(jsonObject4);
|
||||
});
|
||||
jsonObject3.put("materials", jsonArray);
|
||||
lmsToWmsService.feedbackMaterialStatus(jsonObject3);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user