This commit is contained in:
2023-03-17 20:05:01 +08:00
parent 64277c28f7
commit aaf10a6edb
13 changed files with 320 additions and 17 deletions

View File

@@ -49,6 +49,14 @@ public interface StorageCellService {
*/
StorageCellDto findByCode(String code);
/**
* 根据编码查询
*
* @param parent_storage_code parent_storage_code
* @return StorageCell
*/
StorageCellDto findByParentCode(String parent_storage_code);
/**
* 根据地址查询
*

View File

@@ -83,7 +83,18 @@ public class StorageCellServiceImpl implements StorageCellService {
@Override
public StorageCellDto findByCode(String code) {
WQLObject wo = WQLObject.getWQLObject("acs_storage_cell");
JSONObject json = wo.query("code ='" + code + "'").uniqueResult(0);
JSONObject json = wo.query("storage_code ='" + code + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(json)){
final StorageCellDto obj = json.toJavaObject(StorageCellDto.class);
return obj;
}
return null;
}
@Override
public StorageCellDto findByParentCode(String parent_storage_code) {
WQLObject wo = WQLObject.getWQLObject("acs_storage_cell");
JSONObject json = wo.query("parent_storage_code ='" + parent_storage_code + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(json)){
final StorageCellDto obj = json.toJavaObject(StorageCellDto.class);
return obj;

View File

@@ -11,6 +11,8 @@ import lombok.extern.slf4j.Slf4j;
import org.nl.acs.agv.server.NDCAgvService;
import org.nl.acs.auto.run.OneNDCSocketConnectionAutoRun;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device.service.StorageCellService;
import org.nl.acs.device.service.impl.StorageCellServiceImpl;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
@@ -28,7 +30,9 @@ import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.impl.TaskServiceImpl;
import org.nl.modules.system.service.DictDetailService;
import org.nl.modules.system.service.ParamService;
import org.nl.modules.system.service.impl.DictDetailServiceImpl;
import org.nl.modules.system.service.impl.ParamServiceImpl;
import org.nl.modules.wql.util.SpringContextHolder;
@@ -46,6 +50,7 @@ import java.util.Map;
public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements DeviceDriver {
ParamService paramService = SpringContextHolder.getBean(ParamServiceImpl.class);
DictDetailService dictDetailService = SpringContextHolder.getBean(DictDetailServiceImpl.class);
InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class);
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
TaskService taskService = SpringContextHolder.getBean(TaskServiceImpl.class);
@@ -53,6 +58,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class);
StorageCellService storageCellService = SpringContextHolder.getBean(StorageCellServiceImpl.class);
int agvaddr = 0;
int agvaddr_copy = 0;
int weight = 0;
@@ -175,7 +181,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
JSONObject map = new JSONObject();
map.put("Vehiclecode", inst.getVehicle_code());
map.put("Status", "1");
map.put("Devicecode", inst.getStart_point_code());
map.put("Devicecode", storageCellService.findByCode(inst.getStart_point_code()).getParent_storage_code());
map.put("Taskcode", inst.getTask_code());
req.add(map);
HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req);
@@ -233,7 +239,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
JSONObject map = new JSONObject();
map.put("Vehiclecode", inst.getVehicle_code());
map.put("Status", "2");
map.put("Devicecode", inst.getStart_point_code());
map.put("Devicecode", storageCellService.findByCode(inst.getStart_point_code()).getParent_storage_code());
map.put("Taskcode", inst.getTask_code());
req.add(map);
HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req);
@@ -287,7 +293,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
JSONObject map = new JSONObject();
map.put("Vehiclecode", inst.getVehicle_code());
map.put("Status", "3");
map.put("Devicecode", inst.getNext_point_code());
map.put("Devicecode", storageCellService.findByCode(inst.getNext_point_code()).getParent_storage_code());
map.put("Taskcode", inst.getTask_code());
req.add(map);
HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req);
@@ -341,7 +347,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
JSONObject map = new JSONObject();
map.put("Vehiclecode", inst.getVehicle_code());
map.put("Status", "4");
map.put("Devicecode", inst.getNext_point_code());
map.put("Devicecode", storageCellService.findByCode(inst.getNext_point_code()).getParent_storage_code());
map.put("Taskcode", inst.getTask_code());
req.add(map);
HttpResponse httpResponse = acsToWmsService.feedAgvTaskStatus(req);

View File

@@ -12,6 +12,8 @@ import lombok.extern.slf4j.Slf4j;
import org.nl.acs.AcsConfig;
import org.nl.acs.common.IDriverService;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device.service.StorageCellService;
import org.nl.acs.device.service.dto.StorageCellDto;
import org.nl.acs.device_driver.basedriver.cargo_lift_conveyor.CargoLiftConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.empty_vehicle_stacking_position.EmptyVehicleStackingPositionDeviceDriver;
import org.nl.acs.device_driver.basedriver.hongxiang_conveyor.HongXiangStationDeviceDriver;
@@ -31,6 +33,8 @@ import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.system.domain.DictDetail;
import org.nl.modules.system.service.DictDetailService;
import org.nl.modules.system.service.ParamService;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.modules.wql.exception.WDKException;
@@ -58,7 +62,8 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
private final DeviceAppService deviceAppService;
private final RouteLineService routeLineService;
private final AcsToLiKuService acsToLiKuService;
private final DictDetailService dictDetailService;
private final StorageCellService storageCellService;
private String log_file_type = "log_file_type";
private String log_type = "LMS请求ACS";
@@ -493,6 +498,25 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
errArr.add(json);
continue;
}
StorageCellDto startParentCode = storageCellService.findByParentCode(start_device_code);
StorageCellDto nextParentCode = storageCellService.findByParentCode(next_device_code);
if (ObjectUtil.isEmpty(startParentCode)){
JSONObject json = new JSONObject();
json.put("task_code", task_code);
json.put("message", "ACS未查询到该设备!设备号:" + start_device_code);
errArr.add(json);
continue;
}
if (ObjectUtil.isEmpty(nextParentCode)){
JSONObject json = new JSONObject();
json.put("task_code", task_code);
json.put("message", "ACS未查询到该设备!设备号:" + next_device_code);
errArr.add(json);
continue;
}
//start_device_code = startParentCode.getStorage_code();
//next_device_code = nextParentCode.getStorage_code();
JSONObject start_device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + start_device_code + "'").uniqueResult(0);
if (!ObjectUtil.isEmpty(start_device_json)) {
start_point_code = (String) start_device_json.get("parent_storage_code") == null ? start_device_code : (String) start_device_json.get("storage_code");

View File

@@ -33,4 +33,8 @@ public interface DictDetailRepository extends JpaRepository<DictDetail, Long>, J
* @return /
*/
List<DictDetail> findByDictName(String name);
DictDetail findDictDetailByLabelAndName(String label,String name);
DictDetail findDictDetailByValueAndName(String value,String name);
}

View File

@@ -29,7 +29,9 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Set;
@@ -97,4 +99,12 @@ public class DictController {
dictService.delete(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
@PostMapping("/excelImport")
@Log("excel导入")
@ApiOperation("excel导入")
public ResponseEntity<Object> excelImport(@RequestParam("file") MultipartFile file, HttpServletRequest request) {
dictService.excelImport(file, request);
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@@ -61,4 +61,8 @@ public interface DictDetailService {
* @return /
*/
List<DictDetailDto> getDictByName(String name);
DictDetail findDictDetailByLabelAndName(String label,String name);
DictDetail findDictDetailByValueAndName(String value,String name);
}

View File

@@ -19,7 +19,9 @@ import org.nl.modules.system.domain.Dict;
import org.nl.modules.system.service.dto.DictDto;
import org.nl.modules.system.service.dto.DictQueryCriteria;
import org.springframework.data.domain.Pageable;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
@@ -73,4 +75,11 @@ public interface DictService {
* @throws IOException /
*/
void download(List<DictDto> queryAll, HttpServletResponse response) throws IOException;
/**
* excel导入
* @param file
* @param request
*/
void excelImport(MultipartFile file, HttpServletRequest request);
}

View File

@@ -39,9 +39,9 @@ import java.util.List;
import java.util.Map;
/**
* @author Zheng Jie
* @date 2019-04-10
*/
* @author Zheng Jie
* @date 2019-04-10
*/
@Service
@RequiredArgsConstructor
@CacheConfig(cacheNames = "dict")
@@ -53,8 +53,8 @@ public class DictDetailServiceImpl implements DictDetailService {
private final RedisUtils redisUtils;
@Override
public Map<String,Object> queryAll(DictDetailQueryCriteria criteria, Pageable pageable) {
Page<DictDetail> page = dictDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
public Map<String, Object> queryAll(DictDetailQueryCriteria criteria, Pageable pageable) {
Page<DictDetail> page = dictDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
return PageUtil.toPage(page.map(dictDetailMapper::toDto));
}
@@ -70,7 +70,7 @@ public class DictDetailServiceImpl implements DictDetailService {
@Transactional(rollbackFor = Exception.class)
public void update(DictDetail resources) {
DictDetail dictDetail = dictDetailRepository.findById(resources.getId()).orElseGet(DictDetail::new);
ValidationUtil.isNull( dictDetail.getId(),"DictDetail","id",resources.getId());
ValidationUtil.isNull(dictDetail.getId(), "DictDetail", "id", resources.getId());
resources.setId(dictDetail.getId());
dictDetailRepository.save(resources);
// 清理缓存
@@ -83,6 +83,16 @@ public class DictDetailServiceImpl implements DictDetailService {
return dictDetailMapper.toDto(dictDetailRepository.findByDictName(name));
}
@Override
public DictDetail findDictDetailByLabelAndName(String label, String name) {
return dictDetailRepository.findDictDetailByLabelAndName(label, name);
}
@Override
public DictDetail findDictDetailByValueAndName(String value, String name) {
return dictDetailRepository.findDictDetailByValueAndName(value, name);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
@@ -92,7 +102,7 @@ public class DictDetailServiceImpl implements DictDetailService {
dictDetailRepository.deleteById(id);
}
public void delCaches(DictDetail dictDetail){
public void delCaches(DictDetail dictDetail) {
Dict dict = dictRepository.findById(dictDetail.getDict().getId()).orElseGet(Dict::new);
redisUtils.del("dict::name:" + dict.getName());
}

View File

@@ -16,23 +16,38 @@
package org.nl.modules.system.service.impl;
import cn.hutool.core.collection.CollectionUtil;
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 cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import org.nl.acs.device.service.dto.DeviceDto;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.common.utils.*;
import org.nl.modules.system.domain.Dict;
import org.nl.modules.system.domain.DictDetail;
import org.nl.modules.system.repository.DictRepository;
import org.nl.modules.system.service.DictDetailService;
import org.nl.modules.system.service.DictService;
import org.nl.modules.system.service.dto.DictDetailDto;
import org.nl.modules.system.service.dto.DictDto;
import org.nl.modules.system.service.dto.DictQueryCriteria;
import org.nl.modules.system.service.mapstruct.DictMapper;
import org.nl.modules.wql.core.bean.WQLObject;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
/**
@@ -47,6 +62,7 @@ public class DictServiceImpl implements DictService {
private final DictRepository dictRepository;
private final DictMapper dictMapper;
private final RedisUtils redisUtils;
private final DictDetailService dictDetailService;
@Override
public Map<String, Object> queryAll(DictQueryCriteria dict, Pageable pageable){
@@ -116,6 +132,64 @@ public class DictServiceImpl implements DictService {
FileUtil.downloadExcel(list, response);
}
public List<Dict> queryAll(DictQueryCriteria dict,String a) {
List<Dict> list = dictRepository.findAll((root, query, cb) -> QueryHelp.getPredicate(root, dict, cb));
return list;
}
@Override
@Transactional
public void excelImport(MultipartFile file, HttpServletRequest request) {
if (file.isEmpty()) {
throw new BadRequestException("文件为空,请添加数据后重新导入");
}
Long currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
String now = DateUtil.now();
// 1.获取上传文件输入流
InputStream inputStream = null;
try {
inputStream = file.getInputStream();
} catch (Exception e) {
e.printStackTrace();
}
// 调用用 hutool 方法读取数据 默认调用第一个sheet
ExcelReader excelReader = ExcelUtil.getReader(inputStream);
// 从第二行开始获取数据 excelReader.read的结果是一个2纬的list外层是行内层是行对应的所有列
List<List<Object>> read = excelReader.read(1, excelReader.getRowCount());
// 循环获取的数据
for (int i = 0; i < read.size(); i++) {
List list = read.get(i);
JSONObject param = new JSONObject();
String label = list.get(0).toString();
String value = list.get(1).toString();
if (StrUtil.isEmpty(label)) {
throw new BadRequestException("wms编号不能为空!");
}
if (StrUtil.isEmpty(value)) {
throw new BadRequestException("acs编号不能为空!");
}
DictDetail detail = dictDetailService.findDictDetailByLabelAndName(label, "location_comparison");
if (ObjectUtil.isNotEmpty(detail)){
continue;
}
DictQueryCriteria dict = new DictQueryCriteria();
dict.setBlurry("location_comparison");
List<Dict> dictDtos = queryAll(dict,"");
Dict dictDto = dictDtos.get(0);
DictDetail dictDetail = new DictDetail();
dictDetail.setId(IdUtil.getSnowflake().nextId());
dictDetail.setDictSort(i + 1);
dictDetail.setLabel(label);
dictDetail.setValue(value);
dictDetail.setDict(dictDto);
dictDetail.setCreateBy(SecurityUtils.getCurrentUsername());
dictDetail.setName("location_comparison");
dictDetailService.create(dictDetail);
}
}
public void delCaches(Dict dict){
redisUtils.del("dict::name:" + dict.getName());
}