NC65信用占用重算

354 篇文章 102 订阅

在这里插入图片描述
在这里插入图片描述
信用占用重算——节点列表类 nc.ui.credit.recalculation.model.RecalBatchBillTable
信用占用重算——xml文件生成类 nc.ui.credit.recalculation.model.recalculation_config
信用占用重新——重算按钮动作类 nc.ui.credit.recalculation.action.ReCalAction

package nc.ui.credit.recalculation.action;

import java.awt.event.ActionEvent;
import java.util.HashMap;
import java.util.Map;

import nc.itf.scmpub.reference.uap.setting.defaultdata.DefaultDataSettingAccessor;
import nc.ui.credit.pub.DirectUtils;
import nc.ui.credit.recalculation.model.ReCalCulationModel;
import nc.ui.credit.recalculation.model.ReCalCulationService;
import nc.ui.ml.NCLangRes;
import nc.ui.pub.beans.UIDialog;
import nc.ui.pubapp.scale.CardPaneScaleProcessor;
import nc.ui.pubapp.uif2app.query2.QueryConditionDLGDelegator;
import nc.ui.pubapp.uif2app.view.BatchBillTable;
import nc.ui.querytemplate.querytree.IQueryScheme;
import nc.ui.querytemplate.querytree.QueryScheme;
import nc.ui.scmpub.action.SCMActionInitializer;
import nc.ui.scmpub.util.NCActionProgressor;
import nc.ui.uif2.NCAction;
import nc.ui.uif2.ShowStatusBarMsgUtil;
import nc.vo.credit.engrossmaintain.entity.AccountMnyVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.query.ConditionVO;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
import nc.vo.pubapp.scale.BillScaleProcessor;
import nc.vo.pubapp.scale.PosEnum;
import nc.vo.scmpub.res.SCMActionCode;
import nc.vo.uif2.LoginContext;

/**
 * 客户信用重算
 * 
 */
public class ReCalAction extends NCAction {

  private static final long serialVersionUID = -6094115793975599384L;

  private LoginContext context;

  private BatchBillTable list;

  private ReCalCulationModel model;

  private String nodeKey;

  private QueryConditionDLGDelegator queryDlg;

  /**
   * 构造子
   */
  public ReCalAction() {

    // 重算
    SCMActionInitializer.initializeAction(this,
        SCMActionCode.CREDIT_RECALENGROSS);
  }

