Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
83222ff0d9
|
@ -196,16 +196,15 @@ public class AfterApproveRuleSyncMes implements IRule<PMOAggVO> {
|
|||
private void syncOrderItemToMes(PMOHeadVO head, PMOItemVO item) throws BusinessException {
|
||||
JSONObject data = new JSONObject();
|
||||
String vbillcode = head.getVbillcode(); // µ¥¾ÝºÅ
|
||||
String itemRow = item.getVrowno(); // 行号
|
||||
String itemRow = item.getVrowno(); // 行号 obmlog.info("开始为生产订单 " + vbillcode + " 行 " + itemRow + " 构建同步MES数据。");
|
||||
|
||||
obmlog.info("开始为生产订单 " + vbillcode + " 行 " + itemRow + " 构建同步MES数据。");
|
||||
|
||||
// orderNo String 是 生产订单号 vbillcode
|
||||
if (vbillcode.length() > 18) {
|
||||
throw new BusinessException("MES同步要求:生产订单 " + vbillcode + " 行 " + itemRow + " 单据号长度不能超过18位。");
|
||||
// orderNo String 是 生产订单号+行号 vbillcode+itemRow
|
||||
String orderNoWithRow = vbillcode + itemRow;
|
||||
if (orderNoWithRow.length() > 18) {
|
||||
throw new BusinessException("MES同步要求:生产订单 " + vbillcode + " 行 " + itemRow + " 单据号+行号长度不能超过18位,当前长度:" + orderNoWithRow.length());
|
||||
}
|
||||
|
||||
data.put("orderNo", vbillcode);
|
||||
data.put("orderNo", orderNoWithRow);
|
||||
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
package nccloud.openapi.mmpac.wr;
|
||||
|
||||
|
||||
import nc.bs.dao.BaseDAO;
|
||||
import nc.bs.framework.common.InvocationInfoProxy;
|
||||
import nc.bs.framework.common.NCLocator;
|
||||
import nc.bs.logging.Log;
|
||||
import nc.bs.uif2.validation.ValidationFailure;
|
||||
import nc.jdbc.framework.SQLParameter;
|
||||
import nc.jdbc.framework.processor.ColumnProcessor;
|
||||
import nc.util.mmf.framework.base.MMArrayUtil;
|
||||
import nc.util.mmf.framework.base.MMCollectionUtil;
|
||||
import nc.util.mmf.framework.base.MMNumberUtil;
|
||||
import nc.util.mmf.framework.base.MMValueCheck;
|
||||
import nc.vo.mmpac.wr.entity.AggWrVO;
|
||||
import nc.vo.mmpac.wr.entity.WrItemVO;
|
||||
import nc.vo.mmpac.wr.entity.WrQualityVO;
|
||||
import nc.vo.mmpac.wr.entity.WrSerialNoVO;
|
||||
import nc.vo.mmpac.wr.entity.WrVO;
|
||||
import nc.vo.mmpac.wr.entity.*;
|
||||
import nc.vo.mmpac.wr.enumeration.WrBillStatusEnum;
|
||||
import nc.vo.pub.BusinessException;
|
||||
import nc.vo.pub.VOStatus;
|
||||
|
@ -31,14 +31,7 @@ import javax.ws.rs.Consumes;
|
|||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
@Path("mmpac/wr")
|
||||
public class WrResource extends AbstractNCCRestResource {
|
||||
|
@ -312,6 +305,9 @@ public class WrResource extends AbstractNCCRestResource {
|
|||
Map<String, Object> bodyInfo = (Map<String, Object>) paramMap.get(BODYTABLE);
|
||||
itemInfos.add(bodyInfo);
|
||||
}
|
||||
|
||||
// 预处理数据:处理仓库转换和MES相关字段
|
||||
preProcessMesData(headInfo, itemInfos, baseDAO);
|
||||
AggWrVO vo = new AggWrVO();
|
||||
WrVO head = new WrVO();
|
||||
head.setPk_group(AppContext.getInstance().getPkGroup());
|
||||
|
@ -577,9 +573,169 @@ public class WrResource extends AbstractNCCRestResource {
|
|||
}
|
||||
server.delete(deleteVos.toArray(new AggWrVO[0]));
|
||||
return ResultMessageUtil.toJSON(new String[0], "Éú²ú±¨¸æÉ¾³ý³É¹¦");
|
||||
} catch (Exception e) {
|
||||
return ResultMessageUtil.exceptionToJSON(e);
|
||||
} catch (Exception e) { return ResultMessageUtil.exceptionToJSON(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 预处理数据:包含仓库转换和MES相关字段处理
|
||||
* @param headInfo 表头信息
|
||||
* @param itemInfos 表体信息列表
|
||||
* @param baseDAO 数据库操作对象
|
||||
* @throws BusinessException 处理失败时抛出异常
|
||||
*/
|
||||
private void preProcessMesData(Map<String, Object> headInfo, List<Map<String, Object>> itemInfos, BaseDAO baseDAO)
|
||||
throws BusinessException {
|
||||
// 处理表体信息中的数据转换
|
||||
for (Map<String, Object> itemMap : itemInfos) {
|
||||
// 处理MES相关字段自动赋值
|
||||
processMESFields(itemMap, baseDAO);
|
||||
|
||||
// 处理质量信息中的仓库转换
|
||||
if (itemMap.containsKey(QUALITYTABLE)) {
|
||||
List<Map<String, Object>> qualityInfos = (List<Map<String, Object>>) itemMap.get(QUALITYTABLE);
|
||||
processWarehouseConversion(qualityInfos, baseDAO);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理MES相关字段自动赋值
|
||||
* 如果用户code是MES,那么将cbmoid保持和vbsrcid一致,cbmobid保持和vbsrcrowid一致
|
||||
* 增加vbmobillcode单据号,通过cbmoid查询流程生产订单表的vbillcode
|
||||
* @param itemMap 表体信息
|
||||
* @param baseDAO 数据库操作对象
|
||||
* @throws BusinessException 查询失败时抛出异常
|
||||
*/
|
||||
|
||||
private void processMESFields(Map<String, Object> itemMap, BaseDAO baseDAO) throws BusinessException {
|
||||
// 检查是否需要处理MES字段
|
||||
// 这里可以通过上下文、用户信息或其他标识来判断
|
||||
// 暂时通过检查是否存在特定字段来判断是MES用户
|
||||
boolean isMESUser = isMESUser(itemMap);
|
||||
|
||||
if (!isMESUser) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// 设置cbmoid保持和vbsrcid一致
|
||||
if (itemMap.containsKey("vbsrcid") && MMValueCheck.isNotEmpty(itemMap.get("vbsrcid"))) {
|
||||
itemMap.put("cbmoid", itemMap.get("vbsrcid"));
|
||||
}
|
||||
|
||||
// 设置cbmobid保持和vbsrcrowid一致
|
||||
if (itemMap.containsKey("vbsrcrowid") && MMValueCheck.isNotEmpty(itemMap.get("vbsrcrowid"))) {
|
||||
itemMap.put("cbmobid", itemMap.get("vbsrcrowid"));
|
||||
}
|
||||
// 通过cbmoid查询流程生产订单表的vbillcode
|
||||
if (itemMap.containsKey("cbmoid") && MMValueCheck.isNotEmpty(itemMap.get("cbmoid"))) {
|
||||
String cbmoid = String.valueOf(itemMap.get("cbmoid"));
|
||||
String sql = "SELECT vbillcode FROM mm_pmo WHERE cpmohid = ? AND dr = 0";
|
||||
SQLParameter param = new SQLParameter();
|
||||
param.addParam(cbmoid);
|
||||
String vbillcode = (String) baseDAO.executeQuery(sql, param, new ColumnProcessor());
|
||||
|
||||
if (MMValueCheck.isEmpty(vbillcode)) {
|
||||
throw new BusinessException("通过流程生产订单主键【" + cbmoid + "】查询不到对应的单据号,请检查数据");
|
||||
}
|
||||
|
||||
itemMap.put("vbmobillcode", vbillcode);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
if (e instanceof BusinessException) {
|
||||
throw e;
|
||||
}
|
||||
throw new BusinessException("处理MES字段失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 判断是否为MES用户
|
||||
* 通过获取线程上下文中的用户编码来判断是否为MES用户
|
||||
* @param itemMap 表体信息(保留参数以保持方法签名一致性)
|
||||
* @return 是否为MES用户
|
||||
*/
|
||||
|
||||
private boolean isMESUser(Map<String, Object> itemMap) {
|
||||
try {
|
||||
// 获取当前线程上下文中的用户编码
|
||||
String userCode = InvocationInfoProxy.getInstance().getUserCode();
|
||||
|
||||
// 判断用户编码是否为MES
|
||||
return "MES".equals(userCode);
|
||||
|
||||
} catch (Exception e) {
|
||||
// 如果获取用户编码失败,记录日志并返回false
|
||||
Log.getInstance("mm-mes").error("获取用户编码失败:" + e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理仓库转换(将原有的仓库转换逻辑包装成独立函数)
|
||||
* @param qualityInfos 质量信息列表
|
||||
* @param baseDAO 数据库操作对象
|
||||
* @throws BusinessException 转换失败时抛出异常
|
||||
*/
|
||||
private void processWarehouseConversion(List<Map<String, Object>> qualityInfos, BaseDAO baseDAO)
|
||||
throws BusinessException {
|
||||
if (qualityInfos == null || qualityInfos.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Map<String, Object> qualityInfo : qualityInfos) {
|
||||
if (qualityInfo.containsKey("cgwarehouseid") && MMValueCheck.isNotEmpty(qualityInfo.get("cgwarehouseid"))) {
|
||||
String warehouseValue = String.valueOf(qualityInfo.get("cgwarehouseid"));
|
||||
String warehousePk = convertWarehouseCodeToPk(warehouseValue, baseDAO);
|
||||
qualityInfo.put("cgwarehouseid", warehousePk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换仓库编码为主键
|
||||
* 首先假设传入值是主键,如果查询不到,再假设是编码进行查询
|
||||
* @param warehouseValue 仓库值(可能是主键或编码)
|
||||
* @param baseDAO 数据库操作对象
|
||||
* @return 仓库主键
|
||||
* @throws BusinessException 如果仓库不存在
|
||||
*/
|
||||
private String convertWarehouseCodeToPk(String warehouseValue, BaseDAO baseDAO) throws BusinessException {
|
||||
if (MMValueCheck.isEmpty(warehouseValue)) {
|
||||
return warehouseValue;
|
||||
}
|
||||
try {
|
||||
// 首先假设是主键,直接查询
|
||||
String sql = "SELECT pk_stordoc FROM bd_stordoc WHERE pk_stordoc = ? AND dr = 0";
|
||||
SQLParameter param = new SQLParameter();
|
||||
param.addParam(warehouseValue);
|
||||
String result = (String) baseDAO.executeQuery(sql, param, new ColumnProcessor());
|
||||
|
||||
if (MMValueCheck.isNotEmpty(result)) {
|
||||
// 主键查询成功,直接返回
|
||||
return warehouseValue;
|
||||
}
|
||||
|
||||
// 主键查询失败,假设是编码查询
|
||||
sql = "SELECT pk_stordoc FROM bd_stordoc WHERE code = ? AND dr = 0";
|
||||
param = new SQLParameter();
|
||||
param.addParam(warehouseValue);
|
||||
result = (String) baseDAO.executeQuery(sql, param, new ColumnProcessor());
|
||||
|
||||
if (MMValueCheck.isNotEmpty(result)) {
|
||||
// 编码查询成功,返回主键
|
||||
return result;
|
||||
}
|
||||
|
||||
// 都查询不到,抛出异常
|
||||
throw new BusinessException("仓库【" + warehouseValue + "】不存在,请检查仓库编码或主键");
|
||||
|
||||
} catch (Exception e) {
|
||||
if (e instanceof BusinessException) {
|
||||
throw e;
|
||||
}
|
||||
throw new BusinessException("查询仓库信息失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -204,7 +204,7 @@ public class IAPISaleInvMaitainImpl {
|
|||
Logger.error("=====================inv-red-audit-end===============");
|
||||
|
||||
// 查询新生成红冲发票的信息
|
||||
String newPk = returnApproveSaleInvoiceVOs[0].getParentVO().getCsaleinvoiceid();
|
||||
String newPk = returnSaveSaleInvoiceVOs[0].getParentVO().getCsaleinvoiceid();
|
||||
String[] idsNew = {newPk};
|
||||
// String[] idsNew = {"1001A11000000FSB45YA"};
|
||||
SaleInvoiceVO[] redVos = querySaleInvoiceByIds(idsNew);
|
||||
|
@ -503,8 +503,10 @@ public class IAPISaleInvMaitainImpl {
|
|||
}
|
||||
// BIP合同平台的数量对应BIP2312的主数量,BIP2312的 数量=主数量*换算关系
|
||||
UFDouble nnum = new UFDouble(bipBvoJson.getString("nnum"));
|
||||
newInvBVO.setNastnum(nnum.multiply(vchangerateNum).setScale(2, 4)); // 数量
|
||||
UFDouble nastnum = nnum.multiply(vchangerateNum).setScale(2, 4);
|
||||
newInvBVO.setNastnum(nastnum); // 数量
|
||||
newInvBVO.setNnum(nnum); // 主数量
|
||||
newInvBVO.setNqtunitnum(nastnum); // 报价数量
|
||||
newInvBVO.setNqtorigtaxprice(new UFDouble(bipBvoJson.getString("nqtorigtaxprice"))); // 含税单价
|
||||
newInvBVO.setNqtorigprice(new UFDouble(bipBvoJson.getString("nqtorigprice"))); // 无税单价
|
||||
newInvBVO.setNorigtaxprice(new UFDouble(bipBvoJson.getString("norigtaxprice"))); // 主含税单价
|
||||
|
@ -528,11 +530,17 @@ public class IAPISaleInvMaitainImpl {
|
|||
newInvBVO.setNtaxmny(new UFDouble(bipBvoJson.getString("ntaxmny"))); // 本币价税合计
|
||||
newInvBVO.setNcaltaxmny(new UFDouble(bipBvoJson.getString("nmny"))); // 计税金额=本币无税金额
|
||||
newInvBVO.setCopposesrcbid(bipBvoJson.getString("vbdef15")); // 对冲来源子表id
|
||||
newInvBVO.setNqtunitnum(null); // 报价数量
|
||||
newInvBVO.setCunitid(bipBvoJson.getString("castunitid"));// 主单位
|
||||
newInvBVO.setCqtunitid(bipBvoJson.getString("castunitid"));// 报价单位
|
||||
// 通过 ntaxrate 获取 taxcode
|
||||
String taxcodeStr = getTaxcode(bipBvoJson.getString("ntaxrate"));
|
||||
newInvBVO.setCtaxcodeid(taxcodeStr);// 税码
|
||||
|
||||
newInvBVO.setCsaleinvoiceid(null); // 发票关联主表id
|
||||
newInvBVO.setNtotalcostnum(null); // 累计成本结算数量
|
||||
newInvBVO.setNtotalincomemny(null); // 累计确认应收金额
|
||||
newInvBVO.setNtotalincomenum(null); // 累计确认应收数量
|
||||
|
||||
newSaleInvoiceBVOs[i++] = newInvBVO;
|
||||
sumNum = sumNum.add(new UFDouble(bipBvoJson.getString("nnum")));
|
||||
sumNtax = sumNtax.add(new UFDouble(bipBvoJson.getString("ntax")));
|
||||
|
@ -558,6 +566,8 @@ public class IAPISaleInvMaitainImpl {
|
|||
newSaleInvoiceHVO.setCopposesrcid(saleInvoiceHVO.getCsaleinvoiceid()); // 对冲来源发票id
|
||||
newSaleInvoiceHVO.setApprover(null); // 审批人
|
||||
newSaleInvoiceHVO.setTaudittime(null); // 审批日期
|
||||
newSaleInvoiceHVO.setVdef13(null); // 发票号码
|
||||
newSaleInvoiceHVO.setVdef17(bject.getString("vdef17")); // BIP申请单号
|
||||
|
||||
// 组装VO
|
||||
saleInvoiceVO.setParentVO(newSaleInvoiceHVO);
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import nc.bs.dao.BaseDAO;
|
||||
import nc.bs.dao.DAOException;
|
||||
import nc.bs.framework.common.InvocationInfoProxy;
|
||||
import nc.bs.sscivm.ivsale.bp.IVApplicationQueryBP;
|
||||
import nc.bs.sscivm.util.IVMSagaValidationUtils;
|
||||
|
@ -117,53 +118,6 @@ public class IVApplicationQueryServiceImpl implements IVApplicationQueryService
|
|||
}
|
||||
}
|
||||
|
||||
// 当传入第四个参数的时候 进行额外的筛选
|
||||
@Override
|
||||
public Map<String, List<String>> queryApplicationPksBySchema(IQueryScheme queryscheme, String appcode, Boolean sgbzflag, List<Map<String, Object>> extraParams) throws BusinessException {
|
||||
if (queryscheme == null) {
|
||||
return null;
|
||||
} else {
|
||||
String queryCondition = queryscheme.getWhereSQLOnly();
|
||||
Map<String, List<String>> pkAndTsList = null;
|
||||
if (!queryCondition.isEmpty()) {
|
||||
String tradetype = this.getTradetypeByApp(appcode);
|
||||
if ("SSCIVA-kpsq".equals(tradetype)) {
|
||||
queryCondition = "(" + queryCondition + ")";
|
||||
} else {
|
||||
queryCondition = "(" + queryCondition + " and sn.transtypecode = '" + tradetype + "')";
|
||||
}
|
||||
|
||||
if (sgbzflag != null) {
|
||||
if (sgbzflag) {
|
||||
queryCondition = queryCondition + " and sn.sgbz ='Y' ";
|
||||
} else {
|
||||
queryCondition = queryCondition + " and (sn.sgbz='N' or isnull(sn.sgbz,'~')='~') ";
|
||||
}
|
||||
}
|
||||
String sql = this.buildQuerySql(queryCondition, extraParams);
|
||||
pkAndTsList = (Map) this.getBaseDAO().executeQuery(sql, new BaseProcessor() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
Map<String, List<String>> result = new HashMap();
|
||||
List<String> pkList = new ArrayList();
|
||||
List<String> tsList = new ArrayList();
|
||||
|
||||
public Object processResultSet(ResultSet paramResultSet) throws SQLException {
|
||||
while (paramResultSet.next()) {
|
||||
this.pkList.add((String) paramResultSet.getObject("pk_ivapplication"));
|
||||
this.tsList.add((String) paramResultSet.getObject("ts"));
|
||||
}
|
||||
|
||||
this.result.put("pks", this.pkList);
|
||||
this.result.put("ts", this.tsList);
|
||||
return this.result;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return pkAndTsList;
|
||||
}
|
||||
}
|
||||
|
||||
private String buildQuerySql(String queryCondition) {
|
||||
StringBuilder sql = new StringBuilder("SELECT * ");
|
||||
sql.append("from " + IVApplicationHeadVO.getDefaultTableName() + " where ");
|
||||
|
@ -171,64 +125,6 @@ public class IVApplicationQueryServiceImpl implements IVApplicationQueryService
|
|||
return var10000 + queryCondition + " and dr = 0 order by preparedate desc, billno desc";
|
||||
}
|
||||
|
||||
// 添加了参数 otherExtraQueryParams 用于额外参数的查询
|
||||
private String buildQuerySql(String queryCondition, List<Map<String, Object>> otherExtraQueryParams) {
|
||||
String var10000 = "SELECT * " + "from " + IVApplicationHeadVO.getDefaultTableName() +
|
||||
" sn " +
|
||||
" left join " + IVApplogVO.getDefaultTableName() +
|
||||
" sg " +
|
||||
" on " + " sn." + IVApplicationHeadVO.PK_IVAPPLICATION +
|
||||
" = " + " sg." + IVApplogVO.PK_IVAPPLOG +
|
||||
" where 1=1 ";
|
||||
StringBuilder extraSql = new StringBuilder();
|
||||
if (otherExtraQueryParams != null && !otherExtraQueryParams.isEmpty()) {
|
||||
for (Map<String, Object> map : otherExtraQueryParams) {
|
||||
if (map != null && !map.isEmpty()) {
|
||||
Map<String, String> value = (Map<String, String>) map.get("value");
|
||||
String column = (String) map.get("field");
|
||||
String firstValue = value.get("firstvalue");
|
||||
String secondValue = value.get("secondvalue");
|
||||
String alias = " sn.";
|
||||
String oprtype = (String) map.get("oprtype");
|
||||
if (column.equals("KPRQ")) {
|
||||
alias = " sg.";
|
||||
}
|
||||
if (column.equals("pk_org") && oprtype.equals("=")) {
|
||||
String[] pks = firstValue.split(",");
|
||||
extraSql.append(" and (").append(alias).append("pk_org").append(" in (");
|
||||
for (int i = 0; i < pks.length; ++i) {
|
||||
extraSql.append("'").append(pks[i]).append("'");
|
||||
if (i != pks.length - 1) {
|
||||
extraSql.append(",");
|
||||
}
|
||||
}
|
||||
extraSql.append(")");
|
||||
extraSql.append(")");
|
||||
continue;
|
||||
}
|
||||
switch (oprtype) {
|
||||
case "between": {
|
||||
extraSql.append(" and (").append(alias).append(column).append(" >= '").append(firstValue).append("' and ").append(alias).append(column).append(" <= '").append(secondValue).append("' )");
|
||||
break;
|
||||
}
|
||||
case "like": {
|
||||
extraSql.append(" and (").append(alias).append(column).append(" like '%").append(firstValue).append("' )");
|
||||
break;
|
||||
}
|
||||
case "=": {
|
||||
extraSql.append(" and (").append(alias).append(column).append(" = '").append(firstValue).append("' )");
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return var10000 + extraSql + " and sn.dr = 0 order by sn.preparedate desc, sn.billno desc";
|
||||
}
|
||||
|
||||
public String getDefaultOrgUnit() throws Exception {
|
||||
return OrgSettingAccessor.getDefaultOrgUnit();
|
||||
}
|
||||
|
@ -269,6 +165,48 @@ public class IVApplicationQueryServiceImpl implements IVApplicationQueryService
|
|||
}
|
||||
}
|
||||
|
||||
public List<IVApplicationHeadVO> queryApplicationsBySchema(IQueryScheme queryscheme, String pageSize, String appcode, Boolean sgbzflag, Boolean pageControl) throws BusinessException {
|
||||
if (queryscheme == null) {
|
||||
return null;
|
||||
} else {
|
||||
StringBuilder sql = new StringBuilder();
|
||||
String queryCondition = queryscheme.getWhereSQLOnly();
|
||||
String tradetype = this.getTradetypeByApp(appcode);
|
||||
if ("SSCIVA-kpsq".equals(tradetype)) {
|
||||
queryCondition = "(" + queryCondition + ")";
|
||||
} else {
|
||||
queryCondition = "(" + queryCondition + " and transtypecode = '" + tradetype + "')";
|
||||
}
|
||||
|
||||
if (sgbzflag != null) {
|
||||
if (sgbzflag) {
|
||||
queryCondition = queryCondition + " and sgbz ='Y' ";
|
||||
} else {
|
||||
queryCondition = queryCondition + " and (sgbz='N' or isnull(sgbz,'~')='~') ";
|
||||
}
|
||||
}
|
||||
|
||||
List<IVApplicationHeadVO> applicationHeadVOList = null;
|
||||
// 如果pageControl 为false 那么不走分页的逻辑
|
||||
if (null != queryCondition && !queryCondition.isEmpty()) {
|
||||
if (pageControl) {
|
||||
LimitSQLBuilder limitSQLBuilder = SQLBuilderFactory.getInstance().createLimitSQLBuilder(this.getBaseDAO().getDBType());
|
||||
sql.append(limitSQLBuilder.build(this.buildQuerySql(queryCondition), 1, Integer.valueOf(pageSize)));
|
||||
}
|
||||
applicationHeadVOList = (List) this.getBaseDAO().executeQuery(this.buildQuerySql(queryCondition).toString(), new BeanListProcessor(IVApplicationHeadVO.class));
|
||||
}
|
||||
|
||||
if (applicationHeadVOList != null && applicationHeadVOList.size() > Integer.parseInt(pageSize)) {
|
||||
if (!pageControl) {
|
||||
return applicationHeadVOList;
|
||||
}
|
||||
applicationHeadVOList = applicationHeadVOList.subList(0, Integer.parseInt(pageSize));
|
||||
}
|
||||
|
||||
return applicationHeadVOList;
|
||||
}
|
||||
}
|
||||
|
||||
public IVApplicationHeadVO[] queryHeadVOsByFpdmFphm(String fpdm, String fphm) throws BusinessException {
|
||||
StringBuilder querySql = new StringBuilder("select DISTINCT " + IVApplicationHeadVO.getDefaultTableName() + ".* from ");
|
||||
String var10001 = IVApplogVO.getDefaultTableName();
|
||||
|
@ -284,6 +222,25 @@ public class IVApplicationQueryServiceImpl implements IVApplicationQueryService
|
|||
return ivApplicationHeadVOList != null && ivApplicationHeadVOList.size() != 0 ? (IVApplicationHeadVO[]) ivApplicationHeadVOList.toArray(new IVApplicationHeadVO[ivApplicationHeadVOList.size()]) : null;
|
||||
}
|
||||
|
||||
// 根据筛选出的开票申请单的主键查询开票记录
|
||||
public List<IVApplogVO> queryByInvoiceNumberAndAggPK(String[] pks, String[] invoiceDate, String[] invoiceNums) throws BusinessException {
|
||||
StringBuilder sql = new StringBuilder("select lyid from " + IVApplogVO.getDefaultTableName() + " where 1=1");
|
||||
String invoiceDateStr, pkStr, invoiceNumStr;
|
||||
if (pks != null && pks.length > 0) {
|
||||
pkStr = SQLUtil.buildSqlForIn("lyid", pks);
|
||||
sql.append(" and ").append(pkStr);
|
||||
}
|
||||
if (invoiceDate != null && invoiceDate.length > 0) {
|
||||
invoiceDateStr = " KPRQ >= '" + invoiceDate[0] + "'" + " and KPRQ <=" + "'" + invoiceDate[1] + "'";
|
||||
sql.append(" and ").append(invoiceDateStr);
|
||||
}
|
||||
if (invoiceNums != null && invoiceNums.length > 0) {
|
||||
invoiceNumStr = SQLUtil.buildSqlForIn("FPHM", invoiceNums);
|
||||
sql.append(" and ").append(invoiceNumStr);
|
||||
}
|
||||
return (List<IVApplogVO>) this.getBaseDAO().executeQuery(sql.toString(), new BeanListProcessor(IVApplogVO.class));
|
||||
}
|
||||
|
||||
public List<IVApplicationHeadVO> queryHeadVOsByPks(String[] pks) throws BusinessException {
|
||||
List<IVApplicationHeadVO> applicationHeadVOList = this.queryHeadVOsByPks(pks, (Boolean) null);
|
||||
return applicationHeadVOList;
|
||||
|
|
|
@ -9,6 +9,7 @@ import nc.vo.pub.BusinessException;
|
|||
import nc.vo.pub.lang.UFDouble;
|
||||
import nc.vo.sscivm.ivsale.IVApplicationAggVO;
|
||||
import nc.vo.sscivm.ivsale.IVApplicationHeadVO;
|
||||
import nc.vo.sscivm.ivsale.IVApplogVO;
|
||||
|
||||
public interface IVApplicationQueryService {
|
||||
IVApplicationAggVO queryByPK(String var1) throws BusinessException;
|
||||
|
@ -27,10 +28,10 @@ public interface IVApplicationQueryService {
|
|||
|
||||
Map<String, List<String>> queryApplicationPksBySchema(IQueryScheme var1, String var2, Boolean var3) throws BusinessException;
|
||||
|
||||
Map<String, List<String>> queryApplicationPksBySchema(IQueryScheme var1, String var2, Boolean var3, List<Map<String, Object>> var4) throws BusinessException;
|
||||
|
||||
List<IVApplicationHeadVO> queryApplicationsBySchema(IQueryScheme var1, String var2, String var3, Boolean var4) throws BusinessException;
|
||||
|
||||
List<IVApplicationHeadVO> queryApplicationsBySchema(IQueryScheme var1, String var2, String var3, Boolean var4, Boolean var5) throws BusinessException;
|
||||
|
||||
String getDefaultOrgUnit() throws Exception;
|
||||
|
||||
MeasdocVO[] queryMeasdocByPk(String var1) throws BusinessException;
|
||||
|
@ -38,4 +39,6 @@ public interface IVApplicationQueryService {
|
|||
UFDouble queryTaxRateByMaterialPK(String var1) throws BusinessException;
|
||||
|
||||
IVApplicationHeadVO[] queryHeadVOsByFpdmFphm(String var1, String var2) throws BusinessException;
|
||||
|
||||
List<IVApplogVO> queryByInvoiceNumberAndAggPK(String[] pks, String[] invoiceDate, String[] invoiceNums) throws BusinessException;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import nc.vo.pubapp.pattern.exception.ExceptionUtils;
|
|||
import nc.vo.pubapp.query2.sql.process.QueryCondition;
|
||||
import nc.vo.pubapp.query2.sql.process.QuerySchemeProcessor;
|
||||
import nc.vo.sscivm.ivsale.IVApplicationHeadVO;
|
||||
import nc.vo.sscivm.ivsale.IVApplogVO;
|
||||
import nccloud.dto.baseapp.querytree.dataformat.QueryTreeFormatVO;
|
||||
import nccloud.framework.core.json.IJson;
|
||||
import nccloud.framework.service.ServiceLocator;
|
||||
|
@ -64,31 +65,56 @@ public class ApplicationQryAction implements ICommonAction {
|
|||
if (info.getQuerycondition() != null) {
|
||||
INCCloudQueryService ncCloudQueryService = (INCCloudQueryService) ServiceLocator.find(INCCloudQueryService.class);
|
||||
IQueryScheme scheme = ncCloudQueryService.convertCondition(info);
|
||||
|
||||
//TODO获取额外查询条件中的HPRQ和FPHM (开票日期和发票号码)
|
||||
Map<String, Object> queryMap = (Map<String, Object>) map.get("querycondition");
|
||||
List<Map<String, Object>> customQueryContion = (List<Map<String, Object>>) queryMap.get("conditions");
|
||||
List<Map<String, Object>> filteredCondition = customQueryContion.stream()
|
||||
.filter((queryItem) -> queryItem.get("field").equals("FPHM") || queryItem.get("field").equals("KPRQ"))
|
||||
.collect(Collectors.toList());
|
||||
boolean isExtraQuery = filteredCondition != null && filteredCondition.size() > 0;
|
||||
QuerySchemeProcessor processor = new QuerySchemeProcessor(scheme);
|
||||
// TODO
|
||||
|
||||
// 如果是额外查询 走额外的查询 如果不是 走正常的查询
|
||||
Map<String, List<String>> pkAndTsList =
|
||||
isExtraQuery ? queryService.queryApplicationPksBySchema(scheme, appcode, sgbzflag, customQueryContion)
|
||||
: queryService.queryApplicationPksBySchema(scheme, appcode, sgbzflag);
|
||||
|
||||
Map<String, List<String>> pkAndTsList = queryService.queryApplicationPksBySchema(scheme, appcode, sgbzflag);
|
||||
String pageSize = (String) pageInfo.get("pageSize");
|
||||
allApplicationAggVOList = queryService.queryApplicationsBySchema(scheme, pageSize, appcode, sgbzflag);
|
||||
// 拿到allApplicationVOList中的所有PK,以及查询参数中的FPHM 再查询一次数据库
|
||||
boolean isSpcialQuery = false;
|
||||
QuerySchemeProcessor processor = new QuerySchemeProcessor(scheme);
|
||||
QueryCondition kprq = processor.getQueryCondition("KPRQ");
|
||||
QueryCondition fphm = processor.getQueryCondition("FPHM");
|
||||
if (kprq == null && fphm == null) {
|
||||
allApplicationAggVOList = queryService.queryApplicationsBySchema(scheme, pageSize, appcode, sgbzflag);
|
||||
} else {
|
||||
allApplicationAggVOList = queryService.queryApplicationsBySchema(scheme, pageSize, appcode, sgbzflag, false);
|
||||
isSpcialQuery = true;
|
||||
}
|
||||
// 查询数据库 如果 kprq 和 fphm 其中一个不为空 那么就不分页 手动分页查询
|
||||
String[] invoiceDate = {};
|
||||
String[] invoiceNums = {};
|
||||
String[] filteredPks = {};
|
||||
if (isSpcialQuery) {
|
||||
if (kprq != null) {
|
||||
invoiceDate = kprq.getValues();
|
||||
}
|
||||
if (fphm != null) {
|
||||
invoiceNums = fphm.getValues();
|
||||
}
|
||||
if (allApplicationAggVOList.size() != 0) {
|
||||
List<String> ivApplicationHeadVOS = allApplicationAggVOList.stream()
|
||||
.map(IVApplicationHeadVO::getPk_ivapplication)
|
||||
.collect(Collectors.toList());
|
||||
filteredPks = ivApplicationHeadVOS.toArray(new String[0]);
|
||||
}
|
||||
// 如果条件中 填写了发票号码 执行此逻辑
|
||||
if (invoiceDate != null && invoiceDate.length > 0) {
|
||||
List<IVApplogVO> ivApplogVOS = queryService.queryByInvoiceNumberAndAggPK(filteredPks, invoiceDate, invoiceNums);
|
||||
// 将allApplicationAggVOList的主键中 ivApplogVOS每一项的lyid是否包含在内
|
||||
allApplicationAggVOList = allApplicationAggVOList.stream()
|
||||
.filter(aggVO -> ivApplogVOS.stream()
|
||||
.anyMatch(logVO -> logVO.getLyid().equals(aggVO.getPk_ivapplication())))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
filteredPks = allApplicationAggVOList.stream()
|
||||
.map(IVApplicationHeadVO::getPk_ivapplication)
|
||||
.collect(Collectors.toList()).toArray(new String[0]);
|
||||
}
|
||||
if (allApplicationAggVOList != null && allApplicationAggVOList.size() > 0) {
|
||||
invApplication = operator.toGrid(allApplicationAggVOList.toArray(new IVApplicationHeadVO[allApplicationAggVOList.size()]));
|
||||
invApplication.setPageid(pagecode);
|
||||
DataChangeLogic.setViewScala(invApplication);
|
||||
translator.translate(invApplication);
|
||||
result.put(areaid, invApplication);
|
||||
result.put("pks", pkAndTsList.get("pks"));
|
||||
result.put("pks", filteredPks.length > 0 ? filteredPks : pkAndTsList.get("pks"));
|
||||
result.put("ts", pkAndTsList.get("ts"));
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue