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

convert dxUsageLink

parent 5dd910ed
package com.yonde.common;
import com.yonde.part.vo.DxPart;
import com.yonde.part.vo.DxSourceUsageLink;
import wt.fc.ObjectReference;
import wt.fc.Persistable;
import wt.fc.ReferenceFactory;
import wt.org.WTUser;
import wt.part.Quantity;
import wt.part.WTPart;
import wt.part.WTPartMaster;
import wt.part.WTPartUsageLink;
import wt.type.ClientTypedUtility;
import wt.util.WTException;
import wt.vc.wip.WorkInProgressHelper;
import java.lang.reflect.InvocationTargetException;
import java.rmi.RemoteException;
import java.util.Locale;
......@@ -52,6 +57,20 @@ public class BaseConvertUtil {
return dxPart;
}
public static DxSourceUsageLink toDxSourceUsageLink(WTPartUsageLink usageLink) throws WTException, RemoteException, InvocationTargetException {
DxSourceUsageLink dxUsageLink = new DxSourceUsageLink();
WTPart parent = (WTPart)usageLink.getUsedBy();
dxUsageLink.setModifyTime(DateTimeUtil.timeStampToString(usageLink.getModifyTimestamp()));
dxUsageLink.setCreateTime(DateTimeUtil.timeStampToString(usageLink.getCreateTimestamp()));
Quantity qt = usageLink.getQuantity();
dxUsageLink.setId(PartUtil.getWTObjectOid(usageLink));
dxUsageLink.setAmount(String.valueOf(qt.getAmount()));
dxUsageLink.setUnit(qt.getUnit().toString());
WTPartMaster uses = (WTPartMaster) usageLink.getUses();
WTPart child = PartUtil.getLatestPartByNoViewWithState(uses.getNumber(), parent.getViewName(), null, false);
dxUsageLink.setTargetId(PartUtil.getWTObjectOid(child));
dxUsageLink.setSourceId(PartUtil.getWTObjectOid(parent));
return dxUsageLink;
}
}
package com.yonde.part.service;
import com.yonde.common.DateTimeUtil;
import com.yonde.common.BaseConvertUtil;
import com.yonde.common.PartUtil;
import com.yonde.common.UsageLinkUtil;
import com.yonde.part.vo.DxPart;
import com.yonde.part.vo.DxSourceUsageLink;
import org.springframework.stereotype.Service;
import wt.part.Quantity;
import wt.part.WTPart;
import wt.part.WTPartMaster;
import wt.part.WTPartUsageLink;
import wt.util.WTException;
......@@ -18,7 +16,7 @@ import java.util.ArrayList;
import java.util.List;
@Service
public class PartService {
public class PartService extends BaseConvertUtil {
public static DxPart getPartByNumber(String number, String view) throws WTException, RemoteException {
System.out.println("-----getPartByNumber----");
......@@ -33,28 +31,12 @@ public class PartService {
* @throws InvocationTargetException
*/
public static List<DxSourceUsageLink> getUsageLinks(String oid) throws WTException, RemoteException, InvocationTargetException {
System.out.println("getUsageLinks=============1");
List<DxSourceUsageLink> links = new ArrayList<DxSourceUsageLink>();
WTPart parent = (WTPart) UsageLinkUtil.getWTObjectByOid(oid);
System.out.println("getUsageLinks=============2");
System.out.println("part is null:" + parent == null);
System.out.println("part number:" + parent.getNumber());
List<WTPartUsageLink> usageLinks = UsageLinkUtil.getUsageLinks(parent);
System.out.println("usageLinks size:" + usageLinks.size());
for (WTPartUsageLink link : usageLinks) {
DxSourceUsageLink dxUsageLink = new DxSourceUsageLink();
dxUsageLink.setModifyTime(DateTimeUtil.timeStampToString(link.getModifyTimestamp()));
dxUsageLink.setCreateTime(DateTimeUtil.timeStampToString(link.getCreateTimestamp()));
Quantity qt = link.getQuantity();
dxUsageLink.setId(PartUtil.getWTObjectOid(link));
dxUsageLink.setAmount(String.valueOf(qt.getAmount()));
dxUsageLink.setUnit(qt.getUnit().toString());
dxUsageLink.setSourceId(oid);
WTPartMaster uses = (WTPartMaster) link.getUses();
WTPart child = PartUtil.getLatestPartByNoViewWithState(uses.getNumber(), parent.getViewName(), null, false);
dxUsageLink.setTargetId(PartUtil.getWTObjectOid(child));
dxUsageLink.setSourceId(PartUtil.getWTObjectOid(parent));
links.add(dxUsageLink);
links.add(toDxSourceUsageLink(link));
}
return links;
......
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