diff --git a/so/src/private/nccloud/api/impl/so/m30/APISaleOrderMaitainImpl.java b/so/src/private/nccloud/api/impl/so/m30/APISaleOrderMaitainImpl.java index 4961923..ecb7312 100644 --- a/so/src/private/nccloud/api/impl/so/m30/APISaleOrderMaitainImpl.java +++ b/so/src/private/nccloud/api/impl/so/m30/APISaleOrderMaitainImpl.java @@ -77,6 +77,15 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { private static String BODYTABLE = "so_saleorder_b"; private static String HEADTABLE = "so_saleorder"; + public BaseDAO dao; + + public BaseDAO getDao() { + if (dao == null) { + dao = new BaseDAO(); + } + return dao; + } + public SaleOrderVO[] save(SaleOrderVO[] vos) throws BusinessException { SaleOrderVO[] fillvos = vos; @@ -87,7 +96,7 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { SaleOrderBVO[] bvos = vo.getChildrenVO(); String sql = " select bd_currtype.pk_currtype from bd_currtype where (code='" + hvo.getCorigcurrencyid() + "' or pk_currtype='" + hvo.getCorigcurrencyid() + "') and dr=0 "; - Object o = new BaseDAO().executeQuery(sql, new ColumnProcessor()); + Object o = getDao().executeQuery(sql, new ColumnProcessor()); if (o != null) { hvo.setCorigcurrencyid(BFPubTools.getString_TrimAsNull(o)); } else { @@ -95,7 +104,7 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { } sql = " select bd_currtype.pk_currtype from bd_currtype where (code='" + bvos[0].getCcurrencyid() + "' or pk_currtype='" + bvos[0].getCcurrencyid() + "') and dr=0 "; - Object o1 = new BaseDAO().executeQuery(sql, new ColumnProcessor()); + Object o1 = getDao().executeQuery(sql, new ColumnProcessor()); if (o1 == null) { throw new BusinessException("表体币种不能为空或币种不存在"); } @@ -409,7 +418,7 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { + " LEFT JOIN so_saleinvoice b ON a.csaleinvoiceid = b.csaleinvoiceid" + " WHERE b.fopposeflag = 0 AND nvl(b.dr, 0) = 0 and csrcid = '[csrcid]' "; countSql = countSql.replace("[csrcid]", hvo.getCsaleorderid()); - Integer num = (Integer) new BaseDAO().executeQuery(countSql, new ColumnProcessor()); + Integer num = (Integer) getDao().executeQuery(countSql, new ColumnProcessor()); if (num > 0) { // fopposeflag 对冲标记 0=正常 1=已被对冲 2=对冲生成 ExceptionUtils.wrappBusinessException("下游存在未红冲完成的销售发票"); @@ -423,6 +432,10 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { // 保存 ISaleOrderScriptMaintain maintainsrv = NCLocator.getInstance().lookup(ISaleOrderScriptMaintain.class); SaleOrderVO[] retvos = maintainsrv.saleOrderUpdate(combinBillVOs, null, originVos); + if (retvos != null) { + // 同步修改流程生产订单的国网行项目号、国内采购订单号 + updatePmoBill(retvos); + } return retvos; } @@ -460,7 +473,7 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { if (cdeptvid != null && !cdeptvid.isEmpty()) { sql = " select pk_vid,pk_dept from org_dept where code = '[code]' "; sql = sql.replace("[code]", cdeptvid); - Map deptMap = (Map) new BaseDAO().executeQuery(sql, new MapProcessor()); + Map deptMap = (Map) getDao().executeQuery(sql, new MapProcessor()); // NCCForUAPLogger.debug("APISaleOrderMaitainImpl-setOtherId-deptObj:" + deptMap); if (deptMap != null && !deptMap.isEmpty()) { if (!"".equals(deptMap.getOrDefault("pk_dept", "") + "")) { @@ -475,7 +488,7 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { if (cemployeeid != null && !cemployeeid.isEmpty()) { sql = " select pk_psndoc from bd_psndoc where code = '[code]' "; sql = sql.replace("[code]", cemployeeid); - Object staffObj = new BaseDAO().executeQuery(sql, new ColumnProcessor("pk_psndoc")); + Object staffObj = getDao().executeQuery(sql, new ColumnProcessor("pk_psndoc")); // NCCForUAPLogger.debug("APISaleOrderMaitainImpl-setOtherId-staffObj:" + staffObj); if (staffObj != null) { String id = BFPubTools.getString_TrimAsNull(staffObj); @@ -488,7 +501,7 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { if (cinvoicecustid != null && !cinvoicecustid.isEmpty()) { sql = " select pk_customer from bd_customer where nvl(dr,0) = 0 and code = '[code]' "; sql = sql.replace("[code]", cinvoicecustid); - Object invCustObj = new BaseDAO().executeQuery(sql, new ColumnProcessor("pk_customer")); + Object invCustObj = getDao().executeQuery(sql, new ColumnProcessor("pk_customer")); // NCCForUAPLogger.debug("setOtherId-invCustObj:" + invCustObj); if (invCustObj != null) { String id = BFPubTools.getString_TrimAsNull(invCustObj); @@ -501,7 +514,7 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { if (ccustomerid != null && !ccustomerid.isEmpty()) { sql = " select pk_customer from bd_customer where nvl(dr,0) = 0 and code = '[code]' "; sql = sql.replace("[code]", ccustomerid); - Object custObj = new BaseDAO().executeQuery(sql, new ColumnProcessor("pk_customer")); + Object custObj = getDao().executeQuery(sql, new ColumnProcessor("pk_customer")); // NCCForUAPLogger.debug("setOtherId-custObj:" + custObj); if (custObj != null) { String id = BFPubTools.getString_TrimAsNull(custObj); @@ -716,11 +729,12 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { // 新增字段的setter方法 targetBVO.setVbdef10(sourceBVO.getVbdef10()); // 项目名称 targetBVO.setVbdef13(sourceBVO.getVbdef13()); // 国网行项目号 - - - targetBVO.setVbdef18(sourceBVO.getVbdef18()); // 是否定制 targetBVO.setVbdef14(sourceBVO.getVbdef14()); // 合同销售订单变更明细id - targetBVO.setCrowno(sourceBVO.getCrowno()); // 行号 + targetBVO.setVbdef18(sourceBVO.getVbdef18()); // 是否定制 + targetBVO.setVbdef22(sourceBVO.getVbdef22()); // 国内采购订单号 + if (StringUtils.isNotEmpty(sourceBVO.getCrowno())) { + targetBVO.setCrowno(sourceBVO.getCrowno()); // 行号 + } if (StringUtils.isNotEmpty(sourceBVO.getVbdef19())) { targetBVO.setVbdef19(sourceBVO.getVbdef19()); // 计划开工日期 } @@ -952,7 +966,7 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { String sql = " select a.pk_material,a.pk_source, a.pk_measdoc cunitid,nvl(b.pk_measdoc,a.pk_measdoc) castunitid,nvl(b.measrate,'1/1') measrate " + "from bd_material a left join bd_materialconvert b on a.pk_material=b.pk_material " + "where a.code='" + cmaterialvid + "' "; - Map map = (Map) new BaseDAO().executeQuery(sql, new MapProcessor()); + Map map = (Map) getDao().executeQuery(sql, new MapProcessor()); if (map == null) { throw new BusinessException(cmaterialvid + "物料未查到"); } @@ -977,7 +991,7 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { sql = "select sl.pk_taxcode from bd_taxrate sl inner join bd_taxcode sm on sl.pk_taxcode=sm.pk_taxcode where sl.taxrate=" + ntaxrate + " and sm.pk_group<>'~' "; - String o_pk_project = (String) new BaseDAO().executeQuery(sql, new ColumnProcessor()); + String o_pk_project = (String) getDao().executeQuery(sql, new ColumnProcessor()); // 税码 bVO.setAttributeValue("ctaxcodeid", o_pk_project); } catch (BusinessException e) { @@ -1044,7 +1058,7 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { } else { String sql = " select pk_project from bd_project where project_code='" + cprojectid + "' and nvl(dr,0)=0 "; - cprojectid = (String) new BaseDAO().executeQuery(sql, new ColumnProcessor()); + cprojectid = (String) getDao().executeQuery(sql, new ColumnProcessor()); } newBvo.setAttributeValue("cprojectid", cprojectid); @@ -1187,6 +1201,7 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { newBvo.setVbdef5(defList.getOrDefault(vbdef5, "")); newBvo.setVbdef10(bodydata.getOrDefault("vbdef10", "") + "");// 项目名称 newBvo.setVbdef13(bodydata.getOrDefault("vbdef13", "") + "");// 国网行项目号 + newBvo.setVbdef22(bodydata.getOrDefault("vbdef22", "") + "");// 国内采购订单号 bvoList.add(newBvo); } @@ -1538,4 +1553,36 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { return result.toString(); } + private void updatePmoBill(SaleOrderVO[] vos) { + // 同步修改流程生产订单的国网行项目号、国内采购订单号 + for (SaleOrderVO vo : vos) { + SaleOrderBVO[] bvos = vo.getChildrenVO(); + for (SaleOrderBVO bvo : bvos) { + String csaleorderbid = bvo.getCsaleorderbid(); + // 源头单据明细ID(vfirstbid) + if (csaleorderbid == null || csaleorderbid.isEmpty()) { + continue; // 跳过无效数据 + } + + // 从销售订单明细中获取需要更新的字段 + String vbdef13 = bvo.getVbdef13(); // vbdef13 国网行项目号 + String vbdef22 = bvo.getVbdef22(); // vbdef22 国内采购订单号 + if (StringUtils.isEmpty(vbdef13) && StringUtils.isEmpty(vbdef22)) { + continue; + } + + // 构建并执行更新SQL + String updateSql = "UPDATE mm_mo SET vdef8 = '[vdef8]', vdef14 = '[vdef14]' WHERE vfirstbid = '[bid]'"; + updateSql = updateSql.replace("[vdef8]", vbdef13); + updateSql = updateSql.replace("[vdef14]", vbdef22); + updateSql = updateSql.replace("[bid]", csaleorderbid); + try { + getDao().executeUpdate(updateSql); + } catch (Exception e) { + ExceptionUtils.wrappBusinessException("so-updatePmoBill-exp: " + e.getMessage()); + } + } + } + } + }