Commit d0c132cf authored by hanson.yao's avatar hanson.yao

添加批量编号查询WTDocument接口

parent 0bad647d
......@@ -24,10 +24,7 @@ import wt.method.RemoteAccess;
import wt.method.RemoteMethodServer;
import wt.org.WTPrincipal;
import wt.org.WTPrincipalReference;
import wt.query.ClassAttribute;
import wt.query.QuerySpec;
import wt.query.SearchCondition;
import wt.query.SubSelectExpression;
import wt.query.*;
import wt.session.SessionHelper;
import wt.session.SessionServerHelper;
import wt.team.TeamReference;
......@@ -44,7 +41,6 @@ import wt.vc.wip.CheckoutLink;
import wt.vc.wip.WorkInProgressHelper;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
......@@ -107,6 +103,37 @@ public class DocUtil implements RemoteAccess, Serializable {
}
return doc;
}
public static List<WTDocument> getDocs(List<String> docNumbers) {
List<WTDocument> result = new ArrayList<WTDocument>();
WTDocument doc = null;
boolean check = SessionServerHelper.manager.setAccessEnforced(false);
try {
QuerySpec qs = new QuerySpec(WTDocument.class);
SearchCondition sc = new SearchCondition(WTDocument.class, WTDocument.NUMBER,
SearchCondition.IN, String.valueOf(new ArrayExpression(docNumbers.toArray())), false);
qs.appendWhere(sc, new int[]{0});
QueryResult qr = PersistenceHelper.manager.find(qs);
if (qr.hasMoreElements()) {
WTDocument document = (WTDocument)qr.nextElement();
QueryResult qr2 = VersionControlHelper.service.allIterationsOf(
document.getMaster());
if (qr2.hasMoreElements()) {
doc = (WTDocument)qr2.nextElement();
result.add(doc);
}
}
}
catch (Exception e) {
e.printStackTrace();
}
finally {
SessionServerHelper.manager.setAccessEnforced(check);
}
return result;
}
/**
*
* 简述:通过文档编号获取指定版本(业务或者系统版本)文档,否则返回最新
......
......@@ -3,17 +3,12 @@ package com.yonde.doc.controller;
import com.alibaba.fastjson.JSON;
import com.yonde.basedata.controller.AbstractBaseController;
import com.yonde.basedata.entity.api.ApiResult;
import com.yonde.common.CommonUtil;
import com.yonde.doc.service.DxDocService;
import com.yonde.doc.vo.DxDocumentVO;
import com.yonde.part.vo.DxPartVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import wt.session.SessionContext;
import wt.session.SessionHelper;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
@RestController
......@@ -139,6 +134,16 @@ public class DxDocController extends AbstractBaseController {
return ApiResult.error("505", e.getLocalizedMessage(), e);
}
}
//@ApiOperation("通过编号批量获取Document对象")
@GetMapping(value = "findByNumbers")
public ApiResult findByNumber(@RequestParam("number") List<String> number) {
try {
return ApiResult.ok(this.getService().findByNumbers(number));
} catch (Exception e) {
e.printStackTrace();
return ApiResult.error("505", e.getLocalizedMessage(), e);
}
}
//@ApiOperation("获取初始版本")
@GetMapping({"version/getfirstVersion"})
......
package com.yonde.doc.service;
import com.yonde.basedata.entity.users.DxUserVO;
import com.yonde.common.*;
import com.yonde.common.CommonUtil;
import com.yonde.common.DocUtil;
import com.yonde.common.DxCommonUtils;
import com.yonde.common.ObjectsUtil;
import com.yonde.doc.util.DxDocUtil;
import com.yonde.doc.vo.DxDocumentVO;
import com.yonde.part.service.DxPartService;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import wt.doc.WTDocument;
......@@ -13,18 +15,19 @@ import wt.method.RemoteAccess;
import wt.method.RemoteMethodServer;
import wt.session.SessionContext;
import wt.session.SessionHelper;
import wt.util.WTException;
import wt.vc.wip.WorkInProgressHelper;
import java.lang.reflect.InvocationTargetException;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.List;
@Service
public class DxDocService implements RemoteAccess {
private static Logger logger = LogR.getLogger(DxDocService.class.getName());
/**
* 获取工作副本
*
* @param id
* @return
* @throws Exception
......@@ -32,8 +35,8 @@ public class DxDocService implements RemoteAccess {
public static DxDocumentVO getDxDocWorkingCopy(Long id) throws Exception {
if (!RemoteMethodServer.ServerFlag) {
return (DxDocumentVO) RemoteMethodServer.getDefault().invoke("getDxDocWorkingCopy", DxDocService.class.getName(), null,
new Class[] { Long.class},
new Object[] { id});
new Class[]{Long.class},
new Object[]{id});
}
SessionContext previous = SessionContext.newContext();
DxDocumentVO dxDocumentVO = null;
......@@ -63,6 +66,7 @@ public class DxDocService implements RemoteAccess {
/**
* 获取对象
*
* @param id
* @return
* @throws Exception
......@@ -70,8 +74,8 @@ public class DxDocService implements RemoteAccess {
public static DxDocumentVO getDxDoc(Long id) throws Exception {
if (!RemoteMethodServer.ServerFlag) {
return (DxDocumentVO) RemoteMethodServer.getDefault().invoke("getDxDoc", DxDocService.class.getName(), null,
new Class[] { Long.class},
new Object[] { id});
new Class[]{Long.class},
new Object[]{id});
}
SessionContext previous = SessionContext.newContext();
DxDocumentVO dxDocumentVO = null;
......@@ -87,6 +91,7 @@ public class DxDocService implements RemoteAccess {
/**
* 检入
*
* @param id
* @param checkOutNote
* @return
......@@ -95,8 +100,8 @@ public class DxDocService implements RemoteAccess {
public static DxDocumentVO checkin(Long id, String checkOutNote, String userName) throws Exception {
if (!RemoteMethodServer.ServerFlag) {
return (DxDocumentVO) RemoteMethodServer.getDefault().invoke("checkin", DxDocService.class.getName(), null,
new Class[] { Long.class, String.class, String.class},
new Object[] { id, checkOutNote, userName});
new Class[]{Long.class, String.class, String.class},
new Object[]{id, checkOutNote, userName});
}
//SessionContext previous = SessionContext.newContext();
DxDocumentVO dxDocumentVO = null;
......@@ -114,7 +119,6 @@ public class DxDocService implements RemoteAccess {
}
/**
*
* @param id
* @param checkOutNote
* @return
......@@ -123,8 +127,8 @@ public class DxDocService implements RemoteAccess {
public static DxDocumentVO checkout(Long id, String checkOutNote, String userName) throws Exception {
if (!RemoteMethodServer.ServerFlag) {
return (DxDocumentVO) RemoteMethodServer.getDefault().invoke("checkout", DxDocService.class.getName(), null,
new Class[] { Long.class, String.class, String.class},
new Object[] { id, checkOutNote, userName});
new Class[]{Long.class, String.class, String.class},
new Object[]{id, checkOutNote, userName});
}
//SessionContext previous = SessionContext.newContext();
DxDocumentVO dxDocumentVO = null;
......@@ -145,6 +149,7 @@ public class DxDocService implements RemoteAccess {
/**
* 撤销检出
*
* @param id
* @return
* @throws Exception
......@@ -152,8 +157,8 @@ public class DxDocService implements RemoteAccess {
public static DxDocumentVO undoCheckout(Long id) throws Exception {
if (!RemoteMethodServer.ServerFlag) {
return (DxDocumentVO) RemoteMethodServer.getDefault().invoke("undoCheckout", DxDocService.class.getName(), null,
new Class[] { Long.class },
new Object[] { id });
new Class[]{Long.class},
new Object[]{id});
}
SessionContext previous = SessionContext.newContext();
DxDocumentVO dxdocVO = null;
......@@ -172,8 +177,8 @@ public class DxDocService implements RemoteAccess {
public static DxDocumentVO createDxDoc(DxDocumentVO dxDocumentVO, String userName) throws Exception {
if (!RemoteMethodServer.ServerFlag) {
return (DxDocumentVO) RemoteMethodServer.getDefault().invoke("createDxDoc", DxDocService.class.getName(), null,
new Class[] { DxDocumentVO.class, String.class},
new Object[] { dxDocumentVO, userName});
new Class[]{DxDocumentVO.class, String.class},
new Object[]{dxDocumentVO, userName});
}
//SessionContext previous = SessionContext.newContext();
try {
......@@ -189,7 +194,6 @@ public class DxDocService implements RemoteAccess {
}
public DxDocumentVO updateDocumentStatus(DxDocumentVO var1) {
return null;
}
......@@ -199,6 +203,18 @@ public class DxDocService implements RemoteAccess {
return new DxDocumentVO(DocUtil.getDoc(var1));
}
/**
* @return
*/
public List<DxDocumentVO> findByNumbers(List<String> var1) throws Exception {
List<DxDocumentVO> result = new ArrayList<DxDocumentVO>();
List<WTDocument> docs = DocUtil.getDocs(var1);
for (WTDocument doc : docs) {
result.add(new DxDocumentVO(doc));
}
return result;
}
public String getFirstVersion() {
return null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment