N_H33J_SAVEBASE.class
/* */ package nc.bs.pub.action;
/* */
/* */ import nc.bs.framework.common.NCLocator;
/* */ import nc.bs.pubapp.pf.action.AbstractPfAction;
/* */ import nc.impl.fdcprcm.bd.bill.bpplugin.BillPluginPoint;
/* */ import nc.impl.pubapp.pattern.rule.processer.CompareAroundProcesser;
/* */ import nc.itf.fdcprcm.bd.bill.IFDCPRCMBillMaintain;
/* */ import nc.vo.fdcprcm.bd.bill.AggBillVO;
/* */ import nc.vo.fdcprcm.bd.bill.BillVO;
/* */ import nc.vo.jcom.lang.StringUtil;
/* */ import nc.vo.pub.BusinessException;
/* */ import nc.vo.pubapp.pattern.exception.ExceptionUtils;
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class N_H33J_SAVEBASE
/* */ extends AbstractPfAction<AggBillVO>
/* */ {
/* */ protected CompareAroundProcesser<AggBillVO> getCompareAroundProcesserWithRules(Object userObj)
/* */ {
/* 24 */ CompareAroundProcesser<AggBillVO> processor = null;
/* 25 */ AggBillVO[] clientFullVOs = (AggBillVO[])getVos();
/* 26 */ if (!StringUtil.isEmptyWithTrim(clientFullVOs[0].getParentVO().getPrimaryKey()))
/* */ {
/* 28 */ processor = new CompareAroundProcesser(BillPluginPoint.UPDATE);
/* */ }
/* */ else {
/* 31 */ processor = new CompareAroundProcesser(BillPluginPoint.INSERT);
/* */ }
/* */
/* */
/* 35 */ return processor;
/* */ }
/* */
/* */
/* */
/* */ protected AggBillVO[] processBP(Object userObj, AggBillVO[] clientFullVOs, AggBillVO[] originBills)
/* */ {
/* 42 */ AggBillVO[] bills = null;
/* 43 */ IFDCPRCMBillMaintain operator = (IFDCPRCMBillMaintain)NCLocator.getInstance().lookup(IFDCPRCMBillMaintain.class);
/* */
/* 45 */ if (!StringUtil.isEmptyWithTrim(clientFullVOs[0].getParentVO().getPrimaryKey())) {
/* */ try
/* */ {
/* 48 */ bills = operator.update(clientFullVOs, originBills);
/* */ } catch (BusinessException e) {
/* 50 */ ExceptionUtils.wrappBusinessException(e.getMessage());
/* */ }
/* */ } else {
/* */ try {
/* 54 */ bills = operator.insert(clientFullVOs, originBills);
/* */ } catch (BusinessException e) {
/* 56 */ ExceptionUtils.wrappBusinessException(e.getMessage());
/* */ }
/* */ }
/* 59 */ return bills;
/* */ }
/* */ }
/* Location: D:\yonyou\sp\nc65sp\modules\fdcprcm\META-INF\lib\fdcprcm_fdcprcmbd.jar
* Qualified Name: nc.bs.pub.action.N_H33J_SAVEBASE
* Java Class Version: 7 (51.0)
* JD-Core Version: 0.7.1
*/
FDCPRCMBillMaintainImpl.class
/* */ package nc.impl.fdcprcm.bd.bills;
/* */
/* */ import java.sql.ResultSet;
/* */ import java.sql.SQLException;
/* */ import java.util.ArrayList;
/* */ import java.util.HashMap;
/* */ import java.util.HashSet;
/* */ import java.util.List;
/* */ import java.util.Map;
/* */ import java.util.Properties;
/* */ import java.util.Set;
/* */ import nc.bs.dao.BaseDAO;
/* */ import nc.bs.framework.common.NCLocator;
/* */ import nc.impl.fdcpr.util.JZFDCOrderByBuilder;
/* */ import nc.impl.fdcprcm.bd.bill.bp.BillApproveBP;
/* */ import nc.impl.fdcprcm.bd.bill.bp.BillDeleteBP;
/* */ import nc.impl.fdcprcm.bd.bill.bp.BillInsertBP;
/* */ import nc.impl.fdcprcm.bd.bill.bp.BillSaveBP;
/* */ import nc.impl.fdcprcm.bd.bill.bp.BillUnApproveBP;
/* */ import nc.impl.fdcprcm.bd.bill.bp.BillUnSaveBP;
/* */ import nc.impl.fdcprcm.bd.bill.bp.BillUpdateBP;
/* */ import nc.impl.fdcprcm.bd.bill.bpplugin.BillPluginPoint;
/* */ import nc.impl.pubapp.pattern.data.bill.BillQuery;
/* */ import nc.impl.pubapp.pattern.data.bill.template.UpdateBPTemplate;
/* */ import nc.impl.pubapp.pattern.data.bill.tool.BillTransferTool;
/* */ import nc.itf.fdcprcm.bd.bill.IFDCPRCMBillMaintain;
/* */ import nc.itf.fdcprcm.feelist.ICmFeeListMaintain;
/* */ import nc.jdbc.framework.generator.SequenceGenerator;
/* */ import nc.jdbc.framework.processor.ResultSetProcessor;
/* */ import nc.ui.querytemplate.querytree.IQueryScheme;
/* */ import nc.vo.fdcpr.pub.tool.CheckTsTool;
/* */ import nc.vo.fdcpr.pub.tool.CommonUtilObj;
/* */ import nc.vo.fdcpr.pub.tool.FdcprPubFillMnyFieldsTool;
/* */ import nc.vo.fdcpr.pub.tool.ReflectHelper;
/* */ import nc.vo.fdcpr.pub.tool.SafeCompute;
/* */ import nc.vo.fdcprbd.enums.SrcSysCodeEnum;
/* */ import nc.vo.fdcprcm.bd.bill.AggBillVO;
/* */ import nc.vo.fdcprcm.bd.bill.BillMnyNumFldInfo;
/* */ import nc.vo.fdcprcm.bd.bill.BillVO;
/* */ import nc.vo.fdcprcm.bd.bill.DetailVO;
/* */ import nc.vo.pub.AggregatedValueObject;
/* */ import nc.vo.pub.BusinessException;
/* */ import nc.vo.pub.CircularlyAccessibleValueObject;
/* */ import nc.vo.pub.ISuperVO;
/* */ import nc.vo.pub.SuperVO;
/* */ import nc.vo.pub.lang.UFBoolean;
/* */ import nc.vo.pub.lang.UFDateTime;
/* */ import nc.vo.pub.lang.UFDouble;
/* */ import nc.vo.pubapp.AppContext;
/* */ import nc.vo.pubapp.pattern.exception.ExceptionUtils;
/* */ import nc.vo.pubapp.query2.sql.process.QuerySchemeProcessor;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class FDCPRCMBillMaintainImpl
/* */ implements IFDCPRCMBillMaintain
/* */ {
/* */ public AggBillVO[] update(AggBillVO[] clientFullVOs, AggBillVO[] originBills)
/* */ throws BusinessException
/* */ {
/* */ try
/* */ {
/* 69 */ BillTransferTool<AggBillVO> transferTool = new BillTransferTool(clientFullVOs);
/* */
/* 71 */ AggBillVO[] clientVOs = (AggBillVO[])transferTool.getClientFullInfoBill();
/* 72 */ AggBillVO[] origins = (AggBillVO[])transferTool.getOriginBills();
/* */
/* 74 */ BillUpdateBP bp = new BillUpdateBP();
/* 75 */ AggBillVO[] retvos = bp.update(clientVOs, origins);
/* */
/* 77 */ return (AggBillVO[])transferTool.getBillForToClient(retvos);
/* */ } catch (Exception e) {
/* 79 */ ExceptionUtils.marsh(e);
/* */ }
/* 81 */ return null;
/* */ }
/* */
/* */ public AggBillVO[] insert(AggBillVO[] clientFullVOs, AggBillVO[] originBills)
/* */ throws BusinessException
/* */ {
/* */ try
/* */ {
/* 89 */ BillTransferTool<AggBillVO> transferTool = new BillTransferTool(clientFullVOs);
/* */
/* */
/* 92 */ BillInsertBP action = new BillInsertBP();
/* 93 */ return action.insert(clientFullVOs);
/* */ }
/* */ catch (Exception e)
/* */ {
/* 97 */ ExceptionUtils.marsh(e);
/* */ }
/* 99 */ return null;
/* */ }
/* */
/* */ public AggBillVO[] approve(AggBillVO[] clientFullVOs, AggBillVO[] originBills)
/* */ throws BusinessException
/* */ {
/* 105 */ for (int i = 0; (clientFullVOs != null) && (i < clientFullVOs.length); i++) {
/* 106 */ clientFullVOs[i].getParentVO().setStatus(1);
/* */ }
/* 108 */ BillApproveBP bp = new BillApproveBP();
/* 109 */ AggBillVO[] retvos = bp.approve(clientFullVOs, originBills);
/* 110 */ return retvos;
/* */ }
/* */
/* */ public void delete(AggBillVO[] clientFullVOs, AggBillVO[] originBills)
/* */ throws BusinessException
/* */ {
/* */ try
/* */ {
/* 118 */ new BillDeleteBP().delete(clientFullVOs);
/* */ } catch (Exception e) {
/* 120 */ ExceptionUtils.marsh(e);
/* */ }
/* */ }
/* */
/* */
/* */ public AggBillVO[] unsave(AggBillVO[] clientFullVOs, AggBillVO[] originBills)
/* */ throws BusinessException
/* */ {
/* 128 */ BillUnSaveBP bp = new BillUnSaveBP();
/* 129 */ AggBillVO[] retvos = bp.unSend(clientFullVOs, originBills);
/* 130 */ return retvos;
/* */ }
/* */
/* */ public AggBillVO[] unapprove(AggBillVO[] clientFullVOs, AggBillVO[] originBills)
/* */ throws BusinessException
/* */ {
/* 136 */ for (int i = 0; (clientFullVOs != null) && (i < clientFullVOs.length); i++) {
/* 137 */ clientFullVOs[i].getParentVO().setStatus(1);
/* */ }
/* 139 */ BillUnApproveBP bp = new BillUnApproveBP();
/* 140 */ AggBillVO[] retvos = bp.unApprove(clientFullVOs, originBills);
/* 141 */ return retvos;
/* */ }
/* */
/* */ public AggBillVO[] save(AggBillVO[] clientFullVOs, AggBillVO[] originBills)
/* */ throws BusinessException
/* */ {
/* 147 */ BillSaveBP bp = new BillSaveBP();
/* 148 */ AggBillVO[] retvos = bp.sendApprove(clientFullVOs, originBills);
/* 149 */ return retvos;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public String generatePKItem()
/* */ {
/* 160 */ SequenceGenerator pkGenerator = new SequenceGenerator();
/* 161 */ String pk_item = pkGenerator.generate() + AppContext.getInstance().getServerTime().toStdString().substring(11).replaceAll("[:]", "J");
/* */
/* */
/* 164 */ return pk_item;
/* */ }
/* */
/* */
/* */
/* */ public Map<String, UFDouble> queryPreviewBillCarryMny(String pk_service, Set<String> customers)
/* */ throws BusinessException
/* */ {
/* 172 */ if ((pk_service == null) || (CommonUtilObj.isEmpty(customers)))
/* */ {
/* 174 */ return null;
/* */ }
/* */
/* 177 */ StringBuilder sql = new StringBuilder();
/* 178 */ sql.append(" select pk_customer,norigcarrymny from fdcprcm_bd_bill ");
/* 179 */ sql.append(" where isnull(dr,0)=0 and pk_severice ='").append(pk_service).append("' ");
/* 180 */ sql.append(" and pk_severice||'_'||pk_customer||'_'||dbillmonth in ( ");
/* 181 */ sql.append(" select pk_severice||'_'||pk_customer||'_'||max(dbillmonth) from fdcprcm_bd_bill ");
/* 182 */ sql.append(" where isnull(dr,0)=0 and pk_severice ='").append(pk_service).append("' ");
/* 183 */ sql.append(" and norigcarrymny > 0 ");
/* 184 */ sql.append(" and ").append(CommonUtilObj.convertArray2SQL("pk_customer", (String[])customers.toArray(new String[customers.size()])));
/* 185 */ sql.append(" group by pk_severice,pk_customer ");
/* */
/* 187 */ sql.append(" ) ");
/* 188 */ sql.append(" and norigcarrymny > 0 ");
/* */
/* */
/* 191 */ Map<String, UFDouble> retMap = (Map)getDao().executeQuery(sql.toString(), new ResultSetProcessor()
/* */ {
/* */ public Map<String, UFDouble> handleResultSet(ResultSet rs) throws SQLException
/* */ {
/* 195 */ Map<String, UFDouble> map = new HashMap();
/* 196 */ while (rs.next()) {
/* 197 */ if (map.containsKey(rs.getString("pk_customer"))) {
/* 198 */ UFDouble tempmny = (UFDouble)map.get(rs.getString("pk_customer"));
/* 199 */ tempmny = SafeCompute.addWithNull(tempmny, CommonUtilObj.initUFDoubleWithNull(Double.valueOf(rs.getDouble("norigcarrymny"))));
/* */
/* 201 */ map.put(rs.getString("pk_customer"), CommonUtilObj.initUFDoubleWithNull(Double.valueOf(rs.getDouble("norigcarrymny"))));
/* */ } else {
/* 203 */ map.put(rs.getString("pk_customer"), CommonUtilObj.initUFDoubleWithNull(Double.valueOf(rs.getDouble("norigcarrymny"))));
/* */ }
/* */ }
/* 206 */ return map;
/* */ }
/* */
/* */
/* 210 */ });
/* 211 */ return retMap;
/* */ }
/* */
/* */
/* */ public void arapWirteBack2Bill(AggregatedValueObject[] aggvos)
/* */ throws BusinessException
/* */ {
/* */ try
/* */ {
/* 220 */ Properties prop = readerArapCutomerHouseMonthAtt();
/* 221 */ String biswritebackbill = prop.getProperty("biswritebackbill");
/* 222 */ String src_syscode = prop.getProperty("src_syscode");
/* 223 */ String pk_customer = prop.getProperty("pk_customer");
/* 224 */ String pk_house = prop.getProperty("pk_house");
/* 225 */ String dbillmonth = prop.getProperty("dbillmonth");
/* 226 */ String norigrecmny = prop.getProperty("norigrecmny");
/* 227 */ if ((CommonUtilObj.isEmpty(biswritebackbill)) || (CommonUtilObj.isEmpty(biswritebackbill)) || (CommonUtilObj.isEmpty(src_syscode)))
/* */ {
/* */
/* 230 */ ExceptionUtils.wrappBusinessException("请在nchome模块fdcprcm的arapwirtebackbill.properties文件中配置回写账单对照字段");
/* */ }
/* 232 */ if (CommonUtilObj.isEmpty(pk_customer)) {
/* 233 */ ExceptionUtils.wrappBusinessException("请在nchome模块fdcprcm的arapwirtebackbill.properties文件中配置客户对照字段");
/* */ }
/* 235 */ if (CommonUtilObj.isEmpty(pk_house)) {
/* 236 */ ExceptionUtils.wrappBusinessException("请在nchome模块fdcprcm的arapwirtebackbill.properties文件中配置房产对照字段");
/* */ }
/* 238 */ if (CommonUtilObj.isEmpty(dbillmonth)) {
/* 239 */ ExceptionUtils.wrappBusinessException("请在nchome模块fdcprcm的arapwirtebackbill.properties文件中配置账单所属月对照字段");
/* */ }
/* 241 */ if (CommonUtilObj.isEmpty(norigrecmny)) {
/* 242 */ ExceptionUtils.wrappBusinessException("请在nchome模块fdcprcm的arapwirtebackbill.properties文件中配置收款金额对照字段");
/* */ }
/* */
/* */
/* 246 */ List<AggregatedValueObject> arapBills = new ArrayList();
/* */
/* 248 */ for (AggregatedValueObject aggvo : aggvos) {
/* 249 */ if ((CommonUtilObj.initBoolean(aggvo.getParentVO().getAttributeValue(biswritebackbill))) && (!SrcSysCodeEnum.SRC_FDCPR.toString().equals(aggvo.getParentVO().getAttributeValue(src_syscode))))
/* */ {
/* 251 */ arapBills.add(aggvo);
/* */ }
/* */ }
/* */
/* 255 */ if (CommonUtilObj.isEmpty(arapBills)) {
/* 256 */ return;
/* */ }
/* */
/* */
/* 260 */ Map<String, UFDouble> cfmap = readerArapAttrValue((AggregatedValueObject[])arapBills.toArray(new AggregatedValueObject[arapBills.size()]), prop);
/* 261 */ if (CommonUtilObj.isEmpty(cfmap)) {
/* 262 */ return;
/* */ }
/* */
/* 265 */ AggBillVO[] queryBills = queryAggBill4ArapWriteBack(cfmap.keySet());
/* 266 */ if (CommonUtilObj.isEmpty(queryBills)) {
/* 267 */ ExceptionUtils.wrappBusinessException("没有找到可匹配的账单");
/* */ }
/* */
/* 270 */ dealWritePrBill(queryBills, cfmap);
/* */
/* 272 */ FdcprPubFillMnyFieldsTool tool = new FdcprPubFillMnyFieldsTool();
/* 273 */ tool.handlerMnyValue2Fields(queryBills, new BillMnyNumFldInfo());
/* 274 */ update4ArapWriteBill(queryBills);
/* */
/* 276 */ updateFeesBisreceivedFlag(queryBills);
/* */ }
/* */ catch (Exception e) {
/* 279 */ ExceptionUtils.wrappException(e);
/* */ }
/* */ }
/* */
/* */ private Properties readerArapCutomerHouseMonthAtt() throws Exception
/* */ {
/* 285 */ Properties prop = PRCmBillSynFieldReader.getProperties();
/* 286 */ return prop;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ private Map<String, UFDouble> readerArapAttrValue(AggregatedValueObject[] aggvos, Properties prop)
/* */ throws BusinessException
/* */ {
/* 297 */ StringBuilder cond = new StringBuilder();
/* 298 */ Map<String, UFDouble> cfmap = new HashMap();
/* 299 */ String pk_customer = null;
/* 300 */ UFDouble temprecmny = null;
/* */
/* 302 */ String pk_customer_attr = prop.getProperty("pk_customer");
/* 303 */ String pk_house_attr = prop.getProperty("pk_house");
/* 304 */ String dbillmonth_attr = prop.getProperty("dbillmonth");
/* 305 */ String norigrecmny_attr = prop.getProperty("norigrecmny");
/* */
/* 307 */ for (AggregatedValueObject aggvo : aggvos)
/* */ {
/* 309 */ if (pk_customer == null) {
/* 310 */ pk_customer = CommonUtilObj.initStr(aggvo.getParentVO().getAttributeValue(pk_customer_attr));
/* 311 */ if (pk_customer == null) {
/* 312 */ ExceptionUtils.wrappBusinessException("收款单的客户不允许为空");
/* */ }
/* */ }
/* */
/* 316 */ CircularlyAccessibleValueObject[] arapbodys = aggvo.getChildrenVO();
/* 317 */ if (CommonUtilObj.isEmpty(arapbodys)) {
/* 318 */ ExceptionUtils.wrappBusinessException("收款单表体不允许为空");
/* */ }
/* 320 */ for (CircularlyAccessibleValueObject arapbody : arapbodys) {
/* 321 */ cond.setLength(0);
/* 322 */ temprecmny = null;
/* */
/* */
/* 325 */ Object pk_customer_body = arapbody.getAttributeValue(pk_customer_attr);
/* 326 */ if (!pk_customer.equals(pk_customer_body)) {
/* 327 */ ExceptionUtils.wrappBusinessException("收款单表头客户和表体客户不一致");
/* */ }
/* 329 */ cond.append(pk_customer);
/* 330 */ cond.append("_");
/* */
/* */
/* 333 */ Object pk_house_body = arapbody.getAttributeValue(pk_house_attr);
/* 334 */ if (CommonUtilObj.isEmpty(pk_house_body)) {
/* 335 */ ExceptionUtils.wrappBusinessException("收款单表体的房产不允许为空");
/* */ }
/* 337 */ cond.append(pk_house_body);
/* 338 */ cond.append("_");
/* */
/* */
/* 341 */ Object dbillmonth_body = arapbody.getAttributeValue(dbillmonth_attr);
/* 342 */ if (CommonUtilObj.isEmpty(dbillmonth_body)) {
/* 343 */ ExceptionUtils.wrappBusinessException("收款单表体的账单所属月不允许为空");
/* */ }
/* 345 */ cond.append(dbillmonth_body);
/* */
/* */
/* 348 */ temprecmny = CommonUtilObj.initUFDouble(arapbody.getAttributeValue(norigrecmny_attr));
/* 349 */ if (CommonUtilObj.isEmpty(temprecmny)) {
/* 350 */ ExceptionUtils.wrappBusinessException("收款单表体的金额不允许为空");
/* */ }
/* */ }
/* */
/* 354 */ if (cfmap.containsKey(cond.toString())) {
/* 355 */ UFDouble tempmny = (UFDouble)cfmap.get(cond.toString());
/* 356 */ temprecmny = SafeCompute.addWithNull(temprecmny, tempmny);
/* */
/* 358 */ cfmap.put(cond.toString(), temprecmny);
/* */ }
/* */ else {
/* 361 */ cfmap.put(cond.toString(), temprecmny);
/* */ }
/* */ }
/* */
/* */
/* 366 */ return cfmap;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ private AggBillVO[] queryAggBill4ArapWriteBack(Set<String> infos)
/* */ throws BusinessException
/* */ {
/* 376 */ if (CommonUtilObj.isEmpty(infos)) {
/* 377 */ return null;
/* */ }
/* */
/* 380 */ StringBuilder sql = new StringBuilder();
/* 381 */ sql.append("select distinct head.pk_bill from fdcprcm_bd_bill head ");
/* 382 */ sql.append(" inner join fdcprcm_bd_bill_detail bd on bd.pk_bill = head.pk_bill ");
/* 383 */ sql.append(" where isnull(head.dr,0)=0 and isnull(bd.dr,0)=0 and isnull(head.bisreceived,'N')='N' ");
/* 384 */ sql.append(" and ").append(CommonUtilObj.convertArray2SQL("head.pk_customer||'_'||bd.pk_house||'_'||head.dbillmonth", (String[])infos.toArray(new String[infos.size()])));
/* */
/* 386 */ Set<String> pk_bills = (Set)getDao().executeQuery(sql.toString(), new ResultSetProcessor()
/* */ {
/* */ public Set<String> handleResultSet(ResultSet rs) throws SQLException
/* */ {
/* 390 */ Set<String> bills = new HashSet();
/* 391 */ while (rs.next()) {
/* 392 */ bills.add(rs.getString("pk_bill"));
/* */ }
/* 394 */ return bills;
/* */ }
/* */
/* */
/* 398 */ });
/* 399 */ CheckTsTool tool = new CheckTsTool();
/* 400 */ tool.lockPkForAL((String[])pk_bills.toArray(new String[pk_bills.size()]));
/* */
/* 402 */ return queryBillByPKs((String[])pk_bills.toArray(new String[pk_bills.size()]));
/* */ }
/* */
/* */
/* */ public String[] queryPKs(IQueryScheme queryScheme)
/* */ throws BusinessException
/* */ {
/* 409 */ String beanId = (String)queryScheme.get("bean_id");
/* */
/* 411 */ Class headVoClass = (Class)queryScheme.get("headVoClass");
/* 412 */ SuperVO vo = (SuperVO)ReflectHelper.newInstance(headVoClass);
/* */
/* 414 */ String fieldName = vo.getPKFieldName();
/* 415 */ StringBuffer sql = new StringBuffer();
/* 416 */ QuerySchemeProcessor processor = new QuerySchemeProcessor(queryScheme);
/* 417 */ processor.appendFuncPermissionOrgSql();
/* 418 */ processor.appendCurrentGroup();
/* 419 */ String mainAlias = processor.getMainTableAlias();
/* */
/* */
/* */
/* 423 */ List orderList = (List)queryScheme.get("order_list");
/* */
/* 425 */ StringBuilder groupByBuilder = new StringBuilder();
/* */
/* 427 */ StringBuilder orderByBuilder = new StringBuilder();
/* 428 */ orderByBuilder.append("dbillmonth").append(" desc, ");
/* 429 */ orderByBuilder.append("pk_customer");
/* */
/* */
/* 432 */ JZFDCOrderByBuilder.genOrderByAndGroupBy(fieldName, processor, orderList, groupByBuilder, orderByBuilder);
/* */
/* */
/* 435 */ genQuerySql(fieldName, sql, processor, mainAlias, groupByBuilder, orderByBuilder);
/* */
/* */
/* */
/* 439 */ BaseDAO dao = new BaseDAO();
/* 440 */ List<String> list = (List)dao.executeQuery(sql.toString(), new ResultSetProcessor()
/* */ {
/* */ public List<String> handleResultSet(ResultSet rs) throws SQLException
/* */ {
/* 444 */ List<String> list = new ArrayList();
/* 445 */ while (rs.next()) {
/* 446 */ list.add(rs.getString("pk_bill"));
/* */ }
/* 448 */ return list;
/* */ }
/* */
/* */
/* 452 */ });
/* 453 */ return (String[])list.toArray(new String[list.size()]);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ protected static void genQuerySql(String fieldName, StringBuffer sql, QuerySchemeProcessor processor, String mainAlias, StringBuilder groupByBuilder, StringBuilder orderByBuilder)
/* */ {
/* 466 */ sql.append(" select ");
/* 467 */ sql.append(mainAlias).append(".").append(fieldName).append(", ");
/* 468 */ sql.append(mainAlias).append(".").append("dbillmonth").append(", ");
/* 469 */ sql.append(mainAlias).append(".").append("pk_customer").append(" ");
/* 470 */ sql.append(' ');
/* 471 */ sql.append(processor.getFinalFromWhere());
/* */
/* */
/* 474 */ sql.append(" and isnull(dr,0)=0 ");
/* 475 */ if (orderByBuilder.length() > 0) {
/* 476 */ sql.append(" order by ");
/* 477 */ sql.append(orderByBuilder);
/* */ }
/* */ }
/* */
/* */ public AggBillVO[] queryBillByPKs(String[] pks) throws BusinessException
/* */ {
/* 483 */ BillQuery<AggBillVO> query = new BillQuery(AggBillVO.class);
/* 484 */ AggBillVO[] queryAggvos = (AggBillVO[])query.query(pks);
/* 485 */ if (CommonUtilObj.isEmpty(queryAggvos)) {
/* 486 */ return null;
/* */ }
/* */
/* 489 */ return queryAggvos;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ private void dealWritePrBill(AggBillVO[] queryBills, Map<String, UFDouble> cfmap)
/* */ throws BusinessException
/* */ {
/* 502 */ Map<String, DetailVO> rootHouseMap = new HashMap();
/* */
/* 504 */ for (AggBillVO billvo : queryBills)
/* */ {
/* 506 */ ISuperVO[] tempbodyvos = billvo.getChildren(DetailVO.class);
/* 507 */ if (!CommonUtilObj.isEmpty(tempbodyvos))
/* */ {
/* */
/* */
/* 511 */ for (ISuperVO tempvo : tempbodyvos) {
/* 512 */ DetailVO vo = (DetailVO)tempvo;
/* */
/* 514 */ if ((CommonUtilObj.isEmpty(vo.getPk_parent())) && (!vo.getBisreceived().booleanValue()))
/* */ {
/* 516 */ rootHouseMap.put(vo.getPk_bill() + "_" + vo.getPk_house(), vo);
/* */ }
/* */ }
/* */ }
/* */ }
/* 521 */ Set<String> keys = new HashSet();
/* */
/* */
/* 524 */ for (AggBillVO billvo : queryBills) {
/* 525 */ BillVO headvo = billvo.getParentVO();
/* 526 */ headvo.setStatus(1);
/* */
/* 528 */ String pk_customer = headvo.getPk_customer();
/* 529 */ String dbillmonth = headvo.getDbillmonth();
/* */
/* 531 */ UFDouble temptotalmny = null;
/* */
/* */
/* 534 */ ISuperVO[] tempbodyvos = billvo.getChildren(DetailVO.class);
/* 535 */ if (!CommonUtilObj.isEmpty(tempbodyvos))
/* */ {
/* */
/* */
/* 539 */ for (ISuperVO tempvo : tempbodyvos) {
/* 540 */ DetailVO vo = (DetailVO)tempvo;
/* 541 */ vo.setStatus(1);
/* */
/* 543 */ if ((!CommonUtilObj.isEmpty(vo.getPk_parent())) && (!vo.getBisreceived().booleanValue()))
/* */ {
/* */
/* */
/* */
/* 548 */ String pk_house = vo.getPk_house();
/* 549 */ UFDouble norigreceivemny = vo.getNorigreceivemny();
/* 550 */ UFDouble norigbtotalrevmny = vo.getNorigbtotalrevmny();
/* 551 */ UFDouble nbyuemny = SafeCompute.subWithNull(norigreceivemny, norigbtotalrevmny);
/* */
/* */
/* 554 */ UFDouble arapmny = null;
/* 555 */ String cfkey = pk_customer + "_" + pk_house + "_" + dbillmonth;
/* 556 */ if (cfmap.containsKey(cfkey)) {
/* 557 */ arapmny = (UFDouble)cfmap.get(cfkey);
/* 558 */ keys.add(cfkey);
/* */ }
/* 560 */ if (SafeCompute.compare(arapmny, UFDouble.ZERO_DBL) != 0)
/* */ {
/* */
/* */
/* */
/* 565 */ DetailVO rootHouse = (DetailVO)rootHouseMap.get(vo.getPk_bill() + "_" + pk_house);
/* 566 */ rootHouse.setStatus(1);
/* 567 */ UFDouble rootreceivemny = rootHouse.getNorigreceivemny();
/* 568 */ UFDouble rootbtotalmny = rootHouse.getNorigbtotalrevmny();
/* */
/* */
/* */
/* 572 */ if (SafeCompute.compare(arapmny, nbyuemny) >= 0)
/* */ {
/* 574 */ vo.setNorigbtotalrevmny(vo.getNorigreceivemny());
/* 575 */ vo.setBisreceived(UFBoolean.TRUE);
/* */
/* */
/* 578 */ temptotalmny = SafeCompute.addWithNull(temptotalmny, nbyuemny);
/* */
/* */
/* 581 */ rootbtotalmny = SafeCompute.addWithNull(rootbtotalmny, nbyuemny);
/* 582 */ rootHouse.setNorigbtotalrevmny(rootbtotalmny);
/* */
/* */
/* 585 */ arapmny = SafeCompute.subWithNull(arapmny, nbyuemny);
/* 586 */ if (SafeCompute.compare(arapmny, UFDouble.ZERO_DBL) == 0) {
/* 587 */ arapmny = null;
/* */ }
/* */ }
/* */ else
/* */ {
/* 592 */ UFDouble temprecmny = SafeCompute.addWithNull(norigbtotalrevmny, arapmny);
/* 593 */ vo.setNorigbtotalrevmny(temprecmny);
/* 594 */ vo.setBisreceived(UFBoolean.FALSE);
/* */
/* */
/* 597 */ temptotalmny = SafeCompute.addWithNull(temptotalmny, arapmny);
/* */
/* 599 */ rootbtotalmny = SafeCompute.addWithNull(rootbtotalmny, arapmny);
/* 600 */ rootHouse.setNorigbtotalrevmny(rootbtotalmny);
/* */
/* */
/* 603 */ arapmny = null;
/* */ }
/* */
/* 606 */ cfmap.put(cfkey, arapmny);
/* */
/* */
/* 609 */ UFDouble rootbtotalmny_new = rootHouse.getNorigbtotalrevmny();
/* 610 */ if (SafeCompute.compare(rootreceivemny, rootbtotalmny_new) == 0) {
/* 611 */ rootHouse.setBisreceived(UFBoolean.TRUE);
/* */ }
/* */ }
/* */ }
/* */ }
/* */
/* */
/* 618 */ UFDouble norigreceivemny = headvo.getNorigreceivablemny();
/* 619 */ UFDouble norigcarrymny = headvo.getNorigcarrymny();
/* */
/* */
/* 622 */ UFDouble temparapmny = null;
/* 623 */ for (String key : keys) {
/* 624 */ temparapmny = SafeCompute.addWithNull(temparapmny, (UFDouble)cfmap.get(key));
/* */ }
/* */
/* */
/* */
/* */
/* 630 */ headvo.setNorigtotalrevmny(SafeCompute.addWithNull(temptotalmny, headvo.getNorigtotalrevmny()));
/* 631 */ UFDouble tempyuemny = SafeCompute.subWithNull(norigreceivemny, headvo.getNorigtotalrevmny());
/* 632 */ if (SafeCompute.compare(tempyuemny, UFDouble.ZERO_DBL) == 0) {
/* 633 */ tempyuemny = null;
/* */ }
/* 635 */ headvo.setNorigyuemny(tempyuemny);
/* 636 */ headvo.setNorigcarrymny(SafeCompute.addWithNull(norigcarrymny, temparapmny));
/* 637 */ if (SafeCompute.compare(norigreceivemny, headvo.getNorigtotalrevmny()) == 0) {
/* 638 */ headvo.setBisreceived(UFBoolean.TRUE);
/* */ }
/* */ }
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ private void update4ArapWriteBill(AggBillVO[] clientFullVOs)
/* */ throws BusinessException
/* */ {
/* */ try
/* */ {
/* 654 */ BillTransferTool<AggBillVO> transferTool = new BillTransferTool(clientFullVOs);
/* */
/* 656 */ AggBillVO[] originBills = (AggBillVO[])transferTool.getOriginBills();
/* 657 */ AggBillVO[] fullVOs = (AggBillVO[])transferTool.getClientFullInfoBill();
/* */
/* */
/* 660 */ UpdateBPTemplate<AggBillVO> bp = new UpdateBPTemplate(BillPluginPoint.UPDATE);
/* */
/* */
/* 663 */ bp.update(fullVOs, originBills);
/* */ } catch (Exception e) {
/* 665 */ ExceptionUtils.marsh(e);
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */ private void updateFeesBisreceivedFlag(AggBillVO[] vos)
/* */ throws BusinessException
/* */ {
/* 675 */ if (CommonUtilObj.isEmpty(vos)) {
/* 676 */ return;
/* */ }
/* 678 */ Set<String> pk_fees_y = new HashSet();
/* 679 */ for (AggBillVO bill : vos) {
/* 680 */ ISuperVO[] detailvos = bill.getChildren(DetailVO.class);
/* 681 */ if (!CommonUtilObj.isEmpty(detailvos))
/* */ {
/* */
/* */
/* 685 */ for (ISuperVO vo : detailvos) {
/* 686 */ DetailVO detailvo = (DetailVO)vo;
/* */
/* 688 */ if (!CommonUtilObj.isEmpty(detailvo.getPk_parent()))
/* */ {
/* */
/* */
/* 692 */ if (detailvo.getBisreceived().booleanValue())
/* 693 */ pk_fees_y.add(detailvo.getCsrcbid());
/* */ }
/* */ }
/* */ }
/* */ }
/* 698 */ if (!CommonUtilObj.isEmpty(pk_fees_y)) {
/* 699 */ ((ICmFeeListMaintain)NCLocator.getInstance().lookup(ICmFeeListMaintain.class)).updateFeesBisreceived((String[])pk_fees_y.toArray(new String[pk_fees_y.size()]), UFBoolean.TRUE);
/* */ }
/* */ }
/* */
/* */
/* */
/* 705 */ private BaseDAO dao = null;
/* */
/* 707 */ private BaseDAO getDao() { if (dao == null) {
/* 708 */ dao = new BaseDAO();
/* */ }
/* 710 */ return dao;
/* */ }
/* */ }
/* Location: D:\yonyou\sp\nc65sp\modules\fdcprcm\META-INF\lib\fdcprcm_fdcprcmbd.jar
* Qualified Name: nc.impl.fdcprcm.bd.bills.FDCPRCMBillMaintainImpl
* Java Class Version: 7 (51.0)
* JD-Core Version: 0.7.1
*/
IFDCPRCMBillMaintain.class
package nc.itf.fdcprcm.bd.bill;
import java.util.Map;
import java.util.Set;
import nc.ui.querytemplate.querytree.IQueryScheme;
import nc.vo.fdcprcm.bd.bill.AggBillVO;
import nc.vo.pub.AggregatedValueObject;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFDouble;
public abstract interface IFDCPRCMBillMaintain
{
public abstract AggBillVO[] update(AggBillVO[] paramArrayOfAggBillVO1, AggBillVO[] paramArrayOfAggBillVO2)
throws BusinessException;
public abstract AggBillVO[] insert(AggBillVO[] paramArrayOfAggBillVO1, AggBillVO[] paramArrayOfAggBillVO2)
throws BusinessException;
public abstract AggBillVO[] approve(AggBillVO[] paramArrayOfAggBillVO1, AggBillVO[] paramArrayOfAggBillVO2)
throws BusinessException;
public abstract void delete(AggBillVO[] paramArrayOfAggBillVO1, AggBillVO[] paramArrayOfAggBillVO2)
throws BusinessException;
public abstract AggBillVO[] unsave(AggBillVO[] paramArrayOfAggBillVO1, AggBillVO[] paramArrayOfAggBillVO2)
throws BusinessException;
public abstract AggBillVO[] unapprove(AggBillVO[] paramArrayOfAggBillVO1, AggBillVO[] paramArrayOfAggBillVO2)
throws BusinessException;
public abstract AggBillVO[] save(AggBillVO[] paramArrayOfAggBillVO1, AggBillVO[] paramArrayOfAggBillVO2)
throws BusinessException;
public abstract String[] queryPKs(IQueryScheme paramIQueryScheme)
throws BusinessException;
public abstract AggBillVO[] queryBillByPKs(String[] paramArrayOfString)
throws BusinessException;
public abstract String generatePKItem();
public abstract Map<String, UFDouble> queryPreviewBillCarryMny(String paramString, Set<String> paramSet)
throws BusinessException;
public abstract void arapWirteBack2Bill(AggregatedValueObject[] paramArrayOfAggregatedValueObject)
throws BusinessException;
}
/* Location: D:\yonyou\sp\nc65sp\modules\fdcprcm\lib\pubfdcprcm_fdcprcmbd.jar
* Qualified Name: nc.itf.fdcprcm.bd.bill.IFDCPRCMBillMaintain
* Java Class Version: 7 (51.0)
* JD-Core Version: 0.7.1
*/
BillSaveBP.class
/* */ package nc.impl.fdcprcm.bd.bill.bp;
/* */
/* */ import nc.impl.pubapp.pattern.data.bill.BillUpdate;
/* */ import nc.vo.fdcprcm.bd.bill.AggBillVO;
/* */ import nc.vo.fdcprcm.bd.bill.BillVO;
/* */ import nc.vo.pub.pf.BillStatusEnum;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class BillSaveBP
/* */ {
/* */ public AggBillVO[] sendApprove(AggBillVO[] clientBills, AggBillVO[] originBills)
/* */ {
/* 27 */ for (AggBillVO clientFullVO : clientBills) {
/* 28 */ clientFullVO.getParentVO().setAttributeValue("fstatusflag", BillStatusEnum.COMMIT.value());
/* */
/* 30 */ clientFullVO.getParentVO().setStatus(1);
/* */ }
/* */
/* 33 */ AggBillVO[] returnVos = (AggBillVO[])new BillUpdate().update(clientBills, originBills);
/* */
/* 35 */ return returnVos;
/* */ }
/* */ }
/* Location: D:\yonyou\sp\nc65sp\modules\fdcprcm\META-INF\lib\fdcprcm_fdcprcmbd.jar
* Qualified Name: nc.impl.fdcprcm.bd.bill.bp.BillSaveBP
* Java Class Version: 7 (51.0)
* JD-Core Version: 0.7.1
*/
PRCmBillSaveScriptAction.class
/* */ package nc.ui.fdcprcm.bd.bill.action;
/* */
/* */ import java.awt.event.ActionEvent;
/* */ import nc.ui.fdcpr.uipub.action.JZFDCSaveScriptAction;
/* */ import nc.ui.fdcprcm.bd.bill.view.BillShowUpableBillForm;
/* */ import nc.ui.fdcpub.pub.tool.PMTableTreeTool;
/* */ import nc.ui.pub.bill.BillCardPanel;
/* */
/* */
/* */ public class PRCmBillSaveScriptAction
/* */ extends JZFDCSaveScriptAction
/* */ {
/* */ private static final long serialVersionUID = -2714896722865300221L;
/* */
/* */ public void doAction(ActionEvent e)
/* */ throws Exception
/* */ {
/* */ try
/* */ {
/* 20 */ getBillForm().getBillCardPanel().stopEditing();
/* 21 */ getBillForm().getTreetableTool().changeToNormalTable();
/* 22 */ super.doAction(e);
/* */ }
/* */ catch (Exception e1) {
/* 25 */ throw e1;
/* */ } finally {
/* 27 */ getBillForm().getTreetableTool().changeToTreeTable(getBillForm().getTreeCreateStrategy());
/* 28 */ getBillForm().getTreetableTool().setEnable();
/* */ }
/* */ }
/* */
/* */ private BillShowUpableBillForm getBillForm() {
/* 33 */ return (BillShowUpableBillForm)editor;
/* */ }
/* */ }
/* Location: D:\yonyou\sp\nc65sp\modules\fdcprcm\client\lib\uifdcprcm_fdcprcmbd.jar
* Qualified Name: nc.ui.fdcprcm.bd.bill.action.PRCmBillSaveScriptAction
* Java Class Version: 7 (51.0)
* JD-Core Version: 0.7.1
*/
RefundSaveAction.java
ackage nc.ui.fdcprcm.bd.bill.action;
import java.awt.event.ActionEvent;
import nc.vo.pm.util.ExceptionUtils;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFDateTime;
import nc.vo.pubapp.AppContext;
import nc.vo.so.m4331.entity.DeliveryHVO;
import nc.vo.so.m4331.entity.DeliveryVO;
import nc.bs.framework.common.NCLocator;
import nc.itf.fdcprcm.bd.bill.IFDCPRCMBillMaintain;
import nc.ui.uif2.NCAction;
import nc.ui.uif2.model.AbstractAppModel;
import nc.ui.arap.view.InvoiceDialog;
import nc.ui.ls.MessageBox;
import nc.ui.pub.beans.MessageDialog;
import nc.ui.pubapp.uif2app.view.BillForm;
import nc.vo.arap.receivable.AggReceivableBillVO;
import nc.vo.arap.receivable.ReceivableBillVO;
import nc.vo.fdcprcm.bd.bill.AggBillVO;
import nc.vo.fdcprcm.bd.bill.BillVO;
import nc.ui.pubapp.uif2app.actions.RefreshSingleAction;
public class RefundSaveAction extends NCAction{
private BillForm editor;
private AbstractAppModel model;
public RefundSaveAction(){
//初始按钮名称和code
super.setBtnName("退费保存");
//传入值和xml中的code对应
super.setCode("RefundSaveAction");
}
public BillForm getEditor() {
return editor;
}
public void setEditor(BillForm editor) {
this.editor = editor;
}
public AbstractAppModel getModel() {
return model;
}
public void setModel(AbstractAppModel model) {
this.model = model;
//自定义按钮点击条件,必须添加该代码
model.addAppEventListener(this);
}
//设置按钮满足什么条件时,可以点击-返回true可以点击。
@Override
protected boolean isActionEnable() {
return true;
}
@Override
public void doAction(ActionEvent paramActionEvent) throws Exception {
try {
// 1. 安全获取单据数据并进行类型转换
Object value = editor.getValue();
if (value == null || !(value instanceof AggBillVO)) {
MessageDialog.showErrorDlg(editor, "错误", "无效的单据数据");
return;
}
AggBillVO aggVo = (AggBillVO) value;
// 2. 准备保存前的必要数据
prepareForSave(aggVo);
// 3. 获取后台服务
IFDCPRCMBillMaintain service = NCLocator.getInstance().lookup(IFDCPRCMBillMaintain.class);
// 4. 创建单据数组并调用保存方法
AggBillVO[] aggVos = new AggBillVO[]{aggVo};
AggBillVO[] originBills = getOriginBills(aggVo); // 获取原始单据
AggBillVO[] retVos = service.save(aggVos, originBills);
MessageBox.showMessageDialog("提示", "变量值:" + originBills[0].getAllChildrenVO()[0].toString());
MessageBox.showMessageDialog("提示", "变量值:" + retVos[0].toString());
// 5. 处理保存结果
handleSaveResult(retVos);
} catch (BusinessException e) {
handleBusinessException(e);
} catch (Exception e) {
handleGeneralException(e);
}
}
// 准备保存前的必要数据
private void prepareForSave(AggBillVO aggVo) {
BillVO billVO = aggVo.getParentVO();
if (billVO != null) {
// 设置单据修改时间和修改人
billVO.setModifiedtime(new UFDateTime());
billVO.setModifier(AppContext.getInstance().getPkUser());
// 设置单据状态(如果未设置)
if (billVO.getStatus() == 0) {
billVO.setStatus(0); // 假设0是初始状态
}
}
}
// 获取原始单据数据
private AggBillVO[] getOriginBills(AggBillVO currentBill) {
try {
// 只有已存在的单据才需要原始数据
String pk = currentBill.getPrimaryKey();
if (pk != null && !pk.isEmpty()) {
IFDCPRCMBillMaintain service = NCLocator.getInstance().lookup(IFDCPRCMBillMaintain.class);
return service.queryBillByPKs(new String[]{pk});
}
} catch (BusinessException e) {
// 忽略获取原始单据失败的错误
}
return null;
}
// 处理保存结果
private void handleSaveResult(AggBillVO[] retVos) throws BusinessException {
if (retVos == null || retVos.length == 0) {
throw new BusinessException("保存失败:服务返回空结果");
}
// 更新编辑器数据
editor.setValue(retVos[0]);
EditorHelper.refreshBillForm(editor);
MessageDialog.showHintDlg(editor, "提示", "退费保存成功");
}
// 处理业务异常
private void handleBusinessException(BusinessException e) {
String errorMsg = e.getMessage();
if (errorMsg == null || errorMsg.isEmpty()) {
errorMsg = "保存失败:未知业务异常";
}
MessageDialog.showErrorDlg(editor, "错误", errorMsg);
}
// 处理一般异常
private void handleGeneralException(Exception e) {
String errorMsg = e.getMessage();
if (errorMsg == null || errorMsg.isEmpty()) {
errorMsg = "保存失败:未知错误";
}
MessageDialog.showErrorDlg(editor, "错误", errorMsg);
// 记录详细错误日志
System.err.println("退费保存异常详情:");
e.printStackTrace();
}
}
// 辅助类,用于刷新编辑器
class EditorHelper {
public static void refreshBillForm(BillForm editor) {
try {
// 调用NC标准刷新方法
if (editor.getModel() != null) {
editor.getModel().refresh();
}
if (editor.getBillCardPanel() != null) {
editor.getBillCardPanel().refreshBody();
}
} catch (Exception ex) {
// 忽略刷新过程中的次要错误
}
}
}
分析上面几个文件代码,RefundSaveAction.java是退费保存按钮的代码,参考这些代码,调用这些文件,考虑代码中的树,实现调用FDCPRCMBillMaintainImpl中的计算代码,实现计算后完整保存功能,不要考虑保存后刷新
最新发布