add:手动充电
This commit is contained in:
@@ -44,5 +44,5 @@ public interface NDCAgvService {
|
||||
*/
|
||||
public boolean createChargingTaskToNDC(String carno);
|
||||
|
||||
public void charge(String carno);
|
||||
public void charge(String carno,String station);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.nl.acs.agv.server.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -16,6 +17,7 @@ import org.nl.acs.log.LokiLogType;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.opc.DeviceAppServiceImpl;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.system.service.dict.ISysDictService;
|
||||
import org.nl.system.service.dict.dao.Dict;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
@@ -35,9 +37,7 @@ import java.util.Map;
|
||||
@Lazy
|
||||
public class NDCAgvServiceImpl implements NDCAgvService {
|
||||
|
||||
private final DeviceAppService deviceAppService;
|
||||
private final ISysParamService paramService;
|
||||
private final AcsToWmsService acsToWmsService;
|
||||
private final ISysDictService dictService;
|
||||
|
||||
private final DeviceExecuteLogService logServer;
|
||||
@@ -230,26 +230,14 @@ public class NDCAgvServiceImpl implements NDCAgvService {
|
||||
return b;
|
||||
}
|
||||
@Override
|
||||
public void charge(String carno) {
|
||||
//检查数据字典station为0的参数
|
||||
//分配车辆
|
||||
List<Dict> dictList= dictService.getDictByName("station");
|
||||
public void charge(String carno, String station) {
|
||||
//判断当前充电桩是否已下发充电任务
|
||||
Dict temp = dictService.getDictByName2("station", station);
|
||||
if (ObjectUtil.isNotEmpty(temp)) {
|
||||
int satation = 0;
|
||||
Dict temp=new Dict();
|
||||
for(Dict dict : dictList){
|
||||
if ("1".equals(dict.getValue())&&carno.equals(dict.getPara2())){
|
||||
log.info("当前车辆{}已分配充电桩{},退出后续判断",carno,dict.getPara1());
|
||||
return;
|
||||
if(ObjectUtil.isNotEmpty(temp)){
|
||||
satation = Integer.parseInt(temp.getPara1());
|
||||
}
|
||||
}
|
||||
for(Dict dict : dictList){
|
||||
if ("0".equals(dict.getValue())){
|
||||
satation = Integer.parseInt(dict.getPara1());
|
||||
temp=dict;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(satation!=0){
|
||||
String instcode =CodeUtil.getNewCode("INSTRUCT_NO");
|
||||
byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode));
|
||||
byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode));
|
||||
@@ -283,16 +271,16 @@ public class NDCAgvServiceImpl implements NDCAgvService {
|
||||
|
||||
try{
|
||||
OneNDCSocketConnectionAutoRun.write(b);
|
||||
temp.setValue("1");
|
||||
temp.setPara2(String.valueOf(carno));
|
||||
dictService.updateDetail(temp);
|
||||
} catch (Exception e){
|
||||
log.error("下发充电任务失败{}{}",e,e.getMessage());
|
||||
}
|
||||
|
||||
temp.setValue("1");
|
||||
temp.setPara2(String.valueOf(carno));
|
||||
dictService.updateDetail(temp);
|
||||
|
||||
} else {
|
||||
log.error("目前暂无可使用充电桩充电桩,暂不分配{}充电任务",carno);
|
||||
log.info("当前充电桩{}已被使用!请检查充电桩状态再操作!", station);
|
||||
throw new BadRequestException("当前充电桩已被使用或者车号不为空,请检查充电桩状态再操作!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.system.service.dict.ISysDictService;
|
||||
import org.nl.system.service.dict.dao.Dict;
|
||||
import org.nl.system.service.lucene.LuceneExecuteLogService;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
import org.nl.system.service.param.impl.SysParamServiceImpl;
|
||||
@@ -240,6 +241,28 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
}
|
||||
}
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||
} else if (phase == 0x64){
|
||||
log.info("AGV车号{}反馈充电任务下发成功,锁定充电桩{}",agvaddr,station);
|
||||
Dict dict = dictService.getDictByName3("station",String.valueOf(agvaddr),null);
|
||||
if (ObjectUtil.isNotEmpty(dict)){
|
||||
dict.setValue("1");
|
||||
dict.setPara2(String.valueOf(agvaddr));
|
||||
dict.setPara3("下发成功");
|
||||
dictService.updateDetail(dict);
|
||||
}
|
||||
//充电成功
|
||||
}else if (phase == 0x65){
|
||||
log.info("AGV车号{}反馈充电中,充电桩{}",agvaddr,station);
|
||||
//充电取消上报
|
||||
}else if (phase == 0x66){
|
||||
log.info("AGV车号{}反馈充电任务已取消,释放充电桩{}",agvaddr,station);
|
||||
Dict dict = dictService.getDictByName3("station",String.valueOf(agvaddr),null);
|
||||
if (ObjectUtil.isNotEmpty(dict)){
|
||||
dict.setValue("0");
|
||||
dict.setPara2("");
|
||||
dict.setPara3("充电桩空闲");
|
||||
dictService.updateDetail(dict);
|
||||
}
|
||||
}else {
|
||||
//上报异常信息
|
||||
//(不需要WCS反馈)
|
||||
|
||||
@@ -122,6 +122,15 @@ public class DeviceController {
|
||||
return new ResponseEntity<>(deviceService.selectList(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/selectCarList")
|
||||
@Log("下拉选车号")
|
||||
@ApiOperation("下拉选车号")
|
||||
//@PreAuthorize("@el.check('routePlan:list')")
|
||||
public ResponseEntity<Object> selectCarList() {
|
||||
return new ResponseEntity<>(deviceService.selectCarList(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/region/{region}")
|
||||
@Log("根据区域查询设备")
|
||||
@ApiOperation("根据区域查询设备")
|
||||
|
||||
@@ -333,4 +333,6 @@ public interface DeviceService extends CommonService<Device> {
|
||||
* @param request
|
||||
*/
|
||||
void excelImport(MultipartFile file, HttpServletRequest request);
|
||||
|
||||
JSONArray selectCarList();
|
||||
}
|
||||
|
||||
@@ -2115,6 +2115,21 @@ public class DeviceServiceImpl extends CommonServiceImpl<DeviceMapper, Device> i
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray selectCarList() {
|
||||
List<Device> deviceList = new LambdaQueryChainWrapper<>(deviceMapper).apply("device_type = 'agv' AND is_delete= '0' AND is_active= '1' AND is_config = 'true'").orderByAsc(Device::getDevice_code).list();
|
||||
JSONArray arr = JSONArray.parseArray(JSON.toJSONString(deviceList));
|
||||
JSONArray result = new JSONArray();
|
||||
for (int i = 0; i < arr.size(); i++) {
|
||||
JSONObject obj = arr.getJSONObject(i);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("device_code", obj.getString("device_code"));
|
||||
json.put("device_name", obj.getString("device_name"));
|
||||
result.add(json);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public Map<String, Object> getValue1(JSONArray wss, int j, Integer dbInterval, int i) {
|
||||
int size = wss.size();
|
||||
Map<String, Object> map = new ListOrderedMap<>();
|
||||
|
||||
@@ -365,4 +365,6 @@ public interface TaskService extends CommonService<Task> {
|
||||
* @return
|
||||
*/
|
||||
Integer querySameDeviceReadyTask(String start_device,String next_device,String status);
|
||||
|
||||
Task selectTaskByCarno(String carno);
|
||||
}
|
||||
|
||||
@@ -1774,6 +1774,11 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
return num;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task selectTaskByCarno(String carno) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Integer querySameTaskByType(String taskType) {
|
||||
|
||||
@@ -58,6 +58,14 @@ public class SysDictController {
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@Log("查询充电桩")
|
||||
@PutMapping( "/{car}")
|
||||
@ApiOperation("查询充电桩")
|
||||
// @SaCheckPermission("dict:list")
|
||||
public ResponseEntity<Object> selectStationByCar(@PathVariable String car){
|
||||
return new ResponseEntity<>(dictService.selectStationByCar(car), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改字典")
|
||||
@ApiOperation("修改字典")
|
||||
@@ -121,5 +129,18 @@ public class SysDictController {
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/initDict")
|
||||
@Log("初始化充电桩点位信息")
|
||||
public ResponseEntity<Object> initDict(@Validated @RequestBody Dict dto){
|
||||
dictService.initDict(dto);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@GetMapping("/showDetail2")
|
||||
@Log("查询字典明细")
|
||||
public ResponseEntity<Object> showDetail2(@RequestParam String name){
|
||||
return new ResponseEntity<>(dictService.getDictByName(name), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.nl.system.controller.param;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -79,6 +80,15 @@ class SysParamController {
|
||||
return new ResponseEntity<>(paramService.findByCode(code), HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PostMapping("/sendTask")
|
||||
@Log("下发充电任务")
|
||||
@ApiOperation("下发充电任务")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> sendTask(@RequestBody JSONObject json) {
|
||||
paramService.sendTask(json);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.nl.system.service.dict;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
@@ -85,4 +86,17 @@ public interface ISysDictService extends IService<Dict> {
|
||||
* @return
|
||||
*/
|
||||
List<Dict> queryAll();
|
||||
|
||||
JSONArray selectStationByCar(String car);
|
||||
|
||||
Dict getDictByName3(String name,String carno,String station);
|
||||
|
||||
Dict getDictByName2(String name,String station);
|
||||
|
||||
/**
|
||||
* 初始化充电桩点位信息
|
||||
* @param dto
|
||||
*/
|
||||
void initDict(Dict dto);
|
||||
|
||||
}
|
||||
|
||||
@@ -3,11 +3,17 @@ package org.nl.system.service.dict.impl;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
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.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.device.service.mapper.DeviceMapper;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
@@ -35,6 +41,8 @@ import java.util.Set;
|
||||
public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, Dict> implements ISysDictService {
|
||||
@Autowired
|
||||
private SysDictMapper sysDictMapper;
|
||||
@Autowired
|
||||
private DeviceMapper deviceMapper;
|
||||
|
||||
@Override
|
||||
public IPage<Dict> queryAll(Map whereJson, PageQuery page) {
|
||||
@@ -193,4 +201,75 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, Dict> impleme
|
||||
.groupBy(Dict::getCode, Dict::getName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray selectStationByCar(String car) {
|
||||
Device device = deviceMapper.selectOne(new QueryWrapper<Device>().eq("device_code", car));
|
||||
String manufacturer = device.getManufacturer();//车间
|
||||
List<Dict> stations = sysDictMapper.selectList(new LambdaQueryWrapper<Dict>().eq(Dict::getDict_type, manufacturer));
|
||||
JSONArray arr = JSONArray.parseArray(JSON.toJSONString(stations));
|
||||
JSONArray result = new JSONArray();
|
||||
for (int i = 0; i < arr.size(); i++) {
|
||||
JSONObject obj = arr.getJSONObject(i);
|
||||
JSONObject json = new JSONObject();
|
||||
String value = obj.getString("value");
|
||||
json.put("label", obj.getString("label") + ("1".equals(obj.getString("value")) ? "(已使用)" : "(未使用)"));
|
||||
json.put("para1", obj.getString("para1"));
|
||||
result.add(json);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dict getDictByName3(String name, String carno, String station) {
|
||||
Dict dict = null;
|
||||
List<Dict> dictList = sysDictMapper.selectList(
|
||||
new LambdaQueryWrapper<Dict>()
|
||||
.eq(Dict::getCode, name)
|
||||
.eq(ObjectUtil.isNotEmpty(carno), Dict::getPara2, carno)
|
||||
.eq(ObjectUtil.isNotEmpty(station), Dict::getPara1, station)
|
||||
.eq(Dict::getValue, "1")
|
||||
);
|
||||
if (ObjectUtil.isNotEmpty(dictList) && dictList.size() > 0) {
|
||||
dict = dictList.get(0);
|
||||
}
|
||||
return dict;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dict getDictByName2(String name, String station) {
|
||||
Dict dict = null;
|
||||
Dict dict1 = sysDictMapper.selectOne(
|
||||
new LambdaQueryWrapper<Dict>()
|
||||
.eq(Dict::getCode, name)
|
||||
.eq(ObjectUtil.isNotEmpty(station), Dict::getPara1, station)
|
||||
.eq(Dict::getValue, "0")
|
||||
.and(slam -> slam.isNull(Dict::getPara2)
|
||||
.or()
|
||||
.eq(Dict::getPara2, ""))
|
||||
);
|
||||
if (ObjectUtil.isNotEmpty(dict1)) {
|
||||
dict = dict1;
|
||||
}
|
||||
return dict;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void initDict(Dict dto) {
|
||||
Dict dict = sysDictMapper.selectById(dto.getDict_id());
|
||||
if (ObjectUtil.isEmpty(dict)) {
|
||||
throw new BadRequestException("字典不存在");
|
||||
}
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String currentNickName = SecurityUtils.getCurrentNickName();
|
||||
dict.setValue("0");
|
||||
dict.setPara2("");
|
||||
dict.setPara3("充电桩空闲");
|
||||
dict.setUpdate_id(currentUserId);
|
||||
dict.setUpdate_name(currentNickName);
|
||||
dict.setUpdate_time(DateUtil.now());
|
||||
sysDictMapper.updateById(dict);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.nl.system.service.param;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
@@ -55,4 +56,6 @@ public interface ISysParamService extends IService<Param> {
|
||||
* @return Param
|
||||
*/
|
||||
Param findByCode(String code);
|
||||
|
||||
void sendTask(JSONObject json);
|
||||
}
|
||||
|
||||
@@ -3,19 +3,29 @@ package org.nl.system.service.param.impl;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.agv.server.NDCAgvService;
|
||||
import org.nl.acs.task.domain.Task;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.mapper.TaskMapper;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.config.MapOf;
|
||||
import org.nl.system.service.dict.ISysDictService;
|
||||
import org.nl.system.service.dict.dao.Dict;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
import org.nl.system.service.param.dao.Param;
|
||||
import org.nl.system.service.param.dao.mapper.SysParamMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -36,7 +46,11 @@ public class SysParamServiceImpl extends ServiceImpl<SysParamMapper, Param> impl
|
||||
|
||||
@Autowired
|
||||
private SysParamMapper paramMapper;
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private NDCAgvService ndcAgvService;
|
||||
@Autowired
|
||||
private ISysDictService dictService;
|
||||
@Override
|
||||
public Page<Param> queryPage(Map whereJson, PageQuery page) {
|
||||
QueryWrapper<Param> queryWrapper = new QueryWrapper<>();
|
||||
@@ -94,4 +108,23 @@ public class SysParamServiceImpl extends ServiceImpl<SysParamMapper, Param> impl
|
||||
Param param = paramMapper.selectOne(queryWrapper);
|
||||
return param;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTask(JSONObject json) {
|
||||
String carno = json.getString("carno");
|
||||
String station = json.getString("station");
|
||||
if (StrUtil.isEmpty(carno)){
|
||||
throw new BadRequestException("车辆编号不能为空");
|
||||
}
|
||||
if (StrUtil.isEmpty(station)){
|
||||
throw new BadRequestException("充电站编号不能为空");
|
||||
}
|
||||
//判断是否已下发充电任务
|
||||
Dict dict1 = dictService.getDictByName3("station",carno,null);
|
||||
if(ObjectUtil.isNotEmpty(dict1)){
|
||||
log.info("当前车辆{}已分配充电桩{},退出后续判断",carno,dict1.getPara1());
|
||||
}else {
|
||||
ndcAgvService.charge(carno, station);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,9 +25,14 @@
|
||||
<!-- <logger name="org.nl.start.Init" level="info" additivity="false">
|
||||
<appender-ref ref="FILE3"/>
|
||||
</logger>-->
|
||||
<appender name="asyncFileAppender" class="ch.qos.logback.classic.AsyncAppender">
|
||||
<appender-ref ref="OneNDCSocketConnectionAutoRun" />
|
||||
<!-- 设置队列大小,根据您的需求调整 -->
|
||||
<queueSize>512</queueSize>
|
||||
</appender>
|
||||
|
||||
<!-- 打印sql -->
|
||||
<logger name="org.nl.acs.auto.run.OneNDCSocketConnectionAutoRun" level="info" additivity="false">
|
||||
<appender-ref ref="OneNDCSocketConnectionAutoRun"/>
|
||||
<logger name="org.nl.acs.auto.run.OneNDCSocketConnectionAutoRun" level="info" additivity="true">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
</logger>
|
||||
</included>
|
||||
|
||||
Reference in New Issue
Block a user