This commit is contained in:
hefengkai 2024-10-22 17:44:09 +08:00
commit 0fa0c1288b
4 changed files with 210 additions and 129 deletions

View File

@ -1,16 +1,13 @@
package nccloud.web.pu.dhjyd.dhjydmaster.action;
import java.util.HashMap;
import java.util.Map;
import nc.pub.billcode.vo.BillCodeContext;
import nccloud.web.codeplatform.framework.action.base.BaseAction;
import nccloud.web.codeplatform.framework.action.base.RequstParamWapper;
import nccloud.web.codeplatform.framework.action.base.RequestDTO;
import nccloud.web.codeplatform.framework.action.base.VOTransform;
import nc.itf.pu.dhjyd.dhjydmaster.IDhjydMasterVOService;
import nc.vo.pu.dhjyd.AggDhjydMasterVO;
import nccloud.framework.service.ServiceLocator;
import nccloud.framework.web.container.IRequest;
import nc.vo.pu.dhjyd.AggDhjydMasterVO;
import nc.itf.pu.dhjyd.dhjydmaster.IDhjydMasterVOService;
import nccloud.web.codeplatform.framework.action.base.BaseAction;
import nccloud.web.codeplatform.framework.action.base.RequestDTO;
import nccloud.web.codeplatform.framework.action.base.RequstParamWapper;
import nccloud.web.codeplatform.framework.action.base.VOTransform;
public class AddUnPassDhjydMasterVOAction extends BaseAction {
@ -23,11 +20,10 @@ public class AddUnPassDhjydMasterVOAction extends BaseAction {
IDhjydMasterVOService service = ServiceLocator.find(IDhjydMasterVOService.class);
AggDhjydMasterVO[] vos = service.addUnPassDhjydMasterVO(pk);
if (vos == null) {
return false;
AggDhjydMasterVO aggDhjydMasterVO = service.addUnPassDhjydMasterVO(pk);
if (aggDhjydMasterVO == null) {
return null;
}
return true;
return buildResult(param, true, null, aggDhjydMasterVO);
}
}

View File

@ -1,50 +1,38 @@
package nc.impl.pu.dhjyd.dhjydmaster;
import java.util.Map;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.UUID;
import java.lang.String;
import java.util.stream.Stream;
import nc.vo.pub.lang.UFDateTime;
import nc.vo.pub.lang.UFDouble;
import nc.uap.utils.InSQLCreator;
import nc.uif.pub.exception.UifException;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import com.informix.util.stringUtil;
import cn.hutool.core.util.NumberUtil;
import org.apache.commons.beanutils.PropertyUtils;
import nc.vo.pub.BusinessException;
import nc.vo.pub.BusinessRuntimeException;
import nc.vo.pub.ISuperVO;
import nc.vo.pub.SuperVO;
import nc.vo.pub.VOStatus;
import cn.hutool.core.bean.BeanUtil;
import nc.bs.dao.BaseDAO;
import nc.bs.framework.common.InvocationInfoProxy;
import nc.bs.pub.common.PfServiceScmUtil;
import nc.bs.trade.business.HYPubBO;
import nc.codeplatform.framework.service.ServiceSupport;
import nc.pub.billcode.vo.BillCodeContext;
import nc.vo.pu.dhjyd.DhjydMasterVO;
import nc.vo.pu.dhjyd.DhjydSlave0VO;
import nc.vo.pu.dhjyd.AggDhjydMasterVO;
import nc.itf.pu.dhjyd.dhjydmaster.IDhjydMasterVOService;
import nc.jdbc.framework.processor.ColumnProcessor;
import nc.jdbc.framework.processor.MapListProcessor;
import nc.jdbc.framework.processor.MapProcessor;
import nc.pub.billcode.vo.BillCodeContext;
import nc.vo.pu.dhjyd.AggDhjydMasterVO;
import nc.vo.pu.dhjyd.DhjydMasterVO;
import nc.vo.pu.dhjyd.DhjydSlave0VO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.ISuperVO;
import nc.vo.pub.SuperVO;
import nc.vo.pub.VOStatus;
import nc.vo.pub.lang.UFDateTime;
import nc.vo.pub.lang.UFDouble;
import nc.vo.pub.pf.BillStatusEnum;
import nc.vo.pubapp.pattern.pub.MathTool;
import nc.bs.dao.BaseDAO;
import nc.bs.framework.common.InvocationInfoProxy;
import nc.bs.trade.business.HYPubBO;
import nccloud.framework.core.exception.ExceptionUtils;
public class DhjydMasterVOServiceImpl extends ServiceSupport implements IDhjydMasterVOService {
@ -448,11 +436,20 @@ public class DhjydMasterVOServiceImpl extends ServiceSupport implements IDhjydMa
String errors = "";
for (AggDhjydMasterVO vo : vos) {
DhjydMasterVO jydMasterVO = vo.getParentVO();
String code = jydMasterVO.getAttributeValue("code") + "";
// 如果不合格检验数量>0则给出提示
UFDouble brecheck = (UFDouble) jydMasterVO.getAttributeValue("brecheck");
// System.out.println("brecheck = " + brecheck);
if (MathTool.compareTo(brecheck, UFDouble.ZERO_DBL) > 0) {
errors += "单据号:[" + jydMasterVO.getAttributeValue("code") + "]提交失败,失败原因:含有不合格数量,请检查。\n";
errors += "单据号:[" + code + "]提交失败,失败原因:含有不合格数量,请检查。\n";
}
// 存在下游的不合格检验单不能审核
String getBillSql = "select code from hfdl_chekbill_h where srcbillid = '[otherId]'";
getBillSql = getBillSql.replace("[otherId]", jydMasterVO.getPk_chekbill_h());
HashMap<String, String> headMap = (HashMap<String, String>) getBaseDAO().executeQuery(getBillSql,
new MapProcessor());
if (!headMap.isEmpty() && !StringUtils.isEmpty(headMap.get("code"))) {
errors += "单据号:[" + code + "]提交失败,失败原因:存在关联的不合格检验单,请检查。\n";
}
}
if (!"".equals(errors)) {
@ -507,12 +504,26 @@ public class DhjydMasterVOServiceImpl extends ServiceSupport implements IDhjydMa
if ("".equals(otherId) || "null".equals(otherId)) {
continue;
}
// 查询采购入库单是否存在该id
String countSql = "select count(1) from IC_PURCHASEIN_B where csourcebillhid = '[otherId]';";
countSql = countSql.replace("[otherId]", otherId);
Integer num = (Integer) getBaseDAO().executeQuery(countSql, new ColumnProcessor());
if (num > 0) {
errors += "单据号:[" + jydMasterVO.getAttributeValue("code") + "]收回失败,失败原因:到货单已入库,请勿收回。\n";
String transtype = jydMasterVO.getTranstype();
if ("DHJY-Cxx-02".equals(transtype)) {
// 不合格检验单的校验 如果上游的检验单已经审核通过则不能弃审
String getBillSql = "select approvestatus from hfdl_chekbill_h where pk_chekbill_h = '[otherId]'";
getBillSql = getBillSql.replace("[otherId]", otherId);
HashMap<String, Integer> headMap = (HashMap<String, Integer>) getBaseDAO().executeQuery(getBillSql,
new MapProcessor());
Integer status = headMap.getOrDefault("approvestatus", BillStatusEnum.FREE.toIntValue());
if (status == BillStatusEnum.APPROVED.toIntValue()) {
errors += "单据号:[" + jydMasterVO.getAttributeValue("code") + "]收回失败,失败原因:到货检验单已审核通过,请勿收回。\n";
}
} else {
// 到货检验单的校验
// 查询采购入库单是否存在该id
String countSql = "select count(1) from IC_PURCHASEIN_B where csourcebillhid = '[otherId]';";
countSql = countSql.replace("[otherId]", otherId);
Integer num = (Integer) getBaseDAO().executeQuery(countSql, new ColumnProcessor());
if (num > 0) {
errors += "单据号:[" + jydMasterVO.getAttributeValue("code") + "]收回失败,失败原因:到货单已入库,请勿收回。\n";
}
}
}
if (!"".equals(errors)) {
@ -570,18 +581,26 @@ public class DhjydMasterVOServiceImpl extends ServiceSupport implements IDhjydMa
}
@Override
public AggDhjydMasterVO[] addUnPassDhjydMasterVO(String pk) throws BusinessException {
AggDhjydMasterVO vo = dao.findByPk(AggDhjydMasterVO.class, pk, false);
public AggDhjydMasterVO addUnPassDhjydMasterVO(String pk) throws BusinessException {
AggDhjydMasterVO vo = null;
String whereSql = "srcbillid = 'pk'";
whereSql.replace("pk", pk);
AggDhjydMasterVO[] unPassVOs = dao.listByCondition(AggDhjydMasterVO.class, whereSql);
if (unPassVOs != null && unPassVOs.length > 0) {
return unPassVOs[0];
} else {
vo = dao.findByPk(AggDhjydMasterVO.class, pk, false);
}
DhjydMasterVO mainVO = vo.getParentVO();
// SuperVO mainVO = getMainVO(vo);
String oldCode = mainVO.getCode();
mainVO.setPrimaryKey(null);
mainVO.setStatus(VOStatus.NEW);
mainVO.setAttributeValue("srcbilltype", null);
// 来源单据主键改成当前传递的检验单的主键
mainVO.setAttributeValue("srcbillid", pk);
mainVO.setAttributeValue("vsourcecode", mainVO.getCode());
mainVO.setAttributeValue("vsourcecode", oldCode);
mainVO.setAttributeValue("code", null);
// mainVO.setAttributeValue("", null);
@ -612,29 +631,31 @@ public class DhjydMasterVOServiceImpl extends ServiceSupport implements IDhjydMa
"pk_billtypecode = 'DHJY-Cxx-02' ");
mainVO.setAttributeValue("transtypepk", billtypeid);
mainVO.setAttributeValue("transtype", "DHJY-Cxx-02");
// mainVO.setAttributeValue("vmemo", "mzr");
// 获取子表的数据
DhjydSlave0VO[] dhjydSlave0VOs = (DhjydSlave0VO[]) vo.getChildren(DhjydSlave0VO.class);
DhjydSlave0VO[] newVOs = new DhjydSlave0VO[3];
if (dhjydSlave0VOs != null && dhjydSlave0VOs.length > 0) {
DhjydSlave0VO subvo = dhjydSlave0VOs[0];
DhjydSlave0VO oldVo = dhjydSlave0VOs[0];
// 检查结果 合格回用不合格
String def1 = subvo.getDef1();
Object def1Code = null;
try {
def1Code = new HYPubBO().findColValue("bd_defdoc", "code", " dr = 0 and pk_defdoc='" + def1 + "' ");
} catch (UifException e) {
e.printStackTrace();
}
subvo.setPrimaryKey(null);
subvo.setStatus(VOStatus.NEW);
subvo.setAttributeValue("pk_chekbill_b", null);
subvo.setAttributeValue("srcbilltype", null);
subvo.setAttributeValue("srcbillid", null);
subvo.setAttributeValue("rowno", null);
subvo.setAttributeValue("srcrowno", null);
String def1 = oldVo.getDef1();
String getTestResCodeSql = "SELECT a.code,a.pk_defdoc "
+ "FROM bd_defdoc a LEFT JOIN bd_defdoclist b ON a.pk_defdoclist = b.pk_defdoclist "
+ "WHERE a.dr = 0 AND a.pk_defdoc = '[def1]' AND b.code = 'checkresult'";
getTestResCodeSql = getTestResCodeSql.replace("[def1]", def1);
HashMap<String, String> headMap = (HashMap<String, String>) getBaseDAO().executeQuery(getTestResCodeSql,
new MapProcessor());
String def1Code = headMap.getOrDefault("code", "");
oldVo.setPrimaryKey(null);
oldVo.setStatus(VOStatus.NEW);
oldVo.setAttributeValue("pk_chekbill_b", null);
oldVo.setAttributeValue("srcbilltype", null);
oldVo.setAttributeValue("srcbillid", null);
oldVo.setAttributeValue("rowno", null);
oldVo.setAttributeValue("srcrowno", null);
// 根据自定义档案的编码查询对应的主键
String getTestResSql = "select code,pk_defdoc from bd_defdoc where dr = 0 and code in ('01','02','03')";
String getTestResSql = "SELECT a.code,a.pk_defdoc "
+ "FROM bd_defdoc a LEFT JOIN bd_defdoclist b ON a.pk_defdoclist = b.pk_defdoclist "
+ "WHERE a.dr = 0 AND a.code IN ('01','02','03') AND b.code = 'checkresult'";
List<Map<String, Object>> testResList = (List<Map<String, Object>>) getBaseDAO().executeQuery(getTestResSql,
new MapListProcessor());
Map<String, String> testResMap = new HashMap<>();
@ -643,44 +664,101 @@ public class DhjydMasterVOServiceImpl extends ServiceSupport implements IDhjydMa
testResMap.put(map.getOrDefault("code", "") + "", map.getOrDefault("pk_defdoc", "") + "");
}
}
// UFDouble qualifiednum = oldVo.getQualifiednum();
// UFDouble nunqualifiednum = oldVo.getNunqualifiednum();
String vbatch = (oldVo.getVbatch() != null) ? oldVo.getVbatch() : "";// 批次号
// oldVo.setQualifiednum(UFDouble.ZERO_DBL);
// oldVo.setNunqualifiednum(UFDouble.ZERO_DBL);
DhjydSlave0VO vo0 = new DhjydSlave0VO();
DhjydSlave0VO vo1 = new DhjydSlave0VO();
DhjydSlave0VO vo2 = new DhjydSlave0VO();
BeanUtil.copyProperties(oldVo, vo0);
BeanUtil.copyProperties(oldVo, vo1);
BeanUtil.copyProperties(oldVo, vo2);
String[] vbatchStr = { "-合格", "-回用", "-不合格" };
// 第1行 合格 第2行 回用 第3行 不合格
if ("01".equals(def1Code)) {
// 合格
newVOs[0] = subvo;
// 不合格
DhjydSlave0VO vo2 = new DhjydSlave0VO();
vo2 = subvo;
vo2.setNunqualifiednum(UFDouble.ZERO_DBL);
// 设置检验结果的值
vo2.setAttributeValue("def1", testResMap.get("02"));
newVOs[1] = vo2;
vo2.setAttributeValue("def1", testResMap.get("03"));
newVOs[2] = vo2;
} else if ("02".equals(def1Code)) {
// vo0.setQualifiednum(qualifiednum);
vo0.setVbatch(vbatch + vbatchStr[0]);
newVOs[0] = vo0;
// 回用
newVOs[1] = subvo;
newVOs[0] = subvo;
subvo.setAttributeValue("def1", testResMap.get("01"));
newVOs[2] = subvo;
subvo.setAttributeValue("def1", testResMap.get("03"));
} else if ("03".equals(def1Code)) {
// 设置检验结果的值
vo1.setAttributeValue("def1", testResMap.get("02"));
vo1.setVbatch(vbatch + vbatchStr[1]);
newVOs[1] = vo1;
// 不合格
newVOs[2] = subvo;
// 设置检验结果的值
vo2.setAttributeValue("def1", testResMap.get("03"));
vo2.setVbatch(vbatch + vbatchStr[2]);
newVOs[2] = vo2;
// mainVO.setNnum(qualifiednum);
} else if ("02".equals(def1Code)) {
// 合格
vo0.setAttributeValue("def1", testResMap.get("01"));
vo0.setVbatch(vbatch + vbatchStr[0]);
newVOs[0] = vo0;
// 回用
// vo1.setQualifiednum(qualifiednum);
vo1.setVbatch(vbatch + vbatchStr[1]);
newVOs[1] = vo1;
// 不合格
vo2.setAttributeValue("def1", testResMap.get("03"));
vo2.setVbatch(vbatch + vbatchStr[2]);
newVOs[2] = vo2;
// mainVO.setNnum(qualifiednum);
} else if ("03".equals(def1Code)) {
// 合格
DhjydSlave0VO vo0 = new DhjydSlave0VO();
vo0 = subvo;
vo0.setQualifiednum(UFDouble.ZERO_DBL);
// 设置检验结果的值
vo0.setAttributeValue("def1", testResMap.get("01"));
vo0.setVbatch(vbatch + vbatchStr[0]);
newVOs[0] = vo0;
vo0.setAttributeValue("def1", testResMap.get("02"));
newVOs[1] = vo0;
// 回用
// 设置检验结果的值
vo1.setAttributeValue("def1", testResMap.get("02"));
vo1.setVbatch(vbatch + vbatchStr[1]);
newVOs[1] = vo1;
// 不合格
// vo2.setNunqualifiednum(nunqualifiednum);
vo2.setVbatch(vbatch + vbatchStr[2]);
newVOs[2] = vo2;
// mainVO.setNnum(nunqualifiednum);
}
}
vo.setChildren(DhjydSlave0VO.class, newVOs);
AggDhjydMasterVO[] saveAggDhjydMasterVO = this.saveAggDhjydMasterVO(vo);
return saveAggDhjydMasterVO;
// AggDhjydMasterVO[] saveAggDhjydMasterVO = this.saveAggDhjydMasterVO(vo);
return vo;
}
@Override
public void afterAuditUnPass(AggDhjydMasterVO[] vos) throws BusinessException {
if (ArrayUtils.isEmpty(vos)) {
return;
}
for (int i = 0; i < vos.length; i++) {
AggDhjydMasterVO vo = vos[i];
ISuperVO mainVo = vo.getParent();
Object srcbillid = mainVo.getAttributeValue("srcbillid");
if (srcbillid != null && "".equals(srcbillid)) {
String[] pks = { srcbillid + "" };
AggDhjydMasterVO[] listByPk = dao.listByPk(AggDhjydMasterVO.class, pks);
if(listByPk != null) {
}
// 不合格检验单审核通过后同步修改上游的到货检验单的表体
// 不合格检验单审核通过后触发上游的到货检验单审核通过
PfServiceScmUtil.processBatch("APPROVE", "DHJY", vos, null, null);
}
}
}
@Override

View File

@ -4,22 +4,19 @@ import java.util.Arrays;
import nc.bs.framework.common.NCLocator;
import nc.bs.pub.compiler.IWorkFlowRet;
import nc.vo.pub.BusinessException;
import nc.vo.pub.compiler.PfParameterVO;
import nc.vo.pub.VOStatus;
import nc.vo.uap.pf.PFBusinessException;
import nc.vo.pubapp.pattern.model.entity.bill.AbstractBill;
import nc.vo.pubapp.pattern.model.meta.entity.bill.IBillMeta;
import nc.vo.pub.CircularlyAccessibleValueObject;
import nccloud.commons.lang.StringUtils;
import nc.codeplatform.framework.service.AbstractPfScriptAction;
import nc.vo.pu.dhjyd.AggDhjydMasterVO;
import nc.itf.pu.dhjyd.dhjydmaster.IArriveToDhjyd;
import nc.itf.pu.dhjyd.dhjydmaster.IDhjydMasterVOService;
import nc.vo.pu.dhjyd.AggDhjydMasterVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.VOStatus;
import nc.vo.pub.compiler.PfParameterVO;
import nc.vo.uap.pf.PFBusinessException;
import nccloud.commons.lang.StringUtils;
public class N_DHJY_APPROVE extends AbstractPfScriptAction<AggDhjydMasterVO>{
public class N_DHJY_APPROVE extends AbstractPfScriptAction<AggDhjydMasterVO> {
public N_DHJY_APPROVE(){
public N_DHJY_APPROVE() {
super();
}
@ -27,34 +24,38 @@ public class N_DHJY_APPROVE extends AbstractPfScriptAction<AggDhjydMasterVO>{
protected Object process(PfParameterVO paraVO) throws BusinessException {
try {
IDhjydMasterVOService service = NCLocator.getInstance().lookup(IDhjydMasterVOService.class);
AggDhjydMasterVO[] vos = (AggDhjydMasterVO[])this.getVos();
Arrays.stream(vos).forEach(v-> v.getParent().setStatus(VOStatus.UPDATED));
AggDhjydMasterVO[] vos = (AggDhjydMasterVO[]) this.getVos();
Arrays.stream(vos).forEach(v -> v.getParent().setStatus(VOStatus.UPDATED));
IWorkFlowRet workFlowRet = (IWorkFlowRet)this.procActionFlow(paraVO);
IWorkFlowRet workFlowRet = (IWorkFlowRet) this.procActionFlow(paraVO);
vos = service.callbackAPPROVE(vos);
return workFlowRet==null?vos:workFlowRet;
}catch(Exception ex) {
return workFlowRet == null ? vos : workFlowRet;
} catch (Exception ex) {
if (ex instanceof BusinessException) {
throw (BusinessException) ex;
}
throw new PFBusinessException(ex.getMessage(), ex);
throw (BusinessException) ex;
}
throw new PFBusinessException(ex.getMessage(), ex);
}
}
protected void before(PfParameterVO paraVO) throws BusinessException{
AggDhjydMasterVO vo = (AggDhjydMasterVO)this.getVo();
if(StringUtils.isEmpty(vo.getPrimaryKey())){
protected void before(PfParameterVO paraVO) throws BusinessException {
AggDhjydMasterVO vo = (AggDhjydMasterVO) this.getVo();
if (StringUtils.isEmpty(vo.getPrimaryKey())) {
throw new BusinessException("当前单据未执行保存动作脚本,如果配置了业务流程定义,请检查动作驱动配置!");
}
}
protected void after(PfParameterVO paraVO) throws BusinessException {
AggDhjydMasterVO[] vos = (AggDhjydMasterVO[])this.getVos();
AggDhjydMasterVO[] vos = (AggDhjydMasterVO[]) this.getVos();
IArriveToDhjyd service = NCLocator.getInstance().lookup(IArriveToDhjyd.class);
for(int i = 0; i < vos.length; i++) {
for (int i = 0; i < vos.length; i++) {
service.writeBackQc(vos[i]);
}
// IDhjydMasterVOService dhjydMasterVOService =
// NCLocator.getInstance().lookup(IDhjydMasterVOService.class);
// dhjydMasterVOService.afterAuditUnPass(vos);
}
}

View File

@ -287,6 +287,12 @@ public interface IDhjydMasterVOService {
* 生成不合格审批单
*
*/
public AggDhjydMasterVO[] addUnPassDhjydMasterVO(String pk) throws BusinessException;
public AggDhjydMasterVO addUnPassDhjydMasterVO(String pk) throws BusinessException;
/**
* 不合格检验单审批通过之后同步调整关联的到货检验单
*
*/
public void afterAuditUnPass(AggDhjydMasterVO[] vos) throws BusinessException;
}