  /**
   * 检查查询条件
   * 
   * @param convos
   */
  private void checkCondiTionVO(ConditionVO[] convos) {
    int flag = -1;
    // 除信用控制域外的所有条件是否为空
    boolean nullDataFlag = true;
    for (ConditionVO vo : convos) {
      if (vo.getValue() == null || vo.getValue().length() == 0) {
        continue;
      }
      if (!AccountMnyVO.PK_ORG.equals(vo.getFieldCode())) {
        nullDataFlag = false;
      }
      // 客户
      if (AccountMnyVO.CCUSTOMERID.equals(vo.getFieldCode())) {
        flag++;
      }
      // 信用等级
      if ("climitlevelid".equals(vo.getFieldCode())) {
        flag++;
      }
      // 客户分类
      if ("ccustclassid".equals(vo.getFieldCode())) {
        flag++;
      }
      // 销售分类
      if ("ccustsaleclassid".equals(vo.getFieldCode())) {
        flag++;
      }
      // 地区分类
      if ("careaclassid".equals(vo.getFieldCode())) {
        flag++;
      }
    }
    if (nullDataFlag) {
      String message =
          nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4032001_0",
              "04032001-0024")/*@res "您本次业务未输入任何的约束条件,"*/
              + nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID(
                  "4032001_0", "04032001-0025")/*@res "会从本系统提取大量业务数据并进行很长时间的操作,"*/
              + nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID(
                  "4032001_0", "04032001-0026")/*@res "可能需要长时间才能得到您希望的业务数据并会导致系统运行效率急剧下降,"*/
              + nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID(
                  "4032001_0", "04032001-0027")/*@res "造成系统繁忙,请修改约束条件"*/;
      ExceptionUtils.wrappBusinessException(message);
    }
    if (flag > 0) {
      String message =
          nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4032001_0",
              "04032001-0028")/*@res "客户、信用等级、客户分类、销售分类、地区分类只能输入其一"*/;
      ExceptionUtils.wrappBusinessException(message);
    }
  }

  @Override
  public void doAction(ActionEvent e) throws Exception {
    try {
      if (getQueryDlg().showModal() == UIDialog.ID_OK) {
        // 获得查询模板上的查询条件
        IQueryScheme queryScheme = getQueryDlg().getQueryScheme();

        /*"正在信用占用重算,请稍候..."*/
        String name =
            NCLangRes.getInstance().getStrByID("4032001_0", "04032001-0189");
        NCActionProgressor handler =
            new NCActionProgressor(this, "queryReCalData", model.getContext(),
                queryScheme);
        handler.process(name);

      }
    }
    catch (Exception ex) {
      getModel().initModel(null);
      throw ex;
    }
  }

  public LoginContext getContext() {
    return context;
  }

  public BatchBillTable getList() {
    return list;
  }

  public ReCalCulationModel getModel() {
    return model;
  }

  public String getNodeKey() {
    return nodeKey;
  }

  /**
   * 加载查询模板
   * 
   * @return
   */
  private QueryConditionDLGDelegator getQueryDlg() {
    // 加载自己的查询模板
    if (null == queryDlg) {
      queryDlg = DirectUtils.getQueryDlg(getModel(), getNodeKey());
    }
    try {
      String pk_org = DefaultDataSettingAccessor.getDefaultCreditCtlRegionID();
      queryDlg.setDefaultValue("pk_org", pk_org);
    }
    catch (Exception e) {
      ExceptionUtils.wrappException(e);
    }
    DirectUtils.initFilterRef(queryDlg);
    // 权限过滤
    // this.processPowerFilter(this.queryDlg);
    return queryDlg;
  }

  @SuppressWarnings("unused")
  private void processPowerFilter(QueryConditionDLGDelegator dlt) {

    // 主组织使用权限
    dlt.registerNeedPermissionOrgFieldCodes(new String[] {
      AccountMnyVO.PK_ORG
    });

    Map<String, String> columnMapping = new HashMap<String, String>();
    columnMapping.put("ccustomerid", AccountMnyVO.CCUSTOMERID);
    columnMapping.put("pk_org", AccountMnyVO.PK_ORG);
    dlt.registerRefPowerFilterInfo(AccountMnyVO.class, columnMapping);
  }

  @SuppressWarnings("unused")
  private void queryReCalData(QueryScheme queryScheme) throws BusinessException {

    ConditionVO[] convos =
        (ConditionVO[]) queryScheme.get(IQueryScheme.KEY_LOGICAL_CONDITION);
    if (null == convos) {
      String message =
          nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4032001_0",
              "04032001-0022")/*@res "信用控制域为必输条件"*/;
      ExceptionUtils.wrappBusinessException(message);
      return;
    }
    // 检查查询条件
    checkCondiTionVO(convos);
    // 设置到model中,为刷新时时用
    getModel().setVos(convos);

    // 查询重算后的数据
    ReCalCulationService service = new ReCalCulationService();
    AccountMnyVO[] vos = service.queryReCalData(convos);
    // 精度处理
    BillScaleProcessor scale =
        new CardPaneScaleProcessor(context.getPk_group(),
            list.getBillCardPanel());
    setPrecision(scale);
    // 初始化model
    getModel().initModel(vos);
    // 按额度类型排序
    // this.getList().getBillCardPanel().getBillModel()
    // .sortByColumn(AccountMnyVO.CLIMITTYPEID, true);

    ShowStatusBarMsgUtil.showStatusBarMsg(
        nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4032001_0",
            "04032001-0023")/*@res "重算完成。"*/, getModel().getContext());
  }

  public void setContext(LoginContext context) {
    this.context = context;
  }

  public void setList(BatchBillTable list1) {
    list = list1;
  }

  public void setModel(ReCalCulationModel model1) {
    model = model1;
    model.addAppEventListener(this);
  }

  public void setNodeKey(String nodeKey1) {
    nodeKey = nodeKey1;
  }

  /**
   * 精度处理
   * 
   * @param scale
   */
  private void setPrecision(BillScaleProcessor scale) {
    String[] mnykeys =
        new String[] {
          AccountMnyVO.NMNY, AccountMnyVO.NARMNY, AccountMnyVO.NESTARMNY,
          AccountMnyVO.NNOVERIFYMNY, AccountMnyVO.NSUBMNY
        };
    scale.setMnyCtlInfo(mnykeys, PosEnum.body, null,
        AccountMnyVO.CORIGCURRENCYID, PosEnum.body, null);
    scale.process();
  }

}

