Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
22ba0f0264
|
@ -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<String> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<UserNameObject> 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<String, String> 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<String> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue