缓存线手持服务接口更新

This commit is contained in:
2023-03-24 10:21:01 +08:00
parent 4676c418b0
commit 8cc3caa49b
13 changed files with 2575 additions and 632 deletions

View File

@@ -0,0 +1,37 @@
package org.nl.common.utils;
import com.alibaba.fastjson.JSONArray;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import lombok.extern.slf4j.Slf4j;
import org.nl.wms.pda.dto.MaterialDto;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.List;
import java.util.concurrent.TimeUnit;
@Slf4j
@Component
public class LocalCache{
private Cache<String,List<MaterialDto>> localCache = null;
@PostConstruct
private void init() {
localCache = CacheBuilder.newBuilder()
//设置本地缓存容器的初始容量
.initialCapacity(10)
//设置本地缓存的最大容量
.maximumSize(500)
//设置写缓存后多少秒过期
.expireAfterWrite(60, TimeUnit.SECONDS).build();
}
public void setLocalCache(String key, List<MaterialDto> object) {
localCache.put(key, object);
}
public List<MaterialDto> get(String key) {
return localCache.getIfPresent(key);
}
}

View File

@@ -0,0 +1,141 @@
package org.nl.common.utils.api;
/**
* 通用返回对象
*
* @author gbx
* @date 2023-03-02
*/
public class CommonResult<T> {
private long code;
private String desc;
private T result;
public CommonResult() {
}
protected CommonResult(T result) {
this.result = result;
this.desc = ResultCode.SUCCESS.getDesc();
this.code = ResultCode.SUCCESS.getCode();
}
protected CommonResult(long code, String desc, T result) {
this.code = code;
this.desc = desc;
this.result = result;
}
/**
* 成功返回结果
*/
public static <T> CommonResult<T> success() {
return new CommonResult<>(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getDesc(), null);
}
/**
* 成功返回结果
*
* @param result 获取的数据
*/
public static <T> CommonResult<T> success(T result) {
return new CommonResult<>(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getDesc(), result);
}
/**
* 成功返回结果
*
* @param result 获取的数据
* @param desc 提示信息
*/
public static <T> CommonResult<T> success(T result, String desc) {
return new CommonResult<>(ResultCode.SUCCESS.getCode(), desc, result);
}
/**
* 失败返回结果
* @param errorCode 错误码
*/
public static <T> CommonResult<T> failed(IErrorCode errorCode) {
return new CommonResult<>(errorCode.getCode(), errorCode.getDesc(), null);
}
/**
* 失败返回结果
* @param errorCode 错误码
* @param desc 错误信息
*/
public static <T> CommonResult<T> failed(IErrorCode errorCode,String desc) {
return new CommonResult<>(errorCode.getCode(), desc, null);
}
/**
* 失败返回结果
* @param desc 提示信息
*/
public static <T> CommonResult<T> failed(String desc) {
return new CommonResult<>(ResultCode.FAILED.getCode(), desc, null);
}
/**
* 失败返回结果
*/
public static <T> CommonResult<T> failed() {
return failed(ResultCode.FAILED);
}
/**
* 参数验证失败返回结果
*/
public static <T> CommonResult<T> validateFailed() {
return failed(ResultCode.VALIDATE_FAILED);
}
/**
* 参数验证失败返回结果
* @param desc 提示信息
*/
public static <T> CommonResult<T> validateFailed(String desc) {
return new CommonResult<>(ResultCode.MISS_PARAMETER.getCode(), desc, null);
}
/**
* 未登录返回结果
*/
public static <T> CommonResult<T> unauthorized(T result) {
return new CommonResult<>(ResultCode.UNAUTHORIZED.getCode(), ResultCode.UNAUTHORIZED.getDesc(), result);
}
/**
* 未授权返回结果
*/
public static <T> CommonResult<T> forbidden(T result) {
return new CommonResult<>(ResultCode.FORBIDDEN.getCode(), ResultCode.FORBIDDEN.getDesc(), result);
}
public long getCode() {
return code;
}
public void setCode(long code) {
this.code = code;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public T getResult() {
return result;
}
public void setResult(T result) {
this.result = result;
}
}

View File

@@ -0,0 +1,19 @@
package org.nl.common.utils.api;
/**
* 封装API的错误码
*
* @author gbx
* @date 2023-03-02
*/
public interface IErrorCode{
/**
* 返回状态码
*/
long getCode();
/**
* 返回提示
*/
String getDesc();
}

View File

@@ -0,0 +1,85 @@
package org.nl.common.utils.api;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.nl.modules.common.exception.BizCoreException;
/**
* 回调
*
* @author gbx
* @date 2023-03-02
*/
@Slf4j
public class RestBusinessTemplate{
public static <T> CommonResult<T> execute(Callback<T> callback) {
CommonResult<T> result = new CommonResult<>();
try {
result.setCode(ResultCode.SUCCESS.getCode());
result.setDesc(ResultCode.SUCCESS.getDesc());
T object = callback.doExecute();
if(object != null) {
result.setResult(object);
}
}
catch(BizCoreException e) {
String errorMsg;
if(StringUtils.isNotBlank(e.getErrorMsg())) {
errorMsg = e.getErrorMsg();
}
else if(e.getCode() != null) {
errorMsg = e.getCode().getDesc();
}
else{
errorMsg = e.getMessage();
}
log.error(e.getErrorMsg());
ResultCode code = e.getCode() == null ? ResultCode.FAILED : e.getCode();
result.setCode(code.getCode());
result.setDesc(errorMsg);
}
catch(Exception e) {
log.error("execute error", e);
result.setCode(ResultCode.FAILED.getCode());
result.setDesc(ResultCode.FAILED.getDesc());
}
return result;
}
public static CommonResult<Void> execute(VoidCallback callback) {
CommonResult<Void> result = new CommonResult<>();
try {
callback.execute();
result.setCode(ResultCode.SUCCESS.getCode());
result.setDesc(ResultCode.SUCCESS.getDesc());
}
catch(BizCoreException e) {
log.error("", e);
ResultCode code = e.getCode() == null ? ResultCode.FAILED : e.getCode();
result.setCode(code.getCode());
result.setDesc(StringUtils.isBlank(e.getMessage()) ? code.getDesc() : e.getMessage());
}
catch(Exception e) {
log.error("execute error", e);
result.setCode(ResultCode.FAILED.getCode());
result.setDesc(ResultCode.FAILED.getDesc());
}
return result;
}
/**
* 执行回调
*
* @param <T>
*/
public interface Callback<T>{
T doExecute();
}
/**
* 执行回调
*/
public interface VoidCallback{
void execute();
}
}

View File

@@ -0,0 +1,78 @@
package org.nl.common.utils.api;
/**
* 枚举了一些常用API操作码
*
* @author gbx
* @date 2023-03-02
*/
public enum ResultCode implements IErrorCode{
SUCCESS(1, "操作成功"),
FAILED(0, "操作失败"),
MISS_PARAMETER(400, "参数缺失"),
UNAUTHORIZED(401, "暂未登录或token已经过期"),
INVALID_PARAMETER(402, "无效参数"),
FORBIDDEN(403, "没有相关权限"),
VALIDATE_FAILED(404, "参数检验失败"),
INVALID_CAPTCHA(503, "验证码已失效或验证码错误"),
/**
* 员工相关异常 1000 1199
*/
STAFF_NOT_FOUND(1000, "员工不存在"),
STAFF_EXISTED(1001, "员工已存在"),
/**
* 部门相关异常 1200 1399
*/
DEPT_EXIST(1200, "部门已存在"),
PARENT_DEPT_STATUS_EXCEPTION(1201, "父部门状态异常"),
DEPT_NOT_EXIST(1202, "部门不存在"),
/**
* 岗位相关异常 1400 1599
*/
POST_EXIST(1400, "岗位已存在"),
POST_NOT_EXIST(1401, "岗位不存在"),
/**
* 菜单相关异常 1600 1799
*/
MENU_EXIST(1600, "菜单已存在"),
MENU_NOT_EXIST(1601, "菜单不存在"),
MENU_STATUS_EXCEPTION(1602, "菜单状态异常"),
/**
* 角色相关异常 1800 1999
*/
ROLE_EXIST(1800, "角色已存在"),
ROLE_NOT_EXIST(1801, "角色不存在"),
/**
* 账户相关异常 2000 2099
*/
ACCOUNT_EXCEPTION(2000, "账户异常"),
INVALID_RECHARGE_AMOUNT(2001, "无效金额"),
BALANCE_NOT_ENOUGH(2002, "余额不足"),
ACCOUNT_NOT_EXIST(2003, "账户不存在"),
STORAGE_NOT_ENOUGH(2004, "库存不足"),
IS_EXCHANGED(2005, "已有兑换"),
/**
* 短信相关 2100 2199
*/
ERR_MESSAGE(2100, "短信发送失败"),
ERR_SEND_LIMIT(2101, "短信发送上限"),
ERR_PHONE(2102, "短信号码不正确"),
ERR_Content(2103, "短信内容不能为空");
private final long code;
private final String desc;
ResultCode(long code, String desc) {
this.code = code;
this.desc = desc;
}
@Override
public long getCode() {
return code;
}
@Override
public String getDesc() {
return desc;
}
}

View File

@@ -0,0 +1,87 @@
package org.nl.modules.common.exception;
import org.nl.common.utils.api.ResultCode;
/**
* 业务异常
*
* @author gbx
* @date 2022-03-21
*/
public class BizCoreException extends RuntimeException{
private static final long serialVersionUID = -430613633714952314L;
/**
* 错误描述生成错误响应时如果该值不为空则返回message否则返回code对象的描述值
*/
private String errorMsg;
private ResultCode code = ResultCode.FAILED;
/**
* 构造方法
*/
public BizCoreException(String message) {
super(message);
this.errorMsg = message;
}
/**
* 构造方法
*/
public BizCoreException(String message, ResultCode code) {
super(message);
this.errorMsg = message;
this.code = code;
}
/**
* 构造方法
*/
public BizCoreException(ResultCode code) {
super(code.getDesc());
this.code = code;
}
/**
* 构造方法
*/
public BizCoreException(String message, Throwable e) {
super(message, e);
this.errorMsg = message;
}
/**
* 构造方法
*/
public BizCoreException(String message, ResultCode code, Throwable e) {
super(message, e);
this.errorMsg = message;
this.code = code;
}
/**
* 构造方法
*/
public BizCoreException(Throwable e) {
super(e);
this.errorMsg = e.getMessage();
}
/**
* 构造方法
*/
public BizCoreException(ResultCode code, Throwable e) {
super(e);
this.code = code;
}
public ResultCode getCode() {
return code;
}
public void setCode(ResultCode code) {
this.code = code;
}
public String getErrorMsg() {
return this.errorMsg;
}
}

View File

@@ -0,0 +1,30 @@
package org.nl.wms.pda.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @author gbx
* @description 载具库存
* @date 2023-03-23
**/
@Data
public class CachelineVehileMaterialDto implements Serializable{
/**
* 载具库存标识
*/
private String vehmaterial_uuid;
/**
* 缓存线位置编码
*/
private String position_code;
/**
* 缓存线编码
*/
private String cacheLine_code;
/**
* 载具编码
*/
private String vehicle_code;
}

View File

@@ -0,0 +1,34 @@
package org.nl.wms.pda.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @author gbx
* @description 物料列表
* @date 2023-03-23
**/
@Data
public class MaterialDto implements Serializable{
/**
* 物料标识
*/
private String material_uuid;
/**
* 编码
*/
private String material_code;
/**
* 规格
*/
private String material_spec;
/**
* 名称
*/
private String material_name;
/**
* 系列
*/
private String class_name;
}

View File

@@ -0,0 +1,113 @@
package org.nl.wms.pda.rest;
import cn.dev33.satoken.annotation.SaIgnore;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.nl.common.anno.Log;
import org.nl.common.utils.api.CommonResult;
import org.nl.common.utils.api.RestBusinessTemplate;
import org.nl.common.utils.api.ResultCode;
import org.nl.modules.common.exception.BizCoreException;
import org.nl.wms.pda.service.CacheLineHandService;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
* 海亮缓存线手持服务
*
* @author gbx
* @since 2023/3/22
*/
@RestController
@RequiredArgsConstructor
@Api(tags = "海亮缓存线手持服务")
@RequestMapping("/api/cacheLineHand")
@Slf4j
@SaIgnore
public class CacheLineHandController{
private final CacheLineHandService cacheLineHandService;
@PostMapping("/materialQuery")
@Log("物料查询")
@ApiOperation("物料查询")
public CommonResult<Object> materialQuery(@RequestBody JSONObject form) {
log.info("海亮缓存线手持服务 [查询物料] 接口被请求, 请求参数-{}", form);
return RestBusinessTemplate.execute(() -> cacheLineHandService.materialQuery(form.getString("search_bar")));
}
@PostMapping("/semiMaterialSpecQuery")
@Log("规格下拉框查询")
@ApiOperation("规格下拉框查询")
public CommonResult<Object> semiMaterialSpecQuery(@RequestBody JSONObject form) {
log.info("海亮缓存线手持服务 [规格下拉框查询] 接口被请求, 请求参数-{}", form);
return RestBusinessTemplate.execute(() -> cacheLineHandService.materialQuery(form.getString("form")));
}
@PostMapping("/workProcedureQuery")
@Log("工序下拉框查询")
@ApiOperation("工序下拉框查询")
public CommonResult<Object> workProcedureQuery(@RequestBody JSONObject form) {
log.info("海亮缓存线手持服务 [工序下拉框查询] 接口被请求, 请求参数-{}", form);
return RestBusinessTemplate.execute(() -> cacheLineHandService.workProcedureQuery(form.getString("form")));
}
@PostMapping("/deviceQuery")
@Log("缓存线设备下拉框查询")
@ApiOperation("缓存线设备下拉框查询")
public CommonResult<Object> deviceQuery(@RequestBody JSONObject form) {
log.info("海亮缓存线手持服务 [缓存线设备下拉框查询] 接口被请求, 请求参数-{}", form);
return RestBusinessTemplate.execute(() -> cacheLineHandService.deviceQuery(form.getString("form")));
}
@PostMapping("/instStatusQuery")
@Log("指令状态下拉框查询")
@ApiOperation("指令状态下拉框查询")
public CommonResult<Object> instStatusQuery(@RequestBody JSONObject form) {
log.info("海亮缓存线手持服务 [指令状态下拉框查询] 接口被请求, 请求参数-{}", form);
return RestBusinessTemplate.execute(() -> cacheLineHandService.instStatusQuery(form.getString("form")));
}
@PostMapping("/instPageQuery")
@Log("任务分页查询")
@ApiOperation("任务分页数据")
public CommonResult<Object> instPageQuery(@RequestBody Map param, Pageable page) {
log.info("海亮缓存线手持服务 [任务分页查询] 接口被请求, 请求参数-{}", param);
return RestBusinessTemplate.execute(() -> {
if(null == param) {
throw new BizCoreException(ResultCode.MISS_PARAMETER);
}
return cacheLineHandService.instPageQuery(param, page);
});
}
@PostMapping("/cacheLineMaterCheck")
@Log("缓存线物料盘点")
@ApiOperation("缓存线物料盘点")
public CommonResult<Object> cacheLineMaterCheck(@RequestBody JSONObject param) {
log.info("海亮缓存线手持服务 [缓存线物料盘点] 接口被请求, 请求参数-{}", param);
return RestBusinessTemplate.execute(cacheLineHandService::cacheLineMaterCheck);
}
@PostMapping("/instOperation")
@Log("任务操作")
@ApiOperation("任务操作")
public CommonResult<Void> instOperation(@RequestBody JSONObject param) {
log.info("海亮缓存线手持服务 [任务操作] 接口被请求, 请求参数-{}", param);
return RestBusinessTemplate.execute(() -> {
//任务类型和任务ID校验instruct_uuid为前端参数命名本来应为task_id
if(StringUtils.isEmpty(param.getString("instruct_uuid")) || StringUtils.isEmpty(param.getString("opt_type"))) {
throw new BizCoreException(ResultCode.MISS_PARAMETER);
}
cacheLineHandService.instOperation(param);
});
}
}

View File

@@ -0,0 +1,274 @@
package org.nl.wms.pda.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.nl.wms.pda.dto.MaterialDto;
import org.springframework.data.domain.Pageable;
import java.util.List;
import java.util.Map;
/**
* 海亮缓存线手持服务
*
* @author gbx
* @date 2023/3/22
*/
public interface CacheLineHandService{
/**
* 下拉框列表查询
*
* @Param: form 查询条件
* @return: 下拉框列表
* @author gbx
* @date 2023/3/22
*/
JSONArray dropdownListQuery(String param, String type);
/**
* 物料查询
*
* @Param: param 查询条件
* @return: 物料列表
* @author gbx
* @date 2023/3/22
*/
List<MaterialDto> materialQuery(String param);
/**
* 规格下拉框查询
*
* @Param: form 查询条件
* @return: 规格下拉框列表
* @author gbx
* @date 2023/3/22
*/
JSONArray semiMaterialSpecQuery(String param);
/**
* 工序下拉框查询
*
* @Param: form 查询条件
* @return: 工序列表
* @author gbx
* @date 2023/3/22
*/
JSONArray workProcedureQuery(String param);
/**
* 缓存线设备下拉框查询
*
* @Param: form 查询条件
* @return: 设备列表
* @author gbx
* @date 2023/3/22
*/
JSONArray deviceQuery(String param);
/**
* 任务状态下拉框查询
*
* @Param: form 查询条件
* @return: 指令状态列表
* @author gbx
* @date 2023/3/22
*/
JSONArray instStatusQuery(String param);
/**
* 任务操作
*
* @Param: form 任务参数
* @return: 操作结果
* @author gbx
* @date 2023/3/23
*/
void instOperation(JSONObject param);
/**
* 任务分页查询
*
* @Param: form 任务参数
* @return: 分页列表
* @author gbx
* @date 2023/3/23
*/
Map<String,Object> instPageQuery(Map<String,String> param, Pageable page);
/**
* 缓存线盘点
*
* @author gbx
* @date 2023/3/24
*/
Object cacheLineMaterCheck();
/**
* 缓存线料箱条码查询料箱信息
*
* @param param
* @return
* @author gbx
* @date 2023/3/24
*/
Object cachelineMaterInfoQuery(JSONObject param);
/**
* 空箱初始化--出入空箱
*
* @param param 查询参数 inOut_type:1 入空箱 2 出空箱 vehicle_code:载具编码
* @return
* @author gbx
* @date 2023/3/24
*/
Object inOutEmptyBox(JSONObject param);
/**
* 缓存线出入箱异常指令查询
*
* @param param 查询参数 1 扫码异常-入箱扫码 2 扫码异常-出箱扫码
* @return
* @author gbx
* @date 2023/3/24
*/
Object inOutExceptionInstQuery(JSONObject param);
/**
* 缓存线出入箱异常指令确认
*
* @param param 查询参数 1 扫码异常-入箱扫码 2 扫码异常-出箱扫码
* @return
* @author gbx
* @date 2023/3/24
*/
Object inOutExceptionInstConfirm(JSONObject param);
/**
* 设置满匡
*
* @param param
* @return
* @author gbx
* @date 2023/3/24
*/
Object setfullBox(JSONObject param);
/**
* 设置空框
*
* @param param
* @return
* @author gbx
* @date 2023/3/24
*/
Object setEmptyBox(JSONObject param);
/**
* AGV入箱异常-查询
*
* @param param
* @return
* @author gbx
* @date 2023/3/24
*/
Object agvInBoxExceptionQuery(JSONObject param);
/**
* AGV入箱异常-确认
*
* @param param
* @return
* @author gbx
* @date 2023/3/24
*/
Object agvInBoxExceptionConfirm(JSONObject param);
/**
* AGV出箱异常-查询
*
* @param param
* @return
* @author gbx
* @date 2023/3/24
*/
Object agvOutBoxExceptionQuery(JSONObject param);
/**
* AGV出箱异常-确认
*
* @param param
* @return
* @author gbx
* @date 2023/3/24
*/
Object agvOutBoxExceptionConfirm(JSONObject param);
/**
* 缓存线出箱异常-查询
*
* @param param
* @return
* @author gbx
* @date 2023/3/24
*/
Object cacheLineOutBoxExceptionQuery(String account_uuid, JSONObject param);
/**
* 缓存线出箱异常-确认
*
* @param param
* @return
* @author gbx
* @date 2023/3/24
*/
Object cacheLineOutBoxExceptionConfirm(
String account_uuid, JSONObject param);
/**
* 设置缓存线货位为空位置
*
* @param param
* @return
* @author gbx
* @date 2023/3/24
*/
Object setBlankPos(JSONObject param);
/**
* @param param
* @return
* @author gbx
* @date 2023/3/24
*/
Object cacheLineOutBoxExceptionQuery(
JSONObject param);
/**
* @param param
* @return
* @author gbx
* @date 2023/3/24
*/
Object cacheLineOutBoxExceptionConfirm(
JSONObject param);
/**
* 缓存线异常处理
*
* @param param
* @return
* @author gbx
* @date 2023/3/24
*/
Object cacheLineExcepOpt(JSONObject param);
/**
* 倒料操作
*
* @param param
* @return
* @author gbx
* @date 2023/3/24
*/
Object pourMaterial(JSONObject param);
}

View File

@@ -0,0 +1,868 @@
package org.nl.wms.pda.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.nl.common.utils.LocalCache;
import org.nl.common.utils.SecurityUtils;
import org.nl.config.thread.ThreadPoolExecutorUtil;
import org.nl.modules.common.utils.RedisUtils;
import org.nl.modules.wql.WQL;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.wms.pda.dto.CachelineVehileMaterialDto;
import org.nl.wms.pda.dto.MaterialDto;
import org.nl.wms.pda.service.CacheLineHandService;
import org.nl.wms.sch.service.impl.TaskServiceImpl;
import org.nl.wms.sch.tasks.PointToPointTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
* @author gbx
* @Description: Title: CacheLineHandServiceImpl.java Description: 3中异常类型:
* 1、比如要N个空箱子或N个满料料箱。查询出来以后一个码都无法扫描出来这时候标记这些箱子为异常
* 2、箱码扫描不出来则用手持经过WMS中转传输给WCS最后给电器。
* 3、AGV搬运过程中异常非AGVERR,查询条件为设备、起始点等未完成的时候(有可能不是异常)。
* @date 2023/3/22
*/
@Service
@RequiredArgsConstructor
@Slf4j
public class CacheLineHandServiceImpl implements CacheLineHandService{
private final RedisUtils redisUtils;
private final TaskServiceImpl taskServiceImp;
@Autowired
private LocalCache cache;
@Override
public JSONArray dropdownListQuery(String param, String type) {
//初始化下拉框列表1.物料规格2.工序3.指令状态4.设备
return WQL.getWO("PDA_QUERY").addParam("flag", type).addParam("condition", param).process().getResultJSONArray(0);
}
@Override
public List<MaterialDto> materialQuery(String param) {
// StopWatch stopWatch = new StopWatch();
// stopWatch.start();
// stopWatch.stop();
// System.out.println("缓存本地花费时间 totalTime = " + stopWatch.getTotalTimeMillis());
List<MaterialDto> materialList;
ThreadPoolExecutor pool = ThreadPoolExecutorUtil.getPoll();
//12W种物料信息查本地缓存
materialList = cache.get("materialList");
if(null != materialList) {
return getMaterialDto(materialList, param);
}
//2.查reids
materialList = redisUtils.get("materialList", MaterialDto.class);
if(null != materialList) {
//设置本地缓存
cache.setLocalCache("materialList", materialList);
return getMaterialDto(materialList, param);
}
//3.查db缓存到本地与redis
JSONArray materialJsonArray = WQL.getWO("PDA_QUERY").addParam("flag", "5").process().getResultJSONArray(0);
materialList = materialJsonArray.toJavaList(MaterialDto.class);
List<MaterialDto> finalMaterialList = materialList;
CompletableFuture<Void> f1 = CompletableFuture.runAsync(() -> cache.setLocalCache("materialList", finalMaterialList), pool);
List<MaterialDto> finalMaterialList1 = materialList;
CompletableFuture<Void> f2 = CompletableFuture.runAsync(() -> redisUtils.set("materialList", finalMaterialList1, 3600, TimeUnit.SECONDS), pool);
return getMaterialDto(materialList, param);
}
/**
* 按条件查询物料信息
*/
@NotNull
private List<MaterialDto> getMaterialDto(List<MaterialDto> materialList, String param) {
if(StringUtils.isNotEmpty(param)) {
//按条件搜索
materialList = materialList.stream().filter(m -> (m.getMaterial_name().indexOf(param) > -1) || (m.getMaterial_code().indexOf(param)) > -1 || (m.getMaterial_spec().indexOf(param)) > -1).collect(Collectors.toList());
return materialList;
}
return materialList;
}
@Override
public JSONArray semiMaterialSpecQuery(String param) {
return WQL.getWO("PDA_QUERY").addParam("flag", "1").addParam("condition", param).process().getResultJSONArray(0);
}
@Override
public JSONArray workProcedureQuery(String param) {
return WQL.getWO("PDA_QUERY").addParam("flag", "2").addParam("condition", param).process().getResultJSONArray(0);
}
@Override
public JSONArray instStatusQuery(String param) {
return WQL.getWO("PDA_QUERY").addParam("flag", "3").addParam("condition", param).process().getResultJSONArray(0);
}
@Override
public JSONArray deviceQuery(String param) {
return WQL.getWO("PDA_QUERY").addParam("flag", "4").addParam("condition", param).process().getResultJSONArray(0);
}
@Override
public Map<String,Object> instPageQuery(Map<String,String> param, Pageable page) {
return taskServiceImp.queryAll(param, page);
}
@Override
public void instOperation(JSONObject param) {
String optType = param.getString("opt_type");
PointToPointTask pointToPointTask = new PointToPointTask();
WQLObject taskTab = WQLObject.getWQLObject("sch_base_task");
JSONObject taskObject = taskTab.query("task_id =" + param.getString("instruct_uuid")).uniqueResult(0);
//01-取消、02-完成、03-重发,根据操作类型执行相关操作
if("01".equals(optType) || "02".equals(optType)) {
updateTaskStatus(taskObject, optType);
}
if("03".equals(optType)) {
pointToPointTask.createTask(taskObject);
}
}
/**
* 任务取消和完成操作,更新任务状态
*/
public void updateTaskStatus(JSONObject taskObj, String status) {
String currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
HashMap<String,String> map = new HashMap<String,String>(4);
map.put("task_status", status);
map.put("update_optid", currentUserId);
map.put("update_optname", nickName);
map.put("update_time", DateUtil.now());
WQLObject.getWQLObject("sch_base_task").update(map, "task_id = '" + taskObj.getString("task_id") + "'");
}
@Override
public Object cacheLineMaterCheck() {
WQLObject positionTab = WQLObject.getWQLObject("sch_cacheline_position");
JSONArray positionArr = positionTab.query("is_delete = '0'").getResultJSONArray(0);
// 缓存线位置表
List<CachelineVehileMaterialDto> positionList = positionArr.toJavaList(CachelineVehileMaterialDto.class);
WQLObject ivtTab = WQLObject.getWQLObject("sch_cacheline_vehilematerial");
JSONArray ivtArr = ivtTab.query("is_delete = '0'").getResultJSONArray(0);
// 缓存线载具物料表
List<CachelineVehileMaterialDto> ivtList = ivtArr.toJavaList(CachelineVehileMaterialDto.class);
//取缓存线位置表多出来的物料
List<CachelineVehileMaterialDto> resultList = positionList.stream().filter(p -> !ivtList.stream().map(e -> e.getCacheLine_code() + "&" + e.getVehicle_code()).collect(Collectors.toList()).contains(p.getCacheLine_code() + "&" + p.getVehicle_code())).collect(Collectors.toList());
//取载具物料表多出来的物料
List<CachelineVehileMaterialDto> resultLists = ivtList.stream().filter(i -> !positionList.stream().map(e -> e.getCacheLine_code() + "&" + e.getVehicle_code()).collect(Collectors.toList()).contains(i.getCacheLine_code() + "&" + i.getVehicle_code())).collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(resultList)) {
//TODO 缓存线位置表多出来的物料处理
}
if(CollectionUtil.isNotEmpty(resultLists)) {
//TODO 载具物料表多出来的物料处理
}
return null;
}
/**
* 0空位 status = 1 绿色空箱 || status = 2黄色满箱 || status = 3:红色异常 || status = 4 :不显示
*/
@Override
public Object cachelineMaterInfoQuery(JSONObject param) {
/*
* JSONArray arr = WQL.getWO("QWCS_CACHE_004").addParam("flag", "3")
* .addParam("extdevice_code",
* param.opt("wcsdevice_code")).process().getResultJSONArray(0); for (int i = 0;
* i < arr.size(); i++) { JSONObject json = arr.getJSONObject(i); // 默认非异常
* json.put("is_err", "0"); // 去掉小数 json.put("weight",
* uMath.multiply(obj.getString("weight"), "1", 0)); json.put("status",
* obj.getString("status").substring(1, 2));
*
* if (!"00".equals(obj.getString("err_type"))) { json.put("is_err", "1"); } }
*/
// for(int i = 0; i < arr.size(); i++) {
// JSONObject json = arr.getJSONObject(i);
// json.put("seat_order_num", json.opt("order_no"));
// // 0空位 status = 1 绿色空箱 || status = 2黄色满箱 || status = 3:红色异常 || status = 4 :不显示
// json.put("weight", "0");
// json.put("quantity", "0");
// if("0".equals(obj.getString("is_show"))) {
// json.put("vehicle_status", "04");
// }
// else{// 显示
// if("1".equals(obj.getString("is_blank"))) {
// json.put("vehicle_status", "00");
// }
// else{// 载具不为空
// String vehicle_code = obj.getString("vehicle_code");
// JSONObject ivtObj = ivtTab.query("vehicle_code = '" + vehicle_code + "' and extdevice_code like '%" + param.opt("wcsdevice_code") + "%'").uniqueResult(0);
// if(ivtObj == null) {
// // 异常
// json.put("vehicle_status", "03");
// }
// else{
// json.put("vehicle_status", ivtObj.optString("vehicle_status"));
// json.put("weight", ivtObj.optString("weight"));
// json.put("quantity", ivtObj.optString("quantity"));
// json.putAll(ivtObj);
// }
// }
// }
// json.put("is_err", "0");
// json.put("wcsdevice_code", obj.getString("extdevice_code"));
// // 去掉小数
// json.put("weight", uMath.multiply(obj.getString("weight"), "1", 0));
// json.put("status", obj.getString("vehicle_status").substring(1, 2));
// if(!"00".equals(obj.getString("err_type"))) {
// json.put("is_err", "1");
// }
// }
// srb.addJSONArray("result", arr);
// srb.setDesc("查询成功!");
return null;
}
/**
* 出入空箱,出入类型 inOut_type 1 入空箱 2 出空箱 缓存线编码 wcsdevice_code 料箱码 vehicle_code
*/
@Override
public Object inOutEmptyBox(JSONObject param) {
//
// String inOut_type = param.optString("inOut_type");
// String extdevice_code = param.optString("wcsdevice_code");
// String vehicle_code = param.optString("vehicle_code");
// // 缓存线位置表【IF_CacheLine_Position】
// WQLObject positionTab = WQLObject.getWQLObject("IF_CacheLine_Position");
// WQLObject vehMaterTab = WQLObject.getWQLObject("IF_CacheLine_VehileMaterial");
// // 入空箱
// if("1".equals(inOut_type)) {
// // 判断是否可以放入空箱子
// JSONObject ivtObj = positionTab.query("vehicle_code = '" + vehicle_code + "'").uniqueResult(0);
// // 判断箱子是否在缓存线内
// if(ivtObj != null) {
// throw new WDKException("箱子【" + vehicle_code + "】已在库内,无法入空箱!");
// }
// // 判断是否可以放入空箱子
// JSONObject json = positionTab.query("extdevice_code = '" + extdevice_code + "' and is_blank= '1'").uniqueResult(0);
// if(json == null) {
// throw new WDKException("无法找到缓存线【" + extdevice_code + "】的空位,无法入空箱!");
// }
// // 入了空箱子
// JSONObject afterIvt = new JSONObject();
// afterIvt.put("vehmaterial_uuid", WDK.getUUID());
// afterIvt.put("vehicle_uuid", vehicle_code);
// afterIvt.put("vehicle_code", vehicle_code);
// afterIvt.put("extdevice_code", extdevice_code);
// afterIvt.put("vehicle_status", "01");
// afterIvt.put("update_time", WDK.getDateTime());
// afterIvt.put("create_time", WDK.getDateTime());
// vehMaterTab.insert(afterIvt);
// }
// // 出空箱
// if("2".equals(inOut_type)) {
// // 缓存线载具物料表【IF_CacheLine_VehileMaterial】
// JSONObject json = vehMaterTab.query("extdevice_code = '" + extdevice_code + "' and vehicle_status= '01' and vehicle_code = '" + vehicle_code + "'").uniqueResult(0);
// if(json == null) {
// throw new WDKException("无法找到缓存线【" + extdevice_code + "】的空箱【" + vehicle_code + "】,出空箱失败");
// }
// // 删除掉出库的箱子
// vehMaterTab.delete("extdevice_code = '" + extdevice_code + "' and vehicle_code = '" + vehicle_code + "'");
// }
return null;
}
@Override
public Object inOutExceptionInstQuery(JSONObject param) {
//
// // 1 扫码异常-入箱扫码 2 扫码异常-出箱扫码
// // 出入类型 inOut_type
// // 缓存线编码 wcsdevice_code
// // 料箱码 vehicle_code
// // {"inOut_type":"1","wcsdevice_code":"HCX01","vehicle_code":"10001"}
// String vehicle_code = param.optString("vehicle_code");
// String wcsdevice_code = param.optString("wcsdevice_code");
// String inOut_type = param.optString("inOut_type");
// WQLObject instructTab = WQLObject.getWQLObject("IF_WCS_InstructPoint");
// JSONArray result = new JSONArray();
// // 入箱扫码异常
// if("1".equals(inOut_type)) {
// String where = "nextwcsdevice_code = '" + wcsdevice_code + "' and instruct_status <> '06'";
// if(uString.isNotBlank(vehicle_code)) {
// where = "nextwcsdevice_code = '" + wcsdevice_code + "' and invehicle_code = '" + vehicle_code + "' and instruct_status <> '06'";
// }
// JSONArray arr = instructTab.query(where).getResultJSONArray(0);
// for(int i = 0; i < arr.size(); i++) {
// JSONObject row = arr.getJSONObject(i);
// JSONObject json = new JSONObject();
// json.put("instruct_uuid", row.optString("instruct_uuid"));
// json.put("instructorder_no", row.optString("instructorder_no"));
// json.put("wcsdevice_code", row.optString("nextwcsdevice_code"));
// json.put("vehicle_code", row.optString("invehicle_code"));
// json.put("startpoint_code", row.optString("startpoint_code"));
// json.put("nextpoint_code", row.optString("nextpoint_code"));
// json.put("nextpoint_code2", row.optString("nextpoint_code2"));
// result.add(json);
// }
// }
// // 出箱扫码异常
// if("2".equals(inOut_type)) {
// String where = "startwcsdevice_code = '" + wcsdevice_code + "' and instruct_status <> '06'";
// if(uString.isNotBlank(vehicle_code)) {
// where = "startwcsdevice_code = '" + wcsdevice_code + "' and outvehicle_code = '" + vehicle_code + "' and instruct_status <> '06'";
// }
// JSONArray arr = instructTab.query(where).getResultJSONArray(0);
// for(int i = 0; i < arr.size(); i++) {
// JSONObject row = arr.getJSONObject(i);
// JSONObject json = new JSONObject();
// json.put("instruct_uuid", row.optString("instruct_uuid"));
// json.put("instructorder_no", row.optString("instructorder_no"));
// json.put("vehicle_code", row.optString("outvehicle_code"));
// json.put("wcsdevice_code", row.optString("startwcsdevice_code"));
// json.put("startpoint_code", row.optString("startpoint_code"));
// json.put("nextpoint_code", row.optString("nextpoint_code"));
// json.put("nextpoint_code2", row.optString("nextpoint_code2"));
// result.add(json);
// }
// }
// srb.addJSONArray("result", result);
return null;
}
/**
* "inOut_type": "1",1 扫码异常-入箱扫码,2 扫码异常-出箱扫码 "wcsdevice_code": "HCX01",
* "vehicle_code": "10001", "instruct_uuid": "uuid_0101" }
*/
@Override
public Object inOutExceptionInstConfirm(JSONObject param) {
//
// WQLObject instructTab = WQLObject.getWQLObject("IF_WCS_InstructPoint");
// // 1 扫码异常-入箱扫码 2 扫码异常-出箱扫码
// String inOut_type = param.optString("inOut_type");
// // 缓存线编码
// String wcsdevice_code = param.optString("wcsdevice_code");
// //
// String vehicle_code = param.optString("vehicle_code");
// // 指令标识
// // String instruct_uuid = param.optString("instruct_uuid");
// // JSONObject instObj = instructTab.query("instruct_uuid = '" + instruct_uuid +
// // "'").uniqueResult(0);
// // 封装给wcs的数据
// Object[] data = new Object[3];
// data[0] = inOut_type;
// data[1] = wcsdevice_code;
// data[2] = vehicle_code;
// uWcsSchedule.notifyWcs(99, 3001, data);
return null;
}
/**
* 设置满箱物料 缓存线编码 wcsdevice_code 料箱码 vehicle_code 工序标识 workprocedure_uuid 物料标识
* material_uuid 数量 quantity 重量 weight
*/
@Override
public Object setfullBox(JSONObject param) {
//
// String semimanufactures_uuid = param.optString("material_uuid");
// // 料箱码
// String vehicle_code = param.optString("vehicle_code");
// // 层数
// String layer_num = param.optString("layer_num");
// // 顺序号
// String seat_order_num = param.optString("seat_order_num");
// // 缓存线
// String wcsdevice_code = param.optString("wcsdevice_code");
// String weight = param.optString("weight");
// String quantity = param.optString("quantity");
// if(uString.isEmpty(quantity) || param.optInt("quantity") <= 0) {
// srb.setFailure();
// srb.setDesc("数量必须大于0!");
// return null;
// }
// String workprocedure_code = param.optString("workprocedure_uuid");
// // 判断载具编码是否存在
// // 缓存线载具条码表【IF_CacheLine_Vehicle】
// /*
// * WQLObject wql=WQLObject.getWQLObject("IF_CacheLine_Vehicle"); JSONObject
// * vehiobj =
// * wql.query("is_delete='0' AND is_active='1' AND vehicle_code = '"+vehicle_code
// * +"'").uniqueResult(0); if (vehiobj==null) { srb.setFailure();
// * srb.setDesc("条码【" + vehicle_code + "】不存在或已被删除,操作失败!"); return null; }
// */
// WQLObject positionTab = WQLObject.getWQLObject("IF_CacheLine_Position");
// JSONObject vehiobj = positionTab.query("order_no = " + seat_order_num + " and layer_num = " + layer_num + " and extdevice_code like '%" + wcsdevice_code + "%'").uniqueResult(0);
// if(vehiobj == null) {
// srb.setFailure();
// srb.setDesc("位置不存在,设置有误!");
// return null;
// }
// // 判断物料去的缓存线是否正确
// // PDM_BI_WorkshopMaterialCorr
// WQLObject corrTab = WQLObject.getWQLObject("PDM_BI_WorkshopMaterialCorr");
// WQLObject wpTab = WQLObject.getWQLObject("PDM_BI_WorkProcedure");
// // 设置工序信息
// JSONObject wpObj = wpTab.query("workprocedure_code = '" + workprocedure_code + "'").uniqueResult(0);
// // 物料系列
// String materialprocess_series = corrTab.query("semimanufactures_uuid = '" + semimanufactures_uuid + "'").uniqueResult(0).optString("materialprocess_series");
// AgvTwoInst inst = new AgvTwoInst();
// String cachelineCode2 = inst.getCachelineCode(materialprocess_series, wpObj.optString("workprocedure_code"));
// if(!wcsdevice_code.equals(cachelineCode2)) {
// String materialprocess_seriesname = WQLObject.getWQLObject("PF_PB_SysDicInfo").query("sysdic_type = 'IF_WCS_DEVICESERIES' and sysdic_code = '" + materialprocess_series + "'").uniqueResult(0).optString("sysdic_name");
// srb.setFailure();
// srb.setDesc("该缓存线【" + wcsdevice_code + "】不能存放【" + materialprocess_seriesname + "】物料,操作失败!");
// return null;
// }
// vehiobj.put("vehicle_code", vehicle_code);
// vehiobj.put("vehicle_uuid", vehicle_code);
// positionTab.update(vehiobj);
// WQLObject materTab = WQLObject.getWQLObject("PDM_BI_SemiMaterialCorr");
// // 缓存线载具物料表【IF_CacheLine_VehileMaterial】
// WQLObject ivtTab = WQLObject.getWQLObject("IF_CacheLine_VehileMaterial");
// // ivtTab.delete("extdevice_code = '" + wcsdevice_code + "' and vehicle_code =
// // '" + vehicle_code + "'");
// ivtTab.delete("vehicle_code = '" + vehicle_code + "'");
// // 物料信息
// JSONObject materObj = materTab.query("semimanufactures_uuid = '" + semimanufactures_uuid + "'").uniqueResult(0);
// HashMap<String,String> json = new HashMap<String,String>();
// json.put("vehmaterial_uuid", WDK.getUUID());
// json.put("vehicle_code", vehicle_code);
// json.put("vehicle_uuid", vehicle_code);
// json.put("extdevice_code", wcsdevice_code);
// json.put("material_uuid", materObj.optString("semimanufactures_uuid"));
// json.put("material_code", materObj.optString("semimanufactures_code"));
// json.put("material_spec", materObj.optString("semimanufactures_spec"));
// json.put("material_name", materObj.optString("semimanufactures_name"));
// json.put("weight", weight);
// json.put("quantity", quantity);
// json.put("workprocedure_uuid", wpObj.optString("workprocedure_uuid"));
// json.put("workprocedure_code", wpObj.optString("workprocedure_code"));
// json.put("workprocedure_name", wpObj.optString("workprocedure_name"));
// // 有箱有料
// json.put("vehicle_status", "02");
// json.put("create_time", WDK.getDateTime());
// ivtTab.insert(json);
return null;
}
@Override
public Object setEmptyBox(JSONObject param) {
//
// // 层数
// String layer_num = param.optString("layer_num");
// // 顺序号
// String seat_order_num = param.optString("seat_order_num");
// // 载具条码
// String vehicle_code = param.optString("vehicle_code");
// // 缓存线编码
// String wcsdevice_code = param.optString("wcsdevice_code");
// // 判断载具编码是否存在
// // 缓存线载具条码表【IF_CacheLine_Vehicle】
// /*
// * WQLObject wql=WQLObject.getWQLObject("IF_CacheLine_Vehicle"); JSONObject
// * vehiobj =
// * wql.query("is_delete='0' AND is_active='1' AND vehicle_code = '"+vehicle_code
// * +"'").uniqueResult(0); if (vehiobj==null) { srb.setFailure();
// * srb.setDesc("条码【" + vehicle_code + "】不存在或已被删除,操作失败!"); return null; }
// */
// // 缓存线位置表【IF_CacheLine_Position】
// WQLObject positionTab = WQLObject.getWQLObject("IF_CacheLine_Position");
// JSONObject vehiobj = positionTab.query("order_no = " + seat_order_num + " and layer_num = " + layer_num + " and extdevice_code like '%" + wcsdevice_code + "%'").uniqueResult(0);
// if(vehiobj == null) {
// srb.setFailure();
// srb.setDesc("位置不存在,设置有误!");
// return null;
// }
// vehiobj.put("vehicle_code", vehicle_code);
// vehiobj.put("vehicle_uuid", vehicle_code);
// positionTab.update(vehiobj);
// // 缓存线载具物料表【IF_CacheLine_VehileMaterial】
// WQLObject ivtTab = WQLObject.getWQLObject("IF_CacheLine_VehileMaterial");
// // 先删除空箱子位置
// // ivtTab.delete("extdevice_code = '" + wcsdevice_code + "' and vehicle_code =
// // '" + vehicle_code + "'");
// ivtTab.delete("vehicle_code = '" + vehicle_code + "'");
// JSONObject json = new JSONObject();
// // 状态设置为空箱
// json.put("vehmaterial_uuid", WDK.getUUID());
// json.put("vehicle_code", vehicle_code);
// json.put("vehicle_uuid", vehicle_code);
// json.put("extdevice_code", wcsdevice_code);
// json.put("vehicle_status", "01");
// json.put("vehicle_code", vehicle_code);
// // json.put("vehicle_uuid", vehiobj.optString("vehicle_uuid"));
// json.put("material_uuid", "");
// json.put("material_code", "");
// json.put("material_spec", "");
// json.put("material_name", "");
// json.put("weight", "0");
// json.put("quantity", "0");
// json.put("workprocedure_uuid", "");
// json.put("workprocedure_code", "");
// json.put("workprocedure_name", "");
// json.put("create_time", WDK.getDateTime());
// ivtTab.insert(json);
return null;
}
@Override
public Object setBlankPos(JSONObject param) {
//
// // 层数
// String layer_num = param.optString("layer_num");
// // 顺序号
// String seat_order_num = param.optString("seat_order_num");
// // 缓存线编码
// String wcsdevice_code = param.optString("wcsdevice_code");
// // 缓存线位置表【IF_CacheLine_Position】
// WQLObject ivtTab = WQLObject.getWQLObject("IF_CacheLine_Position");
// JSONObject json = ivtTab.query("layer_num = " + layer_num + " and extdevice_code like '%" + wcsdevice_code + "%' and order_no = " + seat_order_num + "").uniqueResult(0);
// // 状态设置为空位
// json.put("is_blank", "1");
// json.put("vehicle_uuid", "");
// json.put("vehicle_code", "");
// ivtTab.update(json);
return null;
}
/**
* AGV入箱子异常,(怎么判断入箱子异常) 缓存线编码 wcsdevice_code 满箱码 vehicle_code
*/
@Override
public Object agvInBoxExceptionQuery(JSONObject param) {
// String vehicle_code = param.optString("vehicle_code");
// String wcsdevice_code = param.optString("wcsdevice_code");
// WQLObject instructTab = WQLObject.getWQLObject("IF_WCS_InstructPoint");
// String where = "nextwcsdevice_code = '" + wcsdevice_code + "' and invehicle_code = '" + vehicle_code + "' and instruct_status <> '06'";
// if(uString.isEmpty(vehicle_code)) {
// where = "nextwcsdevice_code = '" + wcsdevice_code + "' and instruct_status <> '06'";
// }
// JSONArray arr = instructTab.query(where).getResultJSONArray(0);
// JSONArray result = new JSONArray();
// for(int i = 0; i < arr.size(); i++) {
// JSONObject row = arr.getJSONObject(i);
// JSONObject json = new JSONObject();
// json.put("instruct_uuid", row.optString("instruct_uuid"));
// json.put("instructorder_no", row.optString("instructorder_no"));
// json.put("wcsdevice_code", row.optString("nextwcsdevice_code"));
// json.put("startpoint_code", row.optString("startpoint_code"));
// json.put("nextpoint_code", row.optString("nextpoint_code"));
// json.put("nextpoint_code2", row.optString("nextpoint_code2"));
// result.add(json);
// }
// srb.addJSONArray("result", result);
return null;
}
/**
* 缓存线编码 wcsdevice_code 满箱码 full_vehicle_code 空箱码 empty_vehicle_code 指令标识
* instruct_uuid
* { "wcsdevice_code": "HCX01", "full_vehicle_code": "10001",
* "empty_vehicle_code": "10002", "instruct_uuid": "uuid_0101" }
*/
@Override
public Object agvInBoxExceptionConfirm(JSONObject param) {
//
// WQLObject instructTab = WQLObject.getWQLObject("IF_WCS_InstructPoint");
// String instruct_uuid = param.optString("instruct_uuid");
// String extdevice_code = param.optString("wcsdevice_code");
// String empty_vehicle_code = param.optString("empty_vehicle_code");
// String full_vehicle_code = param.optString("full_vehicle_code");
// // 缓存线位置表【IF_CacheLine_Position】
// WQLObject positionTab = WQLObject.getWQLObject("IF_CacheLine_Position");
//
//
// /*
// * JSONObject emptyObj = positionTab
// * .query("is_active = '1' and is_delete = '0' and vehicle_code = '" +
// * empty_vehicle_code + "'") .uniqueResult(0);
// *
// * // 判断箱子是否存在 if (emptyObj == null) { srb.setFailure(); srb.setDesc("条码【" +
// * empty_vehicle_code + "】不存在,操作失败"); return null; } JSONObject fullObj =
// * positionTab .query("is_active = '1' and is_delete = '0' and vehicle_code = '"
// * + full_vehicle_code + "'") .uniqueResult(0); // 判断箱子是否存在 if (fullObj == null)
// * { srb.setFailure(); srb.setDesc("条码【" + full_vehicle_code + "】不存在,操作失败");
// * return null; }
// */
// JSONObject instObj = instructTab.query("instruct_uuid = '" + instruct_uuid + "'").uniqueResult(0);
// // 缓存线载具物料表【IF_CacheLine_VehileMaterial】
// WQLObject ivtTab = WQLObject.getWQLObject("IF_CacheLine_VehileMaterial");
// // 出的空箱子
// /*
// * JSONObject emptyBoxObj =
// * ivtTab.query("vehicle_status = '01' AND extdevice_code = '" + extdevice_code
// * + "' and outvehicle_code = '" + empty_vehicle_code + "'").uniqueResult(0); if
// * (emptyBoxObj == null ||
// * uString.isEmpty(emptyBoxObj.optString("vehicle_code"))) { srb.setFailure();
// * srb.setDesc("缓存线内的空箱:" + empty_vehicle_code + "不存在,操作失败"); return null; }
// *
// * // 找到空位子入满箱 JSONObject fullBoxObj =
// * ivtTab.query("is_blank = '1' AND extdevice_code = '" + extdevice_code + "'")
// * .uniqueResult(0); if (fullBoxObj == null) { srb.setFailure();
// * srb.setDesc("在缓存线:" + extdevice_code + "未找到可用的货位进行满箱入库!"); return null; }
// */
// // 删除出的空箱
// /*
// * ivtTab.delete(("vehicle_status = '01' AND extdevice_code = '" +
// * extdevice_code + "' and vehicle_code = '" + empty_vehicle_code + "'")); //
// * 更新入库物料信息 JSONObject afterIvt = new JSONObject();
// * afterIvt.put("vehmaterial_uuid", WDK.getUUID()); afterIvt.put("vehicle_code",
// * full_vehicle_code); afterIvt.put("vehicle_uuid", full_vehicle_code);
// * afterIvt.put("vehicle_status", "02"); afterIvt.put("produceorder_uuid",
// * instObj.optString("produceorder_uuid")); afterIvt.put("produceorder_code",
// * instObj.optString("produceorder_code")); afterIvt.put("workprocedure_uuid",
// * instObj.optString("startworkprocedure_uuid"));
// * afterIvt.put("workprocedure_code",
// * instObj.optString("startworkprocedure_code"));
// * afterIvt.put("workprocedure_name",
// * instObj.optString("startworkprocedure_name")); afterIvt.put("material_uuid",
// * instObj.optString("processmaterial_uuid")); afterIvt.put("material_code",
// * instObj.optString("processmaterial_code")); afterIvt.put("material_name",
// * instObj.optString("processmaterial_name")); afterIvt.put("material_spec",
// * instObj.optString("processmaterial_spec"));
// * afterIvt.put("deviceprocess_series",
// * instObj.optString("deviceprocess_series")); afterIvt.put("quantity",
// * instObj.optString("quantity")); afterIvt.put("weight",
// * instObj.optString("weight")); afterIvt.put("update_time", WDK.getDateTime());
// * afterIvt.put("create_time", WDK.getDateTime());
// *
// * ivtTab.insert(afterIvt);
// */
// AgvTwoInst inst = new AgvTwoInst();
// instObj.put("inboxtxm", full_vehicle_code);
// instObj.put("outboxtxm", empty_vehicle_code);
// inst.updateInstStatus(instObj, "1");
// inst.updateInstStatus(instObj, "2");
return null;
}
/**
* AGV出空箱异常
*/
@Override
public Object agvOutBoxExceptionQuery(JSONObject param) {
// String vehicle_code = param.optString("vehicle_code");
// String wcsdevice_code = param.optString("wcsdevice_code");
// JSONArray arr = new JSONArray();
// WQLObject instructTab = WQLObject.getWQLObject("IF_WCS_InstructPoint");
// if(uString.isEmpty(vehicle_code)) {
// arr = instructTab.query("startwcsdevice_code = '" + wcsdevice_code + "' and instruct_status <> '06'").getResultJSONArray(0);
// }
// else{
// arr = instructTab.query("startwcsdevice_code = '" + wcsdevice_code + "' and outvehicle_code = '" + vehicle_code + "' and instruct_status <> '06'").getResultJSONArray(0);
// }
// JSONArray result = new JSONArray();
// for(int i = 0; i < arr.size(); i++) {
// JSONObject row = arr.getJSONObject(i);
// JSONObject json = new JSONObject();
// json.put("instruct_uuid", row.optString("instruct_uuid"));
// json.put("instructorder_no", row.optString("instructorder_no"));
// json.put("wcsdevice_code", row.optString("startwcsdevice_code"));
// json.put("vehicle_code", row.optString("outvehicle_code"));
// json.put("startpoint_code", row.optString("startpoint_code"));
// json.put("nextpoint_code", row.optString("nextpoint_code"));
// json.put("nextpoint_code2", row.optString("nextpoint_code2"));
// result.add(json);
// }
// srb.addJSONArray("result", result);
return null;
}
/**
* AGV出空箱异常确认(AGV从缓存线拉物料去专机回来时候入箱异常) { "wcsdevice_code": "HCX01",
* "vehicle_code": "10001", "instruct_uuid": "222" }
*/
@Override
public Object agvOutBoxExceptionConfirm(JSONObject param) {
//
// WQLObject instructTab = WQLObject.getWQLObject("IF_WCS_InstructPoint");
// String instruct_uuid = param.optString("instruct_uuid");
// String vehicle_code = param.optString("vehicle_code");
// String extdevice_code = param.optString("wcsdevice_code");
// JSONObject instObj = instructTab.query("instruct_uuid = '" + instruct_uuid + "'").uniqueResult(0);
//
// /*
// * // 缓存线载具物料表【IF_CacheLine_VehileMaterial】 WQLObject ivtTab =
// * WQLObject.getWQLObject("IF_CacheLine_VehileMaterial"); //
// * 缓存线位置表【IF_CacheLine_Position】 WQLObject positionTab =
// * WQLObject.getWQLObject("IF_CacheLine_Position"); // 查看是否有空位入 JSONObject
// * positionObj = positionTab.query("is_blank = '1' AND extdevice_code = '" +
// * extdevice_code + "'") .uniqueResult(0);
// *
// * if (positionObj == null) {
// * srb.setFailure(); srb.setDesc("缓存线无剩余位置,操作失败"); return null;
// *
// * }
// *
// * // 入的空箱子 JSONObject afterIvt = new JSONObject();
// * afterIvt.put("vehmaterial_uuid", WDK.getUUID()); afterIvt.put("vehicle_uuid",
// * vehicle_code); afterIvt.put("vehicle_code", vehicle_code);
// * afterIvt.put("extdevice_code", extdevice_code);
// *
// * afterIvt.put("vehicle_status", "01"); afterIvt.put("produceorder_uuid", "");
// * afterIvt.put("produceorder_code", ""); afterIvt.put("workprocedure_uuid",
// * ""); afterIvt.put("workprocedure_code", "");
// * afterIvt.put("workprocedure_name", ""); afterIvt.put("material_uuid", "");
// * afterIvt.put("material_code", ""); afterIvt.put("material_name", "");
// * afterIvt.put("material_spec", ""); afterIvt.put("deviceprocess_series", "");
// * afterIvt.put("quantity", "0"); afterIvt.put("weight", "0");
// * afterIvt.put("update_time", WDK.getDateTime()); ivtTab.insert(afterIvt);
// */
// AgvTwoInst inst = new AgvTwoInst();
// // 出箱的时候入箱码和出箱码相同
// instObj.put("inboxtxm", vehicle_code);
// instObj.put("outboxtxm", vehicle_code);
// inst.updateInstStatus(instObj, "1");
// inst.updateInstStatus(instObj, "2");
return null;
}
/**
* 缓存线出箱异常查询
* <p>
* {"wcsdevice_code":"HCX01","agv_no":"2"}
* <p>
* 入满箱查找空箱,出满箱查找满箱时,如果电气经过一圈后查找不到指定条码的箱子,则报警提示; 入满箱空箱找不到: 1、
* 人工先将满箱拿下放在缓存线边上,然后人工找个有条码的空箱拿到满箱的专机上; 2、
* 通过手持选择缓存线设备输入agv车号查询出agv正在执行的指令点击确认按钮mes完成该任务进行满箱物料条码和缓存线设备的绑定同时wcs和agv删除指令。
* <p>
* 3、 Mes系统需要将指令中下发的空箱条码全部设置为异常指令也标识为异常 4、
* 人工还需要将缓存线锁定的任务状态进行复位操作,不影响其他任务的进行;(只有先复位,才能进行盘点,两者冲突) 5、
* 此时空箱说明已经没有了,管理人员必须立即处理,进行盘点检查缓存线物料和箱子信息,通过手持盘点操作保证缓存线有空箱,才能让缓存线设备继续进行出入操作。
* 出满箱找不到满箱: 1、
* 通过手持选择缓存线设备输入agv车号查询出agv正在执行的指令点击确认按钮mes将指令标识为异常同时wcs和agv删除指令。 2、
* Mes系统需要将指令中下发的满箱条码全部设置为异常 3、
* 人工还需要将缓存线锁定的任务状态进行复位操作,不影响其他任务的进行;(只有先复位,才能进行盘点,两者冲突) 4、
* 此时满箱说明已经没有了管理人员必须立即处理进行盘点检查缓存线物料和箱子信息通过手持盘点操作保证缓存线满箱物料和mes系统物料一致才能让缓存线设备继续进行出入操作。
*/
@Override
public Object cacheLineOutBoxExceptionQuery(
JSONObject param) {
//
// String agv_no = param.optString("agv_no");
// String wcsdevice_code = param.optString("wcsdevice_code");
// WQLObject instructTab = WQLObject.getWQLObject("IF_WCS_InstructPoint");
// JSONArray arr = instructTab.query("(startwcsdevice_code = '" + wcsdevice_code + "' or nextwcsdevice_code = '" + wcsdevice_code + "') and instruct_status <> '06' and agv_no like '%" + agv_no + "%'").getResultJSONArray(0);
// JSONArray result = new JSONArray();
// for(int i = 0; i < arr.size(); i++) {
// JSONObject row = arr.getJSONObject(i);
// JSONObject json = new JSONObject();
// json.put("instruct_uuid", row.optString("instruct_uuid"));
// json.put("instructorder_no", row.optString("instructorder_no"));
// json.put("wcsdevice_code", row.optString("startwcsdevice_code"));
// json.put("vehicle_code", "0");
// json.put("startpoint_code", row.optString("startpoint_code"));
// json.put("nextpoint_code", row.optString("nextpoint_code"));
// json.put("nextpoint_code2", row.optString("nextpoint_code2"));
// result.add(json);
// }
// srb.addJSONArray("result", result);
return null;
}
/**
* 缓存线出箱异常确认
*/
@Override
public Object cacheLineOutBoxExceptionConfirm(
JSONObject param) {
//
// WQLObject instructTab = WQLObject.getWQLObject("IF_WCS_InstructPoint");
// String instruct_uuid = param.optString("instruct_uuid");
// JSONObject instObj = instructTab.query("instruct_uuid = '" + instruct_uuid + "'").uniqueResult(0);
// if(instObj != null) {
// instObj.put("instruct_status", "06");
// instObj.put("instructfinish_mode", "02");
// instObj.put("update_time", WDK.getDateTime());
// instObj.put("remark", "缓存线出箱异常确认完成!");
// instructTab.update(instObj);
// // 把所以来该缓存线的AGV指令都完成掉
// if(instObj.optString("nextwcsdevice_code").contains("HCX")) {
// HashMap<String,String> map = new HashMap<>();
// map.put("instruct_status", "06");
// map.put("instructfinish_mode", "02");
// map.put("update_time", WDK.getDateTime());
// map.put("remark", "缓存线出箱异常确认完成!");
// instructTab.update(map, "nextwcsdevice_code = '" + instObj.optString("nextwcsdevice_code") + "' and instruct_status <> '06'");
// }
// // 把所以从该缓存线出AGV指令都完成掉
// if(instObj.optString("startwcsdevice_code").contains("HCX")) {
// HashMap<String,String> map = new HashMap<>();
// map.put("instruct_status", "06");
// map.put("instructfinish_mode", "02");
// map.put("update_time", WDK.getDateTime());
// map.put("remark", "缓存线出箱异常确认完成!");
// instructTab.update(map, "startwcsdevice_code = '" + instObj.optString("startwcsdevice_code") + "' and instruct_status <> '06'");
// }
// // 得到异常的载具号
// String vehicle_codeStr = instObj.optString("vehicle_code");
// String[] arr = vehicle_codeStr.split(",");
// // 缓存线载具物料表【IF_CacheLine_VehileMaterial】
// WQLObject ivtTab = WQLObject.getWQLObject("IF_CacheLine_VehileMaterial");
// for(String vehicle_code : arr) {
// HashMap<String,String> map = new HashMap<>();
// // 异常
// map.put("vehicle_status", "03");
// ivtTab.update(map, "vehicle_code = '" + vehicle_code + "'");
// }
// }
return null;
}
@Override
public Object cacheLineExcepOpt(JSONObject param) {
// // 缓存线编码
// String wcsdevice_code = param.optString("wcsdevice_code");
// // 01-暂停、02-启动
// String opt_type = param.optString("opt_type");
// System.out.println("操作类型:" + opt_type);
// Object[] objs = new Object[2];
// objs[0] = wcsdevice_code;
// // 类型:恢复是0暂停是1
// String type = "1";
// if("02".equals(opt_type)) {
// type = "0";
// }
// objs[1] = type;
// // 下发给wcs
// uWcsSchedule.notifyWcs(99, 1000, objs);
return null;
}
/**
* public static HttpContext getHttpContext(Pageable pageable) { HttpContext ctx
* = new HttpContext(getUUID()); ctx.setPage(pageable.getPageNumber() + 1 + "");
* ctx.setRows(pageable.getPageSize() + ""); return ctx; }
*/
@Override
public Object pourMaterial(JSONObject param) {
// // 指令标识
// String instruct_uuid = param.optString("instruct_uuid");
// // 指令点位表【IF_WCS_InstructPoint】
// JSONObject instObj = WQLObject.getWQLObject("IF_WCS_InstructPoint").query("instruct_uuid = '" + instruct_uuid + "'").uniqueResult(0);
// int putquantity = instObj.optInt("quantity");
// String producer = instObj.optString("nextwcsdevice_code");
// Object[] objs = new Object[2];
// objs[0] = producer;
// objs[1] = putquantity;
// // 下发给wcs
// uWcsSchedule.notifyWcs(99, 3002, objs);
return null;
}
@Override
public Object cacheLineOutBoxExceptionQuery(String account_uuid, JSONObject param) {
return null;
}
@Override
public Object cacheLineOutBoxExceptionConfirm(String account_uuid, JSONObject param) {
return null;
}
}

