123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- package nc.bs.pu.m25.pfxx;
- import nc.bs.ecn.eco.pf.PfParameterUtil;
- import nc.bs.framework.common.InvocationInfoProxy;
- import nc.bs.framework.common.NCLocator;
- import nc.bs.pu.m25.maintain.InvoiceSaveBP;
- import nc.impl.pu.m25.action.InvoiceDeleteAction;
- import nc.impl.pu.m25.action.InvoiceInsertAction;
- import nc.impl.pubapp.pattern.data.bill.BillQuery;
- import nc.itf.scmpub.reference.uap.bd.vat.BuySellFlagEnum;
- import nc.itf.uap.pf.IPFBusiAction;
- import nc.ui.fa.newasset.view.newasset_config;
- import nc.vo.ml.NCLangRes4VoTransl;
- import nc.vo.pu.m25.entity.InvoiceHeaderVO;
- import nc.vo.pu.m25.entity.InvoiceItemVO;
- import nc.vo.pu.m25.entity.InvoiceSettleItemVO;
- import nc.vo.pu.m25.entity.InvoiceVO;
- import nc.vo.pu.m25.env.InvoiceUIToBSEnv;
- import nc.vo.pu.pfxx.plugins.AbstractPuPfxxPlugin;
- 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.scmf.pub.util.BatchNCBaseTypeUtils;
- import nc.vo.scmpub.res.billtype.POBillType;
- import nc.vo.util.CloneUtil;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.util.HashMap;
- import org.apache.commons.lang.ArrayUtils;
- public class M25PfxxPlugin extends AbstractPuPfxxPlugin {
- private void checkMny(AggregatedValueObject vo) {
- StringBuilder errrows = new StringBuilder();
- InvoiceHeaderVO orderHVO = (InvoiceHeaderVO) vo.getParentVO();
- Integer fbuysellflag = orderHVO.getFbuysellflag();
- InvoiceItemVO[] bodyvos = ((InvoiceVO) vo).getChildrenVO();
- InvoiceItemVO[] arr$ = bodyvos;
- int len$ = bodyvos.length;
- for (int i$ = 0; i$ < len$; ++i$) {
- InvoiceItemVO bodyvo = arr$[i$];
- UFDouble nmny = bodyvo.getNmny();
- UFDouble ntaxmny = bodyvo.getNtaxmny();
- UFDouble ntax = bodyvo.getNtax();
- if (BuySellFlagEnum.IMPORT.value().equals(fbuysellflag)) {
- if (!nmny.equals(ntaxmny)) {
- errrows.append(bodyvo.getCrowno() + ",");
- }
- } else if (BuySellFlagEnum.NATIONAL_BUY.value().equals(fbuysellflag)) {
- if (!nmny.add(ntax).equals(ntaxmny)) {
- errrows.append(bodyvo.getCrowno() + ",");
- }
- } else {
- ExceptionUtils.wrappBusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("4004000_0",
- "04004000-0140", (String) null, new String[]{bodyvo.getCrowno()}));
- }
- }
- if (errrows.length() > 0) {
- errrows.deleteCharAt(errrows.length() - 1);
- ExceptionUtils.wrappBusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("4004000_0",
- "04004000-0137", (String) null, new String[]{errrows.toString()}));
- }
- }
- private void checkRwite(AggregatedValueObject vo) {
- InvoiceItemVO[] bodyvos = ((InvoiceVO) vo).getChildrenVO();
- InvoiceItemVO[] arr$ = bodyvos;
- int len$ = bodyvos.length;
- for (int i$ = 0; i$ < len$; ++i$) {
- InvoiceItemVO bodyvo = arr$[i$];
- StringBuilder errstr = new StringBuilder();
- UFDouble naccumsettmny = bodyvo.getNaccumsettmny();
- UFDouble naccumsettnum = bodyvo.getNaccumsettnum();
- if (!BatchNCBaseTypeUtils.isNullOrZero(naccumsettmny)) {
- errstr.append("naccumsettmny,");
- }
- if (!BatchNCBaseTypeUtils.isNullOrZero(naccumsettnum)) {
- errstr.append("naccumsettnum,");
- }
- if (errstr.length() <= 0) {
- return;
- }
- errstr.deleteCharAt(errstr.length() - 1);
- ExceptionUtils.wrappBusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("4004000_0",
- "04004000-0138", (String) null, new String[]{bodyvo.getCrowno(), errstr.toString()}));
- }
- }
- protected void checkCanInster(AggregatedValueObject vo) {
- super.checkCanInster(vo);
- this.checkMny(vo);
- this.checkRwite(vo);
- }
- protected void deleteVO(AggregatedValueObject vo) {
- (new InvoiceDeleteAction()).delete(new InvoiceVO[]{(InvoiceVO) vo}, (InvoiceUIToBSEnv[]) null);
- }
- protected String getChildrenPkFiled() {
- return "pk_invoice_b";
- }
- protected String getParentPkFiled() {
- return "pk_invoice";
- }
- protected AggregatedValueObject insert(AggregatedValueObject vo) {
- if (vo != null) {
- this.checkCanInster(vo);
- }
-
- try {
- // 线程设置业务日期
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Object dateTimeString = vo.getParentVO().getAttributeValue("dbilldate");
- if(dateTimeString != null) {
- Date date = format.parse(dateTimeString.toString());
- long timestamp = date.getTime();
- InvocationInfoProxy.getInstance().setBizDateTime(timestamp);
- }
- } catch (Exception e) {
- ExceptionUtils.wrappException(e);
- }
- InvoiceHeaderVO orderHVO = (InvoiceHeaderVO) vo.getParentVO();
- orderHVO.setFinvoicetype(0);
- vo.setParentVO(orderHVO);
- AggregatedValueObject[] savedVos = (new InvoiceInsertAction()).insert(new InvoiceVO[]{(InvoiceVO) vo}, (InvoiceUIToBSEnv) null);
- // try {
- // HashMap<String, Object> pfparam = new HashMap<String, Object>(); // 该参数用于控制自动审批时按钮的审批状态
- // pfparam.put(PfParameterUtil.ORIGIN_VO_PARAMETER, CloneUtil.deepClone(savedVos));
- // //采购发票审批
- // NCLocator.getInstance().lookup(IPFBusiAction.class) .processBatch("APPROVE", "25",savedVos, null, null, pfparam);
- // } catch (BusinessException e) {
- // // TODO 自动生成的 catch 块
- // ExceptionUtils.wrappException(e);
- // return null;
- // }
- return savedVos[0];
- }
- protected AggregatedValueObject queryVOByPk(String voPk) {
- BillQuery<InvoiceVO> billquery = new BillQuery(InvoiceVO.class);
- InvoiceVO[] vos = (InvoiceVO[]) billquery.query(new String[]{voPk});
- return ArrayUtils.isEmpty(vos) ? null : vos[0];
- }
- protected AggregatedValueObject update(AggregatedValueObject updatevo, AggregatedValueObject origVO) {
- InvoiceUIToBSEnv env = new InvoiceUIToBSEnv();
- InvoiceVO[] savedVos = (new InvoiceSaveBP(env)).save((InvoiceVO[]) null, new InvoiceVO[]{(InvoiceVO) updatevo},
- new InvoiceVO[]{(InvoiceVO) origVO});
- return savedVos[0];
- }
- }
|