diff --git a/qc/META-INF/.gitkeep b/qc/META-INF/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/qc/META-INF/pc_report.rest b/qc/META-INF/pc_report.rest new file mode 100644 index 0000000..9d9c46b --- /dev/null +++ b/qc/META-INF/pc_report.rest @@ -0,0 +1,6 @@ + + + + + + diff --git a/qc/METADATA/.gitkeep b/qc/METADATA/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/qc/component.xml b/qc/component.xml new file mode 100644 index 0000000..95d5b64 --- /dev/null +++ b/qc/component.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/qc/resources/.gitkeep b/qc/resources/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/qc/script/.gitkeep b/qc/script/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/qc/src/client/.gitkeep b/qc/src/client/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/qc/src/private/.gitkeep b/qc/src/private/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/qc/src/public/nc/api/qc/resource/QcBaseRestResource.java b/qc/src/public/nc/api/qc/resource/QcBaseRestResource.java new file mode 100644 index 0000000..59b4618 --- /dev/null +++ b/qc/src/public/nc/api/qc/resource/QcBaseRestResource.java @@ -0,0 +1,315 @@ +package nc.api.qc.resource; + +import com.google.gson.Gson; +import com.google.gson.internal.LinkedTreeMap; +import nc.api.arap.util.ArapAPIUtil; +import nc.bs.framework.common.NCLocator; +import nc.bs.logging.Logger; +import nc.itf.arap.fieldmap.IBillFieldGet; +import nc.itf.arap.pub.IArapBillService; +import nc.vo.arap.basebill.BaseAggVO; +import nc.vo.arap.openapi.ArapBillOpenApiVO; +import nc.vo.arap.openapi.ArapF0EstiOpenApiVO; +import nc.vo.arap.openapi.ArapF1EstiOpenApiVO; +import nc.vo.arap.verify.ArapVerifyVO; +import nc.vo.ml.NCLangRes4VoTransl; +import nc.vo.pub.BusinessException; +import nc.vo.pub.BusinessRuntimeException; +import nc.vo.pub.lang.UFBoolean; +import nc.vo.pub.lang.UFDate; +import nc.vo.pub.lang.UFDouble; +import nccloud.api.rest.utils.NCCRestUtils; +import nccloud.api.rest.utils.ResultMessageUtil; +import nccloud.impl.platform.common.util.StringUtils; +import nccloud.pubitf.arap.openapi.IARAPOpenAPIService; +import nccloud.pubitf.arap.openapi.IBillOpenService; +import nccloud.ws.rest.resource.AbstractNCCRestResource; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.ArrayUtils; +import org.json.JSONString; + +import java.lang.reflect.Method; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class QcBaseRestResource extends AbstractNCCRestResource { + public String getModule() { + return "qc"; + } + + protected T fromJson(String json, Type clazz) { + return (T) (new Gson()).fromJson(json, clazz); + } + + public BaseAggVO fromJsonToAggVO(String json, String billtype) { + ArapBillOpenApiVO apivo = (ArapBillOpenApiVO) fromJson(json, ArapBillOpenApiVO.class); + return apivo.toAggVO(billtype); + } + + public ArapF1EstiOpenApiVO fromJsonToAggVOForSP(String json, String billtype) { + return (ArapF1EstiOpenApiVO) fromJson(json, ArapF1EstiOpenApiVO.class); + } + + public ArapF0EstiOpenApiVO fromJsonToF0AggVOForSP(String json, String billtype) { + return (ArapF0EstiOpenApiVO) fromJson(json, ArapF0EstiOpenApiVO.class); + } + + public ArapVerifyVO fromJsonToArapVerifyVO(String json) { + return (ArapVerifyVO) fromJson(json, ArapVerifyVO.class); + } + + public JSONString unCommitAndDelBill(JSONString str, String keyItem, String pk_billtype) throws BusinessException { + NCCRestUtils.initInvocationInfo(); + String json = str.toJSONString(); + Map billMap = (Map) fromJson(json, Map.class); + String[] pk_bills = null; + IBillOpenService service = (IBillOpenService) NCLocator.getInstance() + .lookup(ArapAPIUtil.getClassName(pk_billtype)); + if (StringUtils.isEmpty((String) billMap.get(keyItem))) { + try { + List returnMap = service.getPkBySrc(billMap); + if (returnMap == null) { + return ResultMessageUtil.exceptionToJSON( + NCLangRes4VoTransl.getNCLangRes().getStrByID("2006pub_0", "02006pub-0970"), "filed"); + } + + pk_bills = (String[]) returnMap.toArray(new String[returnMap.size()]); + } catch (Exception e) { + return ResultMessageUtil.exceptionToJSON(e); + } + } else { + String pk_bill = (String) billMap.get(keyItem); + pk_bills = pk_bill.split(","); + } + + try { + UFBoolean[] checkHasFlowBills = new UFBoolean[0]; + IArapBillService sservice = (IArapBillService) NCLocator.getInstance().lookup(IArapBillService.class); + checkHasFlowBills = sservice.checkHasFlowBills(pk_bills, pk_billtype); + if (!ArrayUtils.isEmpty(checkHasFlowBills) && checkHasFlowBills[0].booleanValue()) { + String mess = NCLangRes4VoTransl.getNCLangRes().getStrByID("2006pub_0", "02006pub-1680"); + throw new BusinessException(mess); + } + + Map returnMap = service.unCommitAndDelBill(pk_bills); + if (returnMap == null) { + return ResultMessageUtil.exceptionToJSON( + NCLangRes4VoTransl.getNCLangRes().getStrByID("2006pub_0", "02006pub-0970"), "filed"); + } + + return ResultMessageUtil.toJSON(returnMap); + } catch (Exception e) { + throw new BusinessException(e); + } + } + + protected JSONString queryBill(JSONString str, String pk_billtype) { + NCCRestUtils.initInvocationInfo(); + String json = str.toJSONString(); + Map conditionMap = (Map) fromJson(json, Map.class); + try { + IBillOpenService service = (IBillOpenService) NCLocator.getInstance() + .lookup(ArapAPIUtil.getClassName(pk_billtype)); + List> bills = service.queryBill(conditionMap); + if (CollectionUtils.isEmpty(bills)) { + bills = new ArrayList>(); + } + return ResultMessageUtil.toJSON(bills); + } catch (Exception e) { + return ResultMessageUtil.exceptionToJSON(e); + } + } + + protected JSONString updateBill(JSONString str, String pk_billtype) { + NCCRestUtils.initInvocationInfo(); + String json = str.toJSONString(); + Map billMap = (Map) fromJson(json, Map.class); + + try { + IBillOpenService service = (IBillOpenService) NCLocator.getInstance() + .lookup(ArapAPIUtil.getClassName(pk_billtype)); + Map returnMap = service.updateBill(billMap); + return ResultMessageUtil.toJSON(returnMap); + } catch (Exception e) { + return ResultMessageUtil.exceptionToJSON(e); + } + } + + public JSONString deleteBill(JSONString str, String keyItem, String pk_billtype) throws BusinessException { + NCCRestUtils.initInvocationInfo(); + String json = str.toJSONString(); + Map billMap = (Map) fromJson(json, Map.class); + String[] pk_bills = null; + if (StringUtils.isEmpty((String) billMap.get(keyItem))) { + try { + IBillOpenService service = (IBillOpenService) NCLocator.getInstance() + .lookup(ArapAPIUtil.getClassName(pk_billtype)); + List returnMap = service.getPkBySrc(billMap); + if (returnMap == null) { + return ResultMessageUtil.exceptionToJSON( + NCLangRes4VoTransl.getNCLangRes().getStrByID("2006pub_0", "02006pub-0970"), "filed"); + } + + pk_bills = (String[]) returnMap.toArray(new String[returnMap.size()]); + } catch (Exception e) { + return ResultMessageUtil.exceptionToJSON(e); + } + } else { + String pk_recbill = (String) billMap.get(keyItem); + pk_bills = pk_recbill.split(","); + } + + try { + IArapBillService service = (IArapBillService) NCLocator.getInstance().lookup(IArapBillService.class); + BaseAggVO[] bills = service.queryArapBillByPKs(pk_bills, pk_billtype); + if (ArrayUtils.isEmpty(bills)) { + return ResultMessageUtil.exceptionToJSON( + NCLangRes4VoTransl.getNCLangRes().getStrByID("2006pub_0", "02006pub-0970"), "filed"); + } + + for (BaseAggVO aggVo : bills) { + aggVo.getParentVO().setAttributeValue("operate", "API"); + } + ((IARAPOpenAPIService) NCLocator.getInstance().lookup(IARAPOpenAPIService.class)).executeBatchPM("DELETE", + bills); + Map returnMap = new HashMap(); + returnMap.put("successful", "Y"); + return ResultMessageUtil.toJSON(returnMap); + } catch (Exception e) { + return ResultMessageUtil.exceptionToJSON(e); + } + } + + protected JSONString isclose(Map conditionMap, String moduleID) { + if (conditionMap == null || conditionMap.size() == 0) { + return null; + } + NCCRestUtils.initInvocationInfo(); + + try { + Map res = ((IARAPOpenAPIService) NCLocator.getInstance().lookup(IARAPOpenAPIService.class)) + .queryIscloseOrIsendaccStatus(conditionMap, moduleID); + return ResultMessageUtil.toJSON(res); + } catch (Exception e) { + return ResultMessageUtil.exceptionToJSON(e); + } + } + + protected JSONString commitBill(JSONString str, String keyItem, String pk_billtype) throws BusinessException { + return commitUnCommitBill(str, keyItem, pk_billtype, "COMMIT"); + } + + protected JSONString unCommitBill(JSONString str, String keyItem, String pk_billtype) throws BusinessException { + return commitUnCommitBill(str, keyItem, pk_billtype, "UNCOMMIT"); + } + + private JSONString commitUnCommitBill(JSONString str, String keyItem, String pk_billtype, String actioncode) { + NCCRestUtils.initInvocationInfo(); + String json = str.toJSONString(); + Map billMap = (Map) fromJson(json, Map.class); + String[] pk_bills = null; + if (StringUtils.isEmpty((String) billMap.get(keyItem))) { + try { + List returnMap = ((IBillOpenService) NCLocator.getInstance().lookup(IBillOpenService.class)) + .getPkBySrc(billMap); + + if (returnMap == null) { + return ResultMessageUtil.exceptionToJSON( + NCLangRes4VoTransl.getNCLangRes().getStrByID("2006pub_0", "02006pub-0970"), "filed"); + } + pk_bills = (String[]) returnMap.toArray(new String[returnMap.size()]); + } catch (Exception e) { + return ResultMessageUtil.exceptionToJSON(e); + } + } else { + String pk_bill = (String) billMap.get(keyItem); + pk_bills = pk_bill.split(","); + } + try { + Map returnMap = ((IARAPOpenAPIService) NCLocator.getInstance() + .lookup(IARAPOpenAPIService.class)).doBatchCommit(pk_bills, pk_billtype, actioncode); + if (Integer.parseInt(returnMap.get("failNum").toString()) == 0) { + return ResultMessageUtil.toJSON(returnMap.get("message")); + } + if (Integer.parseInt(returnMap.get("successNum").toString()) == 0) { + return ResultMessageUtil.exceptionToJSON((String) returnMap.get("message"), "false"); + } + return ResultMessageUtil.toJSON(returnMap.get("message")); + } catch (Exception e) { + return ResultMessageUtil.exceptionToJSON(e); + } + } + + /** + * 转换Map为VO + */ + public static Object fromJsonToVO(Map map, Type t) { + Object obj = null; + Class clazz = (Class) t; + try { + obj = clazz.newInstance(); + Method[] methods = clazz.getMethods(); + if (methods != null) { + for (Method method : methods) { + if (method.getName().startsWith("set")) {// set方法 + String key = (method.getName().replace("set", "")).toLowerCase(); + Object value = map.get(key); + // 说明文档里。收款银行账户,付款银行账户字段拼接了ap或ar,导致此处可能获取不到值 + if (value == null && (IBillFieldGet.PAYACCOUNT.equals(key) + || IBillFieldGet.RECACCOUNT.equals(key) || IBillFieldGet.PK_PAYTERM.equals(key))) { + List> link = (List>) map + .get("items"); + if (CollectionUtils.isEmpty(link)) { + String oldkey = key; + key = "ap_" + key; + if (map.get(key) == null) { + key = "ar_" + oldkey; + } + value = map.get(key); + } else { + LinkedTreeMap linkedMap = link.get(0); + String oldkey = key; + key = "ap_" + key; + if (linkedMap.get(key) == null) { + key = "ar_" + oldkey; + } + value = linkedMap.get(key); + } + + } + if (value == null || StringUtils.isEmpty(value.toString())) + continue; + + Class[] parameterTypes = method.getParameterTypes(); + if (IBillFieldGet.PREPAY.equals(key)) { + method.invoke(obj, + (NCLangRes4VoTransl.getNCLangRes().getStrByID("2006pub_0", "02006pub-0997") + /* @res "预付款" */.equals(value) + || NCLangRes4VoTransl.getNCLangRes() + .getStrByID("2006pub_0", "02006pub-0388") + /* @res "预收款" */.equals(value)) ? 1 : 0); + } else if (parameterTypes[0] == UFBoolean.class) { + method.invoke(obj, UFBoolean.valueOf(value.toString())); + } else if (parameterTypes[0] == UFDouble.class) { + method.invoke(obj, new UFDouble(value.toString())); + } else if (parameterTypes[0] == Integer.class) { + method.invoke(obj, new Integer(value.toString())); + } else if (parameterTypes[0] == UFDate.class) { + method.invoke(obj, new UFDate(value.toString())); + } else { + method.invoke(obj, value); + } + } + } + } + } catch (Exception e) { + Logger.error(e.getMessage(), e); + throw new BusinessRuntimeException(e.getMessage()); + } + return obj; + } + +} diff --git a/qc/src/public/nc/api/qc/resource/QcconclusionRestResource.java b/qc/src/public/nc/api/qc/resource/QcconclusionRestResource.java new file mode 100644 index 0000000..4cec296 --- /dev/null +++ b/qc/src/public/nc/api/qc/resource/QcconclusionRestResource.java @@ -0,0 +1,182 @@ +package nc.api.qc.resource; + +import nc.bs.framework.common.InvocationInfoProxy; +import nc.bs.framework.common.NCLocator; +import nc.bs.trade.business.HYSuperDMO; +import nc.impl.qc.c003.maintain.ReportMaintainImpl; +import nc.itf.qc.c003.maintain.IReportMaintain; +import nc.vo.pub.BusinessException; +import nc.vo.pub.VOStatus; +import nc.vo.pub.lang.UFDouble; +import nc.vo.pubapp.pattern.model.transfer.bill.ClientBillCombinServer; +import nc.vo.qc.c003.entity.ReportItemVO; +import nc.vo.qc.c003.entity.ReportVO; +import nc.vo.qc.c003.util.ReportVOInfoUtils; +import nc.vo.scmpub.res.billtype.QCBillType; +import nc.vo.scmpub.util.ArrayUtil; +import nc.vo.scmpub.util.CollectionUtils; +import nccloud.api.rest.utils.NCCRestUtils; +import nccloud.api.rest.utils.ResultMessageUtil; +import nccloud.base.exception.ExceptionUtils; +import nccloud.framework.service.ServiceLocator; +import nccloud.pubitf.arap.arappub.IArapBillPubUtilService; +import nccloud.pubitf.riart.pflow.CloudPFlowContext; +import nccloud.pubitf.riart.pflow.ICloudScriptPFlowService; +import nccloud.pubitf.scmpub.pub.service.ISCMPubQueryService; +import org.json.JSONString; + +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.HashMap; +import java.util.List; +import java.util.Map; + +/** + * QMS灏嗘楠岀粨鏋滃洖浼犺嚦ERP璐ㄦ鎶ュ憡涓 + */ +@Path("qc/qcconclusion") +public class QcconclusionRestResource extends QcBaseRestResource { + + HYSuperDMO dmo = null; + + public HYSuperDMO getSuperDMO() { + if (dmo == null) { + dmo = new HYSuperDMO(); + } + return dmo; + } + + /** + * QMS灏嗘楠岀粨鏋滃洖浼犺嚦ERP璐ㄦ鎶ュ憡涓 + * + * @param str + * @return + */ + + @POST + @Path("/updateByqms") + @Consumes({"application/json"}) + @Produces({"application/json"}) + public JSONString updateByqms(JSONString str) throws BusinessException { + InvocationInfoProxy.getInstance().setGroupId("0001A110000000000677"); + NCCRestUtils.initInvocationInfo(); + String json = str.toJSONString(); + Map billMap = (Map) fromJson(json, Map.class); +// List list = (List) billMap.get("list"); + //鑾峰彇鍏ㄩ儴璐ㄦ鎶ュ憡 + List> itemMaps = (List) billMap.get("items"); + List list=new ArrayList(); + for (Map itemMap : itemMaps) { + list.add((String) itemMap.get("id")); + } + ReportVO[] vos = (ReportVO[])((ISCMPubQueryService) NCLocator.getInstance().lookup(ISCMPubQueryService.class)).billquery(ReportVO.class, list.toArray(new String[list.size()])); + // 1. 鍒涘缓鏂版暟缁勶紙闀垮害涓庡師鏁扮粍涓鑷达級 + ReportVO[] updatevos = new ReportVO[vos.length]; + +// 2. 閬嶅巻鍘熸暟缁勶紝瀵规瘡涓厓绱犺繘琛屾繁搴﹀厠闅 + for (int i = 0; i < vos.length; i++) { + if (vos[i] != null) { + // 鍋囪ReportVO閲嶅啓浜哻lone()鏂规硶锛屽疄鐜版繁搴﹀厠闅 + updatevos[i] = (ReportVO) vos[i].clone(); + } + } + for (ReportVO vo : vos) { + for (Map itemMap : itemMaps) { + if(itemMap.get("id").equals(vo.getHVO().getPk_reportbill())){ +//nchecknum 妫楠屼富鏁伴噺 +//ncheckastnum 妫楠屾暟閲 +//neliginum 鍚堟牸涓绘暟閲 +//neligiastnum 鍚堟牸鏁伴噺 +//nuneliginum 涓嶅悎鏍间富鏁伴噺 +//nuneligiastnum 涓嶅悎鏍兼暟閲 + vo.getHVO().setStatus(VOStatus.UPDATED); + // 妫楠屼富鏁伴噺 + vo.getHVO().setNchecknum(new UFDouble((Double)itemMap.get("nchecknum"))); + // 妫楠屾暟閲 + vo.getHVO().setNcheckastnum(new UFDouble((Double) itemMap.get("ncheckastnum"))); + // 鍚堟牸涓绘暟閲 + vo.getHVO().setNeliginum(new UFDouble((Double) itemMap.get("neliginum"))); + // 鍚堟牸鏁伴噺 + vo.getHVO().setNeligiastnum(new UFDouble((Double)itemMap.get("neligiastnum"))); + // 涓嶅悎鏍间富鏁伴噺 + vo.getHVO().setNuneliginum(new UFDouble((Double) itemMap.get("nuneliginum"))); + // 涓嶅悎鏍兼暟閲 + vo.getHVO().setNuneligiastnum(new UFDouble((Double)itemMap.get("nuneligiastnum"))); + this.appendPseudoColumn(vo); + List> mapList = (List>) itemMap.get("children"); + if(!mapList.isEmpty()){ + for (int i = 0; i < vo.getBVO().length; i++) { + for (Map childMap : mapList) { + if(vo.getBVO()[i].getCrowno().equals(childMap.get("crowno"))){ + vo.getBVO()[i].setNnum(new UFDouble((Double)childMap.get("nnum"))); + vo.getBVO()[i].setFprocessjudge(((Double)childMap.get("fprocessjudge")).intValue()); + vo.getBVO()[i].setStatus(VOStatus.UPDATED); + } + } + } + } + + } + } + } +// this.doSaveAndCombine(vos); + IReportMaintain reportMaintain=((IReportMaintain) NCLocator.getInstance().lookup(IReportMaintain.class)); + ReportVO[] resultVos= reportMaintain.saveBase(vos,new Object(),updatevos); + //璐ㄦ鎶ュ憡鏇存柊 + Map returnMap = new HashMap(); + returnMap.put("data", resultVos); + returnMap.put("success", true); + return ResultMessageUtil.toJSON(returnMap); + } + + private void doSaveAndCombine(ReportVO[] billVos) { + CloudPFlowContext context = new CloudPFlowContext(); + context.setBillType(QCBillType.ReportBill.getCode()); + context.setTrantype(billVos[0].getHVO().getVtrantypecode()); + context.setBillVos(billVos); + context.setActionName("SAVEBASE"); + ICloudScriptPFlowService service = (ICloudScriptPFlowService) NCLocator.getInstance().lookup(ICloudScriptPFlowService.class); + ReportVO[] retVOs = null; + try { + Object ret = service.exeScriptPFlow(context); + if (ret instanceof ReportVO[]) { + retVOs = (ReportVO[]) ret; + } else { + retVOs = (ReportVO[]) ((Object[]) ret)[0]; + } + } catch (Exception e) { + ExceptionUtils.wrapException(e); + } + if (!ArrayUtil.isEmpty(retVOs)) { + ClientBillCombinServer util = new ClientBillCombinServer(); + this.processDelBody(billVos); + util.combine(billVos, retVOs); + retVOs = ReportVOInfoUtils.synchBatchCodeData(billVos); + } + + } + private void processDelBody(ReportVO[] vos) { + ReportItemVO[] bodys = vos[0].getBVO(); + List realbody = new ArrayList(); + + for(ReportItemVO body : bodys) { + if (body.getStatus() != 3) { + realbody.add(body); + } + } + + vos[0].setBVO((ReportItemVO[]) CollectionUtils.listToArray(realbody)); + } + private void appendPseudoColumn(ReportVO vo) { + ReportItemVO[] bodyvos = vo.getBVO(); + if (bodyvos != null && bodyvos.length > 0) { + for(int i = 0; i < bodyvos.length; ++i) { + bodyvos[i].setAttributeValue("pseudocolumn", i); + } + } + + } +}