信用占用重算——结果更新动作类 nc.ui.credit.recalculation.action.ResultUpdateAction
查询条件——信用控制域 表型参照类 nc.ui.corg.ref.CreditCtlRegionDefaultRefModel
查询条件——额度类型 参照类 nc.ui.credit.limittype.ref.LimitTypeDefaultRefModel
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

一、后台任务部署信用占用重算执行类 nc.pubimpl.credit.alart.CreditRecalculationAlart


package nc.pubimpl.credit.alart;

import nc.bs.credit.alart.CreditRecalculationBP;
import nc.bs.pub.pa.PreAlertObject;
import nc.bs.pub.pa.PreAlertReturnType;
import nc.bs.pub.taskcenter.BgWorkingContext;
import nc.bs.pub.taskcenter.IBackgroundWorkPlugin;
import nc.vo.pub.BusinessException;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;

public class CreditRecalculationAlart implements IBackgroundWorkPlugin {

	@Override
	public PreAlertObject executeTask(BgWorkingContext context) throws BusinessException {
		try {
			CreditRecalculationBP bp = new CreditRecalculationBP();
			bp.recalAlter(context);
		}
		catch (Exception e) {
			ExceptionUtils.marsh(e);
		}
		PreAlertObject retObj = new PreAlertObject();
		retObj.setReturnType(PreAlertReturnType.RETURNDATASOURCE);
		// 返回一个类型为RETURNDATASOURCE的Object即可,具体提示信息由用户定义的消息模板决定。
		return retObj;
	}
}

package nc.impl.credit.recalculation;

import java.util.Map;
import java.util.Map.Entry;

import nc.bs.credit.recalculation.ReCalAction;
import nc.impl.credit.recalculation.util.SqlChangeUtil;
import nc.itf.credit.recalculation.IReCalManage;
import nc.itf.scmpub.reference.uap.bd.customer.CustomerPubService;
import nc.vo.credit.engrossmaintain.entity.AccountMnyVO;
import nc.vo.credit.recalculation.ReCalQueryVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.query.ConditionVO;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
import nc.vo.pubapp.pattern.pub.PubAppTool;

public class ReCalManageImpl implements IReCalManage {

