del:去掉路由校验
This commit is contained in:
@@ -181,7 +181,6 @@ public class MagicAgvServiceImpl implements MagicAgvService {
|
|||||||
agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + instno;
|
agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + instno;
|
||||||
|
|
||||||
log.info("下发agv指令参数:{}", orderjo.toString());
|
log.info("下发agv指令参数:{}", orderjo.toString());
|
||||||
|
|
||||||
HttpResponse result = null;
|
HttpResponse result = null;
|
||||||
try {
|
try {
|
||||||
result = HttpRequest.post(agvurl)
|
result = HttpRequest.post(agvurl)
|
||||||
|
|||||||
@@ -116,11 +116,11 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
|||||||
if (StrUtil.isEmpty(route_plan_code)) {
|
if (StrUtil.isEmpty(route_plan_code)) {
|
||||||
route_plan_code = "normal";
|
route_plan_code = "normal";
|
||||||
}
|
}
|
||||||
List<RouteLineDto> list = RouteLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
|
// List<RouteLineDto> list = RouteLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
|
||||||
|
//
|
||||||
if (ObjectUtil.isEmpty(list)) {
|
// if (ObjectUtil.isEmpty(list)) {
|
||||||
throw new WDKException("路由不通!");
|
// throw new WDKException("路由不通!");
|
||||||
}
|
// }
|
||||||
TaskDto taskDto = TaskService.findByCodeFromCache(task_code);
|
TaskDto taskDto = TaskService.findByCodeFromCache(task_code);
|
||||||
if (taskDto != null) {
|
if (taskDto != null) {
|
||||||
throw new WDKException("不能存在相同的任务号!");
|
throw new WDKException("不能存在相同的任务号!");
|
||||||
|
|||||||
@@ -261,17 +261,17 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
dto.setInstruction_id(IdUtil.simpleUUID());
|
dto.setInstruction_id(IdUtil.simpleUUID());
|
||||||
}
|
}
|
||||||
dto.setInstruction_type(task.getTask_type());
|
dto.setInstruction_type(task.getTask_type());
|
||||||
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(dto.getStart_device_code(), dto.getNext_device_code(), dto.getRoute_plan_code());
|
// List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(dto.getStart_device_code(), dto.getNext_device_code(), dto.getRoute_plan_code());
|
||||||
if (ObjectUtils.isEmpty(shortPathsList)) {
|
// if (ObjectUtils.isEmpty(shortPathsList)) {
|
||||||
throw new Exception(dto.getStart_device_code() + "->" + dto.getNext_device_code() + "路由不通");
|
// throw new Exception(dto.getStart_device_code() + "->" + dto.getNext_device_code() + "路由不通");
|
||||||
}
|
// }
|
||||||
String type = shortPathsList.get(0).getType();
|
// String type = shortPathsList.get(0).getType();
|
||||||
if (!StrUtil.equals(type, "0")) {
|
// if (!StrUtil.equals(type, "0")) {
|
||||||
JSONObject instcheckjson = instwo.query(" instruction_status <2 and next_point_code= '" + dto.getNext_point_code() + "'" + " and start_point_code = '" + dto.getStart_point_code() + "'" + " and task_id = '" + dto.getTask_id() + "'").uniqueResult(0);
|
JSONObject instcheckjson = instwo.query(" instruction_status <2 and next_point_code= '" + dto.getNext_point_code() + "'" + " and start_point_code = '" + dto.getStart_point_code() + "'" + " and task_id = '" + dto.getTask_id() + "'").uniqueResult(0);
|
||||||
if (instcheckjson != null) {
|
if (instcheckjson != null) {
|
||||||
throw new Exception(dto.getTask_code() + ":该任务已存在待完成指令!");
|
throw new Exception(dto.getTask_code() + ":该任务已存在待完成指令!");
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
if (!StrUtil.isEmpty(dto.getVehicle_code())) {
|
if (!StrUtil.isEmpty(dto.getVehicle_code())) {
|
||||||
Instruction inst_dto = this.findByContainer(dto.getVehicle_code());
|
Instruction inst_dto = this.findByContainer(dto.getVehicle_code());
|
||||||
if (ObjectUtils.isNotEmpty(inst_dto) && !StrUtil.equals(inst_dto.getTask_id(), dto.getTask_id())) {
|
if (ObjectUtils.isNotEmpty(inst_dto) && !StrUtil.equals(inst_dto.getTask_id(), dto.getTask_id())) {
|
||||||
@@ -300,7 +300,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// != 0 为agv任务
|
// != 0 为agv任务
|
||||||
if (!StrUtil.equals(type, "0")) {
|
// if (!StrUtil.equals(type, "0")) {
|
||||||
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.AGVTYPE).toString(), "1")) {
|
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.AGVTYPE).toString(), "1")) {
|
||||||
MagicAgvServiceImpl magicAgvService = SpringContextHolder.getBean(MagicAgvServiceImpl.class);
|
MagicAgvServiceImpl magicAgvService = SpringContextHolder.getBean(MagicAgvServiceImpl.class);
|
||||||
HttpResponse result = magicAgvService.sendAgvInstToMagic(dto);
|
HttpResponse result = magicAgvService.sendAgvInstToMagic(dto);
|
||||||
@@ -335,7 +335,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
dto.setSend_status("2");
|
dto.setSend_status("2");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -326,9 +326,9 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
//判断起点终点设备类型
|
//判断起点终点设备类型
|
||||||
String startDeviceType = deviceAppService.findDeviceTypeByCode(dto.getStart_device_code());
|
String startDeviceType = deviceAppService.findDeviceTypeByCode(dto.getStart_device_code());
|
||||||
String nextDeviceType = deviceAppService.findDeviceTypeByCode(dto.getNext_device_code());
|
String nextDeviceType = deviceAppService.findDeviceTypeByCode(dto.getNext_device_code());
|
||||||
if (routelineserver.getShortPathLines(dto.getStart_device_code(), dto.getNext_device_code(), plan_code).size() == 0) {
|
// if (routelineserver.getShortPathLines(dto.getStart_device_code(), dto.getNext_device_code(), plan_code).size() == 0) {
|
||||||
throw new Exception(dto.getStart_point_code() + "->" + dto.getNext_point_code() + "路由不通!");
|
// throw new Exception(dto.getStart_point_code() + "->" + dto.getNext_point_code() + "路由不通!");
|
||||||
}
|
// }
|
||||||
String createTaskCheck = acsConfigService.findConfigFromCache().get(AcsConfig.CREATETASKCHECK);
|
String createTaskCheck = acsConfigService.findConfigFromCache().get(AcsConfig.CREATETASKCHECK);
|
||||||
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
|
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
|
||||||
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||||
@@ -778,25 +778,25 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
/**
|
/**
|
||||||
* 开始平均分解校验
|
* 开始平均分解校验
|
||||||
*/
|
*/
|
||||||
String this_device_code = this.queryAssignedByDevice(acsTask.getStart_device_code(), acsTask.getNext_device_code());
|
// String this_device_code = this.queryAssignedByDevice(acsTask.getStart_device_code(), acsTask.getNext_device_code());
|
||||||
if (StrUtil.isEmpty(this_device_code)) {
|
// if (StrUtil.isEmpty(this_device_code)) {
|
||||||
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, acsTask.getNext_device_code(), route_plan_code);
|
// List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, acsTask.getNext_device_code(), route_plan_code);
|
||||||
RouteLineDto routeLineDto = shortPathsList.get(0);
|
// RouteLineDto routeLineDto = shortPathsList.get(0);
|
||||||
String path = routeLineDto.getPath();
|
// String path = routeLineDto.getPath();
|
||||||
String type = routeLineDto.getType();
|
// String type = routeLineDto.getType();
|
||||||
String[] str = path.split("->");
|
// String[] str = path.split("->");
|
||||||
List<String> pathlist = Arrays.asList(str);
|
// List<String> pathlist = Arrays.asList(str);
|
||||||
int index = 0;
|
// int index = 0;
|
||||||
for (int m = 0; m < pathlist.size(); m++) {
|
// for (int m = 0; m < pathlist.size(); m++) {
|
||||||
if (pathlist.get(m).equals(start_device_code)) {
|
// if (pathlist.get(m).equals(start_device_code)) {
|
||||||
index = m + 1;
|
// index = m + 1;
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
next_device_code = pathlist.get(index);
|
// next_device_code = pathlist.get(index);
|
||||||
} else {
|
// } else {
|
||||||
next_device_code = this_device_code;
|
// next_device_code = this_device_code;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (StrUtil.equals(appService.findDeviceTypeByCode(next_device_code), "storage")) {
|
if (StrUtil.equals(appService.findDeviceTypeByCode(next_device_code), "storage")) {
|
||||||
next_point_code = next_device_code + "-" + acsTask.getTo_y() + "-" + acsTask.getTo_z();
|
next_point_code = next_device_code + "-" + acsTask.getTo_y() + "-" + acsTask.getTo_z();
|
||||||
|
|||||||
@@ -86,48 +86,48 @@ public class AutoCreateInst {
|
|||||||
/**
|
/**
|
||||||
* 开始平均分解校验
|
* 开始平均分解校验
|
||||||
*/
|
*/
|
||||||
String this_device_code = taskserver.queryAssignedByDevice(acsTask.getStart_device_code(), acsTask.getNext_device_code());
|
// String this_device_code = taskserver.queryAssignedByDevice(acsTask.getStart_device_code(), acsTask.getNext_device_code());
|
||||||
if (StrUtil.isEmpty(this_device_code)) {
|
// if (StrUtil.isEmpty(this_device_code)) {
|
||||||
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, acsTask.getNext_device_code(), route_plan_code);
|
// List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, acsTask.getNext_device_code(), route_plan_code);
|
||||||
RouteLineDto routeLineDto = shortPathsList.get(0);
|
// RouteLineDto routeLineDto = shortPathsList.get(0);
|
||||||
String path = routeLineDto.getPath();
|
// String path = routeLineDto.getPath();
|
||||||
String type = routeLineDto.getType();
|
// String type = routeLineDto.getType();
|
||||||
String[] str = path.split("->");
|
// String[] str = path.split("->");
|
||||||
List<String> pathlist = Arrays.asList(str);
|
// List<String> pathlist = Arrays.asList(str);
|
||||||
if(StrUtil.equals(acsTask.getTask_type(),"2")){
|
// if(StrUtil.equals(acsTask.getTask_type(),"2")){
|
||||||
for (int j = 0; j < pathlist.size(); j++) {
|
// for (int j = 0; j < pathlist.size(); j++) {
|
||||||
if (j == 0) {
|
// if (j == 0) {
|
||||||
compound_task_data = pathlist.get(j).trim();
|
// compound_task_data = pathlist.get(j).trim();
|
||||||
} else {
|
// } else {
|
||||||
compound_task_data = compound_task_data + "->" + pathlist.get(j).trim();
|
// compound_task_data = compound_task_data + "->" + pathlist.get(j).trim();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
next_device_code = pathlist.get(pathlist.size()-1);
|
// next_device_code = pathlist.get(pathlist.size()-1);
|
||||||
|
//
|
||||||
} else {
|
// } else {
|
||||||
int index = 0;
|
// int index = 0;
|
||||||
for (int m = 0; m < pathlist.size(); m++) {
|
// for (int m = 0; m < pathlist.size(); m++) {
|
||||||
if (pathlist.get(m).equals(start_device_code)) {
|
// if (pathlist.get(m).equals(start_device_code)) {
|
||||||
index = m + 1;
|
// index = m + 1;
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
next_device_code = pathlist.get(index);
|
// next_device_code = pathlist.get(index);
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
next_device_code = this_device_code;
|
// next_device_code = this_device_code;
|
||||||
}
|
// }
|
||||||
//校验路由关系
|
//校验路由关系
|
||||||
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
|
// List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
|
||||||
if (ObjectUtils.isEmpty(shortPathsList)) {
|
// if (ObjectUtils.isEmpty(shortPathsList)) {
|
||||||
acsTask.setRemark("路由不通无法生成指令");
|
// acsTask.setRemark("路由不通无法生成指令");
|
||||||
taskserver.updateByCodeFromCache(acsTask);
|
// taskserver.updateByCodeFromCache(acsTask);
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (!StrUtil.equals(shortPathsList.get(0).getType(), "1")) {
|
// if (!StrUtil.equals(shortPathsList.get(0).getType(), "1")) {
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
Device startdevice = appService.findDeviceByCode(start_device_code);
|
Device startdevice = appService.findDeviceByCode(start_device_code);
|
||||||
Device nextdevice = appService.findDeviceByCode(next_device_code);
|
Device nextdevice = appService.findDeviceByCode(next_device_code);
|
||||||
if (StrUtil.equals(appService.findDeviceTypeByCode(next_device_code), "storage")) {
|
if (StrUtil.equals(appService.findDeviceTypeByCode(next_device_code), "storage")) {
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,507 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package org.nl.wql.core.engine.object;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import org.nl.exception.WDKException;
|
||||||
|
import org.nl.wql.WQLCore;
|
||||||
|
import org.nl.wql.core.DataType;
|
||||||
|
import org.nl.wql.core.bean.ErrorBean;
|
||||||
|
import org.nl.wql.core.bean.ResultBean;
|
||||||
|
import org.nl.wql.core.bean.XLSTableRow;
|
||||||
|
import org.nl.wql.core.content.BaseContext;
|
||||||
|
import org.nl.wql.core.content.HttpContext;
|
||||||
|
import org.nl.wql.core.db.DBConnBean;
|
||||||
|
import org.nl.wql.core.db.DBConnection;
|
||||||
|
import org.nl.wql.core.engine.Syntax;
|
||||||
|
import org.nl.wql.util.WqlUtil;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
public class WO implements Serializable, Cloneable {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(WO.class);
|
||||||
|
private static final long serialVersionUID = -4831486954013002791L;
|
||||||
|
public WP wp;
|
||||||
|
private String code = "";
|
||||||
|
private String dbname = "dataSource";
|
||||||
|
private String dbtype = "";
|
||||||
|
private String hint_type = "";
|
||||||
|
private ArrayList tempTableList = new ArrayList();
|
||||||
|
private ArrayList processlist = new ArrayList();
|
||||||
|
|
||||||
|
public WO setDbname(String dbname) {
|
||||||
|
this.dbname = dbname;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList getProcesslist() {
|
||||||
|
return this.processlist;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProcesslist(ArrayList processlist) {
|
||||||
|
this.processlist = processlist;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WO addParam(String key, Object value) {
|
||||||
|
int PAGE_PAGERECORDNUM;
|
||||||
|
if (StrUtil.equalsIgnoreCase("PAGE_PAGESTART", key)) {
|
||||||
|
PAGE_PAGERECORDNUM = (Integer)value;
|
||||||
|
this.setPage_PageStart(PAGE_PAGERECORDNUM);
|
||||||
|
} else if (StrUtil.equalsIgnoreCase("PAGE_PAGERECORDNUM", key)) {
|
||||||
|
PAGE_PAGERECORDNUM = (Integer)value;
|
||||||
|
this.setPage_PageRecordNum(PAGE_PAGERECORDNUM);
|
||||||
|
} else {
|
||||||
|
String SORT_ORDERBYFIELD;
|
||||||
|
if (StrUtil.equalsIgnoreCase("SORT_ORDERBYFIELD", key)) {
|
||||||
|
SORT_ORDERBYFIELD = (String)value;
|
||||||
|
this.setPage_OrderByField(SORT_ORDERBYFIELD);
|
||||||
|
} else if (StrUtil.equalsIgnoreCase("ORDERBY", key)) {
|
||||||
|
SORT_ORDERBYFIELD = (String)value;
|
||||||
|
this.setPage_OrderByField(SORT_ORDERBYFIELD);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setParam(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WO addParamMap(HashMap map) {
|
||||||
|
Set keySet = map.keySet();
|
||||||
|
Iterator it = keySet.iterator();
|
||||||
|
|
||||||
|
while(it.hasNext()) {
|
||||||
|
String key = (String)it.next();
|
||||||
|
Object value = map.get(key);
|
||||||
|
this.addParam(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public WO addParamMap(JSONObject map) {
|
||||||
|
Set keySet = map.keySet();
|
||||||
|
Iterator it = keySet.iterator();
|
||||||
|
|
||||||
|
while(it.hasNext()) {
|
||||||
|
String key = (String)it.next();
|
||||||
|
Object value = map.get(key);
|
||||||
|
this.addParam(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResultBean process() {
|
||||||
|
ResultBean rb = this.MainProcess();
|
||||||
|
if (rb.isSuccess()) {
|
||||||
|
return rb;
|
||||||
|
} else {
|
||||||
|
StringBuffer sbuff = new StringBuffer();
|
||||||
|
ArrayList errlist = rb.getInfoError();
|
||||||
|
|
||||||
|
for(int i = 0; i < errlist.size(); ++i) {
|
||||||
|
ErrorBean errBean = (ErrorBean)errlist.get(i);
|
||||||
|
sbuff.append(errBean.toString());
|
||||||
|
sbuff.append("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new WDKException(sbuff.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public JSONObject pageQuery(HttpServletRequest request, String orderby) {
|
||||||
|
HttpContext hctx = new HttpContext(WqlUtil.getUUID());
|
||||||
|
hctx.setRequest(request);
|
||||||
|
return this.pageQuery((BaseContext)hctx, orderby);
|
||||||
|
}
|
||||||
|
|
||||||
|
public JSONObject pageQuery(BaseContext ctx, String orderby) {
|
||||||
|
int nPageRecordNum = -1;
|
||||||
|
int nPageStart = -1;
|
||||||
|
String strRows = ctx.getRows();
|
||||||
|
String strPage = ctx.getPage();
|
||||||
|
if (null != strRows && !"".equals(strRows.trim())) {
|
||||||
|
nPageRecordNum = Integer.parseInt(strRows);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null != strPage && !"".equals(strPage.trim())) {
|
||||||
|
nPageStart = Integer.parseInt(strPage) - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
String orderbyfield = ctx.getOrderbyfield();
|
||||||
|
if (null != orderbyfield && !"".equals(orderbyfield.trim())) {
|
||||||
|
orderby = orderbyfield;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.pageQuery2(nPageStart * nPageRecordNum, nPageRecordNum, orderby);
|
||||||
|
}
|
||||||
|
|
||||||
|
private JSONObject pageQuery2(int startrecord, int pagerecord, String orderby) {
|
||||||
|
this.setPage_PageStart(startrecord);
|
||||||
|
this.setPage_PageRecordNum(pagerecord);
|
||||||
|
this.setPage_OrderByField(orderby);
|
||||||
|
ResultBean rb = this.process();
|
||||||
|
return rb.pageResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
public JSONObject pageQuery(int pageStart, int pageEnd, String orderby) {
|
||||||
|
this.setPage_PageStart(pageStart);
|
||||||
|
this.setPage_PageRecordNum(pageEnd - pageStart);
|
||||||
|
this.setPage_OrderByField(orderby);
|
||||||
|
ResultBean rb = this.process();
|
||||||
|
return rb.pageResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
this.wp.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public WO(String code, ArrayList<String> wqlcontent) throws Exception {
|
||||||
|
this.code = code;
|
||||||
|
this.dbname = this.getDbname();
|
||||||
|
this.wp = new WP();
|
||||||
|
|
||||||
|
try {
|
||||||
|
DBConnBean dbb = (DBConnBean)WQLCore.dbMap.get(this.dbname);
|
||||||
|
if (dbb == null) {
|
||||||
|
throw new Exception("无效的数据库名:" + this.dbname);
|
||||||
|
} else {
|
||||||
|
this.dbtype = dbb.getDbtype();
|
||||||
|
String cmd = "";
|
||||||
|
Iterator it = wqlcontent.iterator();
|
||||||
|
|
||||||
|
while(true) {
|
||||||
|
while(true) {
|
||||||
|
String wql;
|
||||||
|
do {
|
||||||
|
do {
|
||||||
|
do {
|
||||||
|
do {
|
||||||
|
if (!it.hasNext()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
wql = (String)it.next();
|
||||||
|
wql = WqlUtil.ltrim(wql);
|
||||||
|
wql = WqlUtil.rtrim(wql);
|
||||||
|
} while("".equals(wql));
|
||||||
|
} while(wql.startsWith("--"));
|
||||||
|
} while(wql.startsWith("#"));
|
||||||
|
} while(wql.startsWith("//"));
|
||||||
|
|
||||||
|
if (wql.startsWith("[")) {
|
||||||
|
cmd = wql.substring(wql.indexOf("[") + 1, wql.indexOf("]"));
|
||||||
|
} else if ("数据库".equals(cmd)) {
|
||||||
|
this.dbname = wql;
|
||||||
|
dbb = (DBConnBean)WQLCore.dbMap.get(this.dbname);
|
||||||
|
if (dbb == null) {
|
||||||
|
throw new Exception("无效的数据库名:" + this.dbname);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.dbtype = dbb.getDbtype();
|
||||||
|
} else if (!"IO定义".equals(cmd) && !"临时变量".equals(cmd)) {
|
||||||
|
if ("临时表".equals(cmd)) {
|
||||||
|
this.tempTableList.add(wql);
|
||||||
|
} else if ("业务过程".equals(cmd)) {
|
||||||
|
this.processlist.add(WqlUtil.ctrim(wql));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
wql = WqlUtil.ctrim(wql);
|
||||||
|
this.wp.initIOParam(wql);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception var7) {
|
||||||
|
var7.printStackTrace();
|
||||||
|
log.error("WQL加载失败:" + var7.toString());
|
||||||
|
throw new Exception("请检查WQL文件【" + code + ".wql】的语法规范!", var7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResultBean MainProcess() {
|
||||||
|
Connection conn = DBConnection.getConnection(this.dbname);
|
||||||
|
log.debug(this.code + "执行开始");
|
||||||
|
log.debug(this.wp.toString());
|
||||||
|
this.wp.conn = conn;
|
||||||
|
synchronized(this.wp.conn) {
|
||||||
|
try {
|
||||||
|
this.wp._success = this.CreateTempTable();
|
||||||
|
if (this.wp._success) {
|
||||||
|
this.wp._success = this.Process();
|
||||||
|
}
|
||||||
|
} catch (Exception var9) {
|
||||||
|
var9.printStackTrace();
|
||||||
|
this.wp.InfoError = new ErrorBean();
|
||||||
|
this.wp.InfoError.setCode("QUERROR");
|
||||||
|
this.wp.InfoError.setDescription(var9.toString());
|
||||||
|
this.wp.ALInfoError.add(this.wp.InfoError);
|
||||||
|
this.wp._success = false;
|
||||||
|
} finally {
|
||||||
|
if (this.wp._success) {
|
||||||
|
log.debug(this.code + "执行成功");
|
||||||
|
this.wp.rb.setSucess(1);
|
||||||
|
} else {
|
||||||
|
log.warn(this.code + "执行失败");
|
||||||
|
this.wp.rb.setSucess(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
DBConnection.freeConnection(this.wp.conn, this.dbname);
|
||||||
|
this.wp.rb.setInfoDump(this.wp.ALInfoDump);
|
||||||
|
this.wp.rb.setInfoError(this.wp.ALInfoError);
|
||||||
|
this.wp.rb.setInfoTrace(this.wp.ALInfoTrace);
|
||||||
|
return this.wp.rb;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean CreateTempTable() {
|
||||||
|
this.wp._state = true;
|
||||||
|
this.wp.sSQL = "";
|
||||||
|
log.debug("------------开始执行\t创建临时表 ------------");
|
||||||
|
Iterator it = this.tempTableList.iterator();
|
||||||
|
|
||||||
|
while(it.hasNext()) {
|
||||||
|
String tempTableName = (String)it.next();
|
||||||
|
ArrayList rows = (ArrayList)WQLCore.tempTableMap.get(tempTableName.toUpperCase());
|
||||||
|
if (rows == null) {
|
||||||
|
log.error("临时表[" + tempTableName.toUpperCase() + "]未找到数据字典定义");
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder var10000;
|
||||||
|
WP var10002;
|
||||||
|
String pkstr;
|
||||||
|
int i;
|
||||||
|
XLSTableRow xtr;
|
||||||
|
if (DataType.MYSQL.equals(this.dbtype)) {
|
||||||
|
pkstr = new String();
|
||||||
|
this.wp.sSQL = "CREATE TEMPORARY TABLE IF NOT EXISTS " + tempTableName + " (";
|
||||||
|
|
||||||
|
for(i = 0; i < rows.size(); ++i) {
|
||||||
|
xtr = (XLSTableRow)rows.get(i);
|
||||||
|
if ("pk".equalsIgnoreCase(xtr.getParam())) {
|
||||||
|
pkstr = pkstr + xtr.getEnname() + ",";
|
||||||
|
}
|
||||||
|
|
||||||
|
var10000 = new StringBuilder();
|
||||||
|
var10002 = this.wp;
|
||||||
|
var10002.sSQL = var10000.append(var10002.sSQL).append(xtr.getEnname()).append(" ").toString();
|
||||||
|
if (-1 != xtr.getType().indexOf("U_")) {
|
||||||
|
var10000 = new StringBuilder();
|
||||||
|
var10002 = this.wp;
|
||||||
|
var10002.sSQL = var10000.append(var10002.sSQL).append(DataType.getFieldValue(this.dbtype, xtr.getType())).toString();
|
||||||
|
} else {
|
||||||
|
var10000 = new StringBuilder();
|
||||||
|
var10002 = this.wp;
|
||||||
|
var10002.sSQL = var10000.append(var10002.sSQL).append(DataType.getFieldValue(this.dbtype, xtr.getType())).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
var10000 = new StringBuilder();
|
||||||
|
var10002 = this.wp;
|
||||||
|
var10002.sSQL = var10000.append(var10002.sSQL).append(",").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.wp.sSQL = this.wp.sSQL.substring(0, this.wp.sSQL.length() - 1);
|
||||||
|
if (pkstr.length() > 0) {
|
||||||
|
pkstr = pkstr.substring(0, pkstr.length() - 1);
|
||||||
|
var10000 = new StringBuilder();
|
||||||
|
var10002 = this.wp;
|
||||||
|
var10002.sSQL = var10000.append(var10002.sSQL).append(",PRIMARY KEY (").append(pkstr).append(")").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
var10000 = new StringBuilder();
|
||||||
|
var10002 = this.wp;
|
||||||
|
var10002.sSQL = var10000.append(var10002.sSQL).append(" )").toString();
|
||||||
|
} else if (DataType.ORACLE.equals(this.dbtype)) {
|
||||||
|
pkstr = new String();
|
||||||
|
this.wp.sSQL = "CREATE GLOBAL TEMPORARY TABLE " + tempTableName + " (";
|
||||||
|
|
||||||
|
for(i = 0; i < rows.size(); ++i) {
|
||||||
|
xtr = (XLSTableRow)rows.get(i);
|
||||||
|
if ("pk".equalsIgnoreCase(xtr.getParam())) {
|
||||||
|
pkstr = pkstr + xtr.getEnname() + ",";
|
||||||
|
}
|
||||||
|
|
||||||
|
var10000 = new StringBuilder();
|
||||||
|
var10002 = this.wp;
|
||||||
|
var10002.sSQL = var10000.append(var10002.sSQL).append(xtr.getEnname()).append(" ").toString();
|
||||||
|
if (-1 != xtr.getType().indexOf("U_")) {
|
||||||
|
var10000 = new StringBuilder();
|
||||||
|
var10002 = this.wp;
|
||||||
|
var10002.sSQL = var10000.append(var10002.sSQL).append(DataType.getFieldValue(this.dbtype, xtr.getType())).toString();
|
||||||
|
} else {
|
||||||
|
var10000 = new StringBuilder();
|
||||||
|
var10002 = this.wp;
|
||||||
|
var10002.sSQL = var10000.append(var10002.sSQL).append(DataType.getFieldValue(this.dbtype, xtr.getType())).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
var10000 = new StringBuilder();
|
||||||
|
var10002 = this.wp;
|
||||||
|
var10002.sSQL = var10000.append(var10002.sSQL).append(",").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.wp.sSQL = this.wp.sSQL.substring(0, this.wp.sSQL.length() - 1);
|
||||||
|
if (pkstr.length() > 0) {
|
||||||
|
pkstr = pkstr.substring(0, pkstr.length() - 1);
|
||||||
|
var10000 = new StringBuilder();
|
||||||
|
var10002 = this.wp;
|
||||||
|
var10002.sSQL = var10000.append(var10002.sSQL).append(",PRIMARY KEY (").append(pkstr).append(")").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
var10000 = new StringBuilder();
|
||||||
|
var10002 = this.wp;
|
||||||
|
var10002.sSQL = var10000.append(var10002.sSQL).append(" ) ON COMMIT PRESERVE ROWS").toString();
|
||||||
|
} else if (!DataType.DB2.equals(this.dbtype)) {
|
||||||
|
if (DataType.MSSQL.equals(this.dbtype)) {
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pkstr = new String();
|
||||||
|
this.wp.sSQL = "DECLARE GLOBAL TEMPORARY TABLE " + tempTableName + " (";
|
||||||
|
|
||||||
|
for(i = 0; i < rows.size(); ++i) {
|
||||||
|
xtr = (XLSTableRow)rows.get(i);
|
||||||
|
if ("pk".equalsIgnoreCase(xtr.getParam())) {
|
||||||
|
pkstr = pkstr + xtr.getEnname() + ",";
|
||||||
|
}
|
||||||
|
|
||||||
|
var10000 = new StringBuilder();
|
||||||
|
var10002 = this.wp;
|
||||||
|
var10002.sSQL = var10000.append(var10002.sSQL).append(xtr.getEnname()).append(" ").toString();
|
||||||
|
if (-1 != xtr.getType().indexOf("U_")) {
|
||||||
|
var10000 = new StringBuilder();
|
||||||
|
var10002 = this.wp;
|
||||||
|
var10002.sSQL = var10000.append(var10002.sSQL).append(DataType.getFieldValue(this.dbtype, xtr.getType())).toString();
|
||||||
|
} else {
|
||||||
|
var10000 = new StringBuilder();
|
||||||
|
var10002 = this.wp;
|
||||||
|
var10002.sSQL = var10000.append(var10002.sSQL).append(DataType.getFieldValue(this.dbtype, xtr.getType())).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
var10000 = new StringBuilder();
|
||||||
|
var10002 = this.wp;
|
||||||
|
var10002.sSQL = var10000.append(var10002.sSQL).append(",").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.wp.sSQL = this.wp.sSQL.substring(0, this.wp.sSQL.length() - 1);
|
||||||
|
if (pkstr.length() > 0) {
|
||||||
|
pkstr = pkstr.substring(0, pkstr.length() - 1);
|
||||||
|
var10000 = new StringBuilder();
|
||||||
|
var10002 = this.wp;
|
||||||
|
var10002.sSQL = var10000.append(var10002.sSQL).append(",PRIMARY KEY (").append(pkstr).append(")").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
var10000 = new StringBuilder();
|
||||||
|
var10002 = this.wp;
|
||||||
|
var10002.sSQL = var10000.append(var10002.sSQL).append(" ) on commit preserve rows WITH REPLACE").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
log.debug("数据库创建临时表:\n" + this.wp.sSQL);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (null != this.wp.sSQL && !"".equals(this.wp.sSQL)) {
|
||||||
|
if (DataType.MSSQL.equals(this.dbtype)) {
|
||||||
|
Statement st = this.wp.conn.createStatement();
|
||||||
|
st.execute(this.wp.sSQL);
|
||||||
|
} else {
|
||||||
|
this.wp.st = this.wp.conn.prepareStatement(this.wp.sSQL);
|
||||||
|
this.wp.st.execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception var15) {
|
||||||
|
this.wp._state = false;
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (DBConnection.currpooltype != 1) {
|
||||||
|
if (this.wp.st != null) {
|
||||||
|
this.wp.st.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.wp.st = null;
|
||||||
|
}
|
||||||
|
} catch (SQLException var14) {
|
||||||
|
log.error("关闭st,rs出错" + var14.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log.debug("------------结束执行\t创建临时表 ------------");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean Process() {
|
||||||
|
this.wp._state = true;
|
||||||
|
log.debug("------------开始执行\t业务主过程 ------------");
|
||||||
|
this.wp._state = (new Syntax()).exec(this, this.processlist);
|
||||||
|
log.debug("------------结束执行\t业务主过程 ------------");
|
||||||
|
return this.wp._state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDbtype() {
|
||||||
|
return this.dbtype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDbname() {
|
||||||
|
return this.dbname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCode() {
|
||||||
|
return this.code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRowCount() {
|
||||||
|
return this.wp.IRowsCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResultBean getResultBean() {
|
||||||
|
return this.wp.rb;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WO setParam(String name, Object value) {
|
||||||
|
this.wp.setParam(name, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WO setPage_PageStart(int nPageStart) {
|
||||||
|
this.wp.PAGE_PAGESTART = nPageStart;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WO setPage_PageRecordNum(int nPageRecordNum) {
|
||||||
|
this.wp.PAGE_PAGERECORDNUM = nPageRecordNum;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WO setPage_OrderByField(String sOrderByField) {
|
||||||
|
this.wp.SORT_ORDERBYFIELD = sOrderByField;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHintMaster() {
|
||||||
|
this.hint_type = "/!TDDL:MASTER*/";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHintSlave() {
|
||||||
|
this.hint_type = "/!TDDL:SLAVE*/";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHint() {
|
||||||
|
return this.hint_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isHint() {
|
||||||
|
return null != this.hint_type && !"".equals(this.hint_type);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user