rev:优化新增,修改,删除操作时返回的数据格式。
This commit is contained in:
@@ -7,24 +7,24 @@ package org.nl.common.utils.api;
|
|||||||
* @date 2023-03-02
|
* @date 2023-03-02
|
||||||
*/
|
*/
|
||||||
public class CommonResult<T> {
|
public class CommonResult<T> {
|
||||||
private long code;
|
private long status;
|
||||||
private String desc;
|
private String message;
|
||||||
private T result;
|
private T data;
|
||||||
|
|
||||||
public CommonResult() {
|
public CommonResult() {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CommonResult(T result) {
|
protected CommonResult(T data) {
|
||||||
this.result = result;
|
this.data = data;
|
||||||
this.desc = ResultCode.SUCCESS.getDesc();
|
this.message = ResultCode.SUCCESS.getDesc();
|
||||||
this.code = ResultCode.SUCCESS.getCode();
|
this.status = ResultCode.SUCCESS.getCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected CommonResult(long code, String desc, T result) {
|
protected CommonResult(long status, String message, T data) {
|
||||||
this.code = code;
|
this.status = status;
|
||||||
this.desc = desc;
|
this.message = message;
|
||||||
this.result = result;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -38,20 +38,20 @@ public class CommonResult<T> {
|
|||||||
/**
|
/**
|
||||||
* 成功返回结果
|
* 成功返回结果
|
||||||
*
|
*
|
||||||
* @param result 获取的数据
|
* @param data 获取的数据
|
||||||
*/
|
*/
|
||||||
public static <T> CommonResult<T> success(T result) {
|
public static <T> CommonResult<T> success(T data) {
|
||||||
return new CommonResult<>(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getDesc(), result);
|
return new CommonResult<>(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getDesc(), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 成功返回结果
|
* 成功返回结果
|
||||||
*
|
*
|
||||||
* @param result 获取的数据
|
* @param data 获取的数据
|
||||||
* @param desc 提示信息
|
* @param message 提示信息
|
||||||
*/
|
*/
|
||||||
public static <T> CommonResult<T> success(T result, String desc) {
|
public static <T> CommonResult<T> success(T data, String message) {
|
||||||
return new CommonResult<>(ResultCode.SUCCESS.getCode(), desc, result);
|
return new CommonResult<>(ResultCode.SUCCESS.getCode(), message, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,18 +65,18 @@ public class CommonResult<T> {
|
|||||||
/**
|
/**
|
||||||
* 失败返回结果
|
* 失败返回结果
|
||||||
* @param errorCode 错误码
|
* @param errorCode 错误码
|
||||||
* @param desc 错误信息
|
* @param message 错误信息
|
||||||
*/
|
*/
|
||||||
public static <T> CommonResult<T> failed(IErrorCode errorCode,String desc) {
|
public static <T> CommonResult<T> failed(IErrorCode errorCode,String message) {
|
||||||
return new CommonResult<>(errorCode.getCode(), desc, null);
|
return new CommonResult<>(errorCode.getCode(), message, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 失败返回结果
|
* 失败返回结果
|
||||||
* @param desc 提示信息
|
* @param message 提示信息
|
||||||
*/
|
*/
|
||||||
public static <T> CommonResult<T> failed(String desc) {
|
public static <T> CommonResult<T> failed(String message) {
|
||||||
return new CommonResult<>(ResultCode.FAILED.getCode(), desc, null);
|
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) {
|
public static <T> CommonResult<T> validateFailed(String message) {
|
||||||
return new CommonResult<>(ResultCode.MISS_PARAMETER.getCode(), desc, null);
|
return new CommonResult<>(ResultCode.MISS_PARAMETER.getCode(), message, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 未登录返回结果
|
* 未登录返回结果
|
||||||
*/
|
*/
|
||||||
public static <T> CommonResult<T> unauthorized(T result) {
|
public static <T> CommonResult<T> unauthorized(T data) {
|
||||||
return new CommonResult<>(ResultCode.UNAUTHORIZED.getCode(), ResultCode.UNAUTHORIZED.getDesc(), result);
|
return new CommonResult<>(ResultCode.UNAUTHORIZED.getCode(), ResultCode.UNAUTHORIZED.getDesc(), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 未授权返回结果
|
* 未授权返回结果
|
||||||
*/
|
*/
|
||||||
public static <T> CommonResult<T> forbidden(T result) {
|
public static <T> CommonResult<T> forbidden(T data) {
|
||||||
return new CommonResult<>(ResultCode.FORBIDDEN.getCode(), ResultCode.FORBIDDEN.getDesc(), result);
|
return new CommonResult<>(ResultCode.FORBIDDEN.getCode(), ResultCode.FORBIDDEN.getDesc(), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getCode() {
|
public long getStatus() {
|
||||||
return code;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCode(long code) {
|
public void setStatus(long status) {
|
||||||
this.code = code;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDesc() {
|
public String getMessage() {
|
||||||
return desc;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDesc(String desc) {
|
public void setMessage(String message) {
|
||||||
this.desc = desc;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T getResult() {
|
public T getData() {
|
||||||
return result;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResult(T result) {
|
public void setData(T data) {
|
||||||
this.result = result;
|
this.data = data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,11 +15,11 @@ public class RestBusinessTemplate{
|
|||||||
public static <T> CommonResult<T> execute(Callback<T> callback) {
|
public static <T> CommonResult<T> execute(Callback<T> callback) {
|
||||||
CommonResult<T> result = new CommonResult<>();
|
CommonResult<T> result = new CommonResult<>();
|
||||||
try {
|
try {
|
||||||
result.setCode(ResultCode.SUCCESS.getCode());
|
result.setStatus(ResultCode.SUCCESS.getCode());
|
||||||
result.setDesc(ResultCode.SUCCESS.getDesc());
|
result.setMessage(ResultCode.SUCCESS.getDesc());
|
||||||
T object = callback.doExecute();
|
T object = callback.doExecute();
|
||||||
if(object != null) {
|
if(object != null) {
|
||||||
result.setResult(object);
|
result.setData(object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(BizCoreException e) {
|
catch(BizCoreException e) {
|
||||||
@@ -35,13 +35,46 @@ public class RestBusinessTemplate{
|
|||||||
}
|
}
|
||||||
log.error(e.getErrorMsg());
|
log.error(e.getErrorMsg());
|
||||||
ResultCode code = e.getCode() == null ? ResultCode.FAILED : e.getCode();
|
ResultCode code = e.getCode() == null ? ResultCode.FAILED : e.getCode();
|
||||||
result.setCode(code.getCode());
|
result.setStatus(code.getCode());
|
||||||
result.setDesc(errorMsg);
|
result.setMessage(errorMsg);
|
||||||
}
|
}
|
||||||
catch(Exception e) {
|
catch(Exception e) {
|
||||||
log.error("execute error", e);
|
log.error("execute error", e);
|
||||||
result.setCode(ResultCode.FAILED.getCode());
|
result.setStatus(ResultCode.FAILED.getCode());
|
||||||
result.setDesc(ResultCode.FAILED.getDesc()+",原因是:"+e.getMessage());
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -50,19 +83,19 @@ public class RestBusinessTemplate{
|
|||||||
CommonResult<Void> result = new CommonResult<>();
|
CommonResult<Void> result = new CommonResult<>();
|
||||||
try {
|
try {
|
||||||
callback.execute();
|
callback.execute();
|
||||||
result.setCode(ResultCode.SUCCESS.getCode());
|
result.setStatus(ResultCode.SUCCESS.getCode());
|
||||||
result.setDesc(ResultCode.SUCCESS.getDesc());
|
result.setMessage(ResultCode.SUCCESS.getDesc());
|
||||||
}
|
}
|
||||||
catch(BizCoreException e) {
|
catch(BizCoreException e) {
|
||||||
log.error("", e);
|
log.error("", e);
|
||||||
ResultCode code = e.getCode() == null ? ResultCode.FAILED : e.getCode();
|
ResultCode code = e.getCode() == null ? ResultCode.FAILED : e.getCode();
|
||||||
result.setCode(code.getCode());
|
result.setStatus(code.getCode());
|
||||||
result.setDesc(StringUtils.isBlank(e.getMessage()) ? code.getDesc() : e.getMessage());
|
result.setMessage(StringUtils.isBlank(e.getMessage()) ? code.getDesc() : e.getMessage());
|
||||||
}
|
}
|
||||||
catch(Exception e) {
|
catch(Exception e) {
|
||||||
log.error("execute error", e);
|
log.error("execute error", e);
|
||||||
result.setCode(ResultCode.FAILED.getCode());
|
result.setStatus(ResultCode.FAILED.getCode());
|
||||||
result.setDesc(ResultCode.FAILED.getDesc());
|
result.setMessage(ResultCode.FAILED.getDesc());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ package org.nl.common.utils.api;
|
|||||||
* @date 2023-03-02
|
* @date 2023-03-02
|
||||||
*/
|
*/
|
||||||
public enum ResultCode implements IErrorCode{
|
public enum ResultCode implements IErrorCode{
|
||||||
SUCCESS(1, "操作成功"),
|
SUCCESS(200, "操作成功"),
|
||||||
FAILED(0, "操作失败"),
|
FAILED(0, "操作失败"),
|
||||||
MISS_PARAMETER(400, "参数缺失"),
|
MISS_PARAMETER(400, "参数缺失"),
|
||||||
UNAUTHORIZED(401, "暂未登录或token已经过期"),
|
UNAUTHORIZED(401, "暂未登录或token已经过期"),
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import com.alibaba.fastjson.JSONObject;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.nl.common.anno.Log;
|
import org.nl.common.anno.Log;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.nl.modules.common.config.RsaProperties;
|
import org.nl.modules.common.config.RsaProperties;
|
||||||
@@ -43,51 +43,46 @@ import java.util.Map;
|
|||||||
@RequestMapping("/mobile/auth")
|
@RequestMapping("/mobile/auth")
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Api(tags = "手持:系统授权接口")
|
@Api(tags = "手持:系统授权接口")
|
||||||
public class MobileAuthorizationController {
|
public class MobileAuthorizationController{
|
||||||
private final RedisUtils redisUtils;
|
private final RedisUtils redisUtils;
|
||||||
private final ISysUserService userService;
|
private final ISysUserService userService;
|
||||||
private final ISysRoleService roleService;
|
private final ISysRoleService roleService;
|
||||||
|
|
||||||
@ApiOperation("登录授权")
|
@ApiOperation("登录授权")
|
||||||
@PostMapping(value = "/login")
|
@PostMapping(value = "/login")
|
||||||
@SaIgnore
|
@SaIgnore
|
||||||
public ResponseEntity<Object> login(@Validated @RequestBody AuthUserDto authUser, HttpServletRequest request) throws Exception {
|
public ResponseEntity<Object> login(@Validated @RequestBody AuthUserDto authUser, HttpServletRequest request)
|
||||||
// 密码解密 - 前端的加密规则: encrypt(根据实际更改)
|
throws Exception {
|
||||||
// String password = authUser.getPassword();
|
// 密码解密 - 前端的加密规则: encrypt(根据实际更改)
|
||||||
String password = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey, authUser.getPassword());
|
// String password = authUser.getPassword();
|
||||||
// 校验数据库
|
String password = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey, authUser.getPassword());
|
||||||
// 根据用户名查询,在比对密码
|
// 校验数据库
|
||||||
SysUser userDto = userService.getOne(new QueryWrapper<SysUser>().eq("username", authUser.getUsername()));// 拿不到已经抛出异常
|
// 根据用户名查询,在比对密码
|
||||||
if (userDto==null||!userDto.getPassword().equals(SaSecureUtil.md5BySalt(password, "salt"))) { // 这里需要密码加密
|
SysUser userDto = userService.getOne(new QueryWrapper<SysUser>().eq("username", authUser.getUsername()));// 拿不到已经抛出异常
|
||||||
throw new BadRequestException("账号或密码错误");
|
if(userDto == null || !userDto.getPassword().equals(SaSecureUtil.md5BySalt(password, "salt"))) { // 这里需要密码加密
|
||||||
}
|
throw new BadRequestException("账号或密码错误");
|
||||||
// 获取权限列表 - 登录查找权限
|
}
|
||||||
List<String> permissionList = roleService.getPermissionList(JSONObject.parseObject(JSON.toJSONString(userDto)));
|
// 获取权限列表 - 登录查找权限
|
||||||
|
List<String> permissionList = roleService.getPermissionList(JSONObject.parseObject(JSON.toJSONString(userDto)));
|
||||||
// 登录输入,登出删除
|
// 登录输入,登出删除
|
||||||
CurrentUser user = new CurrentUser();
|
CurrentUser user = new CurrentUser();
|
||||||
user.setId(userDto.getUserId());
|
user.setId(userDto.getUserId());
|
||||||
user.setUsername(userDto.getUsername());
|
user.setUsername(userDto.getUsername());
|
||||||
user.setPresonName(userDto.getPersonName());
|
user.setPresonName(userDto.getPersonName());
|
||||||
user.setUser(userDto);
|
user.setUser(userDto);
|
||||||
user.setPermissions(permissionList);
|
user.setPermissions(permissionList);
|
||||||
|
// SaLoginModel 配置登录相关参数
|
||||||
// SaLoginModel 配置登录相关参数
|
StpUtil.login(userDto.getUserId(), new SaLoginModel().setDevice("PE") // 此次登录的客户端设备类型, 用于[同端互斥登录]时指定此次登录的设备类型
|
||||||
StpUtil.login(userDto.getUserId(), new SaLoginModel()
|
.setExtra("loginInfo", user) // Token挂载的扩展参数 (此方法只有在集成jwt插件时才会生效)
|
||||||
.setDevice("PE") // 此次登录的客户端设备类型, 用于[同端互斥登录]时指定此次登录的设备类型
|
);
|
||||||
.setExtra("loginInfo", user) // Token挂载的扩展参数 (此方法只有在集成jwt插件时才会生效)
|
// 返回 token 与 用户信息
|
||||||
);
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("user", userDto);
|
||||||
// 返回 token 与 用户信息
|
Map<String,Object> authInfo = new HashMap<String,Object>(2){{
|
||||||
JSONObject jsonObject = new JSONObject();
|
put("token", StpUtil.getTokenValue());
|
||||||
jsonObject.put("user", userDto);
|
put("user", jsonObject);
|
||||||
Map<String, Object> authInfo = new HashMap<String, Object>(2) {{
|
}};
|
||||||
put("token", StpUtil.getTokenValue());
|
redisUtils.set("pe-satoken", StpUtil.getTokenValue(), StpUtil.getTokenTimeout());
|
||||||
put("user", jsonObject);
|
return ResponseEntity.ok(authInfo);
|
||||||
}};
|
}
|
||||||
|
|
||||||
redisUtils.set("pe-satoken", StpUtil.getTokenValue(), StpUtil.getTokenTimeout());
|
|
||||||
|
|
||||||
return ResponseEntity.ok(authInfo);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,483 +33,464 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ResultBean implements Serializable, Cloneable {
|
public class ResultBean implements Serializable, Cloneable{
|
||||||
private static final long serialVersionUID = -7486919713117296262L;
|
private static final long serialVersionUID = -7486919713117296262L;
|
||||||
private ArrayList rslist = null;
|
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() {
|
||||||
private int ResultCount = 0;
|
return RowsCount;
|
||||||
|
}
|
||||||
|
|
||||||
//如果是删除、更新类操作,返回受影响的记录数
|
public void setRowsCount(int rowsCount) {
|
||||||
private int RowsCount = 0;
|
RowsCount = rowsCount;
|
||||||
|
}
|
||||||
|
|
||||||
private int sucess;
|
/**
|
||||||
|
* 返回是否执行成功
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isSuccess() {
|
||||||
|
if(1 == this.sucess) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private ArrayList InfoDump = null;
|
public int getSucess() {
|
||||||
|
return sucess;
|
||||||
|
}
|
||||||
|
|
||||||
private ArrayList InfoError = null;
|
public void setSucess(int value) {
|
||||||
|
this.sucess = value;
|
||||||
|
}
|
||||||
|
|
||||||
private ArrayList InfoTrace = null;
|
/**
|
||||||
|
* 取得结果集
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public ArrayList getResultSet(int value) {
|
||||||
|
// value = value - 1;
|
||||||
|
if(null == rslist) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if(value < rslist.size()) {
|
||||||
|
if(rslist.get(value) instanceof RowSetDynaClass) {
|
||||||
|
return (ArrayList) ((RowSetDynaClass) rslist.get(value)).getRows();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return (ArrayList) rslist.get(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// /**
|
||||||
|
// * 返回按bc定义的dataset
|
||||||
|
// * @param bc
|
||||||
|
// * @param value
|
||||||
|
// * @return
|
||||||
|
// */
|
||||||
|
// public WQLData getWQLData(WQLObject wo,int value){
|
||||||
|
// if (value < rslist.size()) {
|
||||||
|
//
|
||||||
|
// ArrayList list = getResultSet(value);
|
||||||
|
// try{
|
||||||
|
// WQLData wd = null;
|
||||||
|
// if(null!=wo){
|
||||||
|
// wd = new WQLData(wo);
|
||||||
|
// wd.populate(list);
|
||||||
|
// }else{
|
||||||
|
// wd = new WQLData(list);
|
||||||
|
// }
|
||||||
|
// return wd;
|
||||||
|
// }catch(Exception ex){
|
||||||
|
// ex.printStackTrace();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 返回普通dataset
|
||||||
|
// * @param value
|
||||||
|
// * @return
|
||||||
|
// */
|
||||||
|
// public WQLData getWQLData(int value){
|
||||||
|
// return getWQLData(null,value);
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 泛型
|
||||||
|
*
|
||||||
|
* @param resultSet
|
||||||
|
* @param c
|
||||||
|
* @return
|
||||||
|
* @throws IllegalAccessException
|
||||||
|
* @throws InstantiationException
|
||||||
|
* @throws IntrospectionException
|
||||||
|
*/
|
||||||
|
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++) {
|
||||||
|
JSONObject jrow = jrows.getJSONObject(i);
|
||||||
|
Object o = c.newInstance();
|
||||||
|
Field[] fields = c.getDeclaredFields();
|
||||||
|
//反射读取其中属性,从jrow中取值并调用o中的set方法设置
|
||||||
|
for(Field f : fields) {
|
||||||
|
String fieldName = f.getName();
|
||||||
|
if(-1 != fieldName.toLowerCase().indexOf("serialversion") || -1 != fieldName.toLowerCase().indexOf("param_")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
PropertyDescriptor pd = new PropertyDescriptor(f.getName(), c);
|
||||||
|
String jvalue = jrow.getString(fieldName);
|
||||||
|
Method m = pd.getWriteMethod();
|
||||||
|
m.invoke(o, jvalue);
|
||||||
|
}
|
||||||
|
rows.add(o);
|
||||||
|
}
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
|
||||||
public int getRowsCount() {
|
/**
|
||||||
return RowsCount;
|
* 获取单一的对象
|
||||||
}
|
*
|
||||||
|
* @param resultSet
|
||||||
public void setRowsCount(int rowsCount) {
|
* @param c
|
||||||
RowsCount = rowsCount;
|
* @return
|
||||||
}
|
* @throws Exception
|
||||||
|
*/
|
||||||
/**
|
public Object getObject(int resultSet, Class c)
|
||||||
* 返回是否执行成功
|
throws Exception {
|
||||||
*
|
JSONObject jrow = this.uniqueResult(resultSet);
|
||||||
* @return
|
if(null == jrow) {
|
||||||
*/
|
return null;
|
||||||
public boolean isSuccess() {
|
}
|
||||||
if (1 == this.sucess) {
|
Object o = c.newInstance();
|
||||||
return true;
|
Field[] fields = c.getDeclaredFields();
|
||||||
} else {
|
//反射读取其中属性,从jrow中取值并调用o中的set方法设置
|
||||||
return false;
|
for(Field f : fields) {
|
||||||
}
|
String fieldName = f.getName();
|
||||||
}
|
if(-1 != fieldName.toLowerCase().indexOf("serialversion") || -1 != fieldName.toLowerCase().indexOf("param_")) {
|
||||||
|
|
||||||
public int getSucess() {
|
|
||||||
return sucess;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSucess(int value) {
|
|
||||||
this.sucess = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 取得结果集
|
|
||||||
*
|
|
||||||
* @param value
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public ArrayList getResultSet(int value) {
|
|
||||||
// value = value - 1;
|
|
||||||
if (null == rslist) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (value < rslist.size()) {
|
|
||||||
if (rslist.get(value) instanceof RowSetDynaClass) {
|
|
||||||
return (ArrayList) ((RowSetDynaClass) rslist.get(value)).getRows();
|
|
||||||
} else {
|
|
||||||
return (ArrayList) rslist.get(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * 返回按bc定义的dataset
|
|
||||||
// * @param bc
|
|
||||||
// * @param value
|
|
||||||
// * @return
|
|
||||||
// */
|
|
||||||
// public WQLData getWQLData(WQLObject wo,int value){
|
|
||||||
// if (value < rslist.size()) {
|
|
||||||
//
|
|
||||||
// ArrayList list = getResultSet(value);
|
|
||||||
// try{
|
|
||||||
// WQLData wd = null;
|
|
||||||
// if(null!=wo){
|
|
||||||
// wd = new WQLData(wo);
|
|
||||||
// wd.populate(list);
|
|
||||||
// }else{
|
|
||||||
// wd = new WQLData(list);
|
|
||||||
// }
|
|
||||||
// return wd;
|
|
||||||
// }catch(Exception ex){
|
|
||||||
// ex.printStackTrace();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 返回普通dataset
|
|
||||||
// * @param value
|
|
||||||
// * @return
|
|
||||||
// */
|
|
||||||
// public WQLData getWQLData(int value){
|
|
||||||
// return getWQLData(null,value);
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 泛型
|
|
||||||
*
|
|
||||||
* @param resultSet
|
|
||||||
* @param c
|
|
||||||
* @return
|
|
||||||
* @throws IllegalAccessException
|
|
||||||
* @throws InstantiationException
|
|
||||||
* @throws IntrospectionException
|
|
||||||
*/
|
|
||||||
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++) {
|
|
||||||
JSONObject jrow = jrows.getJSONObject(i);
|
|
||||||
Object o = c.newInstance();
|
|
||||||
Field[] fields = c.getDeclaredFields();
|
|
||||||
//反射读取其中属性,从jrow中取值并调用o中的set方法设置
|
|
||||||
for (Field f : fields) {
|
|
||||||
String fieldName = f.getName();
|
|
||||||
if (-1 != fieldName.toLowerCase().indexOf("serialversion")
|
|
||||||
|| -1 != fieldName.toLowerCase().indexOf("param_")) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
PropertyDescriptor pd = new PropertyDescriptor(f.getName(), c);
|
PropertyDescriptor pd = new PropertyDescriptor(f.getName(), c);
|
||||||
String jvalue = jrow.getString(fieldName);
|
String jvalue = jrow.getString(fieldName);
|
||||||
Method m = pd.getWriteMethod();
|
Method m = pd.getWriteMethod();
|
||||||
m.invoke(o, jvalue);
|
if(null != m) {
|
||||||
}
|
m.invoke(o, jvalue);
|
||||||
rows.add(o);
|
}
|
||||||
}
|
}
|
||||||
return rows;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取单一的对象
|
* 取得jsonarray格式的结果集
|
||||||
*
|
*
|
||||||
* @param resultSet
|
* @param resultSet
|
||||||
* @param c
|
* @return
|
||||||
* @return
|
*/
|
||||||
* @throws Exception
|
public JSONArray getResultJSONArray(int resultSet) {
|
||||||
*/
|
ArrayList rows = this.getResultSet(resultSet);
|
||||||
public Object getObject(int resultSet, Class c) throws Exception {
|
if(null == rows) {
|
||||||
JSONObject jrow = this.uniqueResult(resultSet);
|
rows = new ArrayList();
|
||||||
if (null == jrow) {
|
}
|
||||||
return null;
|
JSONArray jrows = this.rows2jsonarray(rows);
|
||||||
}
|
return jrows;
|
||||||
Object o = c.newInstance();
|
}
|
||||||
Field[] fields = c.getDeclaredFields();
|
|
||||||
//反射读取其中属性,从jrow中取值并调用o中的set方法设置
|
|
||||||
for (Field f : fields) {
|
|
||||||
String fieldName = f.getName();
|
|
||||||
if (-1 != fieldName.toLowerCase().indexOf("serialversion")
|
|
||||||
|| -1 != fieldName.toLowerCase().indexOf("param_")) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
PropertyDescriptor pd = new PropertyDescriptor(f.getName(), c);
|
|
||||||
String jvalue = jrow.getString(fieldName);
|
|
||||||
Method m = pd.getWriteMethod();
|
|
||||||
if (null != m) {
|
|
||||||
m.invoke(o, jvalue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 取得jsonarray格式的结果集
|
* 获取唯一一条记录
|
||||||
*
|
*
|
||||||
* @param resultSet
|
* @param resultSet 结果集序号
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public JSONArray getResultJSONArray(int resultSet) {
|
public JSONObject uniqueResult(int resultSet) {
|
||||||
ArrayList rows = this.getResultSet(resultSet);
|
ArrayList rows = this.getResultSet(resultSet);
|
||||||
if (null == rows) {
|
if(null == rows) {
|
||||||
rows = new ArrayList();
|
rows = new ArrayList();
|
||||||
}
|
}
|
||||||
JSONArray jrows = this.rows2jsonarray(rows);
|
JSONArray jrows = this.rows2jsonarray(rows);
|
||||||
return jrows;
|
JSONObject jrow = null;
|
||||||
}
|
if(jrows.size() > 0) {
|
||||||
|
jrow = jrows.getJSONObject(0);
|
||||||
|
}
|
||||||
|
// log.warn("===========uniqueResult速度 解析结果集="+(t2-t1)+" 转换成JSON="+(t3-t2));
|
||||||
|
return jrow;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取唯一一条记录
|
* 获取适合grid的分页结果集
|
||||||
*
|
*
|
||||||
* @param resultSet 结果集序号
|
* @return
|
||||||
* @return
|
*/
|
||||||
*/
|
public JSONObject pageResult() {
|
||||||
public JSONObject uniqueResult(int resultSet) {
|
JSONObject jres = new JSONObject();
|
||||||
ArrayList rows = this.getResultSet(resultSet);
|
ArrayList rows = this.getResultSet(0);
|
||||||
if (null == rows) {
|
if(null == rows) {
|
||||||
rows = new ArrayList();
|
rows = new ArrayList();
|
||||||
}
|
}
|
||||||
JSONArray jrows = this.rows2jsonarray(rows);
|
JSONArray jrows = this.rows2jsonarray(rows);
|
||||||
JSONObject jrow = null;
|
jres.put("content", jrows);
|
||||||
if (jrows.size() > 0) {
|
ArrayList rows2 = this.getResultSet(1);
|
||||||
jrow = jrows.getJSONObject(0);
|
int nTotalSize = 0;
|
||||||
}
|
if(null != rows2 && rows2.size() > 0) {
|
||||||
// log.warn("===========uniqueResult速度 解析结果集="+(t2-t1)+" 转换成JSON="+(t3-t2));
|
JSONObject jrow2 = this.row2jsonobject((BasicDynaBean) rows2.get(0));
|
||||||
return jrow;
|
nTotalSize = jrow2.getInteger("page_totalrecordnum");
|
||||||
}
|
}
|
||||||
|
jres.put("totalElements", nTotalSize);
|
||||||
|
return jres;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取适合grid的分页结果集
|
* 结果集转换方法
|
||||||
*
|
*
|
||||||
* @return
|
* @param rows
|
||||||
*/
|
* @return
|
||||||
public JSONObject pageResult() {
|
*/
|
||||||
JSONObject jres = new JSONObject();
|
private JSONArray rows2jsonarray(ArrayList<BasicDynaBean> rows) {
|
||||||
ArrayList rows = this.getResultSet(0);
|
JSONArray jrows = new JSONArray();
|
||||||
if (null == rows) {
|
for(Iterator<BasicDynaBean> it = rows.iterator(); it.hasNext(); ) {
|
||||||
rows = new ArrayList();
|
BasicDynaBean row = (BasicDynaBean) it.next();
|
||||||
}
|
jrows.add(row2jsonobject(row));
|
||||||
JSONArray jrows = this.rows2jsonarray(rows);
|
}
|
||||||
jres.put("content", jrows);
|
return jrows;
|
||||||
|
}
|
||||||
|
|
||||||
ArrayList rows2 = this.getResultSet(1);
|
private JSONObject row2jsonobject(BasicDynaBean row) {
|
||||||
int nTotalSize = 0;
|
JSONObject jrow = new JSONObject();
|
||||||
if (null != rows2 && rows2.size() > 0) {
|
DynaProperty[] props = row.getDynaClass().getDynaProperties();
|
||||||
JSONObject jrow2 = this.row2jsonobject((BasicDynaBean) rows2.get(0));
|
for(int j = 0; j < props.length; j++) {
|
||||||
nTotalSize = jrow2.getInteger("page_totalrecordnum");
|
DynaProperty prop = props[j];
|
||||||
}
|
String key = prop.getName();
|
||||||
jres.put("totalElements", nTotalSize);
|
Object value = row.get(key);
|
||||||
return jres;
|
String strValue = WqlUtil.getSQLFieldValue(value).trim();
|
||||||
}
|
if(value instanceof Timestamp)
|
||||||
|
//时间处理
|
||||||
/**
|
{
|
||||||
* 结果集转换方法
|
if(ObjectUtil.isEmpty(strValue) && ObjectUtil.isNotEmpty(value)) {
|
||||||
*
|
if(value instanceof Timestamp) {
|
||||||
* @param rows
|
strValue = value.toString();
|
||||||
* @return
|
}
|
||||||
*/
|
|
||||||
private JSONArray rows2jsonarray(ArrayList<BasicDynaBean> rows) {
|
|
||||||
JSONArray jrows = new JSONArray();
|
|
||||||
for (Iterator<BasicDynaBean> it = rows.iterator(); it.hasNext(); ) {
|
|
||||||
BasicDynaBean row = (BasicDynaBean) it.next();
|
|
||||||
jrows.add(row2jsonobject(row));
|
|
||||||
}
|
|
||||||
return jrows;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private JSONObject row2jsonobject(BasicDynaBean row) {
|
|
||||||
JSONObject jrow = new JSONObject();
|
|
||||||
DynaProperty[] props = row.getDynaClass().getDynaProperties();
|
|
||||||
for (int j = 0; j < props.length; j++) {
|
|
||||||
DynaProperty prop = props[j];
|
|
||||||
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);
|
jrow.put(key, strValue);
|
||||||
}
|
}
|
||||||
return jrow;
|
return jrow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSplitPageResultSet(ResultSet value, int start, int end) throws SQLException {
|
public void addSplitPageResultSet(ResultSet value, int start, int end)
|
||||||
if (start < 0) {
|
throws SQLException {
|
||||||
addResultSet(value);
|
if(start < 0) {
|
||||||
return;
|
addResultSet(value);
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
value.absolute(start);
|
value.absolute(start);
|
||||||
ArrayList rs = new ArrayList();
|
ArrayList rs = new ArrayList();
|
||||||
ResultSetMetaData rsmd = value.getMetaData();
|
ResultSetMetaData rsmd = value.getMetaData();
|
||||||
DynaProperty[] dps = new DynaProperty[rsmd.getColumnCount()];
|
DynaProperty[] dps = new DynaProperty[rsmd.getColumnCount()];
|
||||||
for (int i = 0; i < dps.length; i++) {
|
for(int i = 0; i < dps.length; i++) {
|
||||||
dps[i] = new DynaProperty(rsmd.getColumnName(i + 1).toLowerCase());
|
dps[i] = new DynaProperty(rsmd.getColumnName(i + 1).toLowerCase());
|
||||||
}
|
}
|
||||||
|
for(int i = start; i < end; i++) {
|
||||||
for (int i = start; i < end; i++) {
|
BasicDynaClass bdc = new BasicDynaClass("", BasicDynaBean.class, dps);
|
||||||
BasicDynaClass bdc = new BasicDynaClass("", BasicDynaBean.class, dps);
|
BasicDynaBean bdb = new BasicDynaBean(bdc);
|
||||||
BasicDynaBean bdb = new BasicDynaBean(bdc);
|
if(value.next()) {
|
||||||
if (value.next()) {
|
for(int j = 0; j < dps.length; j++) {
|
||||||
for (int j = 0; j < dps.length; j++) {
|
bdb.set(dps[j].getName(), value.getString(dps[j].getName()));
|
||||||
bdb.set(dps[j].getName(), value.getString(dps[j].getName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
rs.add(bdb);
|
|
||||||
} else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (rslist == null) {
|
|
||||||
rslist = new ArrayList();
|
|
||||||
}
|
|
||||||
rslist.add(rs);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询结束后添加结果集
|
|
||||||
*
|
|
||||||
* @param sqlResultSet jdbc的resultSet
|
|
||||||
*/
|
|
||||||
public void addResultSet(ResultSet sqlResultSet) {
|
|
||||||
if (rslist == null) {
|
|
||||||
rslist = new ArrayList();
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
//支持别名的设置
|
|
||||||
WQLRowSetDynaClass rs = new WQLRowSetDynaClass(sqlResultSet, true, -1);
|
|
||||||
rslist.add(rs);
|
|
||||||
ResultCount = rslist.size();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询结束后添加结果集
|
|
||||||
*
|
|
||||||
* @param list
|
|
||||||
*/
|
|
||||||
public void addResultSet(ArrayList<BasicDynaBean> list) {
|
|
||||||
if (rslist == null) {
|
|
||||||
rslist = new ArrayList();
|
|
||||||
}
|
|
||||||
|
|
||||||
rslist.add(list);
|
|
||||||
ResultCount = rslist.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 开始新的查询前清空之前的结果集记录
|
|
||||||
*/
|
|
||||||
public void clearResultSet() {
|
|
||||||
rslist = null;
|
|
||||||
ResultCount = 0;
|
|
||||||
RowsCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList getInfoDump() {
|
|
||||||
return InfoDump;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInfoDump(ArrayList details) {
|
|
||||||
this.InfoDump = details;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList getInfoError() {
|
|
||||||
return InfoError;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInfoError(ArrayList details) {
|
|
||||||
this.InfoError = details;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList getInfoTrace() {
|
|
||||||
return InfoTrace;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInfoTrace(ArrayList details) {
|
|
||||||
this.InfoTrace = details;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the ResultCount.
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public int getResultCount() {
|
|
||||||
if (rslist != null) {
|
|
||||||
ResultCount = rslist.size();
|
|
||||||
}
|
|
||||||
return ResultCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setResultSets(ArrayList details) {
|
|
||||||
if (details != null) {
|
|
||||||
this.rslist = details;
|
|
||||||
ResultCount = rslist.size();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList getResultSets() {
|
|
||||||
if (rslist == null) {
|
|
||||||
rslist = new ArrayList();
|
|
||||||
}
|
|
||||||
return rslist;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString() {
|
|
||||||
StringBuffer sStr = new StringBuffer();
|
|
||||||
if (InfoTrace != null) {
|
|
||||||
sStr.append("\n InfoTrace Size =" + InfoTrace.size());
|
|
||||||
}
|
|
||||||
if (InfoError != null) {
|
|
||||||
sStr.append(sStr + "\n InfoError Size =" + InfoError.size());
|
|
||||||
}
|
|
||||||
if (InfoDump != null) {
|
|
||||||
sStr.append(sStr + "\n InfoDump Size =" + InfoDump.size());
|
|
||||||
}
|
|
||||||
if (rslist != null) {
|
|
||||||
sStr.append("\n 结果集总数为(" + rslist.size() + ")个");
|
|
||||||
for (int i = 1; i <= rslist.size(); i++) {
|
|
||||||
RowSetDynaClass rs = (RowSetDynaClass) rslist.get(i - 1);
|
|
||||||
List rows = rs.getRows();
|
|
||||||
sStr.append("\n 第(" + i + ")个结果集有(" + rows.size() + ")条记录");
|
|
||||||
// DynaProperty
|
|
||||||
DynaProperty properties[] = rs.getDynaProperties();
|
|
||||||
for (int j = 0; j < properties.length; j++) {
|
|
||||||
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()));
|
|
||||||
}
|
}
|
||||||
}
|
rs.add(bdb);
|
||||||
|
}
|
||||||
|
else{break;}
|
||||||
|
}
|
||||||
|
if(rslist == null) {
|
||||||
|
rslist = new ArrayList();
|
||||||
|
}
|
||||||
|
rslist.add(rs);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
/**
|
||||||
}
|
* 查询结束后添加结果集
|
||||||
return sStr.toString();
|
*
|
||||||
}
|
* @param sqlResultSet jdbc的resultSet
|
||||||
|
*/
|
||||||
|
public void addResultSet(ResultSet sqlResultSet) {
|
||||||
|
if(rslist == null) {
|
||||||
|
rslist = new ArrayList();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
//支持别名的设置
|
||||||
|
WQLRowSetDynaClass rs = new WQLRowSetDynaClass(sqlResultSet, true, -1);
|
||||||
|
rslist.add(rs);
|
||||||
|
ResultCount = rslist.size();
|
||||||
|
}
|
||||||
|
catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 测试用
|
* 查询结束后添加结果集
|
||||||
*
|
*
|
||||||
* @param args
|
* @param list
|
||||||
*/
|
*/
|
||||||
public static void main2s(String[] args) {
|
public void addResultSet(ArrayList<BasicDynaBean> list) {
|
||||||
|
if(rslist == null) {
|
||||||
|
rslist = new ArrayList();
|
||||||
|
}
|
||||||
|
rslist.add(list);
|
||||||
|
ResultCount = rslist.size();
|
||||||
|
}
|
||||||
|
|
||||||
ResultBean ii = new ResultBean();
|
/**
|
||||||
// ii.setResultSets(null);
|
* 开始新的查询前清空之前的结果集记录
|
||||||
// System.exit(0);
|
*/
|
||||||
try {
|
public void clearResultSet() {
|
||||||
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
|
rslist = null;
|
||||||
Connection conn = DriverManager
|
ResultCount = 0;
|
||||||
.getConnection("jdbc:sqlserver://192.168.1.4:1433;User=tc;Password=business;DatabaseName=test");
|
RowsCount = 0;
|
||||||
conn.setAutoCommit(false);
|
}
|
||||||
String sqlStr = "";
|
|
||||||
CallableStatement st;
|
|
||||||
|
|
||||||
// sqlStr =
|
public ArrayList getInfoDump() {
|
||||||
// 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 ",
|
return InfoDump;
|
||||||
// 1);
|
}
|
||||||
st = conn.prepareCall(sqlStr, ResultSet.TYPE_SCROLL_INSENSITIVE,
|
|
||||||
ResultSet.CONCUR_READ_ONLY);
|
|
||||||
st.setString(1, "");
|
|
||||||
st.setString(2, "");
|
|
||||||
st.setString(3, "");
|
|
||||||
st.setString(4, "");
|
|
||||||
st.setString(5, "");
|
|
||||||
st.execute();
|
|
||||||
ResultBean ior = new ResultBean();
|
|
||||||
ResultSet rs = st.getResultSet();
|
|
||||||
ior.addSplitPageResultSet(rs, 1, 5);
|
|
||||||
|
|
||||||
st.close();
|
public void setInfoDump(ArrayList details) {
|
||||||
st = null;
|
this.InfoDump = details;
|
||||||
conn.close();
|
}
|
||||||
conn = null;
|
|
||||||
|
|
||||||
ArrayList al = ior.getResultSets();
|
public ArrayList getInfoError() {
|
||||||
System.out.println(al.size());
|
return InfoError;
|
||||||
ArrayList temp = ior.getResultSet(1);
|
}
|
||||||
System.out.println(temp.size());
|
|
||||||
System.out.println(temp.get(0).getClass().getName());
|
|
||||||
BasicDynaBean bdb = (BasicDynaBean) temp.get(0);
|
|
||||||
BasicDynaClass bdc = (BasicDynaClass) bdb.getDynaClass();
|
|
||||||
DynaProperty[] dp = bdc.getDynaProperties();
|
|
||||||
for (int i = 0; i < dp.length; i++) {
|
|
||||||
System.out.println(dp[i] + "=" + bdb.get(dp[i].getName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
public void setInfoError(ArrayList details) {
|
||||||
e.printStackTrace();
|
this.InfoError = details;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
public ArrayList getInfoTrace() {
|
||||||
|
return InfoTrace;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInfoTrace(ArrayList details) {
|
||||||
|
this.InfoTrace = details;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the ResultCount.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public int getResultCount() {
|
||||||
|
if(rslist != null) {
|
||||||
|
ResultCount = rslist.size();
|
||||||
|
}
|
||||||
|
return ResultCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResultSets(ArrayList details) {
|
||||||
|
if(details != null) {
|
||||||
|
this.rslist = details;
|
||||||
|
ResultCount = rslist.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList getResultSets() {
|
||||||
|
if(rslist == null) {
|
||||||
|
rslist = new ArrayList();
|
||||||
|
}
|
||||||
|
return rslist;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
StringBuffer sStr = new StringBuffer();
|
||||||
|
if(InfoTrace != null) {
|
||||||
|
sStr.append("\n InfoTrace Size =" + InfoTrace.size());
|
||||||
|
}
|
||||||
|
if(InfoError != null) {
|
||||||
|
sStr.append(sStr + "\n InfoError Size =" + InfoError.size());
|
||||||
|
}
|
||||||
|
if(InfoDump != null) {
|
||||||
|
sStr.append(sStr + "\n InfoDump Size =" + InfoDump.size());
|
||||||
|
}
|
||||||
|
if(rslist != null) {
|
||||||
|
sStr.append("\n 结果集总数为(" + rslist.size() + ")个");
|
||||||
|
for(int i = 1; i <= rslist.size(); i++) {
|
||||||
|
RowSetDynaClass rs = (RowSetDynaClass) rslist.get(i - 1);
|
||||||
|
List rows = rs.getRows();
|
||||||
|
sStr.append("\n 第(" + i + ")个结果集有(" + rows.size() + ")条记录");
|
||||||
|
// DynaProperty
|
||||||
|
DynaProperty properties[] = rs.getDynaProperties();
|
||||||
|
for(int j = 0; j < properties.length; j++) {
|
||||||
|
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()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sStr.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试用
|
||||||
|
*
|
||||||
|
* @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");
|
||||||
|
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.setString(1, "");
|
||||||
|
st.setString(2, "");
|
||||||
|
st.setString(3, "");
|
||||||
|
st.setString(4, "");
|
||||||
|
st.setString(5, "");
|
||||||
|
st.execute();
|
||||||
|
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);
|
||||||
|
System.out.println(temp.size());
|
||||||
|
System.out.println(temp.get(0).getClass().getName());
|
||||||
|
BasicDynaBean bdb = (BasicDynaBean) temp.get(0);
|
||||||
|
BasicDynaClass bdc = (BasicDynaClass) bdb.getDynaClass();
|
||||||
|
DynaProperty[] dp = bdc.getDynaProperties();
|
||||||
|
for(int i = 0; i < dp.length; i++) {
|
||||||
|
System.out.println(dp[i] + "=" + bdb.get(dp[i].getName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -19,33 +19,44 @@ import java.util.regex.Matcher;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class WqlUtil {
|
public class WqlUtil{
|
||||||
private static final int[] IA = new int[256];
|
private static final int[] IA = new int[256];
|
||||||
|
|
||||||
public static HttpContext getHttpContext(Pageable pageable) {
|
public static HttpContext getHttpContext(Pageable pageable) {
|
||||||
HttpContext ctx = new HttpContext(WqlUtil.getUUID());
|
HttpContext ctx = new HttpContext(WqlUtil.getUUID());
|
||||||
ctx.setPage((pageable.getPageNumber() + 1) + "");
|
ctx.setPage((pageable.getPageNumber() + 1) + "");
|
||||||
ctx.setRows(pageable.getPageSize() + "");
|
ctx.setRows(pageable.getPageSize() + "");
|
||||||
return ctx;
|
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) {
|
public static String getSQLFieldValue(Object o) {
|
||||||
String str = new String();
|
String str = new String();
|
||||||
if (o == null) {
|
if(o == null) {
|
||||||
return "";
|
return "";
|
||||||
} else {
|
}
|
||||||
String classStr = o.getClass().getName();
|
else{
|
||||||
if ("java.lang.String".equals(classStr)) {
|
String classStr = o.getClass().getName();
|
||||||
str = (String) o;
|
if("java.lang.String".equals(classStr)) {
|
||||||
} else if ("java.lang.Long".equals(classStr)) {
|
str = (String) o;
|
||||||
Long e = (Long) o;
|
}
|
||||||
str = e.toString();
|
else if("java.lang.Long".equals(classStr)) {
|
||||||
} else if ("java.lang.Double".equals(classStr)) {
|
Long e = (Long) o;
|
||||||
str = String.valueOf(o);
|
str = e.toString();
|
||||||
} else if ("java.math.BigInteger".equals(classStr)) {
|
}
|
||||||
str = String.valueOf(o);
|
else if("java.lang.Double".equals(classStr)) {
|
||||||
} else if ("oracle.sql.CLOB".equals(classStr)) {
|
str = String.valueOf(o);
|
||||||
|
}
|
||||||
|
else if("java.math.BigInteger".equals(classStr)) {
|
||||||
|
str = String.valueOf(o);
|
||||||
|
}
|
||||||
|
else if("oracle.sql.CLOB".equals(classStr)) {
|
||||||
/* CLOB e2 = (CLOB) o;
|
/* CLOB e2 = (CLOB) o;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -55,56 +66,59 @@ public class WqlUtil {
|
|||||||
} catch (SQLException arg16) {
|
} catch (SQLException arg16) {
|
||||||
arg16.printStackTrace();
|
arg16.printStackTrace();
|
||||||
}*/
|
}*/
|
||||||
} else if ("java.lang.Integer".equals(classStr)) {
|
}
|
||||||
Integer e3 = (Integer) o;
|
else if("java.lang.Integer".equals(classStr)) {
|
||||||
str = e3.toString();
|
Integer e3 = (Integer) o;
|
||||||
} else if ("java.lang.Short".equals(classStr)) {
|
str = e3.toString();
|
||||||
Short e4 = (Short) o;
|
}
|
||||||
str = e4.toString();
|
else if("java.lang.Short".equals(classStr)) {
|
||||||
} else if ("java.math.BigDecimal".equals(classStr)) {
|
Short e4 = (Short) o;
|
||||||
BigDecimal e5 = (BigDecimal) o;
|
str = e4.toString();
|
||||||
str = e5.toString();
|
}
|
||||||
} else {
|
else if("java.math.BigDecimal".equals(classStr)) {
|
||||||
Method e6;
|
BigDecimal e5 = (BigDecimal) o;
|
||||||
if (classStr.startsWith("com.ibm.db2.jcc")) {
|
str = e5.toString();
|
||||||
try {
|
}
|
||||||
if (o != null) {
|
else{
|
||||||
e6 = o.getClass().getMethod("getSubString", new Class[]{Long.TYPE, Integer.TYPE});
|
Method e6;
|
||||||
Method subo = o.getClass().getMethod("length", new Class[0]);
|
if(classStr.startsWith("com.ibm.db2.jcc")) {
|
||||||
int subclass = ((Long) subo.invoke(o, new Object[0])).intValue();
|
try {
|
||||||
if (subclass > 0) {
|
if(o != null) {
|
||||||
str = (String) e6.invoke(o, new Object[]{Long.valueOf(1L), Integer.valueOf(subclass)});
|
e6 = o.getClass().getMethod("getSubString", new Class[]{Long.TYPE, Integer.TYPE});
|
||||||
}
|
Method subo = o.getClass().getMethod("length", new Class[0]);
|
||||||
}
|
int subclass = ((Long) subo.invoke(o, new Object[0])).intValue();
|
||||||
} catch (Exception arg15) {
|
if(subclass > 0) {
|
||||||
log.error(
|
str = (String) e6.invoke(o, new Object[]{Long.valueOf(1L), Integer.valueOf(subclass)});
|
||||||
"getSQLFieldValue error, class=com.ibm.db2.jcc :" + arg15.getMessage());
|
}
|
||||||
arg15.printStackTrace();
|
}
|
||||||
|
}
|
||||||
|
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 {
|
try {
|
||||||
e6 = o.getClass().getMethod("getVendorObj", new Class[0]);
|
e6 = o.getClass().getMethod("getVendorObj", new Class[0]);
|
||||||
Object subo1 = e6.invoke(o, new Object[0]);
|
Object subo1 = e6.invoke(o, new Object[0]);
|
||||||
String subclass1 = subo1.getClass().getName();
|
String subclass1 = subo1.getClass().getName();
|
||||||
if (subclass1.startsWith("com.ibm.db2.jcc")) {
|
if(subclass1.startsWith("com.ibm.db2.jcc")) {
|
||||||
try {
|
try {
|
||||||
if (subo1 != null) {
|
if(subo1 != null) {
|
||||||
Method clob = subo1.getClass().getMethod("getSubString",
|
Method clob = subo1.getClass().getMethod("getSubString", new Class[]{Long.TYPE, Integer.TYPE});
|
||||||
new Class[]{Long.TYPE, Integer.TYPE});
|
Method e1 = subo1.getClass().getMethod("length", new Class[0]);
|
||||||
Method e1 = subo1.getClass().getMethod("length", new Class[0]);
|
int length = ((Long) e1.invoke(subo1, new Object[0])).intValue();
|
||||||
int length = ((Long) e1.invoke(subo1, new Object[0])).intValue();
|
if(length > 0) {
|
||||||
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) {
|
||||||
} catch (Exception arg9) {
|
log.error("getSQLFieldValue error, class=weblogic.jdbc.wrapper.Clob_com.ibm.db2.jcc.* :" + arg9.getMessage());
|
||||||
log.error(
|
arg9.printStackTrace();
|
||||||
"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;
|
/* CLOB clob1 = (CLOB) subo1;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -114,287 +128,274 @@ public class WqlUtil {
|
|||||||
} catch (Exception arg8) {
|
} catch (Exception arg8) {
|
||||||
arg8.printStackTrace();
|
arg8.printStackTrace();
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
} catch (SecurityException arg10) {
|
}
|
||||||
arg10.printStackTrace();
|
catch(SecurityException arg10) {
|
||||||
} catch (IllegalArgumentException arg11) {
|
arg10.printStackTrace();
|
||||||
arg11.printStackTrace();
|
}
|
||||||
} catch (NoSuchMethodException arg12) {
|
catch(IllegalArgumentException arg11) {
|
||||||
arg12.printStackTrace();
|
arg11.printStackTrace();
|
||||||
} catch (IllegalAccessException arg13) {
|
}
|
||||||
arg13.printStackTrace();
|
catch(NoSuchMethodException arg12) {
|
||||||
} catch (InvocationTargetException arg14) {
|
arg12.printStackTrace();
|
||||||
arg14.printStackTrace();
|
}
|
||||||
|
catch(IllegalAccessException arg13) {
|
||||||
|
arg13.printStackTrace();
|
||||||
|
}
|
||||||
|
catch(InvocationTargetException arg14) {
|
||||||
|
arg14.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return str;
|
public static Object cloneObject(Object obj)
|
||||||
}
|
throws Exception {
|
||||||
}
|
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
|
||||||
|
ObjectOutputStream out = new ObjectOutputStream(byteOut);
|
||||||
|
out.writeObject(obj);
|
||||||
|
ByteArrayInputStream byteIn = new ByteArrayInputStream(byteOut.toByteArray());
|
||||||
|
ObjectInputStream in = new ObjectInputStream(byteIn);
|
||||||
|
return in.readObject();
|
||||||
|
}
|
||||||
|
|
||||||
public static Object cloneObject(Object obj) throws Exception {
|
public static boolean isString(Object o) {
|
||||||
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
|
return "java.lang.String".equals(o.getClass().getName());
|
||||||
ObjectOutputStream out = new ObjectOutputStream(byteOut);
|
}
|
||||||
out.writeObject(obj);
|
|
||||||
ByteArrayInputStream byteIn = new ByteArrayInputStream(byteOut.toByteArray());
|
|
||||||
ObjectInputStream in = new ObjectInputStream(byteIn);
|
|
||||||
return in.readObject();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isString(Object o) {
|
public static String between(String str, String beginStr, String endStr) {
|
||||||
return "java.lang.String".equals(o.getClass().getName());
|
try {
|
||||||
}
|
if(str == null || "".equals(str.trim())) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
str = str.substring(str.indexOf(beginStr) + 1, str.indexOf(endStr));
|
||||||
|
}
|
||||||
|
catch(Exception arg3) {
|
||||||
|
arg3.printStackTrace();
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
public static String between(String str, String beginStr, String endStr) {
|
public static String _replaceStr(String source, String oldString, String newString) {
|
||||||
try {
|
StringBuffer output = new StringBuffer();
|
||||||
if (str == null || "".equals(str.trim())) {
|
int lengthOfSource = source.length();
|
||||||
return "";
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
str = str.substring(str.indexOf(beginStr) + 1, str.indexOf(endStr));
|
public static boolean isNotBlank(String str) {
|
||||||
} catch (Exception arg3) {
|
int length;
|
||||||
arg3.printStackTrace();
|
if(str != null && (length = str.length()) != 0) {
|
||||||
}
|
for(int i = 0; i < length; ++i) {
|
||||||
|
if(!Character.isWhitespace(str.charAt(i))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return str;
|
public static boolean contains(String s1, String s2) {
|
||||||
}
|
boolean ishas = false;
|
||||||
|
if(-1 != s1.indexOf(s2)) {
|
||||||
|
ishas = true;
|
||||||
|
}
|
||||||
|
return ishas;
|
||||||
|
}
|
||||||
|
|
||||||
public static String _replaceStr(String source, String oldString, String newString) {
|
public static String rtrim(String str) {
|
||||||
StringBuffer output = new StringBuffer();
|
Pattern pat = Pattern.compile("[\t\n ]$");
|
||||||
int lengthOfSource = source.length();
|
for(Matcher mat = pat.matcher(str); mat.find(); mat = pat.matcher(str)) {
|
||||||
int lengthOfOld = oldString.length();
|
str = mat.replaceAll("");
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
int posStart;
|
public static String getUUID() {
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isNotBlank(String str) {
|
|
||||||
int length;
|
|
||||||
if (str != null && (length = str.length()) != 0) {
|
|
||||||
for (int i = 0; i < length; ++i) {
|
|
||||||
if (!Character.isWhitespace(str.charAt(i))) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean contains(String s1, String s2) {
|
|
||||||
boolean ishas = false;
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getUUID() {
|
|
||||||
/*String primaryKey = UUIDGenerator.getInstance().generateRandomBasedUUID().toString();
|
/*String primaryKey = UUIDGenerator.getInstance().generateRandomBasedUUID().toString();
|
||||||
primaryKey = primaryKey.replaceAll("-", "");
|
primaryKey = primaryKey.replaceAll("-", "");
|
||||||
primaryKey = primaryKey.toUpperCase();
|
primaryKey = primaryKey.toUpperCase();
|
||||||
return primaryKey;*/
|
return primaryKey;*/
|
||||||
return "11";
|
return "11";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String ctrim(String str) {
|
public static String ctrim(String str) {
|
||||||
Pattern pat = Pattern.compile("[\t]");
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
Matcher mat;
|
/**
|
||||||
for (mat = pat.matcher(str); mat.find(); mat = pat.matcher(str)) {
|
* 获取实体类和表的映射关系
|
||||||
str = mat.replaceAll(" ");
|
*
|
||||||
}
|
* @param instance
|
||||||
|
* @return
|
||||||
pat = Pattern.compile("[ ]{2,}");
|
*/
|
||||||
|
public static Map<String,String> getDeclaredFieldsInfo(Object instance) {
|
||||||
for (mat = pat.matcher(str); mat.find(); mat = pat.matcher(str)) {
|
Map<String,String> map = new HashMap();
|
||||||
str = mat.replaceAll(" ");
|
Class<?> clazz = instance.getClass();
|
||||||
}
|
Field[] fields = clazz.getDeclaredFields();
|
||||||
|
boolean b = false;
|
||||||
return str;
|
for(int i = 0; i < fields.length; i++) {
|
||||||
}
|
fields[i].setAccessible(true);
|
||||||
|
boolean annotationPresent = fields[i].isAnnotationPresent(Column.class);
|
||||||
/**
|
if(annotationPresent) {
|
||||||
* 获取实体类和表的映射关系
|
// 获取注解值
|
||||||
*
|
String name = fields[i].getAnnotation(Column.class).name();
|
||||||
* @param instance
|
// map.put(name, fields[i].getName());
|
||||||
* @return
|
try {
|
||||||
*/
|
//实例值
|
||||||
public static Map<String, String> getDeclaredFieldsInfo(Object instance) {
|
String value = StrUtil.toString(fields[i].get(instance));
|
||||||
Map<String, String> map = new HashMap();
|
if(!"null".equals(value)) {
|
||||||
Class<?> clazz = instance.getClass();
|
map.put(name, value);
|
||||||
Field[] fields = clazz.getDeclaredFields();
|
}
|
||||||
boolean b = false;
|
|
||||||
for (int i = 0; i < fields.length; i++) {
|
|
||||||
fields[i].setAccessible(true);
|
|
||||||
boolean annotationPresent = fields[i].isAnnotationPresent(Column.class);
|
|
||||||
if (annotationPresent) {
|
|
||||||
// 获取注解值
|
|
||||||
String name = fields[i].getAnnotation(Column.class).name();
|
|
||||||
// map.put(name, fields[i].getName());
|
|
||||||
try {
|
|
||||||
//实例值
|
|
||||||
String value = StrUtil.toString(fields[i].get(instance));
|
|
||||||
if (!"null".equals(value)) {
|
|
||||||
map.put(name, value);
|
|
||||||
}
|
}
|
||||||
|
catch(IllegalAccessException e) {
|
||||||
} catch (IllegalAccessException e) {
|
e.printStackTrace();
|
||||||
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 {
|
|
||||||
File file = new File(strFileNameAndPath);
|
|
||||||
return getFileBytes(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
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());
|
|
||||||
fileStream.close();
|
|
||||||
return bfile;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 {
|
|
||||||
File file = new File(uri);
|
|
||||||
FileInputStream fileStream = new FileInputStream(file);
|
|
||||||
byte[] bfile = new byte[(int) file.length()];
|
|
||||||
fileStream.read(bfile, 0, (int) file.length());
|
|
||||||
fileStream.close();
|
|
||||||
return bfile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final String decode2String(byte[] sArr) throws UnsupportedEncodingException {
|
|
||||||
byte[] bytes = decode(sArr);
|
|
||||||
String str = new String(bytes, "UTF-8");
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 {
|
|
||||||
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 {
|
|
||||||
--j;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
dArr[d++] = (byte) (i >> 16);
|
public static String getTableNameByInstance(Class clazz) {
|
||||||
if (d < len) {
|
Table anno = (Table) clazz.getAnnotation(Table.class);
|
||||||
dArr[d++] = (byte) (i >> 8);
|
//返回实体类表名
|
||||||
if (d < len) {
|
return anno.name();
|
||||||
dArr[d++] = (byte) i;
|
}
|
||||||
|
|
||||||
|
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 {
|
||||||
|
File file = new File(strFileNameAndPath);
|
||||||
|
return getFileBytes(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
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());
|
||||||
|
fileStream.close();
|
||||||
|
return bfile;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 {
|
||||||
|
File file = new File(uri);
|
||||||
|
FileInputStream fileStream = new FileInputStream(file);
|
||||||
|
byte[] bfile = new byte[(int) file.length()];
|
||||||
|
fileStream.read(bfile, 0, (int) file.length());
|
||||||
|
fileStream.close();
|
||||||
|
return bfile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String decode2String(byte[] sArr)
|
||||||
|
throws UnsupportedEncodingException {
|
||||||
|
byte[] bytes = decode(sArr);
|
||||||
|
String str = new String(bytes, "UTF-8");
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
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{
|
||||||
|
pad = 0;
|
||||||
|
int len = sLen;
|
||||||
|
while(len > 1) {
|
||||||
|
--len;
|
||||||
|
if(IA[sArr[len] & 255] > 0) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
if(sArr[len] == 126) {
|
||||||
}
|
++pad;
|
||||||
|
}
|
||||||
return dArr;
|
}
|
||||||
}
|
len = ((sLen - sepCnt) * 6 >> 3) - pad;
|
||||||
}
|
byte[] dArr = new byte[len];
|
||||||
|
int s = 0;
|
||||||
public static boolean isBlank(String str) {
|
int d = 0;
|
||||||
int length;
|
while(d < len) {
|
||||||
if (str != null && (length = str.length()) != 0) {
|
int i = 0;
|
||||||
for (int i = 0; i < length; ++i) {
|
for(int j = 0; j < 4; ++j) {
|
||||||
if (!Character.isWhitespace(str.charAt(i))) {
|
int c = IA[sArr[s++] & 255];
|
||||||
return false;
|
if(c >= 0) {
|
||||||
}
|
i |= c << 18 - j * 6;
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
return true;
|
--j;
|
||||||
} else {
|
}
|
||||||
return true;
|
}
|
||||||
}
|
dArr[d++] = (byte) (i >> 16);
|
||||||
}
|
if(d < len) {
|
||||||
|
dArr[d++] = (byte) (i >> 8);
|
||||||
|
if(d < len) {
|
||||||
|
dArr[d++] = (byte) i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dArr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isBlank(String str) {
|
||||||
|
int length;
|
||||||
|
if(str != null && (length = str.length()) != 0) {
|
||||||
|
for(int i = 0; i < length; ++i) {
|
||||||
|
if(!Character.isWhitespace(str.charAt(i))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ import java.util.Map;
|
|||||||
public class CacheLineHandController{
|
public class CacheLineHandController{
|
||||||
private final CacheLineHandService cacheLineHandService;
|
private final CacheLineHandService cacheLineHandService;
|
||||||
|
|
||||||
@PostMapping("/queryMaterial")
|
@PostMapping("/materialQuery")
|
||||||
@Log("物料查询")
|
@Log("物料查询")
|
||||||
@ApiOperation("物料查询")
|
@ApiOperation("物料查询")
|
||||||
public ResponseEntity<List<MaterialDto>> queryMaterial(@RequestBody JSONObject form) {
|
public ResponseEntity<List<MaterialDto>> queryMaterial(@RequestBody JSONObject form) {
|
||||||
@@ -48,14 +48,14 @@ public class CacheLineHandController{
|
|||||||
if(StringUtils.isNotEmpty(params)) {
|
if(StringUtils.isNotEmpty(params)) {
|
||||||
//限制查询参数过短,模糊力度大
|
//限制查询参数过短,模糊力度大
|
||||||
int length = params.getBytes().length;
|
int length = params.getBytes().length;
|
||||||
if(length < 3) {
|
if(length < 4) {
|
||||||
throw new BizCoreException("您输入的条件所匹配的范围太大,请输入大于2个字的内容。");
|
throw new BizCoreException("输入条件所查询的内容过多,请输入大于3个字的查询条件。");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new ResponseEntity<>(cacheLineHandService.queryMaterial(params), HttpStatus.OK);
|
return new ResponseEntity<>(cacheLineHandService.queryMaterial(params), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/materialQuery")
|
@PostMapping("/queryMaterial")
|
||||||
@Log("物料模糊查询")
|
@Log("物料模糊查询")
|
||||||
@ApiOperation("物料模糊查询")
|
@ApiOperation("物料模糊查询")
|
||||||
public ResponseEntity<JSONArray> materialQuery(@RequestBody JSONObject form) {
|
public ResponseEntity<JSONArray> materialQuery(@RequestBody JSONObject form) {
|
||||||
@@ -64,8 +64,8 @@ public class CacheLineHandController{
|
|||||||
if(StringUtils.isNotEmpty(params)) {
|
if(StringUtils.isNotEmpty(params)) {
|
||||||
//限制查询参数过短,模糊力度大
|
//限制查询参数过短,模糊力度大
|
||||||
int length = params.getBytes().length;
|
int length = params.getBytes().length;
|
||||||
if(length < 3) {
|
if(length < 4) {
|
||||||
throw new BizCoreException("您输入的条件所匹配的范围太大,请输入大于2个字的内容。");
|
throw new BizCoreException("输入条件所查询的内容过多,请输入大于3个字的查询条件。");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new ResponseEntity<>(cacheLineHandService.materialQuery(form.getString("search_bar")), HttpStatus.OK);
|
return new ResponseEntity<>(cacheLineHandService.materialQuery(form.getString("search_bar")), HttpStatus.OK);
|
||||||
@@ -117,7 +117,7 @@ public class CacheLineHandController{
|
|||||||
@PostMapping("/instOperation")
|
@PostMapping("/instOperation")
|
||||||
@Log("任务操作")
|
@Log("任务操作")
|
||||||
@ApiOperation("任务操作")
|
@ApiOperation("任务操作")
|
||||||
public ResponseEntity<String> instOperation(@RequestBody JSONObject param) {
|
public ResponseEntity<Object> instOperation(@RequestBody JSONObject param) {
|
||||||
log.info("海亮缓存线手持服务 [任务操作] 接口被请求, 请求参数-{}", param);
|
log.info("海亮缓存线手持服务 [任务操作] 接口被请求, 请求参数-{}", param);
|
||||||
//任务类型和任务ID校验,instruct_uuid为前端参数命名,本来应为task_id
|
//任务类型和任务ID校验,instruct_uuid为前端参数命名,本来应为task_id
|
||||||
if(StringUtils.isEmpty(param.getString("instruct_uuid")) || StringUtils.isEmpty(param.getString("opt_type"))) {
|
if(StringUtils.isEmpty(param.getString("instruct_uuid")) || StringUtils.isEmpty(param.getString("opt_type"))) {
|
||||||
@@ -141,7 +141,7 @@ public class CacheLineHandController{
|
|||||||
@PostMapping("/cacheLineOutBoxExceptionConfirm")
|
@PostMapping("/cacheLineOutBoxExceptionConfirm")
|
||||||
@Log("缓存线出入箱异常-确认")
|
@Log("缓存线出入箱异常-确认")
|
||||||
@ApiOperation("缓存线出入箱异常-确认")
|
@ApiOperation("缓存线出入箱异常-确认")
|
||||||
public ResponseEntity<String> cacheLineOutBoxExceptionConfirm(@RequestBody JSONObject param) {
|
public ResponseEntity<Object> cacheLineOutBoxExceptionConfirm(@RequestBody JSONObject param) {
|
||||||
log.info("海亮缓存线手持服务 [缓存线出箱异常-确认] 接口被请求, 请求参数-{}", param);
|
log.info("海亮缓存线手持服务 [缓存线出箱异常-确认] 接口被请求, 请求参数-{}", param);
|
||||||
//参数校验
|
//参数校验
|
||||||
if(StringUtils.isEmpty(param.getString("wcsdevice_code")) || StringUtils.isEmpty(param.getString("position_code")) || StringUtils.isEmpty(param.getString("vehicle_code"))) {
|
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")
|
@PostMapping("/inOutEmptyBox")
|
||||||
@Log("空箱初始化--出入空箱")
|
@Log("空箱初始化--出入空箱")
|
||||||
@ApiOperation("空箱初始化--出入空箱")
|
@ApiOperation("空箱初始化--出入空箱")
|
||||||
public ResponseEntity<String> inOutEmptyBox(@RequestBody JSONObject param) {
|
public ResponseEntity<Object> inOutEmptyBox(@RequestBody JSONObject param) {
|
||||||
log.info("海亮缓存线手持服务 [空箱初始化--出入空箱] 接口被请求, 请求参数-{}", param);
|
log.info("海亮缓存线手持服务 [空箱初始化--出入空箱] 接口被请求, 请求参数-{}", param);
|
||||||
//参数校验
|
//参数校验
|
||||||
if(StringUtils.isEmpty(param.getString("inOut_type")) || StringUtils.isEmpty(param.getString("wcsdevice_code")) || StringUtils.isEmpty(param.getString("vehicle_code"))) {
|
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")
|
@PostMapping("/inOutExceptionInstConfirm")
|
||||||
@Log("缓存线出入箱异常指令确认")
|
@Log("扫码异常确认")
|
||||||
@ApiOperation("缓存线出入箱异常指令确认")
|
@ApiOperation("缓存线出入箱异常指令确认")
|
||||||
public ResponseEntity<Object> inOutExceptionInstConfirm(@RequestBody JSONObject param) {
|
public ResponseEntity<Object> inOutExceptionInstConfirm(@RequestBody JSONObject param) {
|
||||||
log.info("海亮缓存线手持服务 [缓存线出入箱异常指令确认] 接口被请求, 请求参数-{}", param);
|
log.info("海亮缓存线手持服务 [缓存线出入箱异常指令确认] 接口被请求, 请求参数-{}", param);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package org.nl.wms.pda.service;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import org.nl.common.utils.api.CommonResult;
|
||||||
import org.nl.wms.pda.dto.MaterialDto;
|
import org.nl.wms.pda.dto.MaterialDto;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
|
||||||
@@ -128,10 +129,11 @@ public interface CacheLineHandService{
|
|||||||
* 缓存线出入箱异常指令确认
|
* 缓存线出入箱异常指令确认
|
||||||
*
|
*
|
||||||
* @param param 查询参数 1 扫码异常-入箱扫码 2 扫码异常-出箱扫码
|
* @param param 查询参数 1 扫码异常-入箱扫码 2 扫码异常-出箱扫码
|
||||||
|
* @return
|
||||||
* @author gbx
|
* @author gbx
|
||||||
* @date 2023/3/24
|
* @date 2023/3/24
|
||||||
*/
|
*/
|
||||||
Map<String, Object> inOutExceptionInstConfirm(JSONObject param);
|
Object inOutExceptionInstConfirm(JSONObject param);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 任务操作
|
* 任务操作
|
||||||
@@ -141,7 +143,7 @@ public interface CacheLineHandService{
|
|||||||
* @author gbx
|
* @author gbx
|
||||||
* @date 2023/3/23
|
* @date 2023/3/23
|
||||||
*/
|
*/
|
||||||
String instOperation(JSONObject param);
|
CommonResult<String> instOperation(JSONObject param);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 缓存线出箱异常-确认
|
* 缓存线出箱异常-确认
|
||||||
@@ -151,16 +153,17 @@ public interface CacheLineHandService{
|
|||||||
* @author gbx
|
* @author gbx
|
||||||
* @date 2023/3/24
|
* @date 2023/3/24
|
||||||
*/
|
*/
|
||||||
String cacheLineOutBoxExceptionConfirm(JSONObject param);
|
CommonResult<Integer> cacheLineOutBoxExceptionConfirm(JSONObject param);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 空箱初始化--出入空箱
|
* 空箱初始化--出入空箱
|
||||||
*
|
*
|
||||||
* @param param 查询参数 inOut_type:1 入空箱 2 出空箱 vehicle_code:载具编码
|
* @param param 查询参数 inOut_type:1 入空箱 2 出空箱 vehicle_code:载具编码
|
||||||
|
* @return
|
||||||
* @author gbx
|
* @author gbx
|
||||||
* @date 2023/3/24
|
* @date 2023/3/24
|
||||||
*/
|
*/
|
||||||
String inOutEmptyBox(JSONObject param);
|
CommonResult<Integer> inOutEmptyBox(JSONObject param);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置满框
|
* 设置满框
|
||||||
@@ -245,7 +248,7 @@ public interface CacheLineHandService{
|
|||||||
* @author gbx
|
* @author gbx
|
||||||
* @date 2023/3/24
|
* @date 2023/3/24
|
||||||
*/
|
*/
|
||||||
Map<String,Object> cacheLineExcepOpt(JSONObject param);
|
CommonResult<JSONObject> cacheLineExcepOpt(JSONObject param);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 倒料操作
|
* 倒料操作
|
||||||
|
|||||||
@@ -14,18 +14,18 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.nl.common.enums.StatusEnum;
|
import org.nl.common.enums.StatusEnum;
|
||||||
import org.nl.common.utils.*;
|
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.config.thread.ThreadPoolExecutorUtil;
|
||||||
import org.nl.modules.common.exception.BadRequestException;
|
import org.nl.modules.common.exception.BadRequestException;
|
||||||
import org.nl.modules.common.utils.RedisUtils;
|
import org.nl.modules.common.utils.RedisUtils;
|
||||||
import org.nl.modules.wql.WQL;
|
import org.nl.modules.wql.WQL;
|
||||||
import org.nl.modules.wql.core.bean.WQLObject;
|
import org.nl.modules.wql.core.bean.WQLObject;
|
||||||
import org.nl.modules.wql.util.WqlUtil;
|
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.dto.MaterialDto;
|
||||||
import org.nl.wms.pda.service.CacheLineHandService;
|
import org.nl.wms.pda.service.CacheLineHandService;
|
||||||
import org.nl.wms.sch.tasks.SpeMachineryTask;
|
import org.nl.wms.sch.tasks.SpeMachineryTask;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
@@ -53,6 +53,7 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
|||||||
private final RedisUtils redisUtils;
|
private final RedisUtils redisUtils;
|
||||||
@Autowired
|
@Autowired
|
||||||
private LocalCache cache;
|
private LocalCache cache;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JSONArray dropdownListQuery(String param, String type) {
|
public JSONArray dropdownListQuery(String param, String type) {
|
||||||
//初始化下拉框列表1.物料规格2.工序3.指令状态4.设备
|
//初始化下拉框列表1.物料规格2.工序3.指令状态4.设备
|
||||||
@@ -142,6 +143,8 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
|||||||
public Map<String,Object> instPageQuery(Map<String,String> param, Pageable page) {
|
public Map<String,Object> instPageQuery(Map<String,String> param, Pageable page) {
|
||||||
HashMap<String,String> map = new HashMap<>();
|
HashMap<String,String> map = new HashMap<>();
|
||||||
map.put("flag", "10");
|
map.put("flag", "10");
|
||||||
|
Integer pageNumber = 0;
|
||||||
|
Integer pageSize = 20;
|
||||||
JSONObject whereJson = JSONObject.parseObject(JSON.toJSONString(param));
|
JSONObject whereJson = JSONObject.parseObject(JSON.toJSONString(param));
|
||||||
//任务状态
|
//任务状态
|
||||||
String task_status = whereJson.getString("status");
|
String task_status = whereJson.getString("status");
|
||||||
@@ -182,25 +185,35 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
|||||||
if(StrUtil.isNotEmpty(whereJson.getString("end_date"))) {
|
if(StrUtil.isNotEmpty(whereJson.getString("end_date"))) {
|
||||||
map.put("end_date", 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
|
@Override
|
||||||
public String instOperation(JSONObject param) {
|
public CommonResult<String> instOperation(JSONObject param) {
|
||||||
String optType = param.getString("opt_type");
|
String optType = param.getString("opt_type");
|
||||||
SpeMachineryTask SpeMachineryTask = new SpeMachineryTask();
|
SpeMachineryTask SpeMachineryTask = new SpeMachineryTask();
|
||||||
WQLObject taskTab = WQLObject.getWQLObject("sch_base_task");
|
WQLObject taskTab = WQLObject.getWQLObject("sch_base_task");
|
||||||
JSONObject taskObject = taskTab.query("task_id =" + param.getString("instruct_uuid")).uniqueResult(0);
|
JSONObject taskObject = taskTab.query("task_id =" + param.getString("instruct_uuid")).uniqueResult(0);
|
||||||
//1-取消、2-完成、3-任务下发,根据操作类型执行相关操作
|
//1-取消、2-完成、3-任务下发,根据操作类型执行相关操作
|
||||||
if(StatusEnum.TASK_CANNEL.getCode().equals(optType) || StatusEnum.TASK_FINISH.getCode().equals(optType)) {
|
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)) {
|
else if(StatusEnum.TASK_PUBLISH.getCode().equals(optType)) {
|
||||||
return SpeMachineryTask.createTask(taskObject);
|
return RestBusinessTemplate.execute(() -> SpeMachineryTask.createTask(taskObject));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
return null;
|
return RestBusinessTemplate.execute(() -> "1");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,7 +229,7 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
|||||||
map.put("update_optname", nickName);
|
map.put("update_optname", nickName);
|
||||||
map.put("update_time", DateUtil.now());
|
map.put("update_time", DateUtil.now());
|
||||||
int result = (WQLObject.getWQLObject("sch_base_task").update(map, "task_id = '" + taskObj.getString("task_id") + "'").getSucess());
|
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
|
@Override
|
||||||
@@ -358,9 +371,6 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
|||||||
json.put("vehicle_code", vehicle_code);
|
json.put("vehicle_code", vehicle_code);
|
||||||
json.put("cacheLine_code", cacheLine_code);
|
json.put("cacheLine_code", cacheLine_code);
|
||||||
json.put("material_id", meObj.getString("material_id"));
|
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("weight", weight);
|
||||||
json.put("quantity", quantity);
|
json.put("quantity", quantity);
|
||||||
json.put("workprocedure_code", wpObj.getString("workprocedure_code"));
|
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);
|
JSONObject json = ivtTab.query("vehicle_code = '" + vehicle_code + "'").uniqueResult(0);
|
||||||
json.put("vehicle_status", StatusEnum.CACHE_VEL_EMT.getCode());
|
json.put("vehicle_status", StatusEnum.CACHE_VEL_EMT.getCode());
|
||||||
json.put("material_id", "");
|
json.put("material_id", "");
|
||||||
json.put("material_code", "");
|
|
||||||
json.put("material_spec", "");
|
|
||||||
json.put("material_name", "");
|
|
||||||
json.put("weight", "0");
|
json.put("weight", "0");
|
||||||
json.put("quantity", "0");
|
json.put("quantity", "0");
|
||||||
json.put("workprocedure_code", "");
|
json.put("workprocedure_code", "");
|
||||||
@@ -425,9 +432,11 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 出入空箱,出入类型 inOut_type 1 入空箱 2 出空箱 缓存线编码 wcsdevice_code 料箱码 vehicle_code
|
* 出入空箱,出入类型 inOut_type 1 入空箱 2 出空箱 缓存线编码 wcsdevice_code 料箱码 vehicle_code
|
||||||
|
*
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String inOutEmptyBox(JSONObject param) {
|
public CommonResult<Integer> inOutEmptyBox(JSONObject param) {
|
||||||
String inOut_type = param.getString("inOut_type");
|
String inOut_type = param.getString("inOut_type");
|
||||||
String cacheLine_code = param.getString("wcsdevice_code");
|
String cacheLine_code = param.getString("wcsdevice_code");
|
||||||
String vehicle_code = param.getString("vehicle_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();
|
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
|
* 缓存线编码 wcsdevice_code
|
||||||
* 缓存线位置编码 position_code
|
* 缓存线位置编码 position_code
|
||||||
* 料箱码 vehicle_code
|
* 料箱码 vehicle_code
|
||||||
|
*
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String,Object> inOutExceptionInstConfirm(JSONObject param) {
|
public CommonResult<JSONObject> inOutExceptionInstConfirm(JSONObject param) {
|
||||||
// 1 扫码异常-入箱扫码 2 扫码异常-出箱扫码
|
// 1 扫码异常-入箱扫码 2 扫码异常-出箱扫码
|
||||||
String inOut_type = param.getString("inOut_type");
|
String inOut_type = param.getString("inOut_type");
|
||||||
// 缓存线编码
|
// 缓存线编码
|
||||||
@@ -563,12 +575,8 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
|||||||
jsonArray.add(jsonObject);
|
jsonArray.add(jsonObject);
|
||||||
try {
|
try {
|
||||||
//TOFIX 等确定api后,换成下发的url
|
//TOFIX 等确定api后,换成下发的url
|
||||||
//return AcsUtil.notifyAcs("/api/cacheLineHand", jsonArray);
|
// return AcsUtil.notifyAcs("/api/cacheLineHand", jsonArray);
|
||||||
JSONObject result = new JSONObject();
|
return RestBusinessTemplate.execute(() -> new JSONObject());
|
||||||
result.put("status", HttpStatus.OK.value());
|
|
||||||
result.put("message", "操作成功!");
|
|
||||||
result.put("data", new JSONObject());
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
catch(NullPointerException e) {
|
catch(NullPointerException e) {
|
||||||
throw new BadRequestException(e.toString());
|
throw new BadRequestException(e.toString());
|
||||||
@@ -576,7 +584,7 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String,Object> cacheLineExcepOpt(JSONObject param) {
|
public CommonResult<JSONObject> cacheLineExcepOpt(JSONObject param) {
|
||||||
// 缓存线编码
|
// 缓存线编码
|
||||||
String wcsdevice_code = param.getString("wcsdevice_code");
|
String wcsdevice_code = param.getString("wcsdevice_code");
|
||||||
// opt_type 1-暂停、2-启动,默认为1暂停
|
// opt_type 1-暂停、2-启动,默认为1暂停
|
||||||
@@ -595,11 +603,7 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
|||||||
try {
|
try {
|
||||||
//TOFIX 等确定api后,换成下发的url
|
//TOFIX 等确定api后,换成下发的url
|
||||||
//return AcsUtil.notifyAcs("/api/cacheLineHand", jsonArray);
|
//return AcsUtil.notifyAcs("/api/cacheLineHand", jsonArray);
|
||||||
JSONObject result = new JSONObject();
|
return RestBusinessTemplate.execute(() -> new JSONObject());
|
||||||
result.put("status", HttpStatus.OK.value());
|
|
||||||
result.put("message", "操作成功!");
|
|
||||||
result.put("data", new JSONObject());
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
catch(NullPointerException e) {
|
catch(NullPointerException e) {
|
||||||
throw new BadRequestException(e.toString());
|
throw new BadRequestException(e.toString());
|
||||||
@@ -634,7 +638,13 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
|||||||
if(StringUtils.isEmpty(posiObj.getString("task_id"))) {
|
if(StringUtils.isEmpty(posiObj.getString("task_id"))) {
|
||||||
throw new BadRequestException("未找到该缓存线的点位的任务信息!");
|
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
|
* 缓存线位置编码 wcsdevice_code
|
||||||
* 缓存线点位编码 position_code
|
* 缓存线点位编码 position_code
|
||||||
* 料箱码 vehicle_code
|
* 料箱码 vehicle_code
|
||||||
|
*
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String cacheLineOutBoxExceptionConfirm(JSONObject param) {
|
public CommonResult<Integer> cacheLineOutBoxExceptionConfirm(JSONObject param) {
|
||||||
String inOut_type = param.getString("inOut_type");
|
String inOut_type = param.getString("inOut_type");
|
||||||
String cacheLine_code = param.getString("wcsdevice_code");
|
String cacheLine_code = param.getString("wcsdevice_code");
|
||||||
String position_code = param.getString("position_code");
|
String position_code = param.getString("position_code");
|
||||||
@@ -655,11 +667,11 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
|||||||
// 缓存线载具物料表
|
// 缓存线载具物料表
|
||||||
WQLObject ivtTab = WQLObject.getWQLObject("sch_cacheline_vehilematerial");
|
WQLObject ivtTab = WQLObject.getWQLObject("sch_cacheline_vehilematerial");
|
||||||
//1.确定缓存线点位
|
//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.绑定新料箱条码(入满箱或者入空箱),设置缓存线点位不为空
|
//2.绑定新料箱条码(入满箱或者入空箱),设置缓存线点位不为空
|
||||||
vehiobj.put("vehicle_code", vehicle_code);
|
vehiobj.put("vehicle_code", vehicle_code);
|
||||||
vehiobj.put("is_empty", "0");
|
vehiobj.put("is_empty", "0");
|
||||||
positionTab.update(vehiobj);
|
positionTab.update(vehiobj, "position_code = '" + position_code + "'");
|
||||||
//3.删除入料箱之前的所有关联信息,包括物料,工序,生产区域
|
//3.删除入料箱之前的所有关联信息,包括物料,工序,生产区域
|
||||||
ivtTab.delete("vehicle_code = '" + vehicle_code + "'");
|
ivtTab.delete("vehicle_code = '" + vehicle_code + "'");
|
||||||
//4.初始化料箱
|
//4.初始化料箱
|
||||||
@@ -690,9 +702,6 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
|||||||
}
|
}
|
||||||
//6.重新新建该缓存线位置上的料箱为满箱及所属工序,生产区域等信息
|
//6.重新新建该缓存线位置上的料箱为满箱及所属工序,生产区域等信息
|
||||||
json.put("material_id", meObj.getString("material_id"));
|
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("quantity", instructObj.getString("material_qty"));
|
||||||
json.put("product_area", instructObj.getString("product_area"));
|
json.put("product_area", instructObj.getString("product_area"));
|
||||||
json.put("vehicle_status", StatusEnum.CACHE_VEL_EMT.getCode());
|
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)) {
|
if(StatusEnum.OUT_VEHICLE.getCode().equals(inOut_type)) {
|
||||||
//5.重新新建该缓存线位置上的料箱为空箱子,是空料箱没有放物料等其他信息
|
//5.重新新建该缓存线位置上的料箱为空箱子,是空料箱没有放物料等其他信息
|
||||||
json.put("vehicle_status", StatusEnum.STATUS_TRUE.getCode());
|
json.put("vehicle_status", StatusEnum.STATUS_TRUE.getCode());
|
||||||
json.put("material_uuid", "");
|
json.put("material_id", "");
|
||||||
json.put("material_code", "");
|
|
||||||
json.put("material_spec", "");
|
|
||||||
json.put("material_name", "");
|
|
||||||
json.put("weight", "0");
|
json.put("weight", "0");
|
||||||
json.put("quantity", "0");
|
json.put("quantity", "0");
|
||||||
json.put("workprocedure_code", "");
|
json.put("workprocedure_code", "");
|
||||||
json.put("workprocedure_name", "");
|
json.put("workprocedure_name", "");
|
||||||
json.put("product_area", "");
|
json.put("product_area", "");
|
||||||
}
|
}
|
||||||
int result = ivtTab.insert(json).getSucess();
|
return RestBusinessTemplate.execute(() -> ivtTab.insert(json).getSucess());
|
||||||
return Integer.toString(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -230,7 +230,7 @@
|
|||||||
task.task_id as instruct_uuid,
|
task.task_id as instruct_uuid,
|
||||||
task.task_code as instructoperate_num,
|
task.task_code as instructoperate_num,
|
||||||
task.task_name as mes_no,
|
task.task_name as mes_no,
|
||||||
task.vehicle_code as invehicle_code,
|
task.vehicle_code,
|
||||||
task.vehicle_code2 as outvehicle_code,
|
task.vehicle_code2 as outvehicle_code,
|
||||||
task.create_time,
|
task.create_time,
|
||||||
dict.label as status_name,
|
dict.label as status_name,
|
||||||
@@ -246,7 +246,7 @@
|
|||||||
left join md_me_materialbase mater on task.material_id = mater.material_id
|
left join md_me_materialbase mater on task.material_id = mater.material_id
|
||||||
left join sys_dict dict on dict.`value` = task.task_status
|
left join sys_dict dict on dict.`value` = task.task_status
|
||||||
and dict.`code` = 'task_status'
|
and dict.`code` = 'task_status'
|
||||||
WHERE task.is_delete = '0'
|
WHERE task.is_delete = '0'
|
||||||
OPTION 输入.status <> ""
|
OPTION 输入.status <> ""
|
||||||
find_in_set(task.task_status,输入.status)
|
find_in_set(task.task_status,输入.status)
|
||||||
ENDOPTION
|
ENDOPTION
|
||||||
@@ -270,7 +270,7 @@
|
|||||||
ENDOPTION
|
ENDOPTION
|
||||||
OPTION 输入.end_date <> ""
|
OPTION 输入.end_date <> ""
|
||||||
task.create_time <= 输入.end_date
|
task.create_time <= 输入.end_date
|
||||||
ENDOPTION
|
ENDOPTION ORDER BY task.create_time
|
||||||
ENDSELECT
|
ENDSELECT
|
||||||
ENDPAGEQUERY
|
ENDPAGEQUERY
|
||||||
ENDIF
|
ENDIF
|
||||||
|
|||||||
@@ -172,6 +172,7 @@ sa-token:
|
|||||||
cookie:
|
cookie:
|
||||||
# 配置 Cookie 作用域:根据二级域名实现sso登入如lms.sso.com;acs.sso.com
|
# 配置 Cookie 作用域:根据二级域名实现sso登入如lms.sso.com;acs.sso.com
|
||||||
domain:
|
domain:
|
||||||
|
is-read-cookie: false
|
||||||
|
|
||||||
#jetcache:
|
#jetcache:
|
||||||
# defaultCacheType: LOCAL
|
# defaultCacheType: LOCAL
|
||||||
|
|||||||
Reference in New Issue
Block a user