add: 添加定时删除日志文件,优化pc下料逻辑
This commit is contained in:
@@ -17,6 +17,7 @@ public enum RegionEnum {
|
||||
NBJG("内部加工区","NBJGZCQ"),
|
||||
WXJG("外协加工区","WXJGZCQ"),
|
||||
ZDZWQ("自动折弯区","ZDZWQ"),
|
||||
NBGD("内部过道加工区","NBGDJGQ"),
|
||||
;
|
||||
private final String region_name;
|
||||
private final String region_code;
|
||||
|
||||
@@ -222,49 +222,52 @@ public class FabController {
|
||||
public ResponseEntity<TableDataInfo> sendMater(@RequestBody SendMaterVo materInfo) {
|
||||
JSONObject toJSON = (JSONObject) JSON.toJSON(materInfo);
|
||||
//TODO:待确定
|
||||
List<SendVehicleVo> mater = materInfo.getMater();
|
||||
if (CollUtil.isEmpty(mater)) throw new BadRequestException("物料信息为空,请确认!");
|
||||
JSONObject json = new JSONObject();
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
mater.stream().forEach(material -> {
|
||||
map.put("order_code", material.getOrder_code());
|
||||
map.put("qty", material.getMaterial_qty());
|
||||
jsonArray.add(map);
|
||||
});
|
||||
SchBasePoint schBasePoint = iSchBasePointService.selectByPointCode(materInfo.getDevice_code());
|
||||
json.put("vehicle_code", schBasePoint.getVehicle_code());
|
||||
json.put("region_code", schBasePoint.getRegion_code());
|
||||
json.put("materials", jsonArray);
|
||||
JSONObject jsonObject = wmsToConnectorService.applyRegionAndDueDate(json);
|
||||
if (ObjectUtil.isNotEmpty(jsonObject) && jsonObject.getInteger("status") == 200) {
|
||||
JSONArray data = jsonObject.getJSONArray("data");
|
||||
data.stream().forEach(material -> {
|
||||
JSONObject jsonObject1 = JSONObject.parseObject(StrUtil.toString(material));
|
||||
mater.stream().forEach(material1 -> {
|
||||
if (material1.getOrder_code().equals(jsonObject1.getString("order_code"))) {
|
||||
material1.setDue_date(jsonObject1.getString("due_date"));
|
||||
material1.setRegion_code(jsonObject1.getString("next_region_code"));
|
||||
}
|
||||
});
|
||||
if("1".equals(materInfo.getPoint_code())){
|
||||
List<SendVehicleVo> mater = materInfo.getMater();
|
||||
if (CollUtil.isEmpty(mater)) throw new BadRequestException("物料信息为空,请确认!");
|
||||
JSONObject json = new JSONObject();
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
mater.stream().forEach(material -> {
|
||||
map.put("order_code", material.getOrder_code());
|
||||
map.put("qty", material.getMaterial_qty());
|
||||
jsonArray.add(map);
|
||||
});
|
||||
} else if (ObjectUtil.isNotEmpty(jsonObject) && jsonObject.getInteger("status") == 400) {
|
||||
throw new BadRequestException(jsonObject.getString("msg"));
|
||||
}
|
||||
List<String> materiales = new ArrayList<>();
|
||||
mater.stream().forEach(material -> {
|
||||
materiales.add(JSONObject.toJSONString(material));
|
||||
});
|
||||
toJSON.put("material_info", materiales);
|
||||
toJSON.put("vehicle_code", schBasePoint.getVehicle_code());
|
||||
if ("1".equals(materInfo.getPoint_code())) {
|
||||
SchBasePoint schBasePoint = iSchBasePointService.selectByPointCode(materInfo.getDevice_code());
|
||||
json.put("vehicle_code", schBasePoint.getVehicle_code());
|
||||
json.put("region_code", schBasePoint.getRegion_code());
|
||||
json.put("materials", jsonArray);
|
||||
JSONObject jsonObject = wmsToConnectorService.applyRegionAndDueDate(json);
|
||||
if (ObjectUtil.isNotEmpty(jsonObject) && jsonObject.getInteger("status") == 200) {
|
||||
JSONArray data = jsonObject.getJSONArray("data");
|
||||
data.stream().forEach(material -> {
|
||||
JSONObject jsonObject1 = JSONObject.parseObject(StrUtil.toString(material));
|
||||
mater.stream().forEach(material1 -> {
|
||||
if (material1.getOrder_code().equals(jsonObject1.getString("order_code"))) {
|
||||
material1.setDue_date(jsonObject1.getString("due_date"));
|
||||
material1.setRegion_code(jsonObject1.getString("next_region_code"));
|
||||
}
|
||||
});
|
||||
});
|
||||
} else if (ObjectUtil.isNotEmpty(jsonObject) && jsonObject.getInteger("status") == 400) {
|
||||
throw new BadRequestException(jsonObject.getString("msg"));
|
||||
}
|
||||
List<String> materiales = new ArrayList<>();
|
||||
mater.stream().forEach(material -> {
|
||||
materiales.add(JSONObject.toJSONString(material));
|
||||
});
|
||||
toJSON.put("material_info", materiales);
|
||||
toJSON.put("vehicle_code", schBasePoint.getVehicle_code());
|
||||
toJSON.put("region_code", StrUtil.isNotEmpty(mater.get(0).getRegion_code()) ? mater.get(0).getRegion_code() : schBasePoint.getRegion_code());
|
||||
} else if ("2".equals(materInfo.getPoint_code())) {
|
||||
toJSON.put("region_code", RegionEnum.NBJG.getRegion_code());
|
||||
} else if ("3".equals(materInfo.getPoint_code())) {
|
||||
toJSON.put("region_code", RegionEnum.WXJG.getRegion_code());
|
||||
}else{
|
||||
if ("2".equals(materInfo.getPoint_code())) {
|
||||
toJSON.put("region_code", RegionEnum.NBJG.getRegion_code());
|
||||
} else if ("3".equals(materInfo.getPoint_code())) {
|
||||
toJSON.put("region_code", RegionEnum.WXJG.getRegion_code());
|
||||
} else if ("4".equals(materInfo.getPoint_code())) {
|
||||
toJSON.put("region_code", RegionEnum.NBGD.getRegion_code());
|
||||
}
|
||||
}
|
||||
|
||||
fabService.createAgvTask(toJSON, "smt");
|
||||
return new ResponseEntity(TableDataInfo.build(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public class FabServiceImpl {
|
||||
JSONObject param = new JSONObject();
|
||||
switch (type) {
|
||||
case "cmt":
|
||||
Assert.noNullElements(new Object[]{form.getString("device_code"),form.getString("vehicle_code")}, "参数不能为空!");
|
||||
Assert.noNullElements(new Object[]{form.getString("device_code"), form.getString("vehicle_code")}, "参数不能为空!");
|
||||
CallMaterVo callMaterVo = form.toJavaObject(CallMaterVo.class);
|
||||
param.put("device_code", callMaterVo.getDevice_code());
|
||||
param.put("config_code", "PcOperationCMTask");
|
||||
@@ -101,10 +101,10 @@ public class FabServiceImpl {
|
||||
Assert.noNullElements(new Object[]{form.getString("device_code"), form.getString("vehicle_type")}, "参数不能为空!");
|
||||
CallEmpVo callEmpVo = form.toJavaObject(CallEmpVo.class);
|
||||
SchBasePoint schBasePoint1 = iSchBasePointService.selectByPointCode(form.getString("device_code"));
|
||||
if(ObjectUtil.isEmpty(schBasePoint1)){
|
||||
if (ObjectUtil.isEmpty(schBasePoint1)) {
|
||||
throw new BadRequestException("点位不存在");
|
||||
}
|
||||
if(!schBasePoint1.getPoint_status().equals(GoodsEnum.OUT_OF_STOCK.getValue()) || schBasePoint1.getIs_lock()){
|
||||
if (!schBasePoint1.getPoint_status().equals(GoodsEnum.OUT_OF_STOCK.getValue()) || schBasePoint1.getIs_lock()) {
|
||||
throw new BadRequestException("该点位不是空站点,请确认再呼叫");
|
||||
}
|
||||
param.put("device_code", callEmpVo.getDevice_code());
|
||||
@@ -122,12 +122,14 @@ public class FabServiceImpl {
|
||||
Assert.noNullElements(new Object[]{form.getString("device_code"), form.getString("region_code")}, "参数不能为空!");
|
||||
SendMaterVo sendMaterVo = form.toJavaObject(SendMaterVo.class);
|
||||
MdBaseVehicle vehicle = iMdBaseVehicleService.getOne(new QueryWrapper<MdBaseVehicle>().eq("vehicle_code", sendMaterVo.getVehicle_code()));
|
||||
if(ObjectUtil.isEmpty(vehicle)) throw new BadRequestException("载具不存在");
|
||||
if (ObjectUtil.isEmpty(vehicle)) throw new BadRequestException("载具不存在");
|
||||
param.put("device_code", sendMaterVo.getDevice_code());
|
||||
param.put("ext_data", sendMaterVo);
|
||||
param.put("region_code", sendMaterVo.getRegion_code());
|
||||
if (sendMaterVo.getRegion_code().equals(RegionEnum.NBJG.getRegion_code()) || sendMaterVo.getRegion_code().equals(RegionEnum.WXJG.getRegion_code())) {
|
||||
param.put("config_code", "ProcessingSMTTask");
|
||||
} else if (sendMaterVo.getRegion_code().equals(RegionEnum.NBGD.getRegion_code())) {
|
||||
param.put("config_code", "ProcessingSMTTask");
|
||||
} else {
|
||||
param.put("config_code", "PcOperationSMTTask");
|
||||
}
|
||||
|
||||
@@ -141,5 +141,11 @@ public class HandheldController {
|
||||
return new ResponseEntity<>(handheldService.selectPointByRegion(regionCode),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/createPointInPointTask")
|
||||
@Log("创建点对点任务")
|
||||
public ResponseEntity<Object> createPointTask(String regionCode) {
|
||||
return new ResponseEntity<>(handheldService.selectPointByRegion(regionCode),HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -78,6 +78,7 @@ public class SchBaseTaskServiceImpl extends ServiceImpl<SchBaseTaskMapper, SchBa
|
||||
} else {
|
||||
lam.in(SchBaseTask::getTask_status, TaskStatus.APPLY.getCode(), TaskStatus.CREATED.getCode(), TaskStatus.ISSUED.getCode(), TaskStatus.EXECUTING.getCode());
|
||||
}
|
||||
lam.orderByDesc(SchBaseTask::getUpdate_time);
|
||||
IPage<SchBaseTask> pages = new Page<>(page.getPage() + 1, page.getSize());
|
||||
schBaseTaskMapper.selectPage(pages, lam);
|
||||
return pages;
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
package org.nl.wms.sch.task_manage;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.system.service.param.dao.Param;
|
||||
import org.nl.system.service.param.impl.SysParamServiceImpl;
|
||||
import org.reflections.Reflections;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author LENOVO
|
||||
* 定时清理日志文件
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@Profile("prod")
|
||||
public class AutoCleanFile {
|
||||
|
||||
private static long DAYS_TO_MILLIS = TimeUnit.DAYS.toMillis(14);
|
||||
|
||||
@Value("${logging.file.path}")
|
||||
private String logPath;
|
||||
|
||||
@SneakyThrows
|
||||
public void run() {
|
||||
log.info("定时清理日志文件AutoCleanFile开始:");
|
||||
File directory = new File(logPath);
|
||||
if (directory.exists() && directory.isDirectory()) {
|
||||
cleanDirectory(directory);
|
||||
} else {
|
||||
System.out.println("指定的路径不存在或不是一个目录。");
|
||||
}
|
||||
}
|
||||
|
||||
// 递归清理文件夹内的过期文件
|
||||
private static void cleanDirectory(File directory) {
|
||||
File[] files = directory.listFiles();
|
||||
if (files != null) {
|
||||
long currentTime = System.currentTimeMillis();
|
||||
for (File file : files) {
|
||||
if (file.isDirectory()) {
|
||||
// 如果是目录,递归调用
|
||||
cleanDirectory(file);
|
||||
} else if (file.isFile()) {
|
||||
SysParamServiceImpl sysParamService = SpringContextHolder.getBean(SysParamServiceImpl.class);
|
||||
Param byCode = sysParamService.findByCode(GeneralDefinition.LOGIN_TIME);
|
||||
if (ObjectUtil.isNotNull(byCode)) {
|
||||
DAYS_TO_MILLIS = TimeUnit.DAYS.toMillis(Long.parseLong(byCode.getValue()));
|
||||
}
|
||||
if (currentTime - file.lastModified() > DAYS_TO_MILLIS) {
|
||||
boolean deleted = file.delete();
|
||||
if (deleted) {
|
||||
log.info("已删除文件: " + file.getAbsolutePath());
|
||||
} else {
|
||||
log.info("无法删除文件: " + file.getAbsolutePath());
|
||||
}
|
||||
} else {
|
||||
log.info("文件未超过七天, 不做任何修改: " + file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -67,6 +67,10 @@ public class GeneralDefinition {
|
||||
* 是否调用connector小插件
|
||||
*/
|
||||
public static final String IS_INVOKE_CONNECTOR = "is_invoke_connector";
|
||||
/**
|
||||
* 删除多少天之外的日志文件
|
||||
*/
|
||||
public static final String LOGIN_TIME = "log_time";
|
||||
/**
|
||||
* 手持登录时间
|
||||
*/
|
||||
|
||||
@@ -69,11 +69,11 @@ public class PcOperationSMTTask extends AbstractTask {
|
||||
for (SchBaseTask task : tasks) {
|
||||
SendMaterVo sendMaterVo = JSONObject.parseObject(task.getRequest_param(), SendMaterVo.class);
|
||||
//判断是否指定到外协区
|
||||
String targetRegionCode = sendMaterVo.getTarget_region_code();
|
||||
String targetRegionCode = sendMaterVo.getRegion_code();
|
||||
//TODO: 分配逻辑
|
||||
SchBasePoint schBasePoint = null;
|
||||
if (!StringUtils.isEmpty(targetRegionCode)) {
|
||||
|
||||
schBasePoint = schBasePointService.selectByRegionCode(targetRegionCode, task.getVehicle_code(), "1");
|
||||
} else {
|
||||
// 根据对接位查找对应的载具类型
|
||||
schBasePoint = schBasePointService.selectByRegionCode(task.getRegion_code(), task.getVehicle_code(), "1");
|
||||
@@ -100,7 +100,7 @@ public class PcOperationSMTTask extends AbstractTask {
|
||||
}
|
||||
//删除组盘记录生成新的
|
||||
schBaseVehiclematerialgroupService.remove(new QueryWrapper<SchBaseVehiclematerialgroup>().eq("vehicle_code", sendMaterVo.getVehicle_code()));
|
||||
if(CollUtil.isNotEmpty(sendMaterVos)){
|
||||
if (CollUtil.isNotEmpty(sendMaterVos)) {
|
||||
SchBasePoint finalSchBasePoint = schBasePoint;
|
||||
sendMaterVos.stream().forEach(smv -> {
|
||||
SchBaseVehiclematerialgroup schBaseVehiclematerialgroup = new SchBaseVehiclematerialgroup();
|
||||
|
||||
@@ -62,7 +62,7 @@ public class ProcessingSMTTask extends AbstractTask {
|
||||
|
||||
SendMaterVo sendMaterVo = JSONObject.parseObject(task.getRequest_param(), SendMaterVo.class);
|
||||
//判断是否指定到外协区
|
||||
String targetRegionCode = sendMaterVo.getTarget_region_code();
|
||||
String targetRegionCode = sendMaterVo.getRegion_code();
|
||||
if (StringUtils.isBlank(targetRegionCode)) {
|
||||
task.setRemark("未指定区域!");
|
||||
taskService.updateById(task);
|
||||
|
||||
Reference in New Issue
Block a user