View File

@@ -0,0 +1,142 @@
[交易说明]
交易名: pda手持服务查询
所属模块:
功能简述:
版权所有:
表引用:
版本经历:
[数据库]
--指定数据库为空采用默认值默认为db.properties中列出的第一个库
[IO定义]
#################################################
## 表字段对应输入参数
#################################################
输入.flag TYPEAS s_string
输入.condition TYPEAS s_string
[临时表]
--这边列出来的临时表就会在运行期动态创建
[临时变量]
--所有中间过程变量均可在此处定义
[业务过程]
##########################################
# 1、输入输出检查 #
##########################################
##########################################
# 2、主过程前处理 #
##########################################
##########################################
# 3、业务主过程 #
##########################################
IF 输入.flag = "1"
QUERY
SELECT
material_id material_uuid,
material_code,
material_spec
FROM
md_me_materialbase
WHERE
is_delete = '0'
OPTION 输入.condition <> ""
material_code LIKE CONCAT ( '%', 输入.condition, '%' )
OR material_spec LIKE CONCAT ( '%', 输入.condition, '%' )
ENDOPTION
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "2"
QUERY
SELECT
workprocedure_id,
workprocedure_name,
workprocedure_code
FROM
PDM_BI_WorkProcedure
WHERE
is_used = '1'
OPTION 输入.condition <> ""
workprocedure_code LIKE CONCAT ( '%', 输入.condition, '%' )
OR workprocedure_name LIKE CONCAT ( '%', 输入.condition, '%' )
ENDOPTION
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "3"
QUERY
SELECT
dict_id id,
label text
FROM
sys_dict
WHERE
CODE = 'task_status'
OPTION 输入.condition <> ""
label LIKE CONCAT ( '%', 输入.condition, '%' )
ENDOPTION
ORDER BY dict_sort
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "4"
QUERY
SELECT
device_code id,
device_name text
FROM
`pdm_bi_device`
WHERE
is_delete = '0'
OPTION 输入.condition <> ""
device_name LIKE CONCAT ( '%', 输入.condition, '%' )
ENDOPTION
ORDER BY device_code DESC
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "5"
QUERY
SELECT
mb.material_id material_uuid,
mb.material_code,
mb.material_spec,
mb.material_name,
class.class_name
FROM
md_me_materialbase mb
LEFT JOIN MD_PB_ClassStandard class ON class.class_id = mb.material_type_id
WHERE
mb.is_delete = '0'
ENDSELECT
ENDQUERY
ENDIF