📄 preadvicepagehelper.java
字号:
private EquipmentSizeService equipmentSizeService;
private POService pOService;
private POExceptionService poExceptionService;
// private SessionContext sc;
// private SystemUserService systemUserService;
public PreAdvicePageHelper(SessionContext sessionContext, PreAdvice advice) {
this.sessionContext = sessionContext;
this.advice = advice;
measurementVolume = getMeasurementService().getMeasurementByOID(MeasurementConstant.CBM_OID);
measurementWeight = getMeasurementService().getMeasurementByOID(MeasurementConstant.KILOGRAM_OID);
}
public void advice2Dp(DataPacket dpOut) throws Exception {
advice2Dp(dpOut, new ArrayList());
}
// !!advice could be a modified advice, if has so added, it will be
// contained
// in the advice and soCargos, if has so deleted, it will be also contained
// in
// the advice and soCargos
public void advice2Dp(DataPacket dpOut, List newSOCargos) throws Exception {
advice2Dp(dpOut, newSOCargos, new ArrayList());
}
public void advice2Dp(DataPacket dpOut, List newSOCargos, List deletedSOCargos) throws Exception {
String userId = dpOut.getNodeString("user.user_id");
String custCode = dpOut.getNodeString("cust_code");
List customizedFields = new ArrayList();
FieldCustomizeTemplate template = null;
if (!"".equals(userId)) {
// String userType = dpOut.getNodeString("user.user_type");
template = PreAdviceTemplate.getInstance(sessionContext, userId, custCode);
/*
* for (Iterator it = template.getSections().iterator();
* it.hasNext();) { FieldCustomizeSection section =
* (FieldCustomizeSection) it.next(); for (Iterator ij =
* section.getFields().iterator(); ij.hasNext();) {
* FieldCustomizeField field = (FieldCustomizeField) ij.next();
* FieldSpec customizeField = field.getCustomizeField(); if
* (customizeField != null) { customizedFields.add(field); } } }
*/
}
dpOut.emptyDPList("node_list");
dpOut.emptyDPList(PreAdvicePageConstants.GROUP_PREFIX_BIZ_TYPE);
dpOut.emptyDPList(PreAdvicePageConstants.GROUP_PREFIX_TYPE_OF_MOVEMENT);
dpOut.emptyDPList(PreAdvicePageConstants.GROUP_PREFIX_FORWARDER);
dpOut.emptyDPList(PreAdvicePageConstants.GROUP_PREFIX_CONTAINER);
dpOut.emptyDPList(PreAdvicePageConstants.GROUP_PREFIX_DIVISION);
dpOut.emptyDPList(PreAdvicePageConstants.GROUP_PREFIX_FND);
dpOut.emptyDPList(PreAdvicePageConstants.GROUP_PREFIX_SO);
List soList = advice.getAbstractSO();
soList.addAll(newSOCargos);
Map bizTypeGroup = groupSOList(soList, PreAdvicePageConstants.NODE_TYPE_BIZ_TYPE);
addNode(dpOut, "", "-1");
long noOfPack = 0;
long units = 0;
double vol = 0;
double gwt = 0;
Object[] bizTypeKeyArray = bizTypeGroup.keySet().toArray();
for (int i1 = 0; i1 < bizTypeKeyArray.length; i1++) {
List soList1 = (List) bizTypeGroup.get(bizTypeKeyArray[i1]);
if (!deletedSOCargos.containsAll(soList1)) {
double[] bizTypeSum = fillBizTypeGroupInfo(customizedFields, dpOut, newSOCargos, deletedSOCargos, bizTypeGroup, bizTypeKeyArray[i1].toString(), "0");
noOfPack += bizTypeSum[0];
units += bizTypeSum[1];
vol += bizTypeSum[2];
gwt += bizTypeSum[3];
}
}
dpOut.putNodeString("ctns", getContainerInfo(dpOut));
dpOut.putNodeString("units", Long.toString(units));
dpOut.putNodeString("packs", Long.toString(noOfPack));
dpOut.putNodeString("volume", getMeasurementService().rounding(vol, measurementVolume).toString());
dpOut.putNodeString("weight", getMeasurementService().rounding(gwt, measurementWeight).toString());
if (template != null) {
sortDetail(template, dpOut);
}
}
private String getContainerInfo(DataPacket dpOut) {
StringBuffer buf = new StringBuffer();
Map map = new HashMap();
for (int i1 = 0, l1 = dpOut.getListSize(PreAdvicePageConstants.GROUP_PREFIX_TYPE_OF_MOVEMENT); i1 < l1; i1++) {
String typeOfMovementPrefix = PreAdvicePageConstants.GROUP_PREFIX_TYPE_OF_MOVEMENT + "[" + i1 + "]";
for (int i2 = 0, l2 = dpOut.getListSize(typeOfMovementPrefix + ".proposed_container_list"); i2 < l2; i2++) {
String containerPrefix = typeOfMovementPrefix + ".proposed_container_list[" + i2 + "]";
String qty = dpOut.getNodeString(containerPrefix + ".qty");
String size = dpOut.getNodeString(containerPrefix + ".equipmentsize.abbr");
String type = dpOut.getNodeString(containerPrefix + ".equipmenttype.abbr");
Integer total = (Integer) map.get(size + " " + type);
if (total == null) {
total = new Integer(0);
}
total = new Integer(total.intValue() + ("".equals(qty) ? 0 : Integer.parseInt(qty)));
map.put(size + " " + type, total);
}
}
for (int i1 = 0, l1 = dpOut.getListSize(PreAdvicePageConstants.GROUP_PREFIX_CONTAINER); i1 < l1; i1++) {
String sizeType = dpOut.getNodeString(PreAdvicePageConstants.GROUP_PREFIX_CONTAINER + "[" + i1 + "].size_type");
Integer total = (Integer) map.get(sizeType);
if (total == null) {
total = new Integer(0);
}
total = new Integer(total.intValue() + 1);
map.put(sizeType, total);
}
for (Iterator it = map.keySet().iterator(); it.hasNext();) {
String sizeType = (String) it.next();
if (!(StringHelper.isEmpty(sizeType) || " ".equals(sizeType))) {
buf.append(map.get(sizeType)).append(" x ").append(sizeType).append(it.hasNext() ? ", " : "");
}
}
return buf.toString();
}
public void db2Dp(DataPacket dpOut) throws Exception {
setPageInfo(dpOut, advice);
fillRouteInfo(dpOut);
fillInstructionInfo(advice, dpOut, UserConstant.USER_TYPE_INTERNAL_USER.equals(dpOut.getNodeString("user.user_type")));
fillNotifyPartiesInfo(advice, dpOut);
advice2Dp(dpOut, new ArrayList());
}
public StringBuffer getEmailContent(String userId, String userType) throws Exception {
DataPacket dpOut = PrePostAdvicePresentationHelper.getPresentation(DP_INFO);
dpOut.putNodeString("user.user_id", userId);
dpOut.putNodeString("user.user_type", userType);
db2Dp(dpOut);
AdvicePageBuilder builder = new PreAdvicePageHTMLBuilder(dpOut, PreAdviceServiceConstants.PAGE_STATE_EMAIL_VIEW, userId, advice.getCustomer().getCompanyCode(), sessionContext);
StringBuffer result = builder.buildPage();
// if (advice.getReqShowNotesLog().booleanValue()) {
result.append(new NotesLogServiceImpl(sessionContext).generateNotesLogEmail(dpOut));
// }
// result.append(" <table><tr><td class='SOLID_BORDER1'>").append('\n');
// result.append(" <font
// class='TEXT_NORMAL'>").append("\n").append("<br>");
// result
// .append(
// " <p>Should you have any queries, please contact:</a></p>")
// .append("\n");
// result.append(" <p>Best Regards</p>").append("\n");
// result.append(" <p>OOCL Logistics</p>").append("\n");
// result.append(" </font>").append("\n");
// result.append(" </td></tr></table>").append('\n');
return result;
}
public StringBuffer getFaxContent() throws Exception {
DataPacket dpOut = PrePostAdvicePresentationHelper.getPresentation(DP_INFO);
dpOut.putNodeString("user.user_id", sessionContext.getSessionContextUserID());
dpOut.putNodeString("user.user_type", UserConstant.USER_TYPE_INTERNAL_USER);
db2Dp(dpOut);
AdvicePageBuilder builder = new PreAdvicePageFaxBuilder(dpOut, "", sessionContext);
return builder.buildPage();
}
public String[] addNode(DataPacket dpOut, String type, String parentIndex) throws Exception {
String nodeSize = Integer.toString(dpOut.getListSize("node_list"));
dpOut.putNodeString("node_list[" + nodeSize + "].type", type);
String group = (String) PreAdvicePageConstants.prefixMap.get(type);
String groupInfoSize = "";
if (group != null) {
groupInfoSize = Integer.toString(dpOut.getListSize(group));
dpOut.putNodeString("node_list[" + nodeSize + "].info_index", groupInfoSize);
// set the link to node list for info group.
dpOut.putNodeString(group + "[" + groupInfoSize + "].node_index", nodeSize);
} else {
if (!"".equals(type)) {
throw new PreAdviceServiceException("Invalid node type of " + type) {
};
}
}
if (Integer.parseInt(parentIndex) >= 0) {
String brothers = dpOut.getNodeString("node_list[" + parentIndex + "].children");
dpOut.putNodeString("node_list[" + parentIndex + "].children", brothers + "," + nodeSize);
dpOut.putNodeString("node_list[" + nodeSize + "].parent", parentIndex);
}
return new String[] { nodeSize, group + "[" + groupInfoSize + "]" };
}
private boolean calculateEquipment(List soList1, Map map) throws ServiceException {
boolean isEquipmentReadOnly = false;
// if add so, need remove old proposed containers.
// if (newSOCargos.size() > 0) {
// VDL from SO
List shipmentEquipmentList = advice.getPreEquipment();
if (SrrDomainConstant.BT_VDL.equals(map.get(PreAdvicePageConstants.NODE_TYPE_BIZ_TYPE))) {
shipmentEquipmentList.removeAll(PreAdviceUtil.getProposedContainers(advice, map));
shipmentEquipmentList.addAll(getGeneratePreAdviceService().generateAdviceEquipmentFromSO(soList1));
isEquipmentReadOnly = true;
} else if (SrrDomainConstant.BT_CRD.equals(map.get(PreAdvicePageConstants.NODE_TYPE_BIZ_TYPE))) {
if (advice.getReqShowContainerPlan().booleanValue()) {
List stuffingEquipmentList = getStuffingService().getAllStuffingCargoByAllSO(soList1);
if (stuffingEquipmentList == null) {
shipmentEquipmentList.removeAll(PreAdviceUtil.getProposedContainers(advice, map));
// shipmentEquipmentList.addAll(getGeneratePreAdviceService().generateAdviceEquipmentFromCRR(soList1));
isEquipmentReadOnly = false;
} else {
shipmentEquipmentList.removeAll(PreAdviceUtil.getProposedContainers(advice, map));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -