add: 添加定时删除日志文件,优化pc下料逻辑
This commit is contained in:
@@ -417,6 +417,7 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
if (!StrUtil.isEmpty(create_time) && !StrUtil.isEmpty(end_time)) {
|
||||
wrapper.between(Task::getCreate_time, create_time, end_time);
|
||||
}
|
||||
wrapper.orderByDesc(Task::getUpdate_time);
|
||||
IPage<Task> taskPage = taskMapper.selectPage(queryPage, wrapper);
|
||||
final JSONObject json = (JSONObject) JSON.toJSON(ConvertUtil.convertPage(taskPage, TaskDto.class));
|
||||
JSONArray array = json.getJSONArray("content");
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -224,9 +224,9 @@ export default {
|
||||
popSecList: [],
|
||||
currentRow: null,
|
||||
value: '',
|
||||
options: [{ value: 'G01', label: 'G01' }, { value: 'R01', label: 'R01' }, { value: 'R02', label: 'R02' }, { value: 'S04', label: 'S04' }, { value: 'S06', label: 'S06' }],
|
||||
options: [{ value: 'G01', label: 'G01' }, { value: 'R01', label: 'R01' }, { value: 'R02', label: 'R02' }, { value: 'R03', label: 'R03' }, { value: 'S04', label: 'S04' }, { value: 'S06', label: 'S06' }],
|
||||
value1: '',
|
||||
options1: [{ value: '1', label: '货架' }, { value: '2', label: '内部' }, { value: '3', label: '外协' }],
|
||||
options1: [{ value: '1', label: '货架' }, { value: '2', label: '内部' }, { value: '3', label: '外协' }, { value: '4', label: '内部过道' }],
|
||||
value2: '',
|
||||
options2: [],
|
||||
vcode: '',
|
||||
|
||||
@@ -292,13 +292,13 @@
|
||||
<el-table-column v-if="false" prop="update_name" label="修改人" :min-width="flexWidth('update_name',crud.data,'修改人')" />
|
||||
<el-table-column v-if="false" prop="update_time" label="修改时间" :min-width="flexWidth('update_time',crud.data,'修改时间')" />
|
||||
<el-table-column v-permission="[]" label="操作" width="120px" align="center" fixed="right">
|
||||
<!-- <template slot-scope="scope">
|
||||
<template slot-scope="scope">
|
||||
<udOperation
|
||||
:data="scope.row"
|
||||
:permission="permission"
|
||||
/>
|
||||
</template> -->
|
||||
<template slot-scope="scope">
|
||||
</template>
|
||||
<!-- <template slot-scope="scope">
|
||||
<el-button
|
||||
v-if="!!scope.row.has_work && scope.row.theLocation != null"
|
||||
type="text"
|
||||
@@ -307,7 +307,7 @@
|
||||
>
|
||||
创建任务
|
||||
</el-button>
|
||||
</template>
|
||||
</template> -->
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!--分页组件-->
|
||||
@@ -323,6 +323,7 @@ import crudSchBaseVehiclematerialgroup from './schBaseVehiclematerialgroup'
|
||||
import CRUD, { crud, form, header, presenter } from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import crudOperation from '@crud/CRUD.operation'
|
||||
import udOperation from '@crud/UD.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
import crudMdBaseWorkShop from '@/views/wms/basedata/workshop/mdBaseWorkshop'
|
||||
import MaterialDialog from '@/views/wms/sch/group/MaterialDialog.vue'
|
||||
@@ -365,7 +366,7 @@ const defaultForm = {
|
||||
export default {
|
||||
name: 'VehicleMaterialGroup',
|
||||
dicts: ['group_status', 'group_bind_material_status'],
|
||||
components: { WorkOrderDialog, MaterialDialog, pagination, crudOperation, rrOperation },
|
||||
components: { WorkOrderDialog, MaterialDialog, pagination, crudOperation, rrOperation, udOperation },
|
||||
mixins: [presenter(), header(), form(defaultForm), crud()],
|
||||
cruds() {
|
||||
return CRUD({
|
||||
|
||||
Reference in New Issue
Block a user