rev:优化新增,修改,删除操作时返回的数据格式。

This commit is contained in:
2023-03-30 20:09:17 +08:00
parent 8530b2ec54
commit 9c3b4250f7
12 changed files with 1587 additions and 1584 deletions

View File

@@ -7,24 +7,24 @@ package org.nl.common.utils.api;
* @date 2023-03-02
*/
public class CommonResult<T> {
private long code;
private String desc;
private T result;
private long status;
private String message;
private T data;
public CommonResult() {
}
protected CommonResult(T result) {
this.result = result;
this.desc = ResultCode.SUCCESS.getDesc();
this.code = ResultCode.SUCCESS.getCode();
protected CommonResult(T data) {
this.data = data;
this.message = ResultCode.SUCCESS.getDesc();
this.status = ResultCode.SUCCESS.getCode();
}
protected CommonResult(long code, String desc, T result) {
this.code = code;
this.desc = desc;
this.result = result;
protected CommonResult(long status, String message, T data) {
this.status = status;
this.message = message;
this.data = data;
}
/**
@@ -38,20 +38,20 @@ public class CommonResult<T> {
/**
* 成功返回结果
*
* @param result 获取的数据
* @param data 获取的数据
*/
public static <T> CommonResult<T> success(T result) {
return new CommonResult<>(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getDesc(), result);
public static <T> CommonResult<T> success(T data) {
return new CommonResult<>(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getDesc(), data);
}
/**
* 成功返回结果
*
* @param result 获取的数据
* @param desc 提示信息
* @param data 获取的数据
* @param message 提示信息
*/
public static <T> CommonResult<T> success(T result, String desc) {
return new CommonResult<>(ResultCode.SUCCESS.getCode(), desc, result);
public static <T> CommonResult<T> success(T data, String message) {
return new CommonResult<>(ResultCode.SUCCESS.getCode(), message, data);
}
/**
@@ -65,18 +65,18 @@ public class CommonResult<T> {
/**
* 失败返回结果
* @param errorCode 错误码
* @param desc 错误信息
* @param message 错误信息
*/
public static <T> CommonResult<T> failed(IErrorCode errorCode,String desc) {
return new CommonResult<>(errorCode.getCode(), desc, null);
public static <T> CommonResult<T> failed(IErrorCode errorCode,String message) {
return new CommonResult<>(errorCode.getCode(), message, null);
}
/**
* 失败返回结果
* @param desc 提示信息
* @param message 提示信息
*/
public static <T> CommonResult<T> failed(String desc) {
return new CommonResult<>(ResultCode.FAILED.getCode(), desc, null);
public static <T> CommonResult<T> failed(String message) {
return new CommonResult<>(ResultCode.FAILED.getCode(), message, null);
}
/**
@@ -95,47 +95,47 @@ public class CommonResult<T> {
/**
* 参数验证失败返回结果
* @param desc 提示信息
* @param message 提示信息
*/
public static <T> CommonResult<T> validateFailed(String desc) {
return new CommonResult<>(ResultCode.MISS_PARAMETER.getCode(), desc, null);
public static <T> CommonResult<T> validateFailed(String message) {
return new CommonResult<>(ResultCode.MISS_PARAMETER.getCode(), message, null);
}
/**
* 未登录返回结果
*/
public static <T> CommonResult<T> unauthorized(T result) {
return new CommonResult<>(ResultCode.UNAUTHORIZED.getCode(), ResultCode.UNAUTHORIZED.getDesc(), result);
public static <T> CommonResult<T> unauthorized(T data) {
return new CommonResult<>(ResultCode.UNAUTHORIZED.getCode(), ResultCode.UNAUTHORIZED.getDesc(), data);
}
/**
* 未授权返回结果
*/
public static <T> CommonResult<T> forbidden(T result) {
return new CommonResult<>(ResultCode.FORBIDDEN.getCode(), ResultCode.FORBIDDEN.getDesc(), result);
public static <T> CommonResult<T> forbidden(T data) {
return new CommonResult<>(ResultCode.FORBIDDEN.getCode(), ResultCode.FORBIDDEN.getDesc(), data);
}
public long getCode() {
return code;
public long getStatus() {
return status;
}
public void setCode(long code) {
this.code = code;
public void setStatus(long status) {
this.status = status;
}
public String getDesc() {
return desc;
public String getMessage() {
return message;
}
public void setDesc(String desc) {
this.desc = desc;
public void setMessage(String message) {
this.message = message;
}
public T getResult() {
return result;
public T getData() {
return data;
}
public void setResult(T result) {
this.result = result;
public void setData(T data) {
this.data = data;
}
}

View File

@@ -15,11 +15,11 @@ 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());
result.setStatus(ResultCode.SUCCESS.getCode());
result.setMessage(ResultCode.SUCCESS.getDesc());
T object = callback.doExecute();
if(object != null) {
result.setResult(object);
result.setData(object);
}
}
catch(BizCoreException e) {
@@ -35,13 +35,46 @@ public class RestBusinessTemplate{
}
log.error(e.getErrorMsg());
ResultCode code = e.getCode() == null ? ResultCode.FAILED : e.getCode();
result.setCode(code.getCode());
result.setDesc(errorMsg);
result.setStatus(code.getCode());
result.setMessage(errorMsg);
}
catch(Exception e) {
log.error("execute error", e);
result.setCode(ResultCode.FAILED.getCode());
result.setDesc(ResultCode.FAILED.getDesc()+",原因是:"+e.getMessage());
result.setStatus(ResultCode.FAILED.getCode());
result.setMessage(ResultCode.FAILED.getDesc() + ",原因是:" + e.getMessage());
}
return result;
}
public static <T> CommonResult<T> execute(T object) {
CommonResult<T> result = new CommonResult<>();
try {
result.setStatus(ResultCode.SUCCESS.getCode());
result.setMessage(ResultCode.SUCCESS.getDesc());
if(object != null) {
result.setData(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.setStatus(code.getCode());
result.setMessage(errorMsg);
}
catch(Exception e) {
log.error("execute error", e);
result.setStatus(ResultCode.FAILED.getCode());
result.setMessage(ResultCode.FAILED.getDesc() + ",原因是:" + e);
}
return result;
}
@@ -50,19 +83,19 @@ public class RestBusinessTemplate{
CommonResult<Void> result = new CommonResult<>();
try {
callback.execute();
result.setCode(ResultCode.SUCCESS.getCode());
result.setDesc(ResultCode.SUCCESS.getDesc());
result.setStatus(ResultCode.SUCCESS.getCode());
result.setMessage(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());
result.setStatus(code.getCode());
result.setMessage(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());
result.setStatus(ResultCode.FAILED.getCode());
result.setMessage(ResultCode.FAILED.getDesc());
}
return result;
}

View File

@@ -7,7 +7,7 @@ package org.nl.common.utils.api;
* @date 2023-03-02
*/
public enum ResultCode implements IErrorCode{
SUCCESS(1, "操作成功"),
SUCCESS(200, "操作成功"),
FAILED(0, "操作失败"),
MISS_PARAMETER(400, "参数缺失"),
UNAUTHORIZED(401, "暂未登录或token已经过期"),

View File

@@ -51,7 +51,8 @@ public class MobileAuthorizationController {
@ApiOperation("登录授权")
@PostMapping(value = "/login")
@SaIgnore
public ResponseEntity<Object> login(@Validated @RequestBody AuthUserDto authUser, HttpServletRequest request) throws Exception {
public ResponseEntity<Object> login(@Validated @RequestBody AuthUserDto authUser, HttpServletRequest request)
throws Exception {
// 密码解密 - 前端的加密规则: encrypt根据实际更改
// String password = authUser.getPassword();
String password = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey, authUser.getPassword());
@@ -63,7 +64,6 @@ public class MobileAuthorizationController {
}
// 获取权限列表 - 登录查找权限
List<String> permissionList = roleService.getPermissionList(JSONObject.parseObject(JSON.toJSONString(userDto)));
// 登录输入,登出删除
CurrentUser user = new CurrentUser();
user.setId(userDto.getUserId());
@@ -71,13 +71,10 @@ public class MobileAuthorizationController {
user.setPresonName(userDto.getPersonName());
user.setUser(userDto);
user.setPermissions(permissionList);
// SaLoginModel 配置登录相关参数
StpUtil.login(userDto.getUserId(), new SaLoginModel()
.setDevice("PE") // 此次登录的客户端设备类型, 用于[同端互斥登录]时指定此次登录的设备类型
StpUtil.login(userDto.getUserId(), new SaLoginModel().setDevice("PE") // 此次登录的客户端设备类型, 用于[同端互斥登录]时指定此次登录的设备类型
.setExtra("loginInfo", user) // Token挂载的扩展参数 此方法只有在集成jwt插件时才会生效
);
// 返回 token 与 用户信息
JSONObject jsonObject = new JSONObject();
jsonObject.put("user", userDto);
@@ -85,9 +82,7 @@ public class MobileAuthorizationController {
put("token", StpUtil.getTokenValue());
put("user", jsonObject);
}};
redisUtils.set("pe-satoken", StpUtil.getTokenValue(), StpUtil.getTokenTimeout());
return ResponseEntity.ok(authInfo);
}
}

View File

@@ -36,22 +36,15 @@ import java.util.List;
public class ResultBean implements Serializable, Cloneable{
private static final long serialVersionUID = -7486919713117296262L;
private ArrayList rslist = null;
// 返回的结果集的个数
private int ResultCount = 0;
//如果是删除、更新类操作,返回受影响的记录数
private int RowsCount = 0;
private int sucess;
private ArrayList InfoDump = null;
private ArrayList InfoError = null;
private ArrayList InfoTrace = null;
public int getRowsCount() {
return RowsCount;
}
@@ -68,7 +61,8 @@ public class ResultBean implements Serializable, Cloneable {
public boolean isSuccess() {
if(1 == this.sucess) {
return true;
} else {
}
else{
return false;
}
}
@@ -95,13 +89,13 @@ public class ResultBean implements Serializable, Cloneable {
if(value < rslist.size()) {
if(rslist.get(value) instanceof RowSetDynaClass) {
return (ArrayList) ((RowSetDynaClass) rslist.get(value)).getRows();
} else {
}
else{
return (ArrayList) rslist.get(value);
}
}
return null;
}
// /**
// * 返回按bc定义的dataset
// * @param bc
@@ -147,7 +141,8 @@ public class ResultBean implements Serializable, Cloneable {
* @throws InstantiationException
* @throws IntrospectionException
*/
public ArrayList getObjects(int resultSet, Class c) throws Exception {
public ArrayList getObjects(int resultSet, Class c)
throws Exception {
JSONArray jrows = this.getResultJSONArray(resultSet);
ArrayList rows = new ArrayList();
for(int i = 0; i < jrows.size(); i++) {
@@ -157,8 +152,7 @@ public class ResultBean implements Serializable, Cloneable {
//反射读取其中属性从jrow中取值并调用o中的set方法设置
for(Field f : fields) {
String fieldName = f.getName();
if (-1 != fieldName.toLowerCase().indexOf("serialversion")
|| -1 != fieldName.toLowerCase().indexOf("param_")) {
if(-1 != fieldName.toLowerCase().indexOf("serialversion") || -1 != fieldName.toLowerCase().indexOf("param_")) {
continue;
}
PropertyDescriptor pd = new PropertyDescriptor(f.getName(), c);
@@ -179,7 +173,8 @@ public class ResultBean implements Serializable, Cloneable {
* @return
* @throws Exception
*/
public Object getObject(int resultSet, Class c) throws Exception {
public Object getObject(int resultSet, Class c)
throws Exception {
JSONObject jrow = this.uniqueResult(resultSet);
if(null == jrow) {
return null;
@@ -189,8 +184,7 @@ public class ResultBean implements Serializable, Cloneable {
//反射读取其中属性从jrow中取值并调用o中的set方法设置
for(Field f : fields) {
String fieldName = f.getName();
if (-1 != fieldName.toLowerCase().indexOf("serialversion")
|| -1 != fieldName.toLowerCase().indexOf("param_")) {
if(-1 != fieldName.toLowerCase().indexOf("serialversion") || -1 != fieldName.toLowerCase().indexOf("param_")) {
continue;
}
PropertyDescriptor pd = new PropertyDescriptor(f.getName(), c);
@@ -251,7 +245,6 @@ public class ResultBean implements Serializable, Cloneable {
}
JSONArray jrows = this.rows2jsonarray(rows);
jres.put("content", jrows);
ArrayList rows2 = this.getResultSet(1);
int nTotalSize = 0;
if(null != rows2 && rows2.size() > 0) {
@@ -277,7 +270,6 @@ public class ResultBean implements Serializable, Cloneable {
return jrows;
}
private JSONObject row2jsonobject(BasicDynaBean row) {
JSONObject jrow = new JSONObject();
DynaProperty[] props = row.getDynaClass().getDynaProperties();
@@ -286,25 +278,26 @@ public class ResultBean implements Serializable, Cloneable {
String key = prop.getName();
Object value = row.get(key);
String strValue = WqlUtil.getSQLFieldValue(value).trim();
if(value instanceof Timestamp)
//时间处理
{
if(ObjectUtil.isEmpty(strValue) && ObjectUtil.isNotEmpty(value)) {
if(value instanceof Timestamp) {
strValue = value.toString();
}
}
}
jrow.put(key, strValue);
}
return jrow;
}
public void addSplitPageResultSet(ResultSet value, int start, int end) throws SQLException {
public void addSplitPageResultSet(ResultSet value, int start, int end)
throws SQLException {
if(start < 0) {
addResultSet(value);
return;
}
value.absolute(start);
ArrayList rs = new ArrayList();
ResultSetMetaData rsmd = value.getMetaData();
@@ -312,7 +305,6 @@ public class ResultBean implements Serializable, Cloneable {
for(int i = 0; i < dps.length; i++) {
dps[i] = new DynaProperty(rsmd.getColumnName(i + 1).toLowerCase());
}
for(int i = start; i < end; i++) {
BasicDynaClass bdc = new BasicDynaClass("", BasicDynaBean.class, dps);
BasicDynaBean bdb = new BasicDynaBean(bdc);
@@ -320,10 +312,9 @@ public class ResultBean implements Serializable, Cloneable {
for(int j = 0; j < dps.length; j++) {
bdb.set(dps[j].getName(), value.getString(dps[j].getName()));
}
rs.add(bdb);
} else
break;
}
else{break;}
}
if(rslist == null) {
rslist = new ArrayList();
@@ -345,7 +336,8 @@ public class ResultBean implements Serializable, Cloneable {
WQLRowSetDynaClass rs = new WQLRowSetDynaClass(sqlResultSet, true, -1);
rslist.add(rs);
ResultCount = rslist.size();
} catch (Exception e) {
}
catch(Exception e) {
e.printStackTrace();
}
}
@@ -359,7 +351,6 @@ public class ResultBean implements Serializable, Cloneable {
if(rslist == null) {
rslist = new ArrayList();
}
rslist.add(list);
ResultCount = rslist.size();
}
@@ -446,12 +437,9 @@ public class ResultBean implements Serializable, Cloneable {
sStr.append("\n 字段(" + j + ") " + properties[j].getName());
if(rows.size() > 0) {
BasicDynaBean rowBean = (BasicDynaBean) rows.get(0);
sStr.append(" |"
+ rowBean.get(properties[j].getName()
.toString()));
sStr.append(" |" + rowBean.get(properties[j].getName().toString()));
}
}
}
}
return sStr.toString();
@@ -463,23 +451,19 @@ public class ResultBean implements Serializable, Cloneable {
* @param args
*/
public static void main2s(String[] args) {
ResultBean ii = new ResultBean();
// ii.setResultSets(null);
// System.exit(0);
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = DriverManager
.getConnection("jdbc:sqlserver://192.168.1.4:1433;User=tc;Password=business;DatabaseName=test");
Connection conn = DriverManager.getConnection("jdbc:sqlserver://192.168.1.4:1433;User=tc;Password=business;DatabaseName=test");
conn.setAutoCommit(false);
String sqlStr = "";
CallableStatement st;
// sqlStr =
// BF.ScriptSwitch("SELECT DISTINCT A.IOSTORINVSID AS IOSTORINVSID , B.CORPSID AS CORPSID , B.BUSINESSCORPNAME AS SIMPLENAME , C.STORSID AS STORSID , C.STORNAME AS STORNAME , E.BIZINVTYPE AS BIZINVTYPE , E.TYPENAME AS TYPENAME , A.INVSID AS INVSID , CASE WHEN ? = '1' THEN A.TOTALDEFQTY / 250 WHEN ? = '2' THEN A.TOTALDEFQTY / 50 WHEN ? = '3' THEN A.TOTALDEFQTY WHEN ? = '4' THEN A.TOTALDEFQTY * 10 WHEN ? = '5' THEN A.TOTALDEFQTY * 200 ELSE A.TOTALDEFQTY END AS TOTALDEFQTY , A.FIRSTDTLCOUNT AS FIRSTDTLCOUNT , D.PERSONSID AS PERSONSID , D.PERSONNAME AS PERSONNAME , A.CREATEDATE AS CREATEDATE , A.REMARK AS REMARK , A.STATUS AS STATUS , CASE WHEN A.STATUS = '01' THEN '待分配' WHEN A.STATUS = '02' THEN '分配中' WHEN A.STATUS = '03' THEN '待确认' WHEN A.STATUS = '04' THEN '确认中' ELSE '确认完毕' END AS STATUSNAME FROM DBO.B_ST_BZIOSTORINVMST AS A LEFT OUTER JOIN DBO.G_OG_CORPINFO AS B ON A.CORPSID = B.CORPSID LEFT OUTER JOIN DBO.B_ST_BSREALSTORATTR AS C ON A.STORSID = C.STORSID LEFT OUTER JOIN DBO.G_OG_PERSONINFO AS D ON A.CREATERSID = D.PERSONSID LEFT OUTER JOIN DBO.G_PB_BIZINVTYPE AS E ON A.INVTYPE = E.BIZINVTYPE LEFT OUTER JOIN DBO.B_ST_BZIOSTORINVDIVDTL AS F ON A.IOSTORINVSID = F.IOSTORINVSID WHERE A.IOSTORINVSID = A.IOSTORINVSID AND A.ISOUTINV = '0' AND A.STORSID = '001000001' AND A.CORPSID = '001000000' AND A.STATUS IN ( '01' , '02' , '03' ) AND A.ISACTIVE = '1' ORDER BY A.IOSTORINVSID DESC ",
// 1);
st = conn.prepareCall(sqlStr, ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
st = conn.prepareCall(sqlStr, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
st.setString(1, "");
st.setString(2, "");
st.setString(3, "");
@@ -489,12 +473,10 @@ public class ResultBean implements Serializable, Cloneable {
ResultBean ior = new ResultBean();
ResultSet rs = st.getResultSet();
ior.addSplitPageResultSet(rs, 1, 5);
st.close();
st = null;
conn.close();
conn = null;
ArrayList al = ior.getResultSets();
System.out.println(al.size());
ArrayList temp = ior.getResultSet(1);
@@ -506,10 +488,9 @@ public class ResultBean implements Serializable, Cloneable {
for(int i = 0; i < dp.length; i++) {
System.out.println(dp[i] + "=" + bdb.get(dp[i].getName()));
}
} catch (Exception e) {
}
catch(Exception e) {
e.printStackTrace();
}
}
}

View File

@@ -42,10 +42,8 @@ import java.util.Set;
@Slf4j
public class WO implements Serializable, Cloneable{
private static final long serialVersionUID = -4831486954013002791L;
public WP wp;
private String code = ""; //当前交易编号
private String dbname = "dataSource"; //指定使用的数据库
@@ -57,7 +55,6 @@ public class WO implements Serializable, Cloneable {
String rawJdbcUrl = druidDataSource.getRawJdbcUrl();
DBConnBean dbb = new DBConnBean();
dbb.setDrivers("");
if(StrUtil.containsAnyIgnoreCase(rawJdbcUrl, DataType.MYSQL)) {
dbb.setDbtype("mysql");
}
@@ -67,7 +64,9 @@ public class WO implements Serializable, Cloneable {
if(StrUtil.containsAnyIgnoreCase(rawJdbcUrl, DataType.MSSQL) || StrUtil.containsAnyIgnoreCase(rawJdbcUrl, "sqlserver")) {
dbb.setDbtype("mssql");
}
if (StrUtil.isNotEmpty(dbb.getDbtype()))this.dbtype=dbb.getDbtype();
if(StrUtil.isNotEmpty(dbb.getDbtype())) {
this.dbtype = dbb.getDbtype();
}
WQLCore.dbMap.put(dbname, dbb);
}
return this;
@@ -77,12 +76,9 @@ public class WO implements Serializable, Cloneable {
// private boolean isTransation = false; //是否开启事务
// private boolean isSelfConn = false; //当前数据库连接是否是自身的连接
private String hint_type = ""; //hint类型 空-无hint master-主表 slave-从表
private ArrayList tempTableList = new ArrayList(); //临时表列表
private ArrayList processlist = new ArrayList(); //处理语句
///////////////////////////
//// 动态替换执行语句
///////////////////////////
@@ -94,7 +90,6 @@ public class WO implements Serializable, Cloneable {
this.processlist = processlist;
}
/**
* 按个数添加参数
*/
@@ -104,15 +99,18 @@ public class WO implements Serializable, Cloneable {
int PAGE_PAGESTART = (Integer) value;
this.setPage_PageStart(PAGE_PAGESTART);
// }else if("PAGE_PAGERECORDNUM".toLowerCase().equals(key.toLowerCase())){
} else if (StrUtil.equalsIgnoreCase("PAGE_PAGERECORDNUM", key)) {
}
else if(StrUtil.equalsIgnoreCase("PAGE_PAGERECORDNUM", key)) {
int PAGE_PAGERECORDNUM = (Integer) value;
this.setPage_PageRecordNum(PAGE_PAGERECORDNUM);
// }else if("SORT_ORDERBYFIELD".toLowerCase().equals(key.toLowerCase())){
} else if (StrUtil.equalsIgnoreCase("SORT_ORDERBYFIELD", key)) {
}
else if(StrUtil.equalsIgnoreCase("SORT_ORDERBYFIELD", key)) {
String SORT_ORDERBYFIELD = (String) value;
this.setPage_OrderByField(SORT_ORDERBYFIELD);
// }else if("ORDERBY".toLowerCase().equals(key.toLowerCase())){
} else if (StrUtil.equalsIgnoreCase("ORDERBY", key)) {
}
else if(StrUtil.equalsIgnoreCase("ORDERBY", key)) {
String SORT_ORDERBYFIELD = (String) value;
this.setPage_OrderByField(SORT_ORDERBYFIELD);
}
@@ -166,7 +164,6 @@ public class WO implements Serializable, Cloneable {
HttpContext hctx = new HttpContext(WqlUtil.getUUID());
hctx.setRequest(request);
return pageQuery(hctx, orderby);
}
public JSONObject pageQuery(BaseContext ctx, String orderby) {
@@ -186,7 +183,6 @@ public class WO implements Serializable, Cloneable {
if(null != orderbyfield && !"".equals(orderbyfield.trim())) {
orderby = orderbyfield;
}
return this.pageQuery2(nPageStart * nPageRecordNum, nPageRecordNum, orderby);
}
@@ -219,8 +215,8 @@ public class WO implements Serializable, Cloneable {
this.wp.init();
}
public WO(String code, ArrayList<String> wqlcontent) throws Exception {
public WO(String code, ArrayList<String> wqlcontent)
throws Exception {
// this.isSelfConn = false;
this.code = code;
//this.dbname = WQLCore.defalutDBName;
@@ -229,61 +225,52 @@ public class WO implements Serializable, Cloneable {
// this.isTransation = true;
// }
this.wp = new WP();
try {
DBConnBean dbb = WQLCore.dbMap.get(dbname);
if (dbb == null) throw new Exception("无效的数据库名:" + dbname);
if(dbb == null) {
throw new Exception("无效的数据库名:" + dbname);
}
this.dbtype = dbb.getDbtype();
//当前指令作用域
String cmd = "";
for(Iterator it = wqlcontent.iterator(); it.hasNext(); ) {
String wql = (String) it.next();
//log.debug("wql:"+wql);
//删除空格和\t等制表符
wql = WqlUtil.ltrim(wql);
wql = WqlUtil.rtrim(wql);
//过滤整行的空行、注解和注释
if ("".equals(wql)
|| wql.startsWith("--")
|| wql.startsWith("#")
|| wql.startsWith("//")) {
if("".equals(wql) || wql.startsWith("--") || wql.startsWith("#") || wql.startsWith("//")) {
continue;
}
//分析当前命令域
if(wql.startsWith("[")) {
//1、结束上一个指令域
//2、开启下一个新的指令域
cmd = wql.substring(wql.indexOf("[") + 1, wql.indexOf("]"));
continue;
}
if("数据库".equals(cmd)) {
this.dbname = wql;
dbb = WQLCore.dbMap.get(this.dbname);
if (dbb == null) throw new Exception("无效的数据库名:" + dbname);
if(dbb == null) {
throw new Exception("无效的数据库名:" + dbname);
}
this.dbtype = dbb.getDbtype();
} else if ("IO定义".equals(cmd)
|| "临时变量".equals(cmd)) {
}
else if("IO定义".equals(cmd) || "临时变量".equals(cmd)) {
wql = WqlUtil.ctrim(wql);
this.wp.initIOParam(wql);
} else if ("临时表".equals(cmd)) {
}
else if("临时表".equals(cmd)) {
this.tempTableList.add(wql);
} else if ("业务过程".equals(cmd)) {
}
else if("业务过程".equals(cmd)) {
this.processlist.add(WqlUtil.ctrim(wql));
}
}
} catch (Exception e) {
}
catch(Exception e) {
e.printStackTrace();
log.error("WQL加载失败" + e.toString());
throw new Exception("请检查WQL文件【" + code + ".wql】的语法规范!", e);
@@ -300,7 +287,6 @@ public class WO implements Serializable, Cloneable {
// this.isSelfConn = true;
log.debug(this.code + "执行开始");
log.debug(this.wp.toString());
//2、获取数据库连接并处理事务
this.wp.conn = conn;
synchronized(this.wp.conn) {
@@ -318,15 +304,14 @@ public class WO implements Serializable, Cloneable {
// }
// }
// }
//3、创建临时表
this.wp._success = CreateTempTable();
//4、正式处理
if(this.wp._success) {
this.wp._success = Process();
}
} catch (Exception ex) {
}
catch(Exception ex) {
// TODO Auto-generated catch block
ex.printStackTrace();
this.wp.InfoError = new ErrorBean();
@@ -334,7 +319,8 @@ public class WO implements Serializable, Cloneable {
this.wp.InfoError.setDescription(ex.toString());
this.wp.ALInfoError.add(this.wp.InfoError);
this.wp._success = false;
} finally {
}
finally {
//8、结果处理事务处理
//如果是更新类的操作,则关闭事务
// if(this.code.toUpperCase().startsWith("U")){
@@ -419,11 +405,11 @@ public class WO implements Serializable, Cloneable {
// this.wp.rb.setSucess(0);
// }
// }
if(this.wp._success) {
log.debug(this.code + "执行成功");
this.wp.rb.setSucess(1);
} else {
}
else{
log.warn(this.code + "执行失败");
this.wp.rb.setSucess(0);
}
@@ -456,19 +442,17 @@ public class WO implements Serializable, Cloneable {
this.wp.sSQL = "CREATE TEMPORARY TABLE IF NOT EXISTS " + tempTableName + " (";
for(int i = 0; i < rows.size(); i++) {
XLSTableRow xtr = (XLSTableRow) rows.get(i);
//如果是主键,则增加主键标识
if("pk".equalsIgnoreCase(xtr.getParam())) {
pkstr += xtr.getEnname() + ",";
}
//字段名
this.wp.sSQL += xtr.getEnname() + " ";
//字段属性
if(-1 != xtr.getType().indexOf("U_")) {
this.wp.sSQL += DataType.getFieldValue(this.dbtype, xtr.getType());
} else {
}
else{
// if(null!=xtr.getLen()&&!"".equals(xtr.getLen().trim())){
// this.wp.sSQL += xtr.getType()+"("+xtr.getLen()+")";
// }else{
@@ -485,24 +469,23 @@ public class WO implements Serializable, Cloneable {
this.wp.sSQL += ",PRIMARY KEY (" + pkstr + ")";
}
this.wp.sSQL += " )";
} else if (DataType.ORACLE.equals(dbtype)) { //oracle处理方式
}
else if(DataType.ORACLE.equals(dbtype)) { //oracle处理方式
String pkstr = new String();
this.wp.sSQL = "CREATE GLOBAL TEMPORARY TABLE " + tempTableName + " (";
for(int i = 0; i < rows.size(); i++) {
XLSTableRow xtr = (XLSTableRow) rows.get(i);
//如果是主键,则增加主键标识
if("pk".equalsIgnoreCase(xtr.getParam())) {
pkstr += xtr.getEnname() + ",";
}
//字段名
this.wp.sSQL += xtr.getEnname() + " ";
//字段属性
if(-1 != xtr.getType().indexOf("U_")) {
this.wp.sSQL += DataType.getFieldValue(this.dbtype, xtr.getType());
} else {
}
else{
// if(null!=xtr.getLen()&&!"".equals(xtr.getLen().trim())){
// this.wp.sSQL += xtr.getType()+"("+xtr.getLen()+")";
// }else{
@@ -519,24 +502,23 @@ public class WO implements Serializable, Cloneable {
this.wp.sSQL += ",PRIMARY KEY (" + pkstr + ")";
}
this.wp.sSQL += " ) ON COMMIT PRESERVE ROWS";
} else if (DataType.DB2.equals(dbtype)) { //db2处理方式
}
else if(DataType.DB2.equals(dbtype)) { //db2处理方式
String pkstr = new String();
this.wp.sSQL = "DECLARE GLOBAL TEMPORARY TABLE " + tempTableName + " (";
for(int i = 0; i < rows.size(); i++) {
XLSTableRow xtr = (XLSTableRow) rows.get(i);
//如果是主键,则增加主键标识
if("pk".equalsIgnoreCase(xtr.getParam())) {
pkstr += xtr.getEnname() + ",";
}
//字段名
this.wp.sSQL += xtr.getEnname() + " ";
//字段属性
if(-1 != xtr.getType().indexOf("U_")) {
this.wp.sSQL += DataType.getFieldValue(this.dbtype, xtr.getType());
} else {
}
else{
// if(null!=xtr.getLen()&&!"".equals(xtr.getLen().trim())){
// this.wp.sSQL += xtr.getType()+"("+xtr.getLen()+")";
// }else{
@@ -553,24 +535,25 @@ public class WO implements Serializable, Cloneable {
this.wp.sSQL += ",PRIMARY KEY (" + pkstr + ")";
}
this.wp.sSQL += " ) on commit preserve rows WITH REPLACE";
} else if (DataType.MSSQL.equals(dbtype)) { //mssql处理方式
}
else if(DataType.MSSQL.equals(dbtype)) { //mssql处理方式
}
log.debug("数据库创建临时表:\n" + this.wp.sSQL);
try {
if(null == this.wp.sSQL || "".equals(this.wp.sSQL)) {
} else {
}
else{
if(DataType.MSSQL.equals(dbtype)) { //MS SQLServer 处理方式
Statement st = this.wp.conn.createStatement();
st.execute(this.wp.sSQL);
} else {
}
else{
this.wp.st = this.wp.conn.prepareStatement(this.wp.sSQL);
this.wp.st.execute();
}
}
} catch (Exception ex) {
}
catch(Exception ex) {
// ex.printStackTrace();
// log.error("创建临时表出错:\n" + wp.sSQL + "\n" + ex.toString());
// wp.InfoError = new ErrorBean();
@@ -578,13 +561,17 @@ public class WO implements Serializable, Cloneable {
// wp.InfoError.setDescription("创建临时表出错:\n" + wp.sSQL + "\n" + ex.toString());
// wp.ALInfoError.add(wp.InfoError);
this.wp._state = false;
} finally {
}
finally {
try {
if(DBConnection.currpooltype != DBConnection.DBPOOLTYPE_SPRING) {
if (this.wp.st != null) this.wp.st.close();
if(this.wp.st != null) {
this.wp.st.close();
}
this.wp.st = null;
}
} catch (SQLException e) {
}
catch(SQLException e) {
log.error("关闭st,rs出错" + e.toString());
}
}
@@ -607,12 +594,10 @@ public class WO implements Serializable, Cloneable {
return this.wp._state;
}
/*******************************88
* 基础方法
* @return
*/
public String getDbtype() {
return dbtype;
}
@@ -707,5 +692,4 @@ public class WO implements Serializable, Cloneable {
}
return true;
}
}

View File

@@ -29,23 +29,34 @@ public class WqlUtil {
return ctx;
}
public static HttpContext getHttpContext(Integer pageNumber, Integer pageSize) {
HttpContext ctx = new HttpContext(WqlUtil.getUUID());
ctx.setPage((pageNumber + 1) + "");
ctx.setRows(pageSize + "");
return ctx;
}
public static String getSQLFieldValue(Object o) {
String str = new String();
if(o == null) {
return "";
} else {
}
else{
String classStr = o.getClass().getName();
if("java.lang.String".equals(classStr)) {
str = (String) o;
} else if ("java.lang.Long".equals(classStr)) {
}
else if("java.lang.Long".equals(classStr)) {
Long e = (Long) o;
str = e.toString();
} else if ("java.lang.Double".equals(classStr)) {
}
else if("java.lang.Double".equals(classStr)) {
str = String.valueOf(o);
} else if ("java.math.BigInteger".equals(classStr)) {
}
else if("java.math.BigInteger".equals(classStr)) {
str = String.valueOf(o);
} else if ("oracle.sql.CLOB".equals(classStr)) {
}
else if("oracle.sql.CLOB".equals(classStr)) {
/* CLOB e2 = (CLOB) o;
try {
@@ -55,16 +66,20 @@ public class WqlUtil {
} catch (SQLException arg16) {
arg16.printStackTrace();
}*/
} else if ("java.lang.Integer".equals(classStr)) {
}
else if("java.lang.Integer".equals(classStr)) {
Integer e3 = (Integer) o;
str = e3.toString();
} else if ("java.lang.Short".equals(classStr)) {
}
else if("java.lang.Short".equals(classStr)) {
Short e4 = (Short) o;
str = e4.toString();
} else if ("java.math.BigDecimal".equals(classStr)) {
}
else if("java.math.BigDecimal".equals(classStr)) {
BigDecimal e5 = (BigDecimal) o;
str = e5.toString();
} else {
}
else{
Method e6;
if(classStr.startsWith("com.ibm.db2.jcc")) {
try {
@@ -76,12 +91,13 @@ public class WqlUtil {
str = (String) e6.invoke(o, new Object[]{Long.valueOf(1L), Integer.valueOf(subclass)});
}
}
} catch (Exception arg15) {
log.error(
"getSQLFieldValue error, class=com.ibm.db2.jcc :" + arg15.getMessage());
}
catch(Exception arg15) {
log.error("getSQLFieldValue error, class=com.ibm.db2.jcc :" + arg15.getMessage());
arg15.printStackTrace();
}
} else if (classStr.startsWith("weblogic.jdbc.wrapper.Clob")) {
}
else if(classStr.startsWith("weblogic.jdbc.wrapper.Clob")) {
try {
e6 = o.getClass().getMethod("getVendorObj", new Class[0]);
Object subo1 = e6.invoke(o, new Object[0]);
@@ -89,22 +105,20 @@ public class WqlUtil {
if(subclass1.startsWith("com.ibm.db2.jcc")) {
try {
if(subo1 != null) {
Method clob = subo1.getClass().getMethod("getSubString",
new Class[]{Long.TYPE, Integer.TYPE});
Method clob = subo1.getClass().getMethod("getSubString", new Class[]{Long.TYPE, Integer.TYPE});
Method e1 = subo1.getClass().getMethod("length", new Class[0]);
int length = ((Long) e1.invoke(subo1, new Object[0])).intValue();
if(length > 0) {
str = (String) clob.invoke(subo1,
new Object[]{Long.valueOf(1L), Integer.valueOf(length)});
str = (String) clob.invoke(subo1, new Object[]{Long.valueOf(1L), Integer.valueOf(length)});
}
}
} catch (Exception arg9) {
log.error(
"getSQLFieldValue error, class=weblogic.jdbc.wrapper.Clob_com.ibm.db2.jcc.* :"
+ arg9.getMessage());
}
catch(Exception arg9) {
log.error("getSQLFieldValue error, class=weblogic.jdbc.wrapper.Clob_com.ibm.db2.jcc.* :" + arg9.getMessage());
arg9.printStackTrace();
}
} else if ("oracle.sql.CLOB".equals(subclass1)) {
}
else if("oracle.sql.CLOB".equals(subclass1)) {
/* CLOB clob1 = (CLOB) subo1;
try {
@@ -115,25 +129,30 @@ public class WqlUtil {
arg8.printStackTrace();
}*/
}
} catch (SecurityException arg10) {
}
catch(SecurityException arg10) {
arg10.printStackTrace();
} catch (IllegalArgumentException arg11) {
}
catch(IllegalArgumentException arg11) {
arg11.printStackTrace();
} catch (NoSuchMethodException arg12) {
}
catch(NoSuchMethodException arg12) {
arg12.printStackTrace();
} catch (IllegalAccessException arg13) {
}
catch(IllegalAccessException arg13) {
arg13.printStackTrace();
} catch (InvocationTargetException arg14) {
}
catch(InvocationTargetException arg14) {
arg14.printStackTrace();
}
}
}
return str;
}
}
public static Object cloneObject(Object obj) throws Exception {
public static Object cloneObject(Object obj)
throws Exception {
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(byteOut);
out.writeObject(obj);
@@ -151,12 +170,11 @@ public class WqlUtil {
if(str == null || "".equals(str.trim())) {
return "";
}
str = str.substring(str.indexOf(beginStr) + 1, str.indexOf(endStr));
} catch (Exception arg3) {
}
catch(Exception arg3) {
arg3.printStackTrace();
}
return str;
}
@@ -164,18 +182,15 @@ public class WqlUtil {
StringBuffer output = new StringBuffer();
int lengthOfSource = source.length();
int lengthOfOld = oldString.length();
int posStart;
int pos;
for(posStart = 0; (pos = source.indexOf(oldString, posStart)) >= 0; posStart = pos + lengthOfOld) {
output.append(source.substring(posStart, pos));
output.append(newString);
}
if(posStart < lengthOfSource) {
output.append(source.substring(posStart));
}
return output.toString();
}
@@ -187,9 +202,9 @@ public class WqlUtil {
return true;
}
}
return false;
} else {
}
else{
return false;
}
}
@@ -199,17 +214,14 @@ public class WqlUtil {
if(-1 != s1.indexOf(s2)) {
ishas = true;
}
return ishas;
}
public static String rtrim(String str) {
Pattern pat = Pattern.compile("[\t\n ]$");
for(Matcher mat = pat.matcher(str); mat.find(); mat = pat.matcher(str)) {
str = mat.replaceAll("");
}
return str;
}
@@ -223,18 +235,14 @@ public class WqlUtil {
public static String ctrim(String str) {
Pattern pat = Pattern.compile("[\t]");
Matcher mat;
for(mat = pat.matcher(str); mat.find(); mat = pat.matcher(str)) {
str = mat.replaceAll(" ");
}
pat = Pattern.compile("[ ]{2,}");
for(mat = pat.matcher(str); mat.find(); mat = pat.matcher(str)) {
str = mat.replaceAll(" ");
}
return str;
}
@@ -262,39 +270,37 @@ public class WqlUtil {
if(!"null".equals(value)) {
map.put(name, value);
}
} catch (IllegalAccessException e) {
}
catch(IllegalAccessException e) {
e.printStackTrace();
}
}
}
return map;
}
public static String getTableNameByInstance(Class clazz) {
Table anno = (Table) clazz.getAnnotation(Table.class);
//返回实体类表名
return anno.name();
}
public static String ltrim(String str) {
Pattern pat = Pattern.compile("^[\t\n ]");
for(Matcher mat = pat.matcher(str); mat.find(); mat = pat.matcher(str)) {
str = mat.replaceAll("");
}
return str;
}
public static byte[] getFileBytes(String strFileNameAndPath) throws Exception {
public static byte[] getFileBytes(String strFileNameAndPath)
throws Exception {
File file = new File(strFileNameAndPath);
return getFileBytes(file);
}
public static byte[] getFileBytes(File file) throws Exception {
public static byte[] getFileBytes(File file)
throws Exception {
FileInputStream fileStream = new FileInputStream(file);
byte[] bfile = new byte[(int) file.length()];
fileStream.read(bfile, 0, (int) file.length());
@@ -302,14 +308,16 @@ public class WqlUtil {
return bfile;
}
public static byte[] getFileBytes(InputStream is, long l) throws Exception {
public static byte[] getFileBytes(InputStream is, long l)
throws Exception {
byte[] bfile = new byte[(int) l];
is.read(bfile, 0, bfile.length);
is.close();
return bfile;
}
public static byte[] getFileBytes(URI uri) throws Exception {
public static byte[] getFileBytes(URI uri)
throws Exception {
File file = new File(uri);
FileInputStream fileStream = new FileInputStream(file);
byte[] bfile = new byte[(int) file.length()];
@@ -318,7 +326,8 @@ public class WqlUtil {
return bfile;
}
public static final String decode2String(byte[] sArr) throws UnsupportedEncodingException {
public static final String decode2String(byte[] sArr)
throws UnsupportedEncodingException {
byte[] bytes = decode(sArr);
String str = new String(bytes, "UTF-8");
return str;
@@ -327,48 +336,42 @@ public class WqlUtil {
public static final byte[] decode(byte[] sArr) {
int sLen = sArr.length;
int sepCnt = 0;
int pad;
for(pad = 0; pad < sLen; ++pad) {
if(IA[sArr[pad] & 255] < 0) {
++sepCnt;
}
}
if((sLen - sepCnt) % 4 != 0) {
return null;
} else {
}
else{
pad = 0;
int len = sLen;
while(len > 1) {
--len;
if(IA[sArr[len] & 255] > 0) {
break;
}
if(sArr[len] == 126) {
++pad;
}
}
len = ((sLen - sepCnt) * 6 >> 3) - pad;
byte[] dArr = new byte[len];
int s = 0;
int d = 0;
while(d < len) {
int i = 0;
for(int j = 0; j < 4; ++j) {
int c = IA[sArr[s++] & 255];
if(c >= 0) {
i |= c << 18 - j * 6;
} else {
}
else{
--j;
}
}
dArr[d++] = (byte) (i >> 16);
if(d < len) {
dArr[d++] = (byte) (i >> 8);
@@ -377,7 +380,6 @@ public class WqlUtil {
}
}
}
return dArr;
}
}
@@ -390,11 +392,10 @@ public class WqlUtil {
return false;
}
}
return true;
} else {
}
else{
return true;
}
}
}

View File

@@ -39,7 +39,7 @@ import java.util.Map;
public class CacheLineHandController{
private final CacheLineHandService cacheLineHandService;
@PostMapping("/queryMaterial")
@PostMapping("/materialQuery")
@Log("物料查询")
@ApiOperation("物料查询")
public ResponseEntity<List<MaterialDto>> queryMaterial(@RequestBody JSONObject form) {
@@ -48,14 +48,14 @@ public class CacheLineHandController{
if(StringUtils.isNotEmpty(params)) {
//限制查询参数过短,模糊力度大
int length = params.getBytes().length;
if(length < 3) {
throw new BizCoreException("输入条件所匹配的范围太大,请输入大于2个字的内容");
if(length < 4) {
throw new BizCoreException("输入条件所查询的内容过多,请输入大于3个字的查询条件");
}
}
return new ResponseEntity<>(cacheLineHandService.queryMaterial(params), HttpStatus.OK);
}
@PostMapping("/materialQuery")
@PostMapping("/queryMaterial")
@Log("物料模糊查询")
@ApiOperation("物料模糊查询")
public ResponseEntity<JSONArray> materialQuery(@RequestBody JSONObject form) {
@@ -64,8 +64,8 @@ public class CacheLineHandController{
if(StringUtils.isNotEmpty(params)) {
//限制查询参数过短,模糊力度大
int length = params.getBytes().length;
if(length < 3) {
throw new BizCoreException("输入条件所匹配的范围太大,请输入大于2个字的内容");
if(length < 4) {
throw new BizCoreException("输入条件所查询的内容过多,请输入大于3个字的查询条件");
}
}
return new ResponseEntity<>(cacheLineHandService.materialQuery(form.getString("search_bar")), HttpStatus.OK);
@@ -117,7 +117,7 @@ public class CacheLineHandController{
@PostMapping("/instOperation")
@Log("任务操作")
@ApiOperation("任务操作")
public ResponseEntity<String> instOperation(@RequestBody JSONObject param) {
public ResponseEntity<Object> instOperation(@RequestBody JSONObject param) {
log.info("海亮缓存线手持服务 [任务操作] 接口被请求, 请求参数-{}", param);
//任务类型和任务ID校验instruct_uuid为前端参数命名本来应为task_id
if(StringUtils.isEmpty(param.getString("instruct_uuid")) || StringUtils.isEmpty(param.getString("opt_type"))) {
@@ -141,7 +141,7 @@ public class CacheLineHandController{
@PostMapping("/cacheLineOutBoxExceptionConfirm")
@Log("缓存线出入箱异常-确认")
@ApiOperation("缓存线出入箱异常-确认")
public ResponseEntity<String> cacheLineOutBoxExceptionConfirm(@RequestBody JSONObject param) {
public ResponseEntity<Object> cacheLineOutBoxExceptionConfirm(@RequestBody JSONObject param) {
log.info("海亮缓存线手持服务 [缓存线出箱异常-确认] 接口被请求, 请求参数-{}", param);
//参数校验
if(StringUtils.isEmpty(param.getString("wcsdevice_code")) || StringUtils.isEmpty(param.getString("position_code")) || StringUtils.isEmpty(param.getString("vehicle_code"))) {
@@ -161,7 +161,7 @@ public class CacheLineHandController{
@PostMapping("/inOutEmptyBox")
@Log("空箱初始化--出入空箱")
@ApiOperation("空箱初始化--出入空箱")
public ResponseEntity<String> inOutEmptyBox(@RequestBody JSONObject param) {
public ResponseEntity<Object> inOutEmptyBox(@RequestBody JSONObject param) {
log.info("海亮缓存线手持服务 [空箱初始化--出入空箱] 接口被请求, 请求参数-{}", param);
//参数校验
if(StringUtils.isEmpty(param.getString("inOut_type")) || StringUtils.isEmpty(param.getString("wcsdevice_code")) || StringUtils.isEmpty(param.getString("vehicle_code"))) {
@@ -179,7 +179,7 @@ public class CacheLineHandController{
}
@PostMapping("/inOutExceptionInstConfirm")
@Log("缓存线出入箱异常指令确认")
@Log("扫码异常确认")
@ApiOperation("缓存线出入箱异常指令确认")
public ResponseEntity<Object> inOutExceptionInstConfirm(@RequestBody JSONObject param) {
log.info("海亮缓存线手持服务 [缓存线出入箱异常指令确认] 接口被请求, 请求参数-{}", param);

View File

@@ -2,6 +2,7 @@ package org.nl.wms.pda.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.nl.common.utils.api.CommonResult;
import org.nl.wms.pda.dto.MaterialDto;
import org.springframework.data.domain.Pageable;
@@ -128,10 +129,11 @@ public interface CacheLineHandService{
* 缓存线出入箱异常指令确认
*
* @param param 查询参数 1 扫码异常-入箱扫码 2 扫码异常-出箱扫码
* @return
* @author gbx
* @date 2023/3/24
*/
Map<String, Object> inOutExceptionInstConfirm(JSONObject param);
Object inOutExceptionInstConfirm(JSONObject param);
/**
* 任务操作
@@ -141,7 +143,7 @@ public interface CacheLineHandService{
* @author gbx
* @date 2023/3/23
*/
String instOperation(JSONObject param);
CommonResult<String> instOperation(JSONObject param);
/**
* 缓存线出箱异常-确认
@@ -151,16 +153,17 @@ public interface CacheLineHandService{
* @author gbx
* @date 2023/3/24
*/
String cacheLineOutBoxExceptionConfirm(JSONObject param);
CommonResult<Integer> cacheLineOutBoxExceptionConfirm(JSONObject param);
/**
* 空箱初始化--出入空箱
*
* @param param 查询参数 inOut_type:1 入空箱 2 出空箱 vehicle_code:载具编码
* @return
* @author gbx
* @date 2023/3/24
*/
String inOutEmptyBox(JSONObject param);
CommonResult<Integer> inOutEmptyBox(JSONObject param);
/**
* 设置满框
@@ -245,7 +248,7 @@ public interface CacheLineHandService{
* @author gbx
* @date 2023/3/24
*/
Map<String,Object> cacheLineExcepOpt(JSONObject param);
CommonResult<JSONObject> cacheLineExcepOpt(JSONObject param);
/**
* 倒料操作

View File

@@ -14,18 +14,18 @@ import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.nl.common.enums.StatusEnum;
import org.nl.common.utils.*;
import org.nl.common.utils.api.CommonResult;
import org.nl.common.utils.api.RestBusinessTemplate;
import org.nl.config.thread.ThreadPoolExecutorUtil;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.common.utils.RedisUtils;
import org.nl.modules.wql.WQL;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.modules.wql.util.WqlUtil;
import org.nl.wms.basedata.master.service.ClassstandardService;
import org.nl.wms.pda.dto.MaterialDto;
import org.nl.wms.pda.service.CacheLineHandService;
import org.nl.wms.sch.tasks.SpeMachineryTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.scheduling.annotation.Async;
@@ -53,6 +53,7 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
private final RedisUtils redisUtils;
@Autowired
private LocalCache cache;
@Override
public JSONArray dropdownListQuery(String param, String type) {
//初始化下拉框列表1.物料规格2.工序3.指令状态4.设备
@@ -142,6 +143,8 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
public Map<String,Object> instPageQuery(Map<String,String> param, Pageable page) {
HashMap<String,String> map = new HashMap<>();
map.put("flag", "10");
Integer pageNumber = 0;
Integer pageSize = 20;
JSONObject whereJson = JSONObject.parseObject(JSON.toJSONString(param));
//任务状态
String task_status = whereJson.getString("status");
@@ -182,25 +185,35 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
if(StrUtil.isNotEmpty(whereJson.getString("end_date"))) {
map.put("end_date", whereJson.getString("end_date"));
}
return WQL.getWO("PDA_QUERY").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "task.update_time desc");
//分页参数
if(StrUtil.isNotEmpty(whereJson.getString("page")) && StrUtil.isNotEmpty(whereJson.getString("size"))) {
pageNumber = whereJson.getInteger("page");
pageSize = whereJson.getInteger("size");
}
JSONObject jsonObject = WQL.getWO("PDA_QUERY").addParamMap(map).pageQuery(WqlUtil.getHttpContext(pageNumber, pageSize), "task.update_time desc");
String size = jsonObject.getString("totalElements");
jsonObject.put("size", size);
//适配前端分页条件
jsonObject.remove("totalElements");
return jsonObject;
}
@Override
public String instOperation(JSONObject param) {
public CommonResult<String> instOperation(JSONObject param) {
String optType = param.getString("opt_type");
SpeMachineryTask SpeMachineryTask = new SpeMachineryTask();
WQLObject taskTab = WQLObject.getWQLObject("sch_base_task");
JSONObject taskObject = taskTab.query("task_id =" + param.getString("instruct_uuid")).uniqueResult(0);
//1-取消、2-完成、3-任务下发,根据操作类型执行相关操作
if(StatusEnum.TASK_CANNEL.getCode().equals(optType) || StatusEnum.TASK_FINISH.getCode().equals(optType)) {
return updateTaskStatus(taskObject, optType);
return RestBusinessTemplate.execute(() -> updateTaskStatus(taskObject, optType));
}
//任务下发
else if(StatusEnum.TASK_PUBLISH.getCode().equals(optType)) {
return SpeMachineryTask.createTask(taskObject);
return RestBusinessTemplate.execute(() -> SpeMachineryTask.createTask(taskObject));
}
else{
return null;
return RestBusinessTemplate.execute(() -> "1");
}
}
@@ -216,7 +229,7 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
map.put("update_optname", nickName);
map.put("update_time", DateUtil.now());
int result = (WQLObject.getWQLObject("sch_base_task").update(map, "task_id = '" + taskObj.getString("task_id") + "'").getSucess());
return Integer.toString(result);
return String.valueOf(result);
}
@Override
@@ -358,9 +371,6 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
json.put("vehicle_code", vehicle_code);
json.put("cacheLine_code", cacheLine_code);
json.put("material_id", meObj.getString("material_id"));
json.put("material_code", meObj.getString("material_code"));
json.put("material_spec", meObj.getString("material_spec"));
json.put("material_name", meObj.getString("material_name"));
json.put("weight", weight);
json.put("quantity", quantity);
json.put("workprocedure_code", wpObj.getString("workprocedure_code"));
@@ -395,9 +405,6 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
JSONObject json = ivtTab.query("vehicle_code = '" + vehicle_code + "'").uniqueResult(0);
json.put("vehicle_status", StatusEnum.CACHE_VEL_EMT.getCode());
json.put("material_id", "");
json.put("material_code", "");
json.put("material_spec", "");
json.put("material_name", "");
json.put("weight", "0");
json.put("quantity", "0");
json.put("workprocedure_code", "");
@@ -425,9 +432,11 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
/**
* 出入空箱,出入类型 inOut_type 1 入空箱 2 出空箱 缓存线编码 wcsdevice_code 料箱码 vehicle_code
*
* @return
*/
@Override
public String inOutEmptyBox(JSONObject param) {
public CommonResult<Integer> inOutEmptyBox(JSONObject param) {
String inOut_type = param.getString("inOut_type");
String cacheLine_code = param.getString("wcsdevice_code");
String vehicle_code = param.getString("vehicle_code");
@@ -469,7 +478,8 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
// 删除掉出库的箱子及关联物料
result = vehMaterTab.delete("cacheLine_code = '" + cacheLine_code + "' and vehicle_code = '" + vehicle_code + "'").getSucess();
}
return Integer.toString(result);
int finalResult = result;
return RestBusinessTemplate.execute(() -> finalResult);
}
/**
@@ -538,9 +548,11 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
* 缓存线编码 wcsdevice_code
* 缓存线位置编码 position_code
* 料箱码 vehicle_code
*
* @return
*/
@Override
public Map<String,Object> inOutExceptionInstConfirm(JSONObject param) {
public CommonResult<JSONObject> inOutExceptionInstConfirm(JSONObject param) {
// 1 扫码异常-入箱扫码 2 扫码异常-出箱扫码
String inOut_type = param.getString("inOut_type");
// 缓存线编码
@@ -564,11 +576,7 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
try {
//TOFIX 等确定api后换成下发的url
// return AcsUtil.notifyAcs("/api/cacheLineHand", jsonArray);
JSONObject result = new JSONObject();
result.put("status", HttpStatus.OK.value());
result.put("message", "操作成功!");
result.put("data", new JSONObject());
return result;
return RestBusinessTemplate.execute(() -> new JSONObject());
}
catch(NullPointerException e) {
throw new BadRequestException(e.toString());
@@ -576,7 +584,7 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
}
@Override
public Map<String,Object> cacheLineExcepOpt(JSONObject param) {
public CommonResult<JSONObject> cacheLineExcepOpt(JSONObject param) {
// 缓存线编码
String wcsdevice_code = param.getString("wcsdevice_code");
// opt_type 1-暂停、2-启动,默认为1暂停
@@ -595,11 +603,7 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
try {
//TOFIX 等确定api后换成下发的url
//return AcsUtil.notifyAcs("/api/cacheLineHand", jsonArray);
JSONObject result = new JSONObject();
result.put("status", HttpStatus.OK.value());
result.put("message", "操作成功!");
result.put("data", new JSONObject());
return result;
return RestBusinessTemplate.execute(() -> new JSONObject());
}
catch(NullPointerException e) {
throw new BadRequestException(e.toString());
@@ -634,7 +638,13 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
if(StringUtils.isEmpty(posiObj.getString("task_id"))) {
throw new BadRequestException("未找到该缓存线的点位的任务信息!");
}
return WQL.getWO("PDA_QUERY").addParam("flag", "10").addParam("task_id", posiObj.getString("task_id")).process().getResultJSONArray(0);
JSONArray jsonArray = WQL.getWO("PDA_QUERY").addParam("flag", "10").addParam("task_id", posiObj.getString("task_id")).process().getResultJSONArray(0);
//缓存线编码
for(int i = 0; i < jsonArray.size(); i++) {
JSONObject row = jsonArray.getJSONObject(i);
row.put("wcsdevice_code", wcsdevice_code);
}
return jsonArray;
}
/**
@@ -643,9 +653,11 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
* 缓存线位置编码 wcsdevice_code
* 缓存线点位编码 position_code
* 料箱码 vehicle_code
*
* @return
*/
@Override
public String cacheLineOutBoxExceptionConfirm(JSONObject param) {
public CommonResult<Integer> cacheLineOutBoxExceptionConfirm(JSONObject param) {
String inOut_type = param.getString("inOut_type");
String cacheLine_code = param.getString("wcsdevice_code");
String position_code = param.getString("position_code");
@@ -655,11 +667,11 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
// 缓存线载具物料表
WQLObject ivtTab = WQLObject.getWQLObject("sch_cacheline_vehilematerial");
//1.确定缓存线点位
JSONObject vehiobj = positionTab.query("position_code = " + position_code + " and cacheLine_code like '%" + cacheLine_code + "%'").uniqueResult(0);
JSONObject vehiobj = positionTab.query("vehicle_code = '" + vehicle_code + "' and cacheLine_code = '" + cacheLine_code + "'").uniqueResult(0);
//2.绑定新料箱条码(入满箱或者入空箱),设置缓存线点位不为空
vehiobj.put("vehicle_code", vehicle_code);
vehiobj.put("is_empty", "0");
positionTab.update(vehiobj);
positionTab.update(vehiobj, "position_code = '" + position_code + "'");
//3.删除入料箱之前的所有关联信息,包括物料,工序,生产区域
ivtTab.delete("vehicle_code = '" + vehicle_code + "'");
//4.初始化料箱
@@ -690,9 +702,6 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
}
//6.重新新建该缓存线位置上的料箱为满箱及所属工序,生产区域等信息
json.put("material_id", meObj.getString("material_id"));
json.put("material_code", meObj.getString("material_code"));
json.put("material_spec", meObj.getString("material_spec"));
json.put("material_name", meObj.getString("material_name"));
json.put("quantity", instructObj.getString("material_qty"));
json.put("product_area", instructObj.getString("product_area"));
json.put("vehicle_status", StatusEnum.CACHE_VEL_EMT.getCode());
@@ -701,18 +710,14 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
if(StatusEnum.OUT_VEHICLE.getCode().equals(inOut_type)) {
//5.重新新建该缓存线位置上的料箱为空箱子,是空料箱没有放物料等其他信息
json.put("vehicle_status", StatusEnum.STATUS_TRUE.getCode());
json.put("material_uuid", "");
json.put("material_code", "");
json.put("material_spec", "");
json.put("material_name", "");
json.put("material_id", "");
json.put("weight", "0");
json.put("quantity", "0");
json.put("workprocedure_code", "");
json.put("workprocedure_name", "");
json.put("product_area", "");
}
int result = ivtTab.insert(json).getSucess();
return Integer.toString(result);
return RestBusinessTemplate.execute(() -> ivtTab.insert(json).getSucess());
}
/**

View File

@@ -230,7 +230,7 @@
task.task_id as instruct_uuid,
task.task_code as instructoperate_num,
task.task_name as mes_no,
task.vehicle_code as invehicle_code,
task.vehicle_code,
task.vehicle_code2 as outvehicle_code,
task.create_time,
dict.label as status_name,
@@ -270,7 +270,7 @@
ENDOPTION
OPTION 输入.end_date <> ""
task.create_time <= 输入.end_date
ENDOPTION
ENDOPTION ORDER BY task.create_time
ENDSELECT
ENDPAGEQUERY
ENDIF

View File

@@ -172,6 +172,7 @@ sa-token:
cookie:
# 配置 Cookie 作用域:根据二级域名实现sso登入如lms.sso.com;acs.sso.com
domain:
is-read-cookie: false
#jetcache:
# defaultCacheType: LOCAL