  @Override
  public AccountMnyVO[] queryReCalData(ConditionVO[] convos)
      throws BusinessException {
    if (null == convos || 0 == convos.length) {
      String message =
          nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4032001_0",
              "04032001-0122")/*@res "查询条件不能为空"*/;
      ExceptionUtils.wrappBusinessException(message);
    }
    AccountMnyVO[] vos = new AccountMnyVO[0];
    try {
      ReCalQueryVO queryvo = this.getReCalQueryVO(convos);
      if (null != queryvo) {
        ReCalAction action = new ReCalAction();
        vos = action.recaculate(queryvo);
      }
    }
    catch (Exception e) {
      ExceptionUtils.marsh(e);
    }
    return vos;
  }

  private void checkCustomer(ReCalQueryVO queryvo) {
    String[] creditorg = queryvo.getCreditorg();
    if ((null == creditorg) || (creditorg.length == 0)) {
      String message =
          nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4032001_0",
              "04032001-0022")/*@res "信用控制域为必输条件"*/;
      ExceptionUtils.wrappBusinessException(message);
      return;
    }
    String[] customer = queryvo.getCcustomer();
    if ((null == customer) || (customer.length == 0)) {
      return;
    }
    try {
      for (String org : creditorg) {
        Map<String, String> map =
            CustomerPubService.queryRootCustomerByCreditType(customer, org);
        if ((null == map) || (map.size() == 0)) {
          String message =
              nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID(
                  "4032001_0", "04032001-0123")/*@res "该客户没有分配到该信用控制域"*/;
          ExceptionUtils.wrappBusinessException(message);
          continue;
        }
        for (Entry<String, String> entry : map.entrySet()) {
          if (!PubAppTool.isEqual(entry.getKey(), entry.getValue())) {
            String message =
                nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID(
                    "4032001_0", "04032001-0124")/*@res "不能使用非顶级客户进行查询"*/;
            ExceptionUtils.wrappBusinessException(message);
          }
        }
      }
    }
    catch (Exception e) {
      ExceptionUtils.wrappException(e);
    }
  }

  @Override
  public void reCalculateUpdate(ConditionVO[] convos) throws BusinessException {
    if ((null == convos) || (convos.length == 0)) {

      String message =
          nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("4032001_0",
              "04032001-0122")/*@res "查询条件不能为空"*/;
      ExceptionUtils.wrappBusinessException(message);
    }
    try {
      ReCalQueryVO queryvo = this.getReCalQueryVO(convos);
      if (null != queryvo) {
        ReCalAction action = new ReCalAction();
        action.recaculateUpdate(queryvo);
      }
    }
    catch (Exception e) {
      ExceptionUtils.marsh(e);
    }
  }

  private ReCalQueryVO getReCalQueryVO(ConditionVO[] convos) {
    SqlChangeUtil util = new SqlChangeUtil();
    ReCalQueryVO queryvo = util.getQueryVO(convos);
    this.checkCustomer(queryvo);
    String[] customer = util.findCustomer(queryvo);
    if ((null == customer) || (customer.length == 0)) {
      return null;
    }
    queryvo.setCcustomer(customer);
    return queryvo;
  }

  public void reCalculateUpdateForAll() throws BusinessException {
    try {
      ReCalAction action = new ReCalAction();
      action.recaculateUpdateForAll();
    }
    catch (Exception e) {
      ExceptionUtils.marsh(e);
    }
  }
}

package nc.bs.credit.recalculation;

import java.util.List;
import java.util.Map;

import nc.bs.credit.engrossmaintain.util.EngrossLockUtil;
import nc.bs.credit.engrossmaintain.util.MatchCcregion;
import nc.bs.credit.recalculation.util.GetCsettorgOrgForRecal;
import nc.bs.credit.recalculation.util.GetLimitTypeForRecal;
import nc.impl.credit.limittype.LimitTypeQueryImpl;
import nc.vo.credit.engrossmaintain.entity.AccountMnyVO;
import nc.vo.credit.limittype.entity.LimitTypeVO;
import nc.vo.credit.recalculation.ReCalQueryVO;
import nc.vo.pub.BusinessException;

public class ReCalAction {

  public AccountMnyVO[] recaculate(ReCalQueryVO queryvo)
      throws BusinessException {
    GetLimitTypeForRecal recal = new GetLimitTypeForRecal();
    Map<String, List<LimitTypeVO>> limittypemap =
        recal.getLimitTypeForReCal(queryvo);

    if (null == limittypemap || 0 == limittypemap.size()) {
      return new AccountMnyVO[0];
    }
    String[] creditorgs = queryvo.getCreditorg();
    EngrossLockUtil util = new EngrossLockUtil();
    util.engrossLock(creditorgs);
    GetCsettorgOrgForRecal setrecal = new GetCsettorgOrgForRecal();
    Map<String, String[]> orgmap = setrecal.getCsettorgsForReCal(creditorgs);
    if (null == orgmap || orgmap.size() == 0) {
      return new AccountMnyVO[0];
    }
    ReCaculateBP reBP = new ReCaculateBP();
    String recalTable = reBP.recaculateData(orgmap, limittypemap, queryvo);

    AccountMnyVO[] mnyvos = reBP.getResultData(recalTable);

    return mnyvos;
  }

