opt: 通知、点位管理、任务自动创建

This commit is contained in:
2025-09-28 14:44:23 +08:00
parent e69f55c046
commit 7b6fe148f0
14 changed files with 93 additions and 54 deletions

View File

@@ -95,4 +95,10 @@ public class SysNoticeController {
noticeService.changeRead(jsonObject);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@Log("全部已读")
@PostMapping("/allRead")
public ResponseEntity<Object> allRead(@RequestBody JSONObject jsonObject) {
noticeService.allRead(jsonObject);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
}

View File

@@ -81,4 +81,6 @@ public interface ISysNoticeService extends IService<SysNotice> {
* @param type: 类型
*/
void createNotice(String msg, String title, String type);
void allRead(JSONObject jsonObject);
}

View File

@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -183,10 +184,19 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
res.put("data", "notice_message_update");
SocketMsg messageInfo = new SocketMsg(res, MsgType.INFO);
try {
webSocketServer.sendInfo(messageInfo, "messageInfo");
WebSocketServer.sendInfo(messageInfo, "messageInfo");
} catch (IOException e) {
throw new BadRequestException(LangProcess.msg("error_Send"));
}
}
@Override
public void allRead(JSONObject jsonObject) {
LambdaUpdateWrapper<SysNotice> lam = new LambdaUpdateWrapper<>();
lam.set(SysNotice::getHave_read, "2")
.set(SysNotice::getRead_time, DateUtil.now())
.eq(SysNotice::getHave_read, "1");
this.update(lam);
}
}

View File

@@ -15,18 +15,9 @@
<select id="selectPageLeftJoin" resultType="org.nl.wms.sch.point.service.dao.SchBasePoint"
parameterType="org.nl.wms.sch.point.service.dto.SchBasePointQuery">
SELECT
p.*,
IF(LENGTH(vg.material_qty)>0,vg.material_qty,0) AS material_qty,
IF(LENGTH(mm.material_code)>0,mm.material_code,'-') AS material_code,
IF(LENGTH(mm.material_name)>0,mm.material_name,'-') AS material_name,
IF(LENGTH(mm.material_spec)>0,mm.material_spec,'-') AS material_spec,
IF(LENGTH(mm.material_model)>0,mm.material_model,'-') AS material_model,
IF(LENGTH(mm.raw_material_code)>0,mm.raw_material_code,'-') AS raw_material_code
p.*
FROM
`sch_base_point` p
LEFT JOIN sch_base_vehiclematerialgroup vg ON vg.vehicle_code = p.vehicle_code
AND vg.vehicle_type = p.vehicle_type AND vg.group_bind_material_status = '2'
LEFT JOIN md_base_material mm ON mm.material_id = vg.material_id
<where>
<if test="whereJson.workshop_code != null and whereJson.workshop_code != ''">
p.workshop_code = #{whereJson.workshop_code}

View File

@@ -194,15 +194,26 @@ public abstract class AbstractTask {
* @param taskConfig
* @param task
* @param apply_point_code
* @see TaskDirectionEnum
*/
protected void setTaskPoint(SchBaseTaskconfig taskConfig, SchBaseTask task, String apply_point_code) {
String taskDirection = taskConfig.getTask_direction();
if (TaskDirectionEnum.SEND.getValue().equals(taskDirection)) {
task.setPoint_code1(apply_point_code);
} else {
task.setPoint_code2(apply_point_code);
switch (taskDirection) {
case "1":
task.setPoint_code1(apply_point_code);
break;
case "2":
task.setPoint_code2(apply_point_code);
break;
case "3":
task.setPoint_code3(apply_point_code);
break;
case "4":
task.setPoint_code4(apply_point_code);
break;
default:
break;
}
}
/**
@@ -251,7 +262,6 @@ public abstract class AbstractTask {
SchBaseTask task = new SchBaseTask();
// 请求点
String applyPointCode = param.getString("device_code");
String requestNo = param.getString("requestNo");
String configCode = param.getString("config_code");
// 1、校验数据
@@ -276,13 +286,14 @@ public abstract class AbstractTask {
AbstractTask bean = SpringContextHolder.getBean(this.getClass());
// 2、创建申请任务
// task.setAcs_trace_id(requestNo);
task.setTask_id(IdUtil.getSnowflake(1, 1).nextIdStr());
task.setTask_code(IdUtil.getSnowflake(1, 1).nextIdStr());
task.setConfig_code(configCode);
task.setVehicle_code(vehicleCode);
task.setVehicle_type(vehicleType);
task.setTask_status(TaskStatus.APPLY.getCode());
// 设置起/终点
bean.setTaskPoint(taskConfig, task, applyPointCode);
// 将所有参数存到表中,后续需要可以提取
task.setRequest_param(JSONObject.toJSONString(param));
TaskUtils.setCreateByAcsOrPda(task, param);

View File

@@ -8,7 +8,6 @@ import org.reflections.Reflections;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
@@ -49,12 +48,8 @@ public class AutoCreateTask {
subTypes.forEach(clz -> {
// 调用AbstractAcsTask类的每个子类的schedule()方法
try {
Object obj = SpringContextHolder.getBean(clz);
Method m = obj.getClass().getMethod("schedule");
m.invoke(obj);
} catch (InvocationTargetException e) {
e.printStackTrace();
log.info("定时器执行失败:{}", e.getTargetException().getMessage());
AbstractTask obj = SpringContextHolder.getBean(clz);
obj.schedule();
} catch (Exception e) {
e.printStackTrace();
log.info("定时器执行失败:{}", e.getMessage());

View File

@@ -1,13 +1,7 @@
package org.nl.wms.sch.task_manage.enums;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.nl.config.SpringContextHolder;
import org.nl.system.service.dict.dao.Dict;
import org.nl.system.service.dict.impl.SysDictServiceImpl;
import java.util.List;
/**
* @Author: lyd
@@ -15,33 +9,26 @@ import java.util.List;
* @Date: 2023/5/25
*/
@Getter
@AllArgsConstructor
public enum TaskDirectionEnum {
/**
* 送货
*/
SEND,
POINT1_CONFIRM("1", "取货点1确认"),
/**
* 取货
*/
CALL,
POINT2_CONFIRM("2", "放货点1确认"),
/**
* 移货
*/
MOVE;
POINT3_CONFIRM("3", "取货点2确认"),
POINT4_CONFIRM("4", "放货点2确认"),
POINT_NO_CONFIRM("5", "无确认"),
private String value;
private String label;
;
static {
SysDictServiceImpl bean = SpringContextHolder.getBean(SysDictServiceImpl.class);
List<Dict> taskDirection = bean.list(new LambdaQueryWrapper<Dict>()
.eq(Dict::getCode, "task_direction")
.orderByAsc(Dict::getDict_sort));
TaskDirectionEnum[] values = TaskDirectionEnum.values();
for (int i = 0; i < values.length; i++) {
values[i].value = taskDirection.get(i).getValue();
values[i].label = taskDirection.get(i).getLabel();
}
}
private final String value;
private final String label;
}

View File

@@ -70,7 +70,7 @@ public class DemoTask extends AbstractTask {
// 进行找点创建任务,补齐任务数据
// ....
// 找终点
SchBasePoint point = findNextPoint(nextRegionStr);
SchBasePoint point = this.findNextPoint(nextRegionStr);
if (ObjectUtil.isEmpty(point)) {
task.setRemark("未找到所需点位!");
taskService.updateById(task);