From b10459f27aacc5c33db0458c3357999ee1d83c1c Mon Sep 17 00:00:00 2001 From: mzr Date: Fri, 1 Aug 2025 09:04:20 +0800 Subject: [PATCH 1/2] =?UTF-8?q?refactor(so):=20=E5=90=8C=E6=AD=A5=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=BA=94=E6=94=B6=E5=8D=95=E5=92=8C=E9=94=80=E5=94=AE?= =?UTF-8?q?=E5=8F=91=E7=A5=A8=E4=BF=A1=E6=81=AF=20-=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E9=94=80=E5=94=AE=E8=AE=A2=E5=8D=95=E6=97=B6=EF=BC=8C=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E6=9B=B4=E6=96=B0=E7=9B=B8=E5=85=B3=E7=9A=84=E5=BA=94?= =?UTF-8?q?=E6=94=B6=E5=8D=95=E5=92=8C=E9=94=80=E5=94=AE=E5=8F=91=E7=A5=A8?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=20-=20=E6=9B=B4=E6=96=B0=E5=BA=94=E6=94=B6?= =?UTF-8?q?=E5=8D=95=E7=9A=84=E9=83=A8=E9=97=A8=E3=80=81=E4=B8=9A=E5=8A=A1?= =?UTF-8?q?=E5=91=98=E3=80=81=E5=AE=A2=E6=88=B7=E7=AD=89=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=20-=20=E6=9B=B4=E6=96=B0=E9=94=80=E5=94=AE=E5=8F=91=E7=A5=A8?= =?UTF-8?q?=E7=9A=84=E7=89=A9=E6=96=99=E3=80=81=E5=8D=95=E4=BD=8D=E7=AD=89?= =?UTF-8?q?=E4=BF=A1=E6=81=AF-=20=E4=BC=98=E5=8C=96=E4=BA=86=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=92=8C=E6=9B=B4=E6=96=B0=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E6=8F=90=E9=AB=98=E4=BA=86=E7=B3=BB=E7=BB=9F=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/so/m30/APISaleOrderMaitainImpl.java | 62 ++++++++++++++++--- 1 file changed, 53 insertions(+), 9 deletions(-) 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 52f231c..3c06264 100644 --- a/so/src/private/nccloud/api/impl/so/m30/APISaleOrderMaitainImpl.java +++ b/so/src/private/nccloud/api/impl/so/m30/APISaleOrderMaitainImpl.java @@ -22,6 +22,8 @@ import nc.pubimpl.so.m30.pub.SaleOrderSaveUtil; import nc.pubitf.so.m30.api.ISaleOrderQueryAPI; import nc.vo.arap.gathering.GatheringBillItemVO; import nc.vo.arap.gathering.GatheringBillVO; +import nc.vo.arap.receivable.ReceivableBillItemVO; +import nc.vo.arap.receivable.ReceivableBillVO; import nc.vo.bd.defdoc.DefdocVO; import nc.vo.ml.NCLangRes4VoTransl; import nc.vo.pub.BusinessException; @@ -1867,20 +1869,27 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { if (null != invoiceBVOS) { Set billIds = new HashSet<>(); for (SaleInvoiceBVO invoiceBVO : invoiceBVOS) { - // 查询应收单是否生效 - String countSql = "SELECT count(1) FROM ar_recitem b " - + " left join ar_recbill a on a.pk_recbill = b.pk_recbill " - + " WHERE b.dr = 0 and a.effectstatus = 10 and b.src_billid = '[billId]' "; - countSql = countSql.replace("[billId]", csaleorderid); - Integer num = (Integer) getDao().executeQuery(countSql, new ColumnProcessor()); - if (num > 0) { - continue; - } + // 来源单据子表 + String csrcbid = invoiceBVO.getCsrcbid() != null ? invoiceBVO.getCsrcbid() : "~"; + // 匹配销售订单子表的vo + SaleOrderBVO soBvo = Arrays.stream(bvos) + .filter(bvo -> csrcbid.equals(bvo.getCsaleorderbid())) + .findFirst() + .orElse(null); invoiceBVO.setCordercustid(ccustomerid); invoiceBVO.setCordercustvid(ccustomervid); invoiceBVO.setCdeptid(cdeptid); invoiceBVO.setCdeptvid(cdeptvid); invoiceBVO.setCemployeeid(cemployeeid); + if (soBvo != null) { + invoiceBVO.setCmaterialid(soBvo.getCmaterialid()); + invoiceBVO.setCmaterialvid(soBvo.getCmaterialvid()); + invoiceBVO.setCastunitid(soBvo.getCastunitid()); + invoiceBVO.setCunitid(soBvo.getCunitid()); + invoiceBVO.setVchangerate(soBvo.getVchangerate()); + invoiceBVO.setCqtunitid(soBvo.getCqtunitid()); + invoiceBVO.setVqtunitrate(soBvo.getVqtunitrate()); + } invoiceBVO.setStatus(VOStatus.UPDATED); hypub.update(invoiceBVO); billIds.add(invoiceBVO.getCsaleinvoiceid()); @@ -1897,6 +1906,41 @@ public class APISaleOrderMaitainImpl implements IAPISaleOrderMaitain { } } } + // 同步修改应收单的部门、业务员、客户、开票客户 + for (SaleOrderBVO saleOrderBVO : bvos) { + SqlBuilder recWhere = new SqlBuilder(); + recWhere.append("src_itemid", saleOrderBVO.getCsaleorderbid()); + ReceivableBillItemVO[] receivableBillItemVOS = (ReceivableBillItemVO[]) hypub.queryByCondition(ReceivableBillItemVO.class, recWhere.toString()); + if (null != receivableBillItemVOS) { + for (ReceivableBillItemVO itemVO : receivableBillItemVOS) { + String pkRecbill = itemVO.getPk_recbill();// 应收单id + ReceivableBillVO billVO = (ReceivableBillVO) hypub.queryByPrimaryKey(ReceivableBillVO.class, pkRecbill); + if (billVO != null) { + // 应收单未生效则同步修改 + if (billVO.getEffectstatus() != 10) { + itemVO.setPk_deptid(cdeptid); + itemVO.setPk_deptid_v(cdeptvid); + itemVO.setPk_psndoc(cemployeeid); + itemVO.setCustomer(ccustomerid); + itemVO.setCustomer_v(ccustomervid); + itemVO.setMaterial(saleOrderBVO.getCmaterialid()); + itemVO.setMaterial_src(saleOrderBVO.getCmaterialid()); + itemVO.setStatus(VOStatus.UPDATED); + hypub.update(itemVO); + // 修改应收单 + billVO.setPk_deptid(cdeptid); + billVO.setPk_deptid_v(cdeptvid); + billVO.setPk_psndoc(cemployeeid); + billVO.setCustomer(ccustomerid); + billVO.setCustomer_v(ccustomervid); + billVO.setStatus(VOStatus.UPDATED); + hypub.update(billVO); + } + } + } + } + } + } } From b6e69902faa7ab9c54b5ee185ba279d527d26c81 Mon Sep 17 00:00:00 2001 From: mzr Date: Fri, 1 Aug 2025 09:20:17 +0800 Subject: [PATCH 2/2] =?UTF-8?q?BOM=E6=B6=88=E6=81=AF=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nccloud/api/uapbd/msg/MsgResource.java | 67 +++++++++++++++++-- 1 file changed, 60 insertions(+), 7 deletions(-) diff --git a/uapbd/src/public/nccloud/api/uapbd/msg/MsgResource.java b/uapbd/src/public/nccloud/api/uapbd/msg/MsgResource.java index 00539e1..cb1820d 100644 --- a/uapbd/src/public/nccloud/api/uapbd/msg/MsgResource.java +++ b/uapbd/src/public/nccloud/api/uapbd/msg/MsgResource.java @@ -4,13 +4,18 @@ import com.alibaba.fastjson.JSONObject; import nc.bs.dao.DAOException; import nc.bs.logging.Logger; import nc.bs.trade.business.HYSuperDMO; +import nc.bs.uapbd.util.MyHelper; +import nc.vo.fi.pub.SqlUtils; +import nc.vo.org.FactoryVO; import nc.vo.pub.BusinessException; import nc.vo.pub.lang.UFDateTime; import nc.vo.pub.msg.CommonMessageVO; import nc.vo.pub.msg.UserNameObject; import nc.vo.pubapp.pattern.exception.ExceptionUtils; import nc.vo.sm.UserVO; +import nc.vo.uap.rbac.role.RoleVO; import nccloud.api.rest.utils.ResultMessageUtil; +import nccloud.baseapp.core.log.NCCForUAPLogger; import nccloud.bs.pub.pf.PfMessageUtil; import nccloud.commons.lang.StringUtils; import nccloud.ws.rest.resource.AbstractNCCRestResource; @@ -21,8 +26,7 @@ import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; +import java.util.*; /** * 消息发送api @@ -54,7 +58,7 @@ public class MsgResource extends AbstractNCCRestResource { @Produces({"application/json"}) public JSONString save(JSONObject jsonObject) { String content = (String) jsonObject.get("content"); - String roleId = (String) jsonObject.get("roleId"); + String orgCode = (String) jsonObject.get("orgCode"); try { // 通知消息字段,最大为4000位。 if (content != null && content.length() > 1500) { @@ -65,6 +69,7 @@ public class MsgResource extends AbstractNCCRestResource { ArrayList userList = new ArrayList<>(); // 根据传递的角色查询要发送消息的用户信息 + String roleId = getMsgRole(orgCode); UserVO[] userVOS = getUserByRole(roleId); if (userVOS == null || userVOS.length == 0) { return ResultMessageUtil.toJSON(false, "未查询到用户"); @@ -105,19 +110,26 @@ public class MsgResource extends AbstractNCCRestResource { /** * 查询用户 */ - private UserVO[] getUserByRole(String roleId) { + private UserVO[] getUserByRole(String roleId) throws BusinessException { UserVO[] vos = null; if (StringUtils.isEmpty(roleId) || "~".equals(roleId)) { + ExceptionUtils.wrappBusinessException("角色查询失败"); return null; } + String roleSql = ""; + if (roleId.contains(",")) { + roleSql = SqlUtils.getInStr("pk_role", roleId.split(",", -1), Boolean.TRUE); + } else { + roleSql = "pk_role = '" + roleId + "'"; + } String strWhere = " dr = 0 AND cuserid in (" + - "select cuserid from sm_user_role where pk_role = '[roleId]' and (disabledate is null or disabledate >= '[now]') " + + "select cuserid from sm_user_role where [roleSql] and (disabledate is null or disabledate >= '[now]') " + ")"; - strWhere = strWhere.replace("[roleId]", roleId); + strWhere = strWhere.replace("[roleSql]", roleSql); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String time = sdf.format(new Date()); strWhere = strWhere.replace("[now]", time); - // NCCForUAPLogger.debug("time = " + time); + NCCForUAPLogger.debug("getUserByRole-strWhere = " + strWhere); try { vos = (UserVO[]) getSuperDMO().queryByWhereClause(UserVO.class, strWhere); } catch (DAOException e) { @@ -125,7 +137,48 @@ public class MsgResource extends AbstractNCCRestResource { ExceptionUtils.wrappBusinessException(e.getMessage()); } return vos; + } + /** + * 查询要发消息的角色id + */ + private String getMsgRole(String orgCode) throws BusinessException { + String pkRole = ""; + String pkOrg = MyHelper.transferField(FactoryVO.getDefaultTableName(), FactoryVO.PK_FACTORY, FactoryVO.CODE, orgCode); + Map configParams = MyHelper.getConfigParams("Dldz-config", null); + String strWhere = " dr = 0 "; + String msgRoleCode = configParams.getOrDefault("msgRoleCode", ""); + if (StringUtils.isEmpty(msgRoleCode)) { + ExceptionUtils.wrappBusinessException("未配置消息角色编码"); + } + if (msgRoleCode.contains(",")) { + String inSql = SqlUtils.getInStr("role_code", msgRoleCode.split(",", -1), Boolean.TRUE); + strWhere += " AND " + inSql; + NCCForUAPLogger.debug("多角色-strWhere = " + strWhere); + } else { + strWhere += " AND role_code = '" + msgRoleCode + "'"; + } + if (StringUtils.isNotEmpty(orgCode) && !"~".equals(orgCode) && + StringUtils.isNotEmpty(pkOrg) && !"~".equals(pkOrg)) { + strWhere += " AND pk_org = '" + pkOrg + "'"; + } + Set pkRoleSet = new HashSet<>(); + try { + RoleVO[] vos = (RoleVO[]) getSuperDMO().queryByWhereClause(RoleVO.class, strWhere); + if (vos != null && vos.length > 0) { + for (RoleVO roleVO : vos) { + pkRoleSet.add(roleVO.getPk_role()); + } + pkRole = vos[0].getPk_role(); + } + } catch (DAOException e) { + Logger.error("MsgResource-getMsgRole-exp:" + e.getMessage()); + ExceptionUtils.wrappBusinessException(e.getMessage()); + } + if (!pkRoleSet.isEmpty()) { + pkRole = String.join(",", pkRoleSet); + } + return pkRole; } }