  public void recaculateUpdate(ReCalQueryVO queryvo) throws BusinessException {
    GetLimitTypeForRecal recal = new GetLimitTypeForRecal();
    Map<String, List<LimitTypeVO>> limittypemap =
        recal.getLimitTypeForReCal(queryvo);
    if (null == limittypemap || 0 == limittypemap.size()) {
      return;
    }
    String[] creditorgs = queryvo.getCreditorg();

    EngrossLockUtil util = new EngrossLockUtil();
    util.engrossLock(creditorgs);

    GetCsettorgOrgForRecal setrecal = new GetCsettorgOrgForRecal();
    Map<String, String[]> orgmap = setrecal.getCsettorgsForReCal(creditorgs);
    if (null == orgmap) {
      return;
    }
    ReCaculateBP reBP = new ReCaculateBP();
    reBP.recalUpdate(orgmap, limittypemap, queryvo);
  }

  public void recaculateUpdateForAll() throws BusinessException {
    MatchCcregion match = new MatchCcregion();
    String[] creditorgs = match.getAllCreditOrgs();
    if (null == creditorgs || creditorgs.length == 0) {
      return;
    }
    EngrossLockUtil util = new EngrossLockUtil();
    util.engrossLock(creditorgs);

    LimitTypeQueryImpl queryImpl = new LimitTypeQueryImpl();
    Map<String, List<LimitTypeVO>> limittypemap =
        queryImpl.queryVOMapByCOrg(creditorgs);
    if (null == limittypemap || 0 == limittypemap.size()) {
      return;
    }

    GetCsettorgOrgForRecal setrecal = new GetCsettorgOrgForRecal();
    Map<String, String[]> orgmap = setrecal.getCsettorgsForReCal(creditorgs);
    if (null == orgmap) {
      return;
    }
    ReCaculateBP reBP = new ReCaculateBP();
    reBP.recalUpdate(orgmap, limittypemap, null);
  }

}

//跨模块调用重算信信用

ConditionVO[] conditionVOS=null;
SalesOrgVO salesOrgVO = (SalesOrgVO) this.getPubBO().queryByPrimaryKey(SalesOrgVO.class, saleOutVO[0].getHead().getPk_org());
if(salesOrgVO != null) {
	CreditCtlRegionVO[] creditCtlRegionVOS = (CreditCtlRegionVO[])this.getPubBO().queryByCondition(CreditCtlRegionVO.class, "code='"+salesOrgVO.getCode()+"' and enablestate = 2 and nvl(dr, 0) = 0");
	if(creditCtlRegionVOS != null && creditCtlRegionVOS.length > 0){
		
		conditionVOS = new ConditionVO[2];
				
		ConditionVO conditionVO1 = new ConditionVO();
		conditionVO1.setComboIndex(0);
		conditionVO1.setComboType("N");
		conditionVO1.setDataType(5);
		conditionVO1.setFieldCode("pk_org");
		conditionVO1.setFieldName("信用控制域");
		conditionVO1.setOperaCode("==");
		conditionVO1.setValue(creditCtlRegionVOS[0].getPrimaryKey());
		
		ConditionVO conditionVO2 = new ConditionVO();
		conditionVO2.setFieldCode("ccustomerid");
		conditionVO2.setFieldName("客户");
		conditionVO2.setOperaCode("==");
		conditionVO2.setValue(saleOutVO[0].getHead().getCcustomerid());
		
		conditionVOS[0] = conditionVO1;
		conditionVOS[1] = conditionVO2;
	}
}
if(conditionVOS != null && conditionVOS.length > 0){
	IReCalManage manage = (IReCalManage)NCLocator.getInstance().lookup(IReCalManage.class);
	manage.reCalculateUpdate(conditionVOS);
	returnObj.put("returnFlag", "1");
	returnObj.put("message", "重算完成");
	return returnObj.toString();
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值