|
@@ -0,0 +1,223 @@
|
|
|
+package nc.pubimpl.so.m30.pfxx;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import nc.bs.framework.common.InvocationInfoProxy;
|
|
|
+import nc.bs.framework.common.NCLocator;
|
|
|
+import nc.bs.pub.taskmanager.SynTaskTree;
|
|
|
+import nc.impl.pubapp.pattern.data.bill.BillQuery;
|
|
|
+import nc.impl.pubapp.pattern.data.bill.tool.BillConcurrentTool;
|
|
|
+import nc.impl.pubapp.pattern.rule.IRule;
|
|
|
+import nc.impl.so.m30.action.main.InsertSaleOrderAction;
|
|
|
+import nc.impl.so.m30.action.main.UpdateSaleOrderAction;
|
|
|
+import nc.itf.uap.pf.IPFBusiAction;
|
|
|
+import nc.pubimpl.so.pfxx.AbstractSOPfxxPlugin;
|
|
|
+import nc.pubimpl.so.pfxx.check.BillFreeStatusCheckRule;
|
|
|
+import nc.pubimpl.so.pfxx.check.MnyTaxCheckRule;
|
|
|
+import nc.pubimpl.so.pfxx.check.WriteBackInfoCheckRule;
|
|
|
+import nc.pubitf.uapbd.CurrencyRateUtil;
|
|
|
+import nc.vo.pub.AggregatedValueObject;
|
|
|
+import nc.vo.pub.BusinessException;
|
|
|
+import nc.vo.pub.lang.UFDouble;
|
|
|
+import nc.vo.pub.pf.workflow.IPFActionName;
|
|
|
+import nc.vo.pubapp.pattern.exception.ExceptionUtils;
|
|
|
+import nc.vo.so.m30.entity.SaleOrderBVO;
|
|
|
+import nc.vo.so.m30.entity.SaleOrderHVO;
|
|
|
+import nc.vo.so.m30.entity.SaleOrderVO;
|
|
|
+import nc.vo.wfengine.pub.WFTask;
|
|
|
+
|
|
|
+public class M30PfxxPlugin extends AbstractSOPfxxPlugin {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<IRule<AggregatedValueObject>> getCheckers() {
|
|
|
+ List<IRule<AggregatedValueObject>> rules =
|
|
|
+ new ArrayList<IRule<AggregatedValueObject>>();
|
|
|
+
|
|
|
+ rules.add(new BillFreeStatusCheckRule());
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ rules.add(new WriteBackInfoCheckRule(new String[] {
|
|
|
+ SaleOrderBVO.NTOTALSENDNUM,
|
|
|
+ SaleOrderBVO.NTOTALINVOICENUM,
|
|
|
+ SaleOrderBVO.NTOTALOUTNUM,
|
|
|
+ SaleOrderBVO.NTOTALNOTOUTNUM,
|
|
|
+ SaleOrderBVO.NTOTALSIGNNUM,
|
|
|
+ SaleOrderBVO.NTRANSLOSSNUM,
|
|
|
+ SaleOrderBVO.NTOTALRUSHNUM,
|
|
|
+ SaleOrderBVO.NTOTALESTARNUM,
|
|
|
+ SaleOrderBVO.NTOTALARNUM,
|
|
|
+ SaleOrderBVO.NTOTALCOSTNUM,
|
|
|
+ SaleOrderBVO.NTOTALESTARMNY,
|
|
|
+ SaleOrderBVO.NTOTALARMNY,
|
|
|
+ SaleOrderBVO.NTOTALPAYMNY,
|
|
|
+ SaleOrderBVO.NORIGSUBMNY,
|
|
|
+ SaleOrderBVO.NARRANGESCORNUM,
|
|
|
+ SaleOrderBVO.NARRANGEPOAPPNUM,
|
|
|
+ SaleOrderBVO.NARRANGETOORNUM,
|
|
|
+ SaleOrderBVO.NARRANGETOAPPNUM,
|
|
|
+ SaleOrderBVO.NARRANGEMONUM,
|
|
|
+ SaleOrderBVO.NARRANGEPONUM,
|
|
|
+ SaleOrderBVO.NTOTALPLONUM,
|
|
|
+ SaleOrderBVO.NTOTALRETURNNUM,
|
|
|
+ SaleOrderBVO.NTOTALTRADENUM
|
|
|
+
|
|
|
+ }));
|
|
|
+ return rules;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected AggregatedValueObject insert(AggregatedValueObject vo) {
|
|
|
+
|
|
|
+ SaleOrderVO[] insertvo = new SaleOrderVO[] {
|
|
|
+ (SaleOrderVO) vo
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * 根据源币种主键,目的币种主键,查询指定日期的汇率
|
|
|
+ *
|
|
|
+ * @param src_currency_pk
|
|
|
+ * 源币种主键
|
|
|
+ * @param dest_currency_pk
|
|
|
+ * 目的币种的主键,为null时则认为是默认目的币种主键
|
|
|
+ * @param date
|
|
|
+ * @return
|
|
|
+ * @throws BusinessException
|
|
|
+ */
|
|
|
+
|
|
|
+
|
|
|
+ SaleOrderHVO headvo=(SaleOrderHVO) vo.getParentVO();
|
|
|
+
|
|
|
+ String corigcurrencyid= headvo.getCorigcurrencyid();
|
|
|
+ CurrencyRateUtil currRateUtil = CurrencyRateUtil
|
|
|
+ .getInstanceByOrg(headvo.getPk_org());
|
|
|
+ try {
|
|
|
+ SaleOrderBVO[] bodyvos= (SaleOrderBVO[]) vo.getChildrenVO();
|
|
|
+ for(SaleOrderBVO bodyvo:bodyvos){
|
|
|
+ String ccurrencyid= bodyvo.getCcurrencyid();
|
|
|
+
|
|
|
+ if(corigcurrencyid.equals(ccurrencyid)){
|
|
|
+ UFDouble nqtorigtaxprice = bodyvo.getNqtorigtaxprice();
|
|
|
+ UFDouble nqtorigprice = bodyvo.getNqtorigprice();
|
|
|
+ UFDouble norigmny = bodyvo.getNorigmny();
|
|
|
+ UFDouble norigtaxmny = bodyvo.getNorigtaxmny();
|
|
|
+ bodyvo.setNcaltaxmny(norigtaxmny);
|
|
|
+ bodyvo.setNqttaxprice(nqtorigtaxprice);
|
|
|
+ bodyvo.setNqtprice(nqtorigprice);
|
|
|
+ bodyvo.setNqttaxnetprice(nqtorigtaxprice);
|
|
|
+ bodyvo.setNqtnetprice(nqtorigprice);
|
|
|
+ bodyvo.setNtaxprice(nqtorigtaxprice);
|
|
|
+ bodyvo.setNpiece(nqtorigprice);
|
|
|
+ bodyvo.setNtaxnetprice(nqtorigtaxprice);
|
|
|
+ bodyvo.setNnetprice(nqtorigprice);
|
|
|
+ bodyvo.setNmny(norigmny);
|
|
|
+ bodyvo.setNtaxmny(norigtaxmny);
|
|
|
+
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ UFDouble foreignrate = currRateUtil.getRate(corigcurrencyid,
|
|
|
+ ccurrencyid, headvo.getDbilldate());
|
|
|
+ bodyvo.setNexchangerate(foreignrate);
|
|
|
+
|
|
|
+ UFDouble norigprice=bodyvo.getNorigtaxprice();
|
|
|
+ UFDouble foreignAmount= currRateUtil.getAmountByOpp(corigcurrencyid,
|
|
|
+ ccurrencyid, norigprice, foreignrate, headvo.getDbilldate());
|
|
|
+ bodyvo.setNtaxprice(foreignAmount);
|
|
|
+
|
|
|
+ UFDouble ngprice=currRateUtil.getAmountByOpp(corigcurrencyid,
|
|
|
+ ccurrencyid, bodyvo.getNorigprice(), foreignrate, headvo.getDbilldate());
|
|
|
+
|
|
|
+ bodyvo.setNprice(ngprice);
|
|
|
+
|
|
|
+ bodyvo.setNqtprice(ngprice);
|
|
|
+
|
|
|
+ bodyvo.setNqttaxprice(foreignAmount);
|
|
|
+
|
|
|
+
|
|
|
+ UFDouble nmny=currRateUtil.getAmountByOpp(corigcurrencyid,
|
|
|
+ ccurrencyid, bodyvo.getNorigmny(), foreignrate, headvo.getDbilldate());
|
|
|
+
|
|
|
+ bodyvo.setNmny(nmny);
|
|
|
+
|
|
|
+ UFDouble ntaxmny=currRateUtil.getAmountByOpp(corigcurrencyid,
|
|
|
+ ccurrencyid, bodyvo.getNorigtaxmny(), foreignrate, headvo.getDbilldate());
|
|
|
+
|
|
|
+ bodyvo.setNtaxmny(ntaxmny);
|
|
|
+
|
|
|
+ bodyvo.setNcaltaxmny(nmny);
|
|
|
+ bodyvo.setNqtnetprice(ngprice);
|
|
|
+ bodyvo.setNnetprice(ngprice);
|
|
|
+
|
|
|
+ bodyvo.setNqttaxnetprice(foreignAmount);
|
|
|
+ bodyvo.setNtaxnetprice(foreignAmount);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ bodyvo.setNtax(ntaxmny.sub(nmny));
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (BusinessException e1) {
|
|
|
+ ExceptionUtils.wrappException(e1);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ InsertSaleOrderAction insertact = new InsertSaleOrderAction();
|
|
|
+ SaleOrderVO[] retvos = insertact.insert(insertvo);
|
|
|
+ if (null == retvos || retvos.length == 0) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ String pk_org = retvos[0].getParentVO().getPk_org();
|
|
|
+
|
|
|
+ if(pk_org != null && (pk_org.equals("0001V510000000002GDX"))){
|
|
|
+ IPFBusiAction service = NCLocator.getInstance().lookup(IPFBusiAction.class);
|
|
|
+ InvocationInfoProxy.getInstance().setUserId(retvos[0].getParentVO().getApprover());
|
|
|
+ try {
|
|
|
+ service.processAction(IPFActionName.APPROVE,
|
|
|
+ "30", null, retvos[0], null, null);
|
|
|
+ } catch (BusinessException e) {
|
|
|
+
|
|
|
+ ExceptionUtils.wrappBusinessException(e.getMessage());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return retvos[0];
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected AggregatedValueObject update(AggregatedValueObject vo, String vopk) {
|
|
|
+
|
|
|
+ SaleOrderVO[] updatevo = new SaleOrderVO[] {
|
|
|
+ (SaleOrderVO) vo
|
|
|
+ };
|
|
|
+ BillQuery<SaleOrderVO> billquery =
|
|
|
+ new BillQuery<SaleOrderVO>(SaleOrderVO.class);
|
|
|
+ SaleOrderVO[] origvos = billquery.query(new String[] {
|
|
|
+ vopk
|
|
|
+ });
|
|
|
+ BillConcurrentTool tool = new BillConcurrentTool();
|
|
|
+ tool.lockBill(origvos);
|
|
|
+ UpdateSaleOrderAction insertact = new UpdateSaleOrderAction();
|
|
|
+ SaleOrderVO[] retvos = insertact.update(updatevo, origvos);
|
|
|
+ if (null == retvos || retvos.length == 0) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return retvos[0];
|
|
|
+ }
|
|
|
+
|
|
|
+}
|