同步 ERP 经营办理与验收站工具、MES 制造执行及 PLM 页面更新

This commit is contained in:
Developer
2026-12-06 16:19:58 +08:00
parent cde72c1163
commit b209487661
234 changed files with 41794 additions and 258 deletions

View File

@@ -12,6 +12,23 @@ namespace Jingyao.AIEmployee
const string ContractDraftSave = "ai_合同管理_报价转合同_保存草稿";
const string ContractDraftProof = "ai_合同管理_报价转合同_保存回执";
const string RequirementContract = "ai_合同管理_需求转合同_";
const string RequirementBasis = RequirementContract+"办理依据";
const string RequirementSaveDraft = RequirementContract+"保存草稿";
const string RequirementProof = RequirementContract+"本人回执";
static bool IsRequirementContract(string name) {
return name==RequirementBasis || name==RequirementSaveDraft || name==RequirementProof;
}
static bool WritesContractForm(string name) {
return name==FormalEdit+"保存" || name==ContractDraftSave || name==RequirementSaveDraft;
}
const string FormalEdit = "ai_合同管理_正式合同修改_";
static bool IsFormalEdit(string name) {
return name==FormalEdit+"办理依据" || name==FormalEdit+"本人回执" || name==FormalEdit+"保存";
}
static decimal ContractAmount(decimal value,int places)
{
decimal result = decimal.Round(value,places,MidpointRounding.AwayFromZero);
@@ -20,7 +37,7 @@ namespace Jingyao.AIEmployee
return result;
}
static void BindContractLines(SqlCommand cmd,object[] rows,decimal taxRate,JavaScriptSerializer json)
static void BindContractLines(SqlCommand cmd,object[] rows,decimal taxRate,JavaScriptSerializer json,bool requireQuoteLine)
{
if(rows==null || rows.Length<1 || rows.Length>100) throw BadInput();
var table=new DataTable();
@@ -34,7 +51,10 @@ namespace Jingyao.AIEmployee
for(int i=0;i<rows.Length;i++) {
var row=rows[i] as Dictionary<string,object>;
if(row==null) throw BadInput();
long sourceLine=Positive(row,"sourceQuotationLineId",9007199254740991L,0);
object source;
long sourceLine=0;
if(requireQuoteLine || (row.TryGetValue("sourceQuotationLineId",out source) && source!=null))
sourceLine=Positive(row,"sourceQuotationLineId",9007199254740991L,0);
string product=QuoteString(row,"product",500,true), unit=QuoteString(row,"unit",20,true);
decimal qty=QuoteDecimal(row,"quantity",4,99999999999999.9999m,false);
decimal price=QuoteDecimal(row,"unitPrice",4,99999999999999.9999m,true);
@@ -60,17 +80,37 @@ namespace Jingyao.AIEmployee
static void BindContractDraft(SqlCommand cmd,string name,Dictionary<string,object> inputs)
{
if(name==ContractDraftProof) Only(inputs,"报价流水号","需求流水号","客户流水号","客户端请求号");
else Only(inputs,"报价流水号","需求流水号","客户流水号","原修订","客户端请求号","合同模板","提成模式","付款方式流水号","税率","交付日期","负责人","质保条款","备注","乙方资料","合同协议","产品行");
cmd.Parameters.Add("@报价流水号",SqlDbType.BigInt).Value=Positive(inputs,"报价流水号",9007199254740991L,0);
bool edit=IsFormalEdit(name);
bool direct=IsRequirementContract(name);
bool basis=name==FormalEdit+"办理依据" || name==RequirementBasis;
bool proof=name==RequirementProof || name==ContractDraftProof || name==FormalEdit+"本人回执";
string document=edit?"合同流水号":"报价流水号";
var fields=new List<string>(new[]{"需求流水号","客户流水号"});
if(!direct) fields.Add(document);
if(!basis) fields.Add("客户端请求号");
if(!basis && !proof) {
fields.AddRange(new[]{"原修订","提成模式","付款方式流水号","税率","交付日期","负责人","质保条款","备注","乙方资料","合同协议","产品行"});
if(!edit) fields.Add("合同模板");
if(direct) fields.AddRange(new[]{"跳过报价原因","定价依据","币种"});
}
Only(inputs,fields.ToArray());
if(!direct) cmd.Parameters.Add("@"+document,SqlDbType.BigInt).Value=Positive(inputs,document,9007199254740991L,0);
cmd.Parameters.Add("@需求流水号",SqlDbType.BigInt).Value=Positive(inputs,"需求流水号",9007199254740991L,0);
cmd.Parameters.Add("@客户流水号",SqlDbType.Int).Value=(int)Positive(inputs,"客户流水号",Int32.MaxValue,0);
if(basis) return;
Guid request;
if(!Guid.TryParseExact(Text(inputs,"客户端请求号",36,null),"D",out request) || request==Guid.Empty) throw BadInput();
cmd.Parameters.Add("@客户端请求号",SqlDbType.UniqueIdentifier).Value=request;
if(name==ContractDraftProof) return;
if(proof) return;
BindReviewVersion(cmd,inputs,"原修订");
cmd.Parameters.Add("@合同模板",SqlDbType.VarChar,30).Value=QuoteString(inputs,"合同模板",30,true);
if(direct) {
foreach(string field in new[]{"跳过报价原因","定价依据"})
cmd.Parameters.Add("@"+field,SqlDbType.NVarChar,500).Value=QuoteString(inputs,field,500,true);
string currency=QuoteString(inputs,"币种",3,true);
if(!System.Text.RegularExpressions.Regex.IsMatch(currency,"^[A-Z]{3}$")) throw BadInput();
cmd.Parameters.Add("@币种",SqlDbType.Char,3).Value=currency;
}
if(!edit) cmd.Parameters.Add("@合同模板",SqlDbType.VarChar,30).Value=QuoteString(inputs,"合同模板",30,true);
cmd.Parameters.Add("@提成模式",SqlDbType.VarChar,40).Value=QuoteString(inputs,"提成模式",40,true);
cmd.Parameters.Add("@付款方式流水号",SqlDbType.Int).Value=(int)Positive(inputs,"付款方式流水号",Int32.MaxValue,0);
decimal tax=QuoteDecimal(inputs,"税率",6,1,true);
@@ -89,7 +129,7 @@ namespace Jingyao.AIEmployee
var json=new JavaScriptSerializer {MaxJsonLength=QuoteBodyLimit};
object lines;
if(!inputs.TryGetValue("产品行",out lines)) throw BadInput();
BindContractLines(cmd,lines as object[],tax,json);
BindContractLines(cmd,lines as object[],tax,json,!edit && !direct);
string digest=QuoteFingerprint(cmd);
cmd.Parameters.Add("@请求指纹",SqlDbType.Char,64).Value=digest;
}

View File

@@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
namespace Jingyao.AIEmployee
{
public sealed partial class PersonalInboxHandler
{
static readonly Dictionary<string,string[]> AssemblyForms=new Dictionary<string,string[]>(StringComparer.Ordinal) {
{ "ai_报工质量终判_组装质量处置_安排返工", new[] { "确认安排返工","ncrId|@不合格流水号|id;reason|@依据|text|1000;evidenceReference|@依据引用|text|500;evidenceHash|@依据哈希|text|64;quantity|@数量|positive;workerId|@执行人编号|id","","/qms/final-decision","REWORK_ASSIGN" } },
{ "ai_报工质量终判_组装质量处置_申请处置", new[] { "确认申请处置","ncrId|@不合格流水号|id;reason|@依据|text|1000;evidenceReference|@依据引用|text|500;evidenceHash|@依据哈希|text|64;kind|@处置类型|enum;quantity|@数量|positive","SCRAP|CONCESSION","/qms/final-decision","DISPOSITION_REQUEST" } },
{ "ai_报工质量终判_组装质量处置_审批处置", new[] { "确认审批处置","ncrId|@不合格流水号|id;reason|@依据|text|1000;evidenceReference|@依据引用|text|500;evidenceHash|@依据哈希|text|64;requestId|@处置申请流水号|id;expectedVersion|@预期版本|version;decision|@结论|enum","APPROVE|REJECT","/qms/final-decision","DISPOSITION_REVIEW" } },
{ "ai_报工质量终判_组装质量处置_确认报废实物", new[] { "确认实际报废处置","ncrId|@不合格流水号|id;reason|@依据|text|1000;evidenceReference|@依据引用|text|500;evidenceHash|@依据哈希|text|64;requestId|@处置申请流水号|id;expectedVersion|@预期版本|version;expectedConfirmedQuantity|@预期已处置数量|nonnegative;quantity|@数量|positive;occurredAtUtc|@处置时间UTC|utc","","/qms/final-decision","SCRAP_CONFIRM" } },
{ "ai_通用件装配返工_返工执行_核对准备", new[] { "确认返工准备","workId|@返工任务流水号|id;expectedVersion|@预期执行版本|version?;reason|@依据|text|1000;materialEvidence|@物料依据|text|1000;checkResult|@检查结果|enum;validUntilUtc|@有效截止UTC|utc","PASS|BLOCKED","/mes/assembly-rework","PREPARE" } },
{ "ai_通用件装配返工_返工执行_开工", new[] { "确认返工开工","workId|@返工任务流水号|id;expectedVersion|@预期执行版本|version;reason|@依据|text?|1000","","/mes/assembly-rework","START" } },
{ "ai_通用件装配返工_返工执行_暂停", new[] { "确认返工暂停","workId|@返工任务流水号|id;expectedVersion|@预期执行版本|version;reason|@依据|text?|1000;pauseReason|@暂停原因|enum","OFF_DUTY|BREAK|DOWNTIME|OTHER","/mes/assembly-rework","PAUSE" } },
{ "ai_通用件装配返工_返工执行_恢复", new[] { "确认返工恢复","workId|@返工任务流水号|id;expectedVersion|@预期执行版本|version;reason|@依据|text?|1000","","/mes/assembly-rework","RESUME" } },
{ "ai_通用件装配返工_返工执行_报工", new[] { "确认返工报工","workId|@返工任务流水号|id;expectedVersion|@预期执行版本|version;reason|@依据|text?|1000;quantity|@报工数量|positive;selfQualifiedQuantity|@自检合格数量|nonnegative;pendingQuantity|@不合格待处理数量|nonnegative;exception|@异常说明|text?|1000","","/mes/assembly-rework","REPORT" } },
{ "ai_通用件装配返工_返工执行_送检", new[] { "确认返工送检","workId|@返工任务流水号|id;expectedVersion|@预期执行版本|version;reason|@依据|text|1000","","/mes/assembly-rework","SEND" } },
{ "ai_报工质量终判_组装质量处置_接收复检", new[] { "确认接收复检","workId|@返工任务流水号|id;expectedVersion|@预期执行版本|version;reason|@依据|text|1000;expectedTaskVersion|@预期送检版本|version","","/qms/final-decision","ACCEPT" } },
};
static void RegisterAssemblyDisposition()
{
foreach(var entry in AssemblyForms) MesWorkRoutes.Add(entry.Key,entry.Value[3]);
NavigationRoutes.Add("ai_通用件装配返工_返工任务_查询",new[] { "/mes/assembly-rework" });
MesResultSets.Add("ai_通用件装配返工_返工任务_查询",new[] { "context","checks","reports","audit" });
}
static bool BindAssemblyForm(SqlCommand command,string name,Dictionary<string,object> inputs)
{
string[] spec;
if (!AssemblyForms.TryGetValue(name,out spec)) return false;
BindQualityForm(command,inputs,spec);
if (command.Parameters.Contains("@执行人编号") && Convert.ToInt64(command.Parameters["@执行人编号"].Value,Invariant)>Int32.MaxValue) throw BadInput();
string op=spec[4];
if (inputs.ContainsKey("依据哈希") && !System.Text.RegularExpressions.Regex.IsMatch(Text(inputs,"依据哈希",64,null),"^[A-Fa-f0-9]{64}$")) throw BadInput();
if (op=="PAUSE" && Text(inputs,"暂停原因",30,null)=="OTHER" && String.IsNullOrWhiteSpace(Text(inputs,"依据",1000,""))) throw BadInput();
if (op=="ACCEPT" && Text(inputs,"依据",1000,"").Trim().Length<10) throw BadInput();
if (op=="REPORT") {
long good=Convert.ToInt64(command.Parameters["@自检合格数量"].Value,Invariant),bad=Convert.ToInt64(command.Parameters["@不合格待处理数量"].Value,Invariant);
if (good+bad!=Convert.ToInt64(command.Parameters["@报工数量"].Value,Invariant) || (bad>0 && String.IsNullOrWhiteSpace(Text(inputs,"异常说明",1000,"")))) throw BadInput();
}
return true;
}
static object AssemblyDispositionReceipt(SqlDataReader reader,SqlCommand command,string name)
{
var rows=ReadRows(reader,1);
if (rows.Count!=1 || reader.NextResult()) throw Unavailable();
var row=rows[0];var op=AssemblyForms[name][4];
if (!Object.Equals(row["本次动作"],op) || Convert.ToString(row["本次操作人"],Invariant)!=Convert.ToString(command.Parameters["@人员编号"].Value,Invariant) || !Object.Equals(row["幂等键"],command.Parameters["@幂等键"].Value)) throw Unavailable();
foreach(string key in new[] { "返工任务流水号","不合格流水号","处置申请流水号" }) {
if(command.Parameters.Contains("@"+key) && Convert.ToInt64(row[key],Invariant)!=Convert.ToInt64(command.Parameters["@"+key].Value,Invariant)) throw Unavailable();
}
if (Convert.ToInt64(row[command.Parameters.Contains("@返工任务流水号")?"返工任务流水号":"处置申请流水号"],Invariant)<=0) throw Unavailable();
if (op=="SCRAP_CONFIRM" && (Convert.ToInt64(row["报废确认流水号"],Invariant)<=0 || Convert.ToInt32(row["本次确认数量"],Invariant)!=Convert.ToInt32(command.Parameters["@数量"].Value,Invariant) || !Object.Equals(row["库存变更"],false))) throw Unavailable();
bool repeat=(bool)row["是否幂等返回"];
FormatMesBinaryFields(row);
return new { record=row,idempotent=repeat,refreshRequired=true,productionReady=false };
}
}
}

View File

@@ -0,0 +1,74 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
namespace Jingyao.AIEmployee
{
public sealed partial class PersonalInboxHandler
{
const string AssemblyDrillPrefix="ai_报工质量终判_组装检验演练";
static readonly Dictionary<string,string[]> AssemblyDrillForms=new Dictionary<string,string[]>(StringComparer.Ordinal) {
{ "ai_报工质量终判_组装检验演练_方案创建",new[] { "确认登记检验方案","sourceId|@送检流水号|id;expectedSourceVersion|@预期送检版本|version;planNumber|@方案编号|text|100;planVersion|@方案版本|text|40;standardVersion|@标准版本|text|100;processVersion|@工艺版本|text|100;approvalReference|@批准依据|text|500;validFrom|@有效开始|utc;validUntil|@有效截止|utc;mode|@检验方式|enum;sampleQuantity|@样本数量|positive;acceptanceNumber|@接收数|nonnegative;rejectionNumber|@拒收数|positive;samplingXml|@抽样依据|xml?;characteristicsXml|@必检项目|xml","FULL|SAMPLE" } },
{ "ai_报工质量终判_组装检验演练_方案复核",new[] { "确认复核检验方案","planId|@方案流水号|id;expectedVersion|@预期版本|version;decision|@结论|enum;opinion|@意见|text|1000","APPROVE|REJECT" } },
{ "ai_报工质量终判_组装检验演练_结果提交",new[] { "确认提交检验结果","planId|@方案流水号|id;expectedPlanVersion|@预期方案版本|version;priorRejectedResultId|@前次驳回结果|id?;releaseQuantity|@拟放行数量|nonnegative;rejectedQuantity|@不合格数量|nonnegative;pendingQuantity|@待定数量|nonnegative;measurementsXml|@测量记录|xml;qualificationReference|@人员资质依据|text|500;description|@提交说明|text|1000","" } },
{ "ai_报工质量终判_组装检验演练_结果复核",new[] { "确认复核检验结果","resultId|@结果流水号|id;expectedVersion|@预期版本|version;decision|@结论|enum;opinion|@意见|text|1000","APPROVE|REJECT" } },
{ "ai_报工质量终判_组装检验演练_项目草稿保存",new[] { "确认仅保存检验项目表草稿","sourceId|@送检流水号|id;expectedSourceVersion|@预期送检版本|version;expectedDraftVersion|@预期草稿版本|version;title|@标题|text|100;note|@说明|text?|1000;itemsXml|@项目内容|xml","" } },
};
static bool AssemblyDrillCase(string name)
{
return name==AssemblyDrillPrefix || name==AssemblyDrillPrefix+"_送检任务" || name==AssemblyDrillPrefix+"_项目草稿查询" || AssemblyDrillForms.ContainsKey(name);
}
static void RegisterAssemblyDrill()
{
var route=new[] { "/qms/final-decision" };
foreach(string suffix in new[] { "", "_送检任务", "_项目草稿查询" }) NavigationRoutes.Add(AssemblyDrillPrefix+suffix,route);
MesResultSets.Add(AssemblyDrillPrefix,new[] { "source","plans","results","permissions" });
MesResultSets.Add(AssemblyDrillPrefix+"_送检任务",new[] { "rows","page" });
MesResultSets.Add(AssemblyDrillPrefix+"_项目草稿查询",new[] { "drafts" });
foreach(string name in AssemblyDrillForms.Keys) MesWorkRoutes.Add(name,route[0]);
}
static object AssemblyAuditReceipt(SqlCommand write,string name,Dictionary<string,object> row)
{
var suffix=name.Substring(AssemblyDrillPrefix.Length+1);
string action,field;
switch (suffix) {
case "方案创建": action="PLAN_CREATE";field="方案流水号";break;
case "方案复核": action="PLAN_REVIEW";field="方案流水号";break;
case "结果提交": action="RESULT_SUBMIT";field="结果流水号";break;
case "结果复核": action="RESULT_REVIEW";field="结果流水号";break;
default: throw Unavailable();
}
object key;
if(!row.TryGetValue(field,out key) || Convert.ToInt64(key)<1) throw Unavailable();
using(var audit=new SqlCommand("dbo.[ai_报工质量终判_组装检验演练_办理回执]",write.Connection)) {
audit.CommandType=CommandType.StoredProcedure;
audit.Parameters.Add("@人员编号",SqlDbType.Int).Value=write.Parameters["@人员编号"].Value;
audit.Parameters.Add("@动作",SqlDbType.VarChar,30).Value=action;
audit.Parameters.Add("@幂等键",SqlDbType.NVarChar,100).Value=write.Parameters["@幂等键"].Value;
audit.Parameters.Add("@对象流水号",SqlDbType.BigInt).Value=key;
using(var reader=audit.ExecuteReader()) {
var records=ReadRows(reader,1);
if(records.Count!=1 || reader.NextResult() || Convert.ToInt64(records[0]["对象流水号"])!=Convert.ToInt64(key)) throw Unavailable();
records[0][field]=key;
return new { record=records[0],productionReady=false,refreshRequired=true };
}
}
}
static void BindAssemblyDrill(SqlCommand command,string name,Dictionary<string,object> inputs,Dictionary<string,object> body)
{
string[] form;
if (AssemblyDrillForms.TryGetValue(name,out form)) { BindQualityForm(command,inputs,form); return; }
Only(inputs,"送检流水号");
if(name==AssemblyDrillPrefix+"_送检任务") {
MesOptional(command,inputs,"送检流水号",SqlDbType.BigInt);
command.Parameters.Add("@页码",SqlDbType.Int).Value=(int)Positive(body,"pageList",100000,1);
command.Parameters.Add("@每页条数",SqlDbType.Int).Value=(int)Positive(body,"pageSize",100,20);
} else command.Parameters.Add("@送检流水号",SqlDbType.BigInt).Value=Positive(inputs,"送检流水号",9007199254740991L,0);
}
}
}

View File

@@ -0,0 +1,398 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Globalization;
namespace Jingyao.AIEmployee
{
public sealed partial class PersonalInboxHandler
{
static bool ApsWindowOpen()
{
return String.Equals(System.Configuration.ConfigurationManager.AppSettings["MesApsWriteWindow"], "enabled", StringComparison.Ordinal);
}
static void RegisterMesCrossDomain()
{
RegisterSeikoDrill();
RegisterAssemblyDisposition();
NavigationRoutes.Add("ai_组装排产与派工_送检交接_查询",new[] { "/mes/assembly-schedule" });
MesResultSets.Add("ai_组装排产与派工_送检交接_查询",new[] { "context","rows","lines","page" });
MesWorkRoutes.Add("ai_组装排产与派工_送检交接_发出","/mes/assembly-schedule");
MesWorkRoutes.Add("ai_报工质量终判_组装送检_接收","/qms/final-decision");
NavigationRoutes.Add("ai_报工质量终判_组装送检_查询",new[] { "/qms/final-decision" });
MesResultSets.Add("ai_报工质量终判_组装送检_查询",new[] { "context","rows","lines","page" });
NavigationRoutes.Add("ai_报工质量终判_组装质量处置_查询",new[] { "/qms/final-decision" });
MesResultSets.Add("ai_报工质量终判_组装质量处置_查询",new[] { "rows","summary" });
NavigationRoutes.Add("ai_报工质量终判_组装检验_查询",new[] { "/qms/final-decision" });
MesResultSets.Add("ai_报工质量终判_组装检验_查询",new[] { "source","plans","results" });
NavigationRoutes.Add("ai_报工质量终判_组装质量链_查询",new[] { "/qms/final-decision" });
MesResultSets.Add("ai_报工质量终判_组装质量链_查询",new[] { "context","nodes","events","dispositions" });
NavigationRoutes.Add("ai_报工质量终判_组装质量处置_详情",new[] { "/qms/final-decision" });
MesResultSets.Add("ai_报工质量终判_组装质量处置_详情",new[] { "context","plan","result","requests","workers","scrapHistory","scrapSummary" });
NavigationRoutes.Add("ai_MES跨系统办理_本人权限与职责", new[] { "/wms/replenishment", "/aps/readiness-preparation", "/aps/mes-handoff-request", "/qms/seiko-process-release", "/qms/final-decision", "/qms/ncr-disposition", "/qms/rework-reinspection" });
MesResultSets.Add("ai_MES跨系统办理_本人权限与职责", new[] { "permissions", "duties" });
NavigationRoutes.Add("ai_补料管理_补货物料_查询", new[] { "/wms/replenishment" });
MesResultSets.Add("ai_补料管理_补货物料_查询", new[] { "rows", "page" });
NavigationRoutes.Add("ai_补料管理_补货草稿_查询", new[] { "/wms/replenishment" });
MesResultSets.Add("ai_补料管理_补货草稿_查询", new[] { "rows", "history" });
MesWorkRoutes.Add("ai_补料管理_补货草稿_保存", "/wms/replenishment");
MesWorkRoutes.Add("ai_补料管理_补货草稿_移除", "/wms/replenishment");
MesWorkRoutes.Add("ai_补料管理_补货申请_提交", "/wms/replenishment");
MesWorkRoutes.Add("ai_补料管理_外购补货_纠偏并交接采购", "/wms/replenishment");
MesWorkRoutes.Add("ai_排产准备检查_排产准备_登记检查", "/aps/readiness-preparation");
MesWorkRoutes.Add("ai_排产准备检查_工程定义绑定_创建", "/aps/readiness-preparation");
MesWorkRoutes.Add("ai_排产准备检查_排产准备_创建", "/aps/readiness-preparation");
MesWorkRoutes.Add("ai_排产准备检查_排产准备_生成草案", "/aps/readiness-preparation");
NavigationRoutes.Add("ai_排产准备检查_工程定义门禁_查询", new[] { "/aps/readiness-preparation" });
MesResultSets.Add("ai_排产准备检查_工程定义门禁_查询", new[] { "gate", "candidates", "events" });
NavigationRoutes.Add("ai_排产准备检查_交接箱_查询", new[] { "/aps/readiness-preparation" });
MesResultSets.Add("ai_排产准备检查_交接箱_查询", new[] { "rows", "page", "lines" });
NavigationRoutes.Add("ai_排产准备检查_排产准备_查询", new[] { "/aps/readiness-preparation" });
MesResultSets.Add("ai_排产准备检查_排产准备_查询", new[] { "rows", "page" });
NavigationRoutes.Add("ai_排产准备检查_资源候选_查询", new[] { "/aps/readiness-preparation" });
MesResultSets.Add("ai_排产准备检查_资源候选_查询", new[] { "devices", "people", "skills", "skillSummary" });
NavigationRoutes.Add("ai_APS转MES下达申请_本机发布台账_查询", new[] { "/aps/mes-handoff-request" });
MesResultSets.Add("ai_APS转MES下达申请_本机发布台账_查询", new[] { "rows", "page" });
NavigationRoutes.Add("ai_APS转MES下达申请_APS转MES下达申请_查询", new[] { "/aps/mes-handoff-request" });
MesResultSets.Add("ai_APS转MES下达申请_APS转MES下达申请_查询", new[] { "rows", "page" });
MesWorkRoutes.Add("ai_APS转MES下达申请_转MES下达申请_创建", "/aps/mes-handoff-request");
MesWorkRoutes.Add("ai_APS转MES下达申请_转MES下达申请_流转", "/aps/mes-handoff-request");
NavigationRoutes.Add("ai_报工质量终判_MES报工申请_查询", new[] { "/qms/final-decision" });
MesResultSets.Add("ai_报工质量终判_MES报工申请_查询", new[] { "rows", "page" });
NavigationRoutes.Add("ai_报工质量终判_QMS质量终判_查询", new[] { "/qms/final-decision", "/qms/ncr-disposition" });
MesResultSets.Add("ai_报工质量终判_QMS质量终判_查询", new[] { "rows", "page" });
MesWorkRoutes.Add("ai_报工质量终判_质量终判_创建", "/qms/final-decision");
MesWorkRoutes.Add("ai_报工质量终判_质量终判_登记检验", "/qms/final-decision");
MesWorkRoutes.Add("ai_报工质量终判_质量终判_流转", "/qms/final-decision");
NavigationRoutes.Add("ai_NCR责任判定与处置_QMS_NCR处置_查询", new[] { "/qms/ncr-disposition" });
MesResultSets.Add("ai_NCR责任判定与处置_QMS_NCR处置_查询", new[] { "rows", "page" });
MesWorkRoutes.Add("ai_NCR责任判定与处置_NCR处置_创建", "/qms/ncr-disposition");
MesWorkRoutes.Add("ai_NCR责任判定与处置_NCR处置_登记方案", "/qms/ncr-disposition");
MesWorkRoutes.Add("ai_NCR责任判定与处置_NCR处置_流转", "/qms/ncr-disposition");
NavigationRoutes.Add("ai_返工复检与NCR关闭_MES返工接收_查询", new[] { "/qms/rework-reinspection" });
MesResultSets.Add("ai_返工复检与NCR关闭_MES返工接收_查询", new[] { "rows", "page" });
NavigationRoutes.Add("ai_返工复检与NCR关闭_返工复检_查询", new[] { "/qms/rework-reinspection" });
MesResultSets.Add("ai_返工复检与NCR关闭_返工复检_查询", new[] { "rows", "page" });
MesWorkRoutes.Add("ai_返工复检与NCR关闭_返工复检_创建", "/qms/rework-reinspection");
MesWorkRoutes.Add("ai_返工复检与NCR关闭_返工复检_登记结果", "/qms/rework-reinspection");
MesWorkRoutes.Add("ai_返工复检与NCR关闭_返工复检_流转", "/qms/rework-reinspection");
}
static void CrossDate(SqlCommand command, Dictionary<string,object> inputs, string field)
{
DateTime date;
if (!DateTime.TryParseExact(Text(inputs,field,10,null), "yyyy-MM-dd", Invariant, DateTimeStyles.None, out date)) throw BadInput();
command.Parameters.Add("@"+field, SqlDbType.Date).Value=date;
}
static bool BindMesCrossDomain(SqlCommand command, string name, Dictionary<string,object> inputs, Dictionary<string,object> body)
{
if (BindAssemblyForm(command,name,inputs)) return true;
string route;
if (MesWorkRoutes.TryGetValue(name, out route) && route.StartsWith("/aps/", StringComparison.Ordinal) && !ApsWindowOpen())
throw new ApiFailure(403, "本站的 APS 办理窗口尚未开启");
switch (name) {
case "ai_通用件装配返工_返工任务_查询":
Only(inputs,"返工任务流水号");
ReworkKey(command,inputs,"返工任务流水号");
return true;
case "ai_组装排产与派工_送检交接_发出":
case "ai_报工质量终判_组装送检_接收":
bool accepting = name=="ai_报工质量终判_组装送检_接收";
if(accepting) {
Only(inputs,"装配计划流水号","装配执行流水号","预期计划版本","预期执行版本","组装送检流水号","预期任务版本","依据","确认声明","幂等键");
ReworkKey(command,inputs,"组装送检流水号");
MesVersion(command,inputs,"预期任务版本");
} else Only(inputs,"装配计划流水号","装配执行流水号","预期计划版本","预期执行版本","依据","确认声明","幂等键");
ReworkKey(command,inputs,"装配计划流水号"); ReworkKey(command,inputs,"装配执行流水号");
MesVersion(command,inputs,"预期计划版本"); MesVersion(command,inputs,"预期执行版本");
AddText(command,inputs,"依据",1000,"");
AddText(command,inputs,"确认声明",30,null,"CONFIRMED");
string handoffKey=Text(inputs,"幂等键",100,null);
if (!System.Text.RegularExpressions.Regex.IsMatch(handoffKey,@"\A[A-Za-z0-9_.:-]+\z")) throw BadInput();
command.Parameters.Add("@幂等键",SqlDbType.NVarChar,100).Value=handoffKey;
return true;
case "ai_组装排产与派工_送检交接_查询":
case "ai_报工质量终判_组装送检_查询":
Only(inputs,"装配计划流水号");
MesOptional(command,inputs,"装配计划流水号",SqlDbType.BigInt);
command.Parameters.Add("@页码",SqlDbType.Int).Value=(int)Positive(body,"pageList",100000,1);
command.Parameters.Add("@每页条数",SqlDbType.Int).Value=(int)Positive(body,"pageSize",50,25);
return true;
case "ai_报工质量终判_组装质量处置_查询":
Only(inputs,"状态");
string status=Text(inputs,"状态",10,"PENDING");
if(status!="PENDING" && status!="ALL") throw BadInput();
command.Parameters.Add("@待审批",SqlDbType.Bit).Value=status=="PENDING";
command.Parameters.Add("@页码",SqlDbType.Int).Value=(int)Positive(body,"pageList",100000,1);
command.Parameters.Add("@每页条数",SqlDbType.Int).Value=(int)Positive(body,"pageSize",50,25);
return true;
case "ai_报工质量终判_组装检验_查询":
Only(inputs,"送检流水号");
ReworkKey(command,inputs,"送检流水号");
return true;
case "ai_报工质量终判_组装质量链_查询":
Only(inputs,"送检流水号");
ReworkKey(command,inputs,"送检流水号");
return true;
case "ai_报工质量终判_组装质量处置_详情":
Only(inputs,"送检流水号","报废页码","报废每页条数");
ReworkKey(command,inputs,"送检流水号");
command.Parameters.Add("@报废页码",SqlDbType.Int).Value=(int)Positive(inputs,"报废页码",100000,1);
command.Parameters.Add("@报废每页条数",SqlDbType.Int).Value=(int)Positive(inputs,"报废每页条数",50,25);
return true;
case "ai_MES跨系统办理_本人权限与职责":
Only(inputs);
return true;
case "ai_补料管理_补货物料_查询":
Only(inputs, "补货类型", "关键词");
AddText(command, inputs, "补货类型", 20, null, "PURCHASE", "SELF_MADE");
AddText(command, inputs, "关键词", 100, "");
command.Parameters.Add("@页码", SqlDbType.Int).Value = (int)Positive(body, "pageList", 100000, 1);
command.Parameters.Add("@每页条数", SqlDbType.Int).Value = (int)Positive(body, "pageSize", 300, 100);
return true;
case "ai_补料管理_补货草稿_查询":
Only(inputs, "补货类型");
AddText(command, inputs, "补货类型", 20, null, "PURCHASE", "SELF_MADE");
return true;
case "ai_补料管理_补货草稿_保存":
Only(inputs, "补货类型", "物料流水号", "补货数量", "确认声明", "幂等键");
AddText(command, inputs, "补货类型", 20, null, "PURCHASE", "SELF_MADE");
command.Parameters.Add("@物料流水号", SqlDbType.Int).Value = (int)Positive(inputs, "物料流水号", Int32.MaxValue, 0);
command.Parameters.Add("@补货数量", SqlDbType.Int).Value = (int)Positive(inputs, "补货数量", 1000000, 0);
AddText(command, inputs, "确认声明", 100, "");
BindIdempotency(command, inputs, true);
return true;
case "ai_补料管理_补货草稿_移除":
Only(inputs, "补货草稿明细流水号", "确认声明", "幂等键");
ReworkKey(command, inputs, "补货草稿明细流水号");
AddText(command, inputs, "确认声明", 100, "");
BindIdempotency(command, inputs, true);
return true;
case "ai_补料管理_补货申请_提交":
Only(inputs, "补货类型", "补货期限", "申请说明", "确认声明", "幂等键");
AddText(command, inputs, "补货类型", 20, null, "PURCHASE", "SELF_MADE");
CrossDate(command, inputs, "补货期限");
AddText(command, inputs, "申请说明", 1000, null);
AddText(command, inputs, "确认声明", 100, "");
BindIdempotency(command, inputs, true);
return true;
case "ai_补料管理_外购补货_纠偏并交接采购":
Only(inputs, "补货申请流水号", "处置原因", "确认声明", "幂等键");
ReworkKey(command, inputs, "补货申请流水号");
AddText(command, inputs, "处置原因", 500, null);
AddText(command, inputs, "确认声明", 100, "");
BindIdempotency(command, inputs, true);
return true;
case "ai_排产准备检查_排产准备_登记检查":
Only(inputs, "排产准备流水号", "检查项", "结论", "依据", "幂等键");
ReworkKey(command, inputs, "排产准备流水号");
AddText(command, inputs, "检查项", 20, null, "PROCESS_BOM", "MATERIAL", "CAPACITY", "DUE_DATE");
AddText(command, inputs, "结论", 10, null, "PASS", "FAIL");
AddText(command, inputs, "依据", 500, null);
BindIdempotency(command, inputs, true);
return true;
case "ai_排产准备检查_工程定义绑定_创建":
Only(inputs, "排产准备流水号", "工程定义快照流水号", "别名映射状态流水号", "绑定原因", "确认声明", "幂等键");
ReworkKey(command, inputs, "排产准备流水号");
ReworkKey(command, inputs, "工程定义快照流水号");
ReworkKey(command, inputs, "别名映射状态流水号");
AddText(command, inputs, "绑定原因", 500, null);
AddText(command, inputs, "确认声明", 100, "");
BindIdempotency(command, inputs, true);
command.Parameters.Add("@关联标识", SqlDbType.UniqueIdentifier).Value = Guid.NewGuid();
return true;
case "ai_排产准备检查_排产准备_创建":
Only(inputs, "APS交接流水号", "幂等键");
ReworkKey(command, inputs, "APS交接流水号");
BindIdempotency(command, inputs, true);
return true;
case "ai_排产准备检查_排产准备_生成草案":
Only(inputs, "排产准备流水号", "幂等键");
ReworkKey(command, inputs, "排产准备流水号");
BindIdempotency(command, inputs, true);
return true;
case "ai_排产准备检查_工程定义门禁_查询":
Only(inputs, "排产准备流水号");
ReworkKey(command, inputs, "排产准备流水号");
return true;
case "ai_排产准备检查_交接箱_查询":
Only(inputs, "APS交接流水号", "生产需求流水号", "状态", "关键字");
MesOptional(command, inputs, "APS交接流水号", SqlDbType.BigInt);
MesOptional(command, inputs, "生产需求流水号", SqlDbType.BigInt);
AddText(command, inputs, "状态", 30, "");
AddText(command, inputs, "关键字", 200, "");
command.Parameters.Add("@页码", SqlDbType.Int).Value = (int)Positive(body, "pageList", 100000, 1);
command.Parameters.Add("@每页条数", SqlDbType.Int).Value = (int)Positive(body, "pageSize", 200, 50);
return true;
case "ai_排产准备检查_排产准备_查询":
Only(inputs, "排产准备流水号", "APS交接流水号", "状态", "关键字");
MesOptional(command, inputs, "排产准备流水号", SqlDbType.BigInt);
MesOptional(command, inputs, "APS交接流水号", SqlDbType.BigInt);
AddText(command, inputs, "状态", 20, "");
AddText(command, inputs, "关键字", 200, "");
command.Parameters.Add("@页码", SqlDbType.Int).Value = (int)Positive(body, "pageList", 100000, 1);
command.Parameters.Add("@每页条数", SqlDbType.Int).Value = (int)Positive(body, "pageSize", 200, 50);
return true;
case "ai_排产准备检查_资源候选_查询":
Only(inputs, "关键字");
AddText(command, inputs, "关键字", 100, "");
return true;
case "ai_APS转MES下达申请_本机发布台账_查询":
Only(inputs, "发布执行流水号", "发布审批流水号", "状态");
MesOptional(command, inputs, "发布执行流水号", SqlDbType.BigInt);
MesOptional(command, inputs, "发布审批流水号", SqlDbType.BigInt);
AddText(command, inputs, "状态", 30, "");
command.Parameters.Add("@页码", SqlDbType.Int).Value = (int)Positive(body, "pageList", 100000, 1);
command.Parameters.Add("@每页条数", SqlDbType.Int).Value = (int)Positive(body, "pageSize", 200, 50);
return true;
case "ai_APS转MES下达申请_APS转MES下达申请_查询":
Only(inputs, "MES下达申请流水号", "发布执行流水号", "状态");
MesOptional(command, inputs, "MES下达申请流水号", SqlDbType.BigInt);
MesOptional(command, inputs, "发布执行流水号", SqlDbType.BigInt);
AddText(command, inputs, "状态", 30, "");
command.Parameters.Add("@页码", SqlDbType.Int).Value = (int)Positive(body, "pageList", 100000, 1);
command.Parameters.Add("@每页条数", SqlDbType.Int).Value = (int)Positive(body, "pageSize", 200, 50);
return true;
case "ai_APS转MES下达申请_转MES下达申请_创建":
Only(inputs, "发布执行流水号", "幂等键");
ReworkKey(command, inputs, "发布执行流水号");
BindIdempotency(command, inputs, true);
return true;
case "ai_APS转MES下达申请_转MES下达申请_流转":
Only(inputs, "MES下达申请流水号", "动作", "意见", "幂等键");
ReworkKey(command, inputs, "MES下达申请流水号");
AddText(command, inputs, "动作", 20, null);
AddText(command, inputs, "意见", 1000, "");
BindIdempotency(command, inputs, true);
return true;
case "ai_报工质量终判_MES报工申请_查询":
Only(inputs, "报工申请流水号", "开工门禁流水号", "状态");
MesOptional(command, inputs, "报工申请流水号", SqlDbType.BigInt);
MesOptional(command, inputs, "开工门禁流水号", SqlDbType.BigInt);
AddText(command, inputs, "状态", 40, "");
command.Parameters.Add("@页码", SqlDbType.Int).Value = (int)Positive(body, "pageList", 100000, 1);
command.Parameters.Add("@每页条数", SqlDbType.Int).Value = (int)Positive(body, "pageSize", 300, 300);
return true;
case "ai_报工质量终判_QMS质量终判_查询":
Only(inputs, "质量终判流水号", "报工申请流水号", "状态");
MesOptional(command, inputs, "质量终判流水号", SqlDbType.BigInt);
MesOptional(command, inputs, "报工申请流水号", SqlDbType.BigInt);
AddText(command, inputs, "状态", 40, "");
command.Parameters.Add("@页码", SqlDbType.Int).Value = (int)Positive(body, "pageList", 100000, 1);
command.Parameters.Add("@每页条数", SqlDbType.Int).Value = (int)Positive(body, "pageSize", 300, 300);
return true;
case "ai_报工质量终判_质量终判_创建":
Only(inputs, "报工申请流水号", "预期报工版本", "预期门禁版本", "幂等键");
ReworkKey(command, inputs, "报工申请流水号");
MesVersion(command, inputs, "预期报工版本");
MesVersion(command, inputs, "预期门禁版本");
BindIdempotency(command, inputs, true);
return true;
case "ai_报工质量终判_质量终判_登记检验":
Only(inputs, "质量终判流水号", "质量终判明细流水号", "检验结论", "终判合格数量", "终判不合格数量", "缺陷代码", "缺陷说明", "检验证据", "预期版本", "预期明细版本", "预期报工版本", "预期报工明细版本", "预期门禁版本", "幂等键");
ReworkKey(command, inputs, "质量终判流水号");
ReworkKey(command, inputs, "质量终判明细流水号");
AddText(command, inputs, "检验结论", 20, null);
MesQuantity(command, inputs, "终判合格数量", 4);
MesQuantity(command, inputs, "终判不合格数量", 4);
AddText(command, inputs, "缺陷代码", 100, "");
AddText(command, inputs, "缺陷说明", 1000, "");
AddText(command, inputs, "检验证据", 1000, null);
MesVersion(command, inputs, "预期版本");
MesVersion(command, inputs, "预期明细版本");
MesVersion(command, inputs, "预期报工版本");
MesVersion(command, inputs, "预期报工明细版本");
MesVersion(command, inputs, "预期门禁版本");
BindIdempotency(command, inputs, true);
return true;
case "ai_报工质量终判_质量终判_流转":
Only(inputs, "质量终判流水号", "动作", "意见", "确认声明", "预期版本", "预期报工版本", "预期门禁版本", "幂等键");
ReworkKey(command, inputs, "质量终判流水号");
AddText(command, inputs, "动作", 30, null);
AddText(command, inputs, "意见", 1000, "");
AddText(command, inputs, "确认声明", 100, "");
MesVersion(command, inputs, "预期版本");
MesVersion(command, inputs, "预期报工版本");
MesVersion(command, inputs, "预期门禁版本");
BindIdempotency(command, inputs, true);
return true;
case "ai_NCR责任判定与处置_QMS_NCR处置_查询":
Only(inputs, "NCR处置流水号", "NCR候选流水号", "状态");
MesOptional(command, inputs, "NCR处置流水号", SqlDbType.BigInt);
MesOptional(command, inputs, "NCR候选流水号", SqlDbType.BigInt);
AddText(command, inputs, "状态", 40, "");
command.Parameters.Add("@页码", SqlDbType.Int).Value = (int)Positive(body, "pageList", 100000, 1);
command.Parameters.Add("@每页条数", SqlDbType.Int).Value = (int)Positive(body, "pageSize", 300, 300);
return true;
case "ai_NCR责任判定与处置_NCR处置_创建":
Only(inputs, "NCR候选流水号", "幂等键");
ReworkKey(command, inputs, "NCR候选流水号");
BindIdempotency(command, inputs, true);
return true;
case "ai_NCR责任判定与处置_NCR处置_登记方案":
Only(inputs, "NCR处置流水号", "处置方式", "责任部门", "原因判定", "纠正要求", "计划完成日期", "处置证据", "幂等键");
ReworkKey(command, inputs, "NCR处置流水号");
AddText(command, inputs, "处置方式", 30, null);
AddText(command, inputs, "责任部门", 100, null);
AddText(command, inputs, "原因判定", 1000, null);
AddText(command, inputs, "纠正要求", 1000, null);
CrossDate(command, inputs, "计划完成日期");
AddText(command, inputs, "处置证据", 1000, null);
BindIdempotency(command, inputs, true);
return true;
case "ai_NCR责任判定与处置_NCR处置_流转":
Only(inputs, "NCR处置流水号", "动作", "意见", "确认声明", "幂等键");
ReworkKey(command, inputs, "NCR处置流水号");
AddText(command, inputs, "动作", 30, null);
AddText(command, inputs, "意见", 1000, "");
AddText(command, inputs, "确认声明", 100, "");
BindIdempotency(command, inputs, true);
return true;
case "ai_返工复检与NCR关闭_MES返工接收_查询":
Only(inputs, "返工接收流水号", "返工候选流水号", "状态");
MesOptional(command, inputs, "返工接收流水号", SqlDbType.BigInt);
MesOptional(command, inputs, "返工候选流水号", SqlDbType.BigInt);
AddText(command, inputs, "状态", 40, "");
command.Parameters.Add("@页码", SqlDbType.Int).Value = (int)Positive(body, "pageList", 100000, 1);
command.Parameters.Add("@每页条数", SqlDbType.Int).Value = (int)Positive(body, "pageSize", 300, 300);
return true;
case "ai_返工复检与NCR关闭_返工复检_查询":
Only(inputs, "返工复检流水号", "复检候选流水号", "状态");
MesOptional(command, inputs, "返工复检流水号", SqlDbType.BigInt);
MesOptional(command, inputs, "复检候选流水号", SqlDbType.BigInt);
AddText(command, inputs, "状态", 40, "");
command.Parameters.Add("@页码", SqlDbType.Int).Value = (int)Positive(body, "pageList", 100000, 1);
command.Parameters.Add("@每页条数", SqlDbType.Int).Value = (int)Positive(body, "pageSize", 300, 300);
return true;
case "ai_返工复检与NCR关闭_返工复检_创建":
Only(inputs, "复检候选流水号", "幂等键");
ReworkKey(command, inputs, "复检候选流水号");
BindIdempotency(command, inputs, true);
return true;
case "ai_返工复检与NCR关闭_返工复检_登记结果":
Only(inputs, "返工复检流水号", "复检结论", "合格数量", "不合格数量", "缺陷代码", "缺陷说明", "复检证据", "幂等键");
ReworkKey(command, inputs, "返工复检流水号");
AddText(command, inputs, "复检结论", 20, null);
MesQuantity(command, inputs, "合格数量", 4);
MesQuantity(command, inputs, "不合格数量", 4);
AddText(command, inputs, "缺陷代码", 100, "");
AddText(command, inputs, "缺陷说明", 1000, "");
AddText(command, inputs, "复检证据", 1000, null);
BindIdempotency(command, inputs, true);
return true;
case "ai_返工复检与NCR关闭_返工复检_流转":
Only(inputs, "返工复检流水号", "动作", "意见", "确认声明", "幂等键");
ReworkKey(command, inputs, "返工复检流水号");
AddText(command, inputs, "动作", 30, null);
AddText(command, inputs, "意见", 1000, "");
AddText(command, inputs, "确认声明", 100, "");
BindIdempotency(command, inputs, true);
return true;
default: return false;
}
}
}
}

View File

@@ -0,0 +1,142 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
namespace Jingyao.AIEmployee
{
public sealed partial class PersonalInboxHandler
{
static readonly Dictionary<string,string[]> MesResultSets = new Dictionary<string,string[]>(StringComparer.Ordinal) {
{ "ai_订单装配选型_配置详情", new[] { "record", "options", "values", "snapshots", "cascades" } },
{ "ai_订单装配选型_传动方式联动候选", new[] { "rows" } },
{ "ai_专机装配工作台_BOM版本", new[] { "rows" } },
{ "ai_专机装配工作台_工程变更", new[] { "rows" } },
{ "ai_专机装配工作台_版本门禁", new[] { "rows" } },
{ "ai_专机工作包执行", new[] { "summary", "tasks", "materials", "requests", "transitions", "movements" } },
{ "ai_专机装配工作台_项目工作包", new[] { "record", "packages", "materials", "receiptTasks" } },
{ "ai_组装排产与派工", new[] { "summary", "plans", "sourceSummary", "sources", "preparationSummary", "preparations" } },
{ "ai_组装返工待办", new[] { "rows", "summary" } },
{ "ai_装配领补退料_装配计划", new[] { "summary", "tasks", "materials", "requests", "postings" } },
{ "ai_装配领补退料_工单草稿", new[] { "summary", "tasks", "materials", "requests", "postings" } },
{ "ai_精工分批接收_任务依据", new[] { "rows" } },
{ "ai_专机装配工作台_投产接收人", new[] { "rows" } },
{ "ai_专机装配工作台_旧专机在制", new[] { "orders", "components" } }
};
static void RegisterMesLinkedRoutes()
{
NavigationRoutes.Add("ai_订单装配选型_配置详情", new[] { "/mes/assembly-configuration" });
NavigationRoutes.Add("ai_订单装配选型_传动方式联动候选", new[] { "/mes/assembly-configuration" });
NavigationRoutes.Add("ai_专机装配工作台_BOM版本", new[] { "/mes/special-machine-workbench" });
NavigationRoutes.Add("ai_专机装配工作台_工程变更", new[] { "/mes/special-machine-workbench" });
NavigationRoutes.Add("ai_专机装配工作台_版本门禁", new[] { "/mes/special-machine-workbench" });
NavigationRoutes.Add("ai_专机工作包执行", new[] { "/mes/special-machine-execution" });
NavigationRoutes.Add("ai_专机装配工作台_项目工作包", new[] { "/mes/special-machine-workbench" });
NavigationRoutes.Add("ai_组装排产与派工", new[] { "/mes/assembly-schedule" });
NavigationRoutes.Add("ai_组装返工待办", new[] { "/mes/assembly-rework" });
NavigationRoutes.Add("ai_装配领补退料_装配计划", new[] { "/mes/assembly-schedule", "/mes/assembly-material-flow" });
NavigationRoutes.Add("ai_装配领补退料_工单草稿", new[] { "/mes/assembly-material-flow", "/mes/assembly-schedule" });
NavigationRoutes.Add("ai_精工分批接收_任务依据", new[] { "/mes/seiko-partial-transfer" });
NavigationRoutes.Add("ai_专机装配工作台_投产接收人", new[] { "/mes/assembly-configuration", "/mes/assembly-schedule", "/mes/special-machine-workbench", "/mes/special-machine-execution" });
NavigationRoutes.Add("ai_专机装配工作台_旧专机在制", new[] { "/mes/special-machine-workbench" });
}
static bool BindMesLinkedQuery(SqlCommand command,string name,Dictionary<string,object> inputs,Dictionary<string,object> body)
{
switch(name) {
case "ai_订单装配选型_配置详情":
Only(inputs, "订单配置流水号");
MesOptional(command,inputs,"订单配置流水号",SqlDbType.BigInt);
return true;
case "ai_订单装配选型_传动方式联动候选":
Only(inputs, "订单配置流水号", "上游选项代码", "上游选项值代码");
MesOptional(command,inputs,"订单配置流水号",SqlDbType.BigInt);
AddText(command,inputs,"上游选项代码",50,"");
AddText(command,inputs,"上游选项值代码",100,"");
return true;
case "ai_专机装配工作台_BOM版本":
Only(inputs, "Keyword", "VersionStatus");
AddText(command,inputs,"Keyword",100,"");
AddText(command,inputs,"VersionStatus",20,"");
return true;
case "ai_专机装配工作台_工程变更":
Only(inputs, "Keyword", "ChangeStatus");
AddText(command,inputs,"Keyword",100,"");
AddText(command,inputs,"ChangeStatus",30,"");
return true;
case "ai_专机装配工作台_版本门禁":
Only(inputs, "Keyword", "GateStatus");
AddText(command,inputs,"Keyword",100,"");
AddText(command,inputs,"GateStatus",20,"");
return true;
case "ai_专机工作包执行":
Only(inputs, "专机工作包接收任务流水号", "ERP项目流水号", "关键词", "状态");
MesOptional(command,inputs,"专机工作包接收任务流水号",SqlDbType.BigInt);
MesOptional(command,inputs,"ERP项目流水号",SqlDbType.Int);
AddText(command,inputs,"关键词",200,"");
AddText(command,inputs,"状态",40,"");
command.Parameters.Add("@页码",SqlDbType.Int).Value=(int)Positive(body,"pageList",100000,1);
command.Parameters.Add("@每页条数",SqlDbType.Int).Value=(int)Positive(body,"pageSize",200,25);
return true;
case "ai_专机装配工作台_项目工作包":
Only(inputs, "ERP项目流水号");
MesOptional(command,inputs,"ERP项目流水号",SqlDbType.Int);
return true;
case "ai_组装排产与派工":
Only(inputs, "关键词");
AddText(command,inputs,"关键词",200,"");
command.Parameters.Add("@页码",SqlDbType.Int).Value=(int)Positive(body,"pageList",100000,1);
command.Parameters.Add("@每页条数",SqlDbType.Int).Value=(int)Positive(body,"pageSize",100,25);
return true;
case "ai_组装返工待办":
Only(inputs, "仅待办");
MesOptional(command,inputs,"仅待办",SqlDbType.Bit);
command.Parameters.Add("@页码",SqlDbType.Int).Value=(int)Positive(body,"pageList",100000,1);
command.Parameters.Add("@每页条数",SqlDbType.Int).Value=(int)Positive(body,"pageSize",50,25);
return true;
case "ai_装配领补退料_装配计划":
Only(inputs, "装配计划流水号", "关键词");
MesOptional(command,inputs,"装配计划流水号",SqlDbType.BigInt);
AddText(command,inputs,"关键词",200,"");
command.Parameters.Add("@页码",SqlDbType.Int).Value=(int)Positive(body,"pageList",100000,1);
command.Parameters.Add("@每页条数",SqlDbType.Int).Value=(int)Positive(body,"pageSize",100,25);
return true;
case "ai_装配领补退料_工单草稿":
Only(inputs, "MES工单草稿流水号", "机械任务流水号", "关键词", "状态");
MesOptional(command,inputs,"MES工单草稿流水号",SqlDbType.BigInt);
MesOptional(command,inputs,"机械任务流水号",SqlDbType.BigInt);
AddText(command,inputs,"关键词",200,"");
AddText(command,inputs,"状态",30,"");
command.Parameters.Add("@页码",SqlDbType.Int).Value=(int)Positive(body,"pageList",100000,1);
command.Parameters.Add("@每页条数",SqlDbType.Int).Value=(int)Positive(body,"pageSize",200,25);
return true;
case "ai_精工分批接收_任务依据":
Only(inputs, "后序任务");
MesOptional(command,inputs,"后序任务",SqlDbType.Int);
return true;
case "ai_专机装配工作台_投产接收人":
Only(inputs, "目标代码");
AddText(command,inputs,"目标代码",40,"");
return true;
case "ai_专机装配工作台_旧专机在制":
Only(inputs, "关键词");
AddText(command,inputs,"关键词",200,"");
return true;
default: return false;
}
}
static List<Dictionary<string,object>> ReadMesLinkedQuery(SqlDataReader reader,string[] sets)
{
var result=new List<Dictionary<string,object>>();
foreach(string set in sets) {
if (set!=sets[0] && !reader.NextResult()) throw Unavailable();
foreach(var row in ReadRows(reader,100000)) {
row.Add("结果集",set);
FormatMesBinaryFields(row);
result.Add(row);
}
}
if(reader.NextResult()) throw Unavailable();
return result;
}
}
}

View File

@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Globalization;
namespace Jingyao.AIEmployee
{
public sealed partial class PersonalInboxHandler
{
const string PackageReceipt = "ai_专机工作包执行_接收办理";
const string PackageExecution = "ai_专机工作包执行_执行办理";
static bool MesPackageAction(string name) { return name == PackageReceipt || name == PackageExecution; }
static void PackageDate(SqlCommand command, Dictionary<string,object> inputs, string field)
{
string value = Text(inputs,field,10,"");
if (value.Length == 0) return;
DateTime parsed;
if (!DateTime.TryParseExact(value,"yyyy-MM-dd",Invariant,DateTimeStyles.None,out parsed)) throw BadInput();
command.Parameters.Add("@" + field,SqlDbType.Date).Value = parsed;
}
static void BindMesPackage(SqlCommand command, string name, Dictionary<string,object> inputs)
{
if (name == PackageReceipt) {
Only(inputs,"专机工作包接收任务流水号","动作","新接收人编号","计划开工日期","计划完工日期","意见","确认声明","幂等键");
ReworkKey(command,inputs,"专机工作包接收任务流水号");
AddText(command,inputs,"动作",20,null,"ACCEPT","REJECT","REASSIGN");
MesOptional(command,inputs,"新接收人编号",SqlDbType.Int);
PackageDate(command,inputs,"计划开工日期");
PackageDate(command,inputs,"计划完工日期");
AddText(command,inputs,"意见",1000,"");
} else {
Only(inputs,"专机工作包执行流水号","动作","说明","证据","确认声明","幂等键");
ReworkKey(command,inputs,"专机工作包执行流水号");
AddText(command,inputs,"动作",30,null,"START","REPORT_COMPLETE","CLOSE");
AddText(command,inputs,"说明",1000,"");
AddText(command,inputs,"证据",2000,"");
}
AddText(command,inputs,"确认声明",30,null,"CONFIRMED");
BindIdempotency(command,inputs,true);
}
}
}

View File

@@ -0,0 +1,220 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Globalization;
namespace Jingyao.AIEmployee
{
public sealed partial class PersonalInboxHandler
{
static PersonalInboxHandler()
{
RegisterMesLinkedRoutes();
RegisterMesCrossDomain();
NavigationRoutes.Add("ai_精工领料出库",new[] { "/mes/seiko-material-requisition" });
NavigationRoutes.Add("ai_精工生产执行",new[] { "/mes/seiko-production-execution" });
NavigationRoutes.Add("ai_精工完工复核",new[] { "/mes/seiko-completion-review" });
NavigationRoutes.Add("ai_报工申请与复核",new[] { "/mes/reporting-review" });
NavigationRoutes.Add("ai_开工前门禁",new[] { "/mes/reporting-review", "/mes/start-gate" });
NavigationRoutes.Add("ai_工单草稿审核",new[] { "/mes/work-order-draft-review", "/mes/dispatch-pool", "/mes/start-gate" });
NavigationRoutes.Add("ai_待派工池",new[] { "/mes/dispatch-pool", "/mes/start-gate" });
NavigationRoutes.Add("ai_APS下达待接收箱",new[] { "/mes/aps-receipt-inbox", "/mes/work-order-draft-review" });
NavigationRoutes.Add("ai_返工接收与重新送检",new[] { "/mes/rework-receipt" });
NavigationRoutes.Add("ai_返工接收与重新送检_NCR处置",new[] { "/mes/rework-receipt" });
NavigationRoutes.Add("ai_返工接收与重新送检_质量终判",new[] { "/mes/rework-receipt" });
NavigationRoutes.Add("ai_APS下达待接收箱_下达申请",new[] { "/mes/aps-receipt-inbox" });
NavigationRoutes.Add("ai_订单装配选型",new[] { "/mes/assembly-configuration" });
NavigationRoutes.Add("ai_订单装配选型_旧版选型",new[] { "/mes/assembly-configuration" });
NavigationRoutes.Add("ai_专机装配工作台_接管记录",new[] { "/mes/special-machine-workbench" });
NavigationRoutes.Add("ai_精工生产任务查询_订单选项",new[] { "/mes/seiko-production-task-query" });
NavigationRoutes.Add("ai_精工生产任务查询_产品选项",new[] { "/mes/seiko-production-task-query" });
NavigationRoutes.Add("ai_精工生产任务查询_任务清单",new[] { "/mes/seiko-production-task-query" });
NavigationRoutes.Add("ai_精工生产任务查询_工序追溯",new[] { "/mes/seiko-production-task-query" });
NavigationRoutes.Add("ai_MES制造执行_本人操作权限",new[] { "/mes/control-center", "/mes/seiko-production-task-query", "/mes/seiko-material-requisition", "/mes/seiko-production-execution", "/mes/seiko-completion-review", "/mes/seiko-partial-transfer", "/mes/assembly-configuration", "/mes/assembly-schedule", "/mes/assembly-rework", "/mes/assembly-material-flow", "/mes/special-machine-workbench", "/mes/special-machine-execution", "/mes/reporting-review", "/mes/internal-rework-domain-acceptance", "/mes/aps-receipt-inbox", "/mes/work-order-draft-review", "/mes/dispatch-pool", "/mes/start-gate", "/mes/rework-receipt" });
}
static bool MesUnpaged(string name)
{
return name=="ai_精工生产任务查询_订单选项" || name=="ai_精工生产任务查询_产品选项" || name=="ai_精工生产任务查询_工序追溯" || name=="ai_MES制造执行_本人操作权限";
}
static void MesOptional(SqlCommand command, Dictionary<string,object> inputs,string key,SqlDbType type)
{
object raw;
if (!inputs.TryGetValue(key,out raw) || raw==null || Object.Equals(raw,"")) return;
object value;
if (type==SqlDbType.DateTime) {
DateTime date;
if (!DateTime.TryParseExact(Convert.ToString(raw,Invariant),new[] {"yyyy-MM-dd","yyyy-MM-dd HH:mm:ss"},Invariant,DateTimeStyles.None,out date)) throw BadInput();
value=date;
} else {
long number;
if (!Int64.TryParse(Convert.ToString(raw,Invariant),NumberStyles.None,Invariant,out number) || number<0 ||
(type==SqlDbType.Int && number>Int32.MaxValue) || (type==SqlDbType.Bit && number>1)) throw BadInput();
value=number;
}
command.Parameters.Add("@"+key,type).Value=value;
}
static bool BindMesQuery(SqlCommand command,string name,Dictionary<string,object> inputs,Dictionary<string,object> body)
{
if (BindMesLinkedQuery(command,name,inputs,body)) return true;
switch(name) {
case "ai_精工领料出库":
Only(inputs ,"关键字","状态");
AddText(command,inputs,"关键字",200,"");
AddText(command,inputs,"状态",30,"");
command.Parameters.Add("@页码",SqlDbType.Int).Value=(int)Positive(body,"pageList",100000,1);
command.Parameters.Add("@每页条数",SqlDbType.Int).Value=(int)Positive(body,"pageSize",300,25);
return true;
case "ai_精工生产执行":
Only(inputs ,"关键字","状态");
AddText(command,inputs,"关键字",200,"");
AddText(command,inputs,"状态",30,"");
command.Parameters.Add("@页码",SqlDbType.Int).Value=(int)Positive(body,"pageList",100000,1);
command.Parameters.Add("@每页条数",SqlDbType.Int).Value=(int)Positive(body,"pageSize",300,25);
return true;
case "ai_精工完工复核":
Only(inputs ,"关键字","状态");
AddText(command,inputs,"关键字",200,"");
AddText(command,inputs,"状态",30,"");
command.Parameters.Add("@页码",SqlDbType.Int).Value=(int)Positive(body,"pageList",100000,1);
command.Parameters.Add("@每页条数",SqlDbType.Int).Value=(int)Positive(body,"pageSize",300,25);
return true;
case "ai_报工申请与复核":
Only(inputs ,"报工申请流水号","开工门禁流水号","状态");
MesOptional(command,inputs,"报工申请流水号",SqlDbType.BigInt);
MesOptional(command,inputs,"开工门禁流水号",SqlDbType.BigInt);
AddText(command,inputs,"状态",40,"");
command.Parameters.Add("@页码",SqlDbType.Int).Value=(int)Positive(body,"pageList",100000,1);
command.Parameters.Add("@每页条数",SqlDbType.Int).Value=(int)Positive(body,"pageSize",300,25);
return true;
case "ai_开工前门禁":
Only(inputs ,"开工门禁流水号","待派工流水号","状态");
MesOptional(command,inputs,"开工门禁流水号",SqlDbType.BigInt);
MesOptional(command,inputs,"待派工流水号",SqlDbType.BigInt);
AddText(command,inputs,"状态",40,"");
command.Parameters.Add("@页码",SqlDbType.Int).Value=(int)Positive(body,"pageList",100000,1);
command.Parameters.Add("@每页条数",SqlDbType.Int).Value=(int)Positive(body,"pageSize",300,25);
return true;
case "ai_工单草稿审核":
Only(inputs ,"工单审核流水号","MES工单草稿流水号","状态");
MesOptional(command,inputs,"工单审核流水号",SqlDbType.BigInt);
MesOptional(command,inputs,"MES工单草稿流水号",SqlDbType.BigInt);
AddText(command,inputs,"状态",30,"");
command.Parameters.Add("@页码",SqlDbType.Int).Value=(int)Positive(body,"pageList",100000,1);
command.Parameters.Add("@每页条数",SqlDbType.Int).Value=(int)Positive(body,"pageSize",300,25);
return true;
case "ai_待派工池":
Only(inputs ,"待派工流水号","工单审核流水号","状态");
MesOptional(command,inputs,"待派工流水号",SqlDbType.BigInt);
MesOptional(command,inputs,"工单审核流水号",SqlDbType.BigInt);
AddText(command,inputs,"状态",40,"");
command.Parameters.Add("@页码",SqlDbType.Int).Value=(int)Positive(body,"pageList",100000,1);
command.Parameters.Add("@每页条数",SqlDbType.Int).Value=(int)Positive(body,"pageSize",300,25);
return true;
case "ai_APS下达待接收箱":
Only(inputs ,"MES接收流水号","MES下达申请流水号","MES工单草稿流水号","状态");
MesOptional(command,inputs,"MES接收流水号",SqlDbType.BigInt);
MesOptional(command,inputs,"MES下达申请流水号",SqlDbType.BigInt);
MesOptional(command,inputs,"MES工单草稿流水号",SqlDbType.BigInt);
AddText(command,inputs,"状态",30,"");
command.Parameters.Add("@页码",SqlDbType.Int).Value=(int)Positive(body,"pageList",100000,1);
command.Parameters.Add("@每页条数",SqlDbType.Int).Value=(int)Positive(body,"pageSize",300,25);
return true;
case "ai_返工接收与重新送检":
Only(inputs ,"返工接收流水号","返工候选流水号","状态");
MesOptional(command,inputs,"返工接收流水号",SqlDbType.BigInt);
MesOptional(command,inputs,"返工候选流水号",SqlDbType.BigInt);
AddText(command,inputs,"状态",40,"");
command.Parameters.Add("@页码",SqlDbType.Int).Value=(int)Positive(body,"pageList",100000,1);
command.Parameters.Add("@每页条数",SqlDbType.Int).Value=(int)Positive(body,"pageSize",300,25);
return true;
case "ai_返工接收与重新送检_NCR处置":
Only(inputs ,"NCR处置流水号","NCR候选流水号","状态");
MesOptional(command,inputs,"NCR处置流水号",SqlDbType.BigInt);
MesOptional(command,inputs,"NCR候选流水号",SqlDbType.BigInt);
AddText(command,inputs,"状态",40,"");
command.Parameters.Add("@页码",SqlDbType.Int).Value=(int)Positive(body,"pageList",100000,1);
command.Parameters.Add("@每页条数",SqlDbType.Int).Value=(int)Positive(body,"pageSize",300,25);
return true;
case "ai_返工接收与重新送检_质量终判":
Only(inputs ,"质量终判流水号","报工申请流水号","状态");
MesOptional(command,inputs,"质量终判流水号",SqlDbType.BigInt);
MesOptional(command,inputs,"报工申请流水号",SqlDbType.BigInt);
AddText(command,inputs,"状态",40,"");
command.Parameters.Add("@页码",SqlDbType.Int).Value=(int)Positive(body,"pageList",100000,1);
command.Parameters.Add("@每页条数",SqlDbType.Int).Value=(int)Positive(body,"pageSize",300,25);
return true;
case "ai_APS下达待接收箱_下达申请":
Only(inputs ,"MES下达申请流水号","发布执行流水号","状态");
MesOptional(command,inputs,"MES下达申请流水号",SqlDbType.BigInt);
MesOptional(command,inputs,"发布执行流水号",SqlDbType.BigInt);
AddText(command,inputs,"状态",30,"");
command.Parameters.Add("@页码",SqlDbType.Int).Value=(int)Positive(body,"pageList",100000,1);
command.Parameters.Add("@每页条数",SqlDbType.Int).Value=(int)Positive(body,"pageSize",300,25);
return true;
case "ai_订单装配选型":
Only(inputs ,"销售订单流水号","产品类别代码","状态","关键字");
MesOptional(command,inputs,"销售订单流水号",SqlDbType.BigInt);
AddText(command,inputs,"产品类别代码",30,"");
AddText(command,inputs,"状态",30,"");
AddText(command,inputs,"关键字",200,"");
command.Parameters.Add("@页码",SqlDbType.Int).Value=(int)Positive(body,"pageList",100000,1);
command.Parameters.Add("@每页条数",SqlDbType.Int).Value=(int)Positive(body,"pageSize",300,25);
return true;
case "ai_订单装配选型_旧版选型":
Only(inputs ,"关键字","产品类别代码");
AddText(command,inputs,"关键字",200,"");
AddText(command,inputs,"产品类别代码",30,"");
command.Parameters.Add("@页码",SqlDbType.Int).Value=(int)Positive(body,"pageList",100000,1);
command.Parameters.Add("@每页条数",SqlDbType.Int).Value=(int)Positive(body,"pageSize",300,25);
return true;
case "ai_专机装配工作台_接管记录":
Only(inputs ,"关键字","旧机床流水号","ERP项目流水号");
AddText(command,inputs,"关键字",200,"");
MesOptional(command,inputs,"旧机床流水号",SqlDbType.Int);
MesOptional(command,inputs,"ERP项目流水号",SqlDbType.Int);
command.Parameters.Add("@页码",SqlDbType.Int).Value=(int)Positive(body,"pageList",100000,1);
command.Parameters.Add("@每页条数",SqlDbType.Int).Value=(int)Positive(body,"pageSize",300,25);
return true;
case "ai_精工生产任务查询_订单选项":
Only(inputs);
return true;
case "ai_精工生产任务查询_产品选项":
Only(inputs ,"订单流水号");
MesOptional(command,inputs,"订单流水号",SqlDbType.Int);
return true;
case "ai_精工生产任务查询_任务清单":
Only(inputs ,"时间_check","开始时间","结束时间","订单流水号","订单流水号_check","组件流水号","组件流水号_check","零件名称_check","零件名称","图号_check","图号","状态流水号_check","状态流水号","排序名称","排序方式");
MesOptional(command,inputs,"时间_check",SqlDbType.Bit);
MesOptional(command,inputs,"开始时间",SqlDbType.DateTime);
MesOptional(command,inputs,"结束时间",SqlDbType.DateTime);
MesOptional(command,inputs,"订单流水号",SqlDbType.Int);
MesOptional(command,inputs,"订单流水号_check",SqlDbType.Int);
MesOptional(command,inputs,"组件流水号",SqlDbType.Int);
MesOptional(command,inputs,"组件流水号_check",SqlDbType.Int);
MesOptional(command,inputs,"零件名称_check",SqlDbType.Int);
AddText(command,inputs,"零件名称",50,"");
MesOptional(command,inputs,"图号_check",SqlDbType.Int);
AddText(command,inputs,"图号",50,"");
MesOptional(command,inputs,"状态流水号_check",SqlDbType.Bit);
AddText(command,inputs,"状态流水号",50,"");
MesOptional(command,inputs,"排序名称",SqlDbType.Int);
MesOptional(command,inputs,"排序方式",SqlDbType.Int);
command.Parameters.Add("@页码",SqlDbType.Int).Value=(int)Positive(body,"pageList",100000,1);
command.Parameters.Add("@每页条数",SqlDbType.Int).Value=(int)Positive(body,"pageSize",300,25);
return true;
case "ai_精工生产任务查询_工序追溯":
Only(inputs ,"工艺计划流水号");
MesOptional(command,inputs,"工艺计划流水号",SqlDbType.Int);
return true;
case "ai_MES制造执行_本人操作权限":
Only(inputs);
return true;
default: return false;
}
}
}
}

View File

@@ -0,0 +1,84 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Globalization;
using System.Text.RegularExpressions;
namespace Jingyao.AIEmployee
{
public sealed partial class PersonalInboxHandler
{
const string ReportCreate="ai_报工申请与复核_建立申请", ReportLine="ai_报工申请与复核_登记明细", ReportTransition="ai_报工申请与复核_办理";
static bool MesReportAction(string name) { return name==ReportCreate || name==ReportLine || name==ReportTransition; }
static void MesVersion(SqlCommand command,Dictionary<string,object> input,string field)
{
string value=Text(input,field,18,null);
if (!Regex.IsMatch(value,@"\A(?:0x)?[0-9A-Fa-f]{16}\z")) throw BadInput();
if(value.Length==18) value=value.Substring(2);
byte[] bytes=new byte[8];
for(int i=0;i<8;i++) bytes[i]=Byte.Parse(value.Substring(i*2,2),NumberStyles.HexNumber,Invariant);
command.Parameters.Add("@"+field,SqlDbType.Binary,8).Value=bytes;
}
static decimal MesQuantity(SqlCommand command,Dictionary<string,object> input,string field,byte scale)
{
object raw; decimal value;
if (!input.TryGetValue(field,out raw) || raw==null ||
!Decimal.TryParse(Convert.ToString(raw,Invariant),NumberStyles.AllowDecimalPoint,Invariant,out value) ||
value<0 || value!=Decimal.Round(value,scale) || value>=(scale==4 ? 100000000000000m : 10000000000000000m)) throw BadInput();
var p=command.Parameters.Add("@"+field,SqlDbType.Decimal);p.Precision=18;p.Scale=scale;p.Value=value;
return value;
}
static void BindMesReport(SqlCommand command,string name,Dictionary<string,object> inputs)
{
if (name==ReportCreate) {
Only(inputs,"开工门禁流水号","预期门禁版本","幂等键");
ReworkKey(command,inputs,"开工门禁流水号");
} else if (name==ReportLine) {
Only(inputs,"报工申请流水号","报工明细流水号","完成数量","合格数量","不合格数量","实际分钟","报工证据","预期申请版本","预期明细版本","预期门禁版本","幂等键");
ReworkKey(command,inputs,"报工申请流水号");ReworkKey(command,inputs,"报工明细流水号");
decimal completed=MesQuantity(command,inputs,"完成数量",4), good=MesQuantity(command,inputs,"合格数量",4), bad=MesQuantity(command,inputs,"不合格数量",4);
if (completed<=0 || good+bad!=completed || MesQuantity(command,inputs,"实际分钟",2)<=0) throw BadInput();
AddText(command,inputs,"报工证据",1000,null);
MesVersion(command,inputs,"预期申请版本");MesVersion(command,inputs,"预期明细版本");
} else {
Only(inputs,"报工申请流水号","动作","意见","确认声明","预期版本","预期门禁版本","幂等键");
ReworkKey(command,inputs,"报工申请流水号");
string action=Text(inputs,"动作",30,null);
if (Array.IndexOf(new[]{"SUBMIT","APPROVE","REJECT","REVISE","POST"},action)<0) throw BadInput();
AddText(command,inputs,"动作",30,null);AddText(command,inputs,"意见",1000,"");AddText(command,inputs,"确认声明",100,"");
MesVersion(command,inputs,"预期版本");
}
MesVersion(command,inputs,"预期门禁版本");
BindIdempotency(command,inputs,true);
}
static void FormatMesBinaryFields(Dictionary<string,object> row)
{
foreach (string key in new List<string>(row.Keys)) {
byte[] value = row[key] as byte[];
if (value != null) row[key] = "0x" + BitConverter.ToString(value).Replace("-","");
}
}
static bool IsMesNavigationRead(string name)
{
string[] routes;
return NavigationRoutes.TryGetValue(name,out routes) &&
Array.Exists(routes,route => route.StartsWith("/mes/",StringComparison.Ordinal));
}
static object MesReportReceipt(SqlDataReader reader)
{
var rows=ReadRows(reader,1);
if(rows.Count!=1 || reader.NextResult()) throw Unavailable();
var row=rows[0];object replay;
if(!row.TryGetValue("是否幂等返回",out replay) || !(replay is bool)) throw Unavailable();
FormatMesBinaryFields(row);
return new { record=row, idempotent=(bool)replay };
}
}
}

View File

@@ -0,0 +1,169 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Globalization;
using System.IO;
using System.Xml;
namespace Jingyao.AIEmployee
{
public sealed partial class PersonalInboxHandler
{
const string SeikoDrillQuery = "ai_精工工序质量放行_隔离演练";
static readonly Dictionary<string,string[]> SeikoDrillForms = new Dictionary<string,string[]>(StringComparer.Ordinal) {
{ "ai_精工工序质量放行_隔离演练_精工质量送检_创建",new[] { "确认送检","reportId|@精工完工报工流水号|id;expectedReportVersion|@预期报工版本|version;expectedRouteHash|@预期路线快照指纹|hash;batch|@送检批次|text|100;quantity|@送检数量|positive;unit|@单位|text|10;evidence|@报检依据|text|1000","" } },
{ "ai_精工工序质量放行_隔离演练_精工检验方案_创建",new[] { "确认登记检验方案","sourceId|@送检流水号|id;expectedSourceVersion|@预期送检版本|version;planNumber|@方案编号|text|100;planVersion|@方案版本|text|40;standardVersion|@标准版本|text|100;processVersion|@工艺版本|text|100;approvalReference|@批准依据|text|500;validFrom|@有效开始|utc;validUntil|@有效截止|utc;mode|@检验方式|enum;sampleQuantity|@样本数量|positive;acceptanceNumber|@接收数|nonnegative;rejectionNumber|@拒收数|positive;samplingXml|@抽样依据|xml?;characteristicsXml|@必检项目|xml","FULL|SAMPLE" } },
{ "ai_精工工序质量放行_隔离演练_精工检验方案_复核",new[] { "确认复核检验方案","planId|@方案流水号|id;expectedVersion|@预期版本|version;decision|@结论|enum;opinion|@意见|text|1000","APPROVE|REJECT" } },
{ "ai_精工工序质量放行_隔离演练_精工检验结果_提交",new[] { "确认提交检验结果","planId|@方案流水号|id;expectedPlanVersion|@预期方案版本|version;priorRejectedResultId|@前次驳回结果|id?;releaseQuantity|@拟放行数量|nonnegative;rejectedQuantity|@不合格数量|nonnegative;pendingQuantity|@待定数量|nonnegative;measurementsXml|@测量记录|xml;qualificationReference|@人员资质依据|text|500;description|@提交说明|text|1000","" } },
{ "ai_精工工序质量放行_隔离演练_精工检验结果_复核",new[] { "确认复核检验结果","resultId|@结果流水号|id;expectedVersion|@预期版本|version;decision|@结论|enum;opinion|@意见|text|1000","APPROVE|REJECT" } },
{ "ai_精工工序质量放行_隔离演练_冻结路线",new[] { "确认质量冻结处理","action|@动作|enum;releaseId|@放行流水号|id;evidence|@依据|text|1000","HOLD" } },
{ "ai_精工工序质量放行_隔离演练_冻结处置",new[] { "确认质量冻结处理","action|@动作|enum;releaseId|@放行流水号|id;holdId|@冻结流水号|id?;expectedVersion|@预期版本|version?;evidence|@依据|text|1000","HOLD|RESOLVE_HOLD" } },
{ "ai_精工工序质量放行_隔离演练_精工转序关系_创建",new[] { "确认建立前后序关系","releaseId|@放行流水号|id;craftTaskId|@后序任务|positive;evidence|@关系依据|text|1000","" } },
{ "ai_精工工序质量放行_隔离演练_精工转序关系_复核",new[] { "确认复核前后序关系","edgeId|@关系流水号|id;expectedVersion|@预期版本|version;decision|@结论|enum;opinion|@意见|text|1000","APPROVE|REJECT" } },
{ "ai_精工工序质量放行_隔离演练_分批交接",new[] { "确认分批交接","action|@动作|enum;releaseId|@放行流水号|id;edgeId|@关系流水号|id;receiptId|@接收流水号|id?;expectedVersion|@预期版本|version?;expectedReleaseVersion|@预期放行版本|version?;quantity|@数量|positive;unit|@单位|text|10;evidence|@依据|text|1000","RESERVE|RECEIVE|CANCEL|RETURN_REQUEST" } },
{ "ai_精工工序质量放行_隔离演练_退回复核",new[] { "确认复核未加工退回","action|@动作|enum;releaseId|@放行流水号|id;edgeId|@关系流水号|id;receiptId|@接收流水号|id?;expectedVersion|@预期版本|version?;expectedReleaseVersion|@预期放行版本|version?;quantity|@数量|positive;unit|@单位|text|10;evidence|@依据|text|1000","RETURN_APPROVE|RETURN_REJECT" } },
{ "ai_精工工序质量放行_隔离演练_精工转序报工_补正",new[] { "确认补正报工额度","reportId|@报工流水号|id;expectedVersion|@预期版本|version;evidence|@依据|text|1000","" } }
};
const string DrillTasks="ai_精工分批接收_隔离演练_任务查询", DrillTransfer="ai_精工分批接收_隔离演练";
static bool TransferDrillCase(string name)
{
return name==DrillTasks || name==DrillTransfer || (SeikoDrillForms.ContainsKey(name) && Array.IndexOf(TransferDrillForms,name)>=0);
}
static readonly string[] TransferDrillForms = { "ai_精工工序质量放行_隔离演练_精工转序关系_创建","ai_精工工序质量放行_隔离演练_精工转序关系_复核","ai_精工工序质量放行_隔离演练_分批交接","ai_精工工序质量放行_隔离演练_退回复核","ai_精工工序质量放行_隔离演练_精工转序报工_补正" };
static bool SeikoDrillCase(string name) { return AssemblyDrillCase(name) || name == SeikoDrillQuery || name==DrillTasks || name==DrillTransfer || SeikoDrillForms.ContainsKey(name); }
static void RegisterSeikoDrill()
{
RegisterAssemblyDrill();
NavigationRoutes.Add(SeikoDrillQuery, new[] { "/qms/seiko-process-release" });
MesResultSets.Add(SeikoDrillQuery,new[] { "reports","reportContext","sources","plans","results","releases","holds","page","permissions","duties" });
foreach (string name in SeikoDrillForms.Keys) MesWorkRoutes.Add(name,TransferDrillCase(name)?"/mes/seiko-partial-transfer":"/qms/seiko-process-release");
NavigationRoutes.Add(DrillTasks,new[] { "/mes/seiko-partial-transfer" });
NavigationRoutes.Add(DrillTransfer,new[] { "/mes/seiko-partial-transfer" });
MesResultSets.Add(DrillTasks,new[] { "rows","page" });
MesResultSets.Add(DrillTransfer,new[] { "summary","releases","edges","receipts","allocations","holds","permissions","duties" });
}
static void BindSeikoDrill(SqlCommand command,string name,Dictionary<string,object> inputs,Dictionary<string,object> body)
{
if (AssemblyDrillCase(name)) { BindAssemblyDrill(command,name,inputs,body); return; }
if(name==DrillTasks || name==DrillTransfer) {
Only(inputs,"后序任务");
if(name==DrillTransfer) command.Parameters.Add("@后序任务",SqlDbType.Int).Value=(int)Positive(inputs,"后序任务",Int32.MaxValue,0);
else {
MesOptional(command,inputs,"后序任务",SqlDbType.Int);
command.Parameters.Add("@页码",SqlDbType.Int).Value=(int)Positive(body,"pageList",100000,1);
command.Parameters.Add("@每页条数",SqlDbType.Int).Value=(int)Positive(body,"pageSize",100,20);
}
return;
}
if (name==SeikoDrillQuery) {
Only(inputs,"报工流水号","送检流水号","关键字");
MesOptional(command,inputs,"报工流水号",SqlDbType.BigInt);
MesOptional(command,inputs,"送检流水号",SqlDbType.BigInt);
AddText(command,inputs,"关键字",200,"");
command.Parameters.Add("@页码",SqlDbType.Int).Value=(int)Positive(body,"pageList",100000,1);
command.Parameters.Add("@每页条数",SqlDbType.Int).Value=(int)Positive(body,"pageSize",100,20);
return;
}
BindQualityForm(command,inputs,SeikoDrillForms[name]);
}
static void BindQualityForm(SqlCommand command,Dictionary<string,object> inputs,string[] form)
{
var allowed=new List<string> { "确认声明","幂等键" };
if (Text(inputs,"确认声明",80,null)!=form[0]) throw BadInput();
string key=Text(inputs,"幂等键",100,null);
if (String.IsNullOrWhiteSpace(key)) throw BadInput();
command.Parameters.Add("@幂等键",SqlDbType.NVarChar,100).Value=key;
foreach (var field in form[1].Split(';')) {
var spec=field.Split('|');
string param=spec[1].Substring(1),kind=spec[2].TrimEnd('?');
allowed.Add(param);
object raw;
string value=inputs.TryGetValue(param,out raw) ? Convert.ToString(raw,Invariant) : "";
bool empty=String.IsNullOrWhiteSpace(value);
if (empty && !spec[2].EndsWith("?")) throw BadInput();
object data=DBNull.Value;
SqlDbType type;
int size=0;
switch(kind) {
case "id":
type=SqlDbType.BigInt;
long id;
if (!empty) { if (!Int64.TryParse(value,NumberStyles.None,Invariant,out id) || id<1) throw BadInput(); data=id; }
break;
case "positive": case "nonnegative":
type=SqlDbType.Int;
int number;
if (!empty) { if (!Int32.TryParse(value,NumberStyles.None,Invariant,out number) || (kind=="positive" && number<1)) throw BadInput(); data=number; }
break;
case "version": case "hash":
type=SqlDbType.Binary; size=kind=="version"?8:32;
if (!empty) {
if (value.StartsWith("0x",StringComparison.OrdinalIgnoreCase)) value=value.Substring(2);
if (value.Length!=size*2) throw BadInput();
var bytes=new byte[size];
for (int i=0;i<size;i++) if (!Byte.TryParse(value.Substring(2*i,2),NumberStyles.AllowHexSpecifier,Invariant,out bytes[i])) throw BadInput();
data=bytes;
}
break;
case "utc":
type=SqlDbType.DateTime2;
DateTimeOffset instant;
if (!empty) {
if (!System.Text.RegularExpressions.Regex.IsMatch(value,@"(Z|[+-][0-9]{2}:[0-9]{2})$") || !DateTimeOffset.TryParse(value,Invariant,DateTimeStyles.None,out instant)) throw BadInput();
data=instant.UtcDateTime;
}
break;
case "enum":
type=SqlDbType.VarChar; size=30;
if (!empty) { if (Array.IndexOf(form[2].Split('|'),value)<0) throw BadInput(); data=value; }
break;
case "xml":
type=SqlDbType.Xml;
if (!empty) {
if(value.Length>2097152) throw BadInput();
var settings=new XmlReaderSettings { DtdProcessing=DtdProcessing.Prohibit,XmlResolver=null,MaxCharactersInDocument=2097152 };
try { using(var reader=XmlReader.Create(new StringReader(value),settings)) while(reader.Read()) {} } catch(XmlException) { throw BadInput(); }
data=value;
}
break;
case "text":
type=SqlDbType.NVarChar; size=Int32.Parse(spec[3],Invariant);
if (!empty) { if(value.Length>size) throw BadInput(); data=value; }
break;
default: throw Unavailable();
}
var bound=size==0?command.Parameters.Add(spec[1],type):command.Parameters.Add(spec[1],type,size);
bound.Value=data;
}
Only(inputs,allowed.ToArray());
}
static object RunSeikoDrill(SqlCommand command,string name,SqlConnection live)
{
bool assembly=AssemblyDrillCase(name);
using(var gate=new SqlCommand(assembly ? "dbo.[ai_报工质量终判_组装检验演练_入口]" : "dbo.[ai_精工工序质量放行_演练入口]",live)) {
gate.CommandType=CommandType.StoredProcedure;
foreach(string key in new[] { "@人员编号","@角色编号" }) gate.Parameters.Add(key,SqlDbType.Int).Value=command.Parameters[key].Value;
if (!assembly) gate.Parameters.Add("@分批",SqlDbType.Bit).Value=TransferDrillCase(name);
if (!Object.Equals(gate.ExecuteScalar(),1)) throw new ApiFailure(403,"当前员工无此演练入口权限");
}
command.Parameters.RemoveAt("@角色编号");
using(var drill=new SqlConnection(@"Data Source=lpc:.;Initial Catalog=JY_RESTORE_DRILL_20260910084616_0B711B60CF13;Integrated Security=True;Pooling=False;Connect Timeout=5;Application Name=JY9528-SeikoDrill")) {
drill.Open(); command.Connection=drill;
using(var reader=command.ExecuteReader()) {
if(MesResultSets.ContainsKey(name)) return ReadMesLinkedQuery(reader,MesResultSets[name]);
var rows=ReadRows(reader,1);
if(rows.Count!=1 || reader.NextResult()) throw Unavailable();
FormatMesBinaryFields(rows[0]);
if (name==AssemblyDrillPrefix+"_项目草稿保存") return new { record=rows[0], draftOnly=true,productionReady=false,refreshRequired=true };
if (assembly) { reader.Close(); return AssemblyAuditReceipt(command,name,rows[0]); }
return new { record=rows[0], productionReady=false,refreshRequired=true };
}
}
}
}
}

View File

@@ -0,0 +1,113 @@
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
namespace Jingyao.AIEmployee
{
public sealed partial class PersonalInboxHandler
{
static readonly Dictionary<string,string> MesWorkRoutes = new Dictionary<string,string>(StringComparer.Ordinal) {
{ "ai_APS下达待接收箱_送达", "/mes/aps-receipt-inbox" },
{ "ai_APS下达待接收箱_办理", "/mes/aps-receipt-inbox" },
{ "ai_工单草稿审核_提交", "/mes/work-order-draft-review" },
{ "ai_工单草稿审核_办理", "/mes/work-order-draft-review" },
{ "ai_待派工池_建立", "/mes/dispatch-pool" },
{ "ai_待派工池_办理", "/mes/dispatch-pool" },
{ "ai_开工前门禁_建立", "/mes/start-gate" },
{ "ai_开工前门禁_登记检查", "/mes/start-gate" },
{ "ai_开工前门禁_办理", "/mes/start-gate" },
{ "ai_返工接收与重新送检_建立接收", "/mes/rework-receipt" },
{ "ai_返工接收与重新送检_接收办理", "/mes/rework-receipt" },
{ "ai_返工接收与重新送检_工单办理", "/mes/rework-receipt" }
};
static void BindMesWork(SqlCommand command,string name,Dictionary<string,object> inputs)
{
switch(name) {
case "ai_APS下达待接收箱_送达":
Only(inputs,"MES下达申请流水号","幂等键");
ReworkKey(command,inputs,"MES下达申请流水号");
break;
case "ai_APS下达待接收箱_办理":
Only(inputs,"MES接收流水号","动作","意见","幂等键");
ReworkKey(command,inputs,"MES接收流水号");
AddText(command,inputs,"动作",20,null,"REJECT","RESUBMIT","RECEIVE");
AddText(command,inputs,"意见",1000,"");
break;
case "ai_工单草稿审核_提交":
Only(inputs,"MES工单草稿流水号","预期MES接收版本","预期工单版本","幂等键");
ReworkKey(command,inputs,"MES工单草稿流水号");
MesVersion(command,inputs,"预期MES接收版本");
MesVersion(command,inputs,"预期工单版本");
break;
case "ai_工单草稿审核_办理":
Only(inputs,"工单审核流水号","动作","意见","预期版本","幂等键");
ReworkKey(command,inputs,"工单审核流水号");
AddText(command,inputs,"动作",20,null,"RESUBMIT","REJECT","APPROVE");
AddText(command,inputs,"意见",1000,"");
MesVersion(command,inputs,"预期版本");
break;
case "ai_待派工池_建立":
Only(inputs,"工单审核流水号","预期工单审核版本","预期工单版本","幂等键");
ReworkKey(command,inputs,"工单审核流水号");
MesVersion(command,inputs,"预期工单审核版本");
MesVersion(command,inputs,"预期工单版本");
break;
case "ai_待派工池_办理":
Only(inputs,"待派工流水号","动作","意见","确认声明","预期版本","幂等键");
ReworkKey(command,inputs,"待派工流水号");
AddText(command,inputs,"动作",30,null,"RESUBMIT","REJECT","CONFIRM","DISPATCH");
AddText(command,inputs,"意见",1000,"");
AddText(command,inputs,"确认声明",100,"");
MesVersion(command,inputs,"预期版本");
break;
case "ai_开工前门禁_建立":
Only(inputs,"待派工流水号","预期待派工版本","预期工单审核版本","预期工单版本","幂等键");
ReworkKey(command,inputs,"待派工流水号");
MesVersion(command,inputs,"预期待派工版本");
MesVersion(command,inputs,"预期工单审核版本");
MesVersion(command,inputs,"预期工单版本");
break;
case "ai_开工前门禁_登记检查":
Only(inputs,"开工门禁流水号","门禁代码","检查结果","检查证据","预期门禁版本","预期门禁项版本","幂等键");
ReworkKey(command,inputs,"开工门禁流水号");
AddText(command,inputs,"门禁代码",40,null);
AddText(command,inputs,"检查结果",20,null,"PASSED","BLOCKED");
AddText(command,inputs,"检查证据",1000,null);
MesVersion(command,inputs,"预期门禁版本");
MesVersion(command,inputs,"预期门禁项版本");
break;
case "ai_开工前门禁_办理":
Only(inputs,"开工门禁流水号","动作","意见","确认声明","预期版本","幂等键");
ReworkKey(command,inputs,"开工门禁流水号");
AddText(command,inputs,"动作",30,null,"SUBMIT","APPROVE","START","REJECT","REVISE");
AddText(command,inputs,"意见",1000,"");
AddText(command,inputs,"确认声明",100,"");
MesVersion(command,inputs,"预期版本");
break;
case "ai_返工接收与重新送检_建立接收":
Only(inputs,"返工候选流水号","幂等键");
ReworkKey(command,inputs,"返工候选流水号");
break;
case "ai_返工接收与重新送检_接收办理":
Only(inputs,"返工接收流水号","动作","意见","幂等键");
ReworkKey(command,inputs,"返工接收流水号");
AddText(command,inputs,"动作",30,null,"REJECT","RESUBMIT","RECEIVE");
AddText(command,inputs,"意见",1000,"");
break;
case "ai_返工接收与重新送检_工单办理":
Only(inputs,"返工工单草稿流水号","动作","实际返工数量","证据","意见","确认声明","幂等键");
ReworkKey(command,inputs,"返工工单草稿流水号");
AddText(command,inputs,"动作",30,null,"SUBMIT_COMPLETION","APPROVE_COMPLETION","REJECT_COMPLETION","SEND_QMS");
object quantity;
if (inputs.TryGetValue("实际返工数量",out quantity) && quantity!=null && !Object.Equals(quantity,"")) MesQuantity(command,inputs,"实际返工数量",4);
AddText(command,inputs,"证据",1000,"");
AddText(command,inputs,"意见",1000,"");
AddText(command,inputs,"确认声明",100,"");
break;
default: throw BadInput();
}
BindIdempotency(command,inputs,true);
}
}
}

View File

@@ -20,12 +20,12 @@ namespace Jingyao.AIEmployee
return name == DraftList || name == DraftDetail || name == DraftSave || name == DraftRehearsal;
}
static void BindIdempotency(SqlCommand command, Dictionary<string,object> inputs)
static void BindIdempotency(SqlCommand command, Dictionary<string,object> inputs, bool useParameterScale=false)
{
string key = Text(inputs, "幂等键", 100, null);
if (!Regex.IsMatch(key, @"\A[A-Za-z0-9_.:-]+\z")) throw BadInput();
command.Parameters.Add("@幂等键", SqlDbType.VarChar, 100).Value = key;
string fingerprint = RequestFingerprint(command);
string fingerprint = RequestFingerprint(command,useParameterScale);
command.Parameters.Add("@请求指纹", SqlDbType.Char, 64).Value = fingerprint;
}

View File

@@ -88,7 +88,7 @@ namespace Jingyao.AIEmployee
}
// 给已验证的、固定顺序的参数编码,长度前缀避免说明或引用中的分隔符导致碰撞。
static string RequestFingerprint(SqlCommand command)
static string RequestFingerprint(SqlCommand command, bool useParameterScale=false)
{
using (var buffer = new MemoryStream())
using (var writer = new BinaryWriter(buffer, Encoding.UTF8))
@@ -98,7 +98,7 @@ namespace Jingyao.AIEmployee
writer.Write(parameter.ParameterName);
object value = parameter.Value;
if (value is byte[]) writer.Write(Convert.ToBase64String((byte[])value));
else if (value is decimal) writer.Write(((decimal)value).ToString("F2", Invariant));
else if (value is decimal) writer.Write(((decimal)value).ToString(useParameterScale ? "F"+parameter.Scale.ToString(Invariant) : "F2", Invariant));
else writer.Write(Convert.ToString(value, Invariant));
}
writer.Flush();

View File

@@ -168,7 +168,7 @@ namespace Jingyao.AIEmployee
{ "ai_工程变更_历史修改记录_机床明细", new[] { "/plm/engineering-change" } },
{ "ai_工程变更_历史修改记录_组件明细", new[] { "/plm/engineering-change" } },
{ "ai_物料信息_启用物料清单", new[] { "/plm/material-info" } },
{ "ai_MES综合工作台_我的投产接收", new[] { "/mes/control-center" } },
{ "ai_MES综合工作台_我的投产接收", new[] { "/mes/control-center", "/mes/assembly-material-flow" } },
{ PerformanceSummary, new[] { "/erp/personal-performance" } },
{ PerformanceContracts, new[] { "/erp/personal-performance" } },
{ "ai_客户档案", new[] { "/erp/customers", "/erp/contracts", "/erp/quotations", "/erp/sales-orders", "/erp/customer-value" } },
@@ -240,6 +240,7 @@ namespace Jingyao.AIEmployee
static void BindNavigation(SqlCommand command, string name, Dictionary<string,object> inputs, Dictionary<string,object> body)
{
if (BindMesQuery(command,name,inputs,body)) return;
string[] fields;
switch(name) {
case "ai_图纸与文档版本_历史图纸":
@@ -344,6 +345,7 @@ namespace Jingyao.AIEmployee
AiEmployeeSessions.RequireCurrent(context);
// 付款核销的原请求可以包含两百个应付行,其他办理继续使用各过程自己的参数上限。
if (context.Request.Headers["X-JY-Request-Class"] == "quotation-draft" || context.Request.Headers["X-JY-Request-Class"] == "contract-draft") return QuoteBodyLimit;
if (context.Request.Headers["X-JY-Request-Class"] == "contract-revision") return 2097152;
return context.Request.Headers["X-JY-Request-Class"] == "payment-journal" ? 1048576 : 98304;
}
static readonly Regex Revision = new Regex(@"\A[0-9A-F]{64}\z", RegexOptions.CultureInvariant);
@@ -395,10 +397,10 @@ namespace Jingyao.AIEmployee
var inputs = new Dictionary<string, object>(StringComparer.Ordinal);
string procedure = Text(body, "name", 128, null);
bool rework = ReworkRoute(procedure) != null;
string param = Text(body, "param", (procedure==ContractDraftSave || QuoteFormWrite(procedure)) ? QuoteBodyLimit : procedure==SalesDraftSave ? 20000 : CustomerWrite(procedure) ? 32768 : IsPaymentJournal(procedure) ? 262144 : (procedure == LabelGenerate || procedure == LabelPrint) ? 10000 : (procedure == LegacyScheduleReview || procedure == LegacyScheduleCreate || procedure == LegacyReleaseSave || procedure == ReleaseSave || procedure == LegacyPlanCreate || procedure == ProductionCreate || procedure == DatePlanCreate || IsDatePlanTransition(procedure) || procedure == DraftSave || IsAssessmentSave(procedure) || IsBomDecision(procedure)) ? 20000 : rework || LegacyWrite(procedure) ? 8000 : 3072, null);
string param = Text(body, "param", MesPackageAction(procedure) ? 24000 : procedure==LegacyRevision+"保存" ? 1048576 : (WritesContractForm(procedure) || QuoteFormWrite(procedure)) ? QuoteBodyLimit : procedure==SalesDraftSave ? 20000 : CustomerWrite(procedure) ? 32768 : IsPaymentJournal(procedure) ? 262144 : (procedure == LabelGenerate || procedure == LabelPrint) ? 10000 : (procedure == LegacyScheduleReview || procedure == LegacyScheduleCreate || procedure == LegacyReleaseSave || procedure == ReleaseSave || procedure == LegacyPlanCreate || procedure == ProductionCreate || procedure == DatePlanCreate || IsDatePlanTransition(procedure) || procedure == DraftSave || IsAssessmentSave(procedure) || IsBomDecision(procedure)) ? 20000 : rework || LegacyWrite(procedure) ? 8000 : 3072, null);
if (param.Length == 0) return inputs;
object[] items = Parse(param, false, (procedure==ContractDraftSave || QuoteFormWrite(procedure)) ? QuoteBodyLimit : 2097152) as object[];
int limit = (procedure==SalesReject || procedure==SalesCancel+"确认取消") ? 7 : procedure==SalesDraftSave ? 13 : procedure==ContractDraftSave ? 16 : procedure==QuoteDirect ? 14 : procedure==QuoteEdit ? 15 : procedure==QuoteSave ? 13 : CustomerWrite(procedure) ? 20 : (procedure == LegacyScheduleCreate || procedure == LegacyScheduleReview) ? 9 : procedure == LegacyHandoffItems ? 7 : procedure == LegacyPlanCreate ? 8 : procedure == LegacyReleaseSave ? 15 : procedure == ReleaseSave ? 12 : procedure == RequirementSave ? 9 : (procedure == ShortageSave || IsPlanWrite(procedure)) ? 7 : procedure == ProductionCreate ? 11 : IsReceiptWrite(procedure) ? 9 : procedure == DatePlanCreate ? 9 : IsDatePlanTransition(procedure) ? 7 : IsBomDecision(procedure) ? 7 : IsAssessmentSave(procedure) ? 10 : procedure == ReviewDraftCreate ? 7 : (procedure == WmsSubmitSave || procedure == ReceiptPayableSave || procedure == LabelGenerate) ? 10 : procedure == LabelPrint ? 7 : procedure == InspectionSave ? 8 : procedure == CorrectionSave ? 10 : procedure == ArrivalSave ? 9 : procedure == PurchaseTermsSave ? 14 : procedure == PurchaseSave ? 11 : LegacyWrite(procedure) ? 18 : rework ? 9 : procedure == Transition ? 7 : procedure == PerformanceContracts || IsSettlementWrite(procedure) || procedure == PayableConfirm ? 8 : 6;
object[] items = Parse(param, false, (WritesContractForm(procedure) || QuoteFormWrite(procedure)) ? QuoteBodyLimit : 2097152) as object[];
int limit = MesWorkRoutes.ContainsKey(procedure) ? 16 : procedure == PackageReceipt ? 8 : procedure == ReportLine ? 11 : procedure == ReportTransition ? 7 : procedure=="ai_精工生产任务查询_任务清单" ? 15 : (procedure==SalesReject || procedure==SalesCancel+"确认取消") ? 7 : procedure==SalesDraftSave ? 13 : procedure==RequirementSaveDraft ? 18 : WritesContractForm(procedure) ? 16 : procedure==QuoteReference+"保存" ? 16 : procedure==QuoteDirect ? 14 : procedure==QuoteEdit ? 15 : procedure==QuoteSave ? 13 : CustomerWrite(procedure) ? 20 : (procedure == LegacyScheduleCreate || procedure == LegacyScheduleReview) ? 9 : procedure == LegacyHandoffItems ? 7 : procedure == LegacyPlanCreate ? 8 : procedure == LegacyReleaseSave ? 15 : procedure == ReleaseSave ? 12 : procedure == RequirementSave ? 9 : (procedure == ShortageSave || IsPlanWrite(procedure)) ? 7 : procedure == ProductionCreate ? 11 : IsReceiptWrite(procedure) ? 9 : procedure == DatePlanCreate ? 9 : IsDatePlanTransition(procedure) ? 7 : IsBomDecision(procedure) ? 7 : IsAssessmentSave(procedure) ? 10 : procedure == ReviewDraftCreate ? 7 : (procedure == WmsSubmitSave || procedure == ReceiptPayableSave || procedure == LabelGenerate) ? 10 : procedure == LabelPrint ? 7 : procedure == InspectionSave ? 8 : procedure == CorrectionSave ? 10 : procedure == ArrivalSave ? 9 : procedure == PurchaseTermsSave ? 14 : procedure == PurchaseSave ? 11 : LegacyWrite(procedure) ? 18 : rework ? 9 : procedure == Transition ? 7 : procedure == PerformanceContracts || IsSettlementWrite(procedure) || procedure == PayableConfirm ? 8 : 6;
if (items == null || items.Length > limit) throw BadInput();
foreach (object item in items) {
var pair = item as Dictionary<string, object>;
@@ -1011,6 +1013,13 @@ namespace Jingyao.AIEmployee
static void Bind(SqlCommand command, string name, Dictionary<string, object> inputs, Dictionary<string, object> body)
{
if (SeikoDrillCase(name)) { BindSeikoDrill(command,name,inputs,body); return; }
if (BindMesCrossDomain(command,name,inputs,body)) return;
if (MesWorkRoutes.ContainsKey(name)) { BindMesWork(command,name,inputs); return; }
if (MesPackageAction(name)) { BindMesPackage(command,name,inputs); return; }
if (MesReportAction(name)) { BindMesReport(command,name,inputs); return; }
if (IsQuoteReference(name)) { BindQuoteReference(command,name,inputs); return; }
if (IsLegacyRevision(name)) { BindLegacyRevision(command,name,inputs); return; }
if (name==SalesSubmitBasis || name==SalesSubmit || name==SalesSubmitProof || OrderDecision(name) || name==SalesReview+"依据" || name==SalesReview+"回执" || DispositionBasis(name) || DispositionProof(name) || DispositionWrite(name)) {
if (name==SalesReject) Only(inputs,"销售订单流水号","合同流水号","需求流水号","客户流水号","原修订","客户端请求号","驳回原因");
else if (name==SalesCancel+"确认取消") Only(inputs,"销售订单流水号","合同流水号","需求流水号","客户流水号","原修订","客户端请求号","取消原因");
@@ -1041,7 +1050,7 @@ namespace Jingyao.AIEmployee
if (inputs.ContainsKey("客户流水号")) command.Parameters.Add("@客户流水号",SqlDbType.Int).Value=(int)Positive(inputs,"客户流水号",Int32.MaxValue,0);
return;
}
if (name==ContractDraftSave || name==ContractDraftProof) { BindContractDraft(command,name,inputs); return; }
if (IsRequirementContract(name) || IsFormalEdit(name) || name==ContractDraftSave || name==ContractDraftProof) { BindContractDraft(command,name,inputs); return; }
if (QuoteDetails(name)) { BindQuoteDetails(command,name,inputs,body); return; }
if (QuoteFormWrite(name) || name==QuoteReceipt || name==QuoteEditReceipt || name==QuoteDirectProof || name==QuoteDirectAccess) { BindQuotationDraft(command,name,inputs); return; }
if (name==ContractActivate || name==ContractApprove || name==ContractReject || name==ContractSubmit || name==QuoteSubmit || name==QuoteApprove || name==QuoteReject || QuoteSubmitQuery(name)) { BindQuoteSubmit(command,name,inputs); return; }
@@ -1712,15 +1721,15 @@ namespace Jingyao.AIEmployee
string reworkRoute = ReworkRoute(name);
string invoiceRoute = InvoiceRoute(name);
bool noticeWrite = name == MarkRead || name == MarkHandled;
if (!OrderRead(name) && !OrderWrite(name) && !QuoteDetails(name) && !QuoteWrite(name) && !QuoteSubmitQuery(name) && name!=QuoteReceipt && !QuoteRead(name) && !CustomerQuery(name) && !CustomerWrite(name) && !IsRequirement(name) && !IsProductionWrite(name) && !IsReleaseRead(name) && !IsProductionDraft(name) && !IsReviewWrite(name) && !IsReviewRecordRead(name) && !IsReviewDraft(name) && !IsReviewEvidence(name) && !IsGroupRenumber(name) && !IsGroupPublish(name) && !IsGroupAppend(name) && name != GroupDraftRead && name != GroupDraftSave && name != LegacySyncRead && name != LegacySyncSave && name != LegacySyncAccess && name != QualityLinkAccess && !IsWmsSubmit(name) && name != Summary && name != List && name != Receipts && !noticeWrite && name != Transition && name != WorkflowPermissions && name != LabelRights && name != LabelBasis && name != LabelReceipt && name != LabelPrint && name != LabelGenerate && name != LabelAccess && name != LabelPreview && name != InspectionAccess && name != InspectionBasis && name != InspectionSave && name != InspectionRead && name != CorrectionAccess && name != CorrectionBasis && name != CorrectionSave && name != CorrectionRead && name != ArrivalSave && name != ArrivalRead && name != ReceiptRegisterAccess && name != ReceiptOrderChoices && name != ReceiptPayableSave && name != ReceiptPayableRead && name != ReceiptPayableAccess && name != ReceiptPayableBasis && !IsOrderFollow(name) && !IsOrderRelease(name) && name != OrderConfirmBasis && name != OrderConfirmSave && name != OrderConfirmRead && name != PurchaseOrderHistory && name != PurchaseConvert && name != PurchaseConvertReceipt && name != PurchaseApprovalAccess && name != PurchaseApprovalReceipt && name != PurchaseApprovalSave && name != PurchaseReviewBasis && name != PurchaseTermsAccess && name != PurchaseTermsReceipt && name != PurchaseTermsSave && name != PurchaseRequestAccess && name != PurchaseFormSource && name != PurchaseSave && name != PurchaseReceipt && name != OutputAccess && !quality && !risk && ReviewRoute(name) == null && !NavigationRoutes.ContainsKey(name) && !IsSettlement(name) && !IsPayableSource(name) && !IsDraft(name) && !IsLegacy(name) && !IsPaymentJournal(name) && reworkRoute == null && invoiceRoute == null) throw BadInput();
bool write = OrderWrite(name) || QuoteWrite(name) || CustomerWrite(name) || name == RequirementSave || IsProductionWrite(name) || IsReviewWrite(name) || name == ReviewDraftCreate || name == GroupRenumberSave || name == GroupPublishSave || name == GroupAppendSave || name == GroupDraftSave || name == LegacySyncSave || name == WmsSubmitSave || name == ReceiptPayableSave || name == FollowDelay || name == FollowNudge || name == OrderReleaseSave || name == OrderConfirmSave || name == LabelGenerate || name == LabelPrint || name == InspectionSave || name == CorrectionSave || name == ArrivalSave || name == PurchaseConvert || name == PurchaseApprovalSave || name == PurchaseTermsSave || name == PurchaseSave || noticeWrite || name == Transition || name == RiskCreate || IsSettlementWrite(name) || name == PayableConfirm || name == DraftSave || LegacyWrite(name) || InvoiceWrite(name) || IsPaymentJournalWrite(name) || (reworkRoute != null && !ReworkQuery(name));
if (!MesWorkRoutes.ContainsKey(name) && !MesPackageAction(name) && !MesReportAction(name) && !OrderRead(name) && !OrderWrite(name) && !QuoteDetails(name) && !QuoteWrite(name) && !QuoteSubmitQuery(name) && name!=QuoteReceipt && !QuoteRead(name) && !CustomerQuery(name) && !CustomerWrite(name) && !IsRequirement(name) && !IsProductionWrite(name) && !IsReleaseRead(name) && !IsProductionDraft(name) && !IsReviewWrite(name) && !IsReviewRecordRead(name) && !IsReviewDraft(name) && !IsReviewEvidence(name) && !IsGroupRenumber(name) && !IsGroupPublish(name) && !IsGroupAppend(name) && name != GroupDraftRead && name != GroupDraftSave && name != LegacySyncRead && name != LegacySyncSave && name != LegacySyncAccess && name != QualityLinkAccess && !IsWmsSubmit(name) && name != Summary && name != List && name != Receipts && !noticeWrite && name != Transition && name != WorkflowPermissions && name != LabelRights && name != LabelBasis && name != LabelReceipt && name != LabelPrint && name != LabelGenerate && name != LabelAccess && name != LabelPreview && name != InspectionAccess && name != InspectionBasis && name != InspectionSave && name != InspectionRead && name != CorrectionAccess && name != CorrectionBasis && name != CorrectionSave && name != CorrectionRead && name != ArrivalSave && name != ArrivalRead && name != ReceiptRegisterAccess && name != ReceiptOrderChoices && name != ReceiptPayableSave && name != ReceiptPayableRead && name != ReceiptPayableAccess && name != ReceiptPayableBasis && !IsOrderFollow(name) && !IsOrderRelease(name) && name != OrderConfirmBasis && name != OrderConfirmSave && name != OrderConfirmRead && name != PurchaseOrderHistory && name != PurchaseConvert && name != PurchaseConvertReceipt && name != PurchaseApprovalAccess && name != PurchaseApprovalReceipt && name != PurchaseApprovalSave && name != PurchaseReviewBasis && name != PurchaseTermsAccess && name != PurchaseTermsReceipt && name != PurchaseTermsSave && name != PurchaseRequestAccess && name != PurchaseFormSource && name != PurchaseSave && name != PurchaseReceipt && name != OutputAccess && !quality && !risk && ReviewRoute(name) == null && !NavigationRoutes.ContainsKey(name) && !IsSettlement(name) && !IsPayableSource(name) && !IsDraft(name) && !IsLegacy(name) && !IsPaymentJournal(name) && reworkRoute == null && invoiceRoute == null) throw BadInput();
bool write = MesWorkRoutes.ContainsKey(name) || MesPackageAction(name) || MesReportAction(name) || OrderWrite(name) || QuoteWrite(name) || CustomerWrite(name) || name == RequirementSave || IsProductionWrite(name) || IsReviewWrite(name) || name == ReviewDraftCreate || name == GroupRenumberSave || name == GroupPublishSave || name == GroupAppendSave || name == GroupDraftSave || name == LegacySyncSave || name == WmsSubmitSave || name == ReceiptPayableSave || name == FollowDelay || name == FollowNudge || name == OrderReleaseSave || name == OrderConfirmSave || name == LabelGenerate || name == LabelPrint || name == InspectionSave || name == CorrectionSave || name == ArrivalSave || name == PurchaseConvert || name == PurchaseApprovalSave || name == PurchaseTermsSave || name == PurchaseSave || noticeWrite || name == Transition || name == RiskCreate || IsSettlementWrite(name) || name == PayableConfirm || name == DraftSave || LegacyWrite(name) || InvoiceWrite(name) || IsPaymentJournalWrite(name) || (reworkRoute != null && !ReworkQuery(name));
string route = Text(body, "ModularID", 100, null);
string businessRoute = name == Transition || name == WorkflowPermissions || name == OutputAccess ? "/erp/workflow-center" : "/erp/workflow-inbox";
if (ReviewRoute(name) != null) businessRoute = ReviewRoute(name);
if (IsProductionWrite(name) || IsReleaseRead(name) || IsProductionDraft(name)) businessRoute="/erp/production-demand";
else if (IsReviewWrite(name) || IsReviewRecordRead(name) || IsReviewEvidence(name) || IsReviewDraft(name)) businessRoute="/erp/delivery-review";
if (QuoteDetails(name) || QuoteRead(name) || QuoteWrite(name) || QuoteSubmitQuery(name) || name==QuoteReceipt) businessRoute=(ContractApproval(name) || ContractSubmission(name) || name==ContractQuoteSource || name==ContractNumberPreview || name==ContractDraftSave || name==ContractDraftProof) ? "/erp/contracts" : "/erp/quotations";
if (context.Request.Headers["X-JY-Request-Class"]=="contract-draft" && name!=ContractDraftSave) throw BadInput();
if (context.Request.Headers["X-JY-Request-Class"]=="contract-draft" && !WritesContractForm(name)) throw BadInput();
if (context.Request.Headers["X-JY-Request-Class"]=="quotation-draft" && !QuoteFormWrite(name)) throw BadInput();
if (OrderRead(name) || OrderWrite(name)) businessRoute="/erp/sales-orders";
if (CustomerQuery(name) || CustomerWrite(name)) businessRoute="/erp/customers";
@@ -1745,6 +1754,9 @@ namespace Jingyao.AIEmployee
if (route != "/BasicData/ProcedureExecution" && Array.IndexOf(routes,route)<0) throw BadInput();
businessRoute=route;
}
if (MesWorkRoutes.ContainsKey(name)) businessRoute=MesWorkRoutes[name];
if (MesPackageAction(name)) businessRoute="/mes/special-machine-execution";
if (MesReportAction(name)) businessRoute="/mes/reporting-review";
if (route != businessRoute && (write || route != "/BasicData/ProcedureExecution"))
throw new ApiFailure(403, "请从对应业务页面进行此项操作");
if (Text(body, "type", 2, null) != (write ? "12" : "11") ||
@@ -1755,12 +1767,20 @@ namespace Jingyao.AIEmployee
command.CommandTimeout = 30;
command.Parameters.Add("@人员编号", SqlDbType.Int).Value = Int32.Parse(employee.PersonId, Invariant);
command.Parameters.Add("@角色编号", SqlDbType.Int).Value = Int32.Parse(employee.RoleId, Invariant);
if (SeikoDrillCase(name)) command.Parameters.Add("@登录工号",SqlDbType.NVarChar,50).Value=employee.AttendanceNumber;
Bind(command, name, inputs, body);
try {
return new { actor = employee.PersonId, data = Run(command, name) };
} catch (SqlException error) {
foreach (SqlError detail in error.Errors) {
if (SeikoDrillCase(name)) {
if (detail.Number==55261 || (detail.Number==50000 && detail.State==41)) throw new ApiFailure(403,"当前员工无此演练权限");
if (AssemblyDrillCase(name) && detail.Number>=58000 && detail.Number<58100) throw new ApiFailure(422, detail.Message);
if (AssemblyDrillCase(name) && detail.Number==57477) throw new ApiFailure(403,detail.Message);
if (detail.Number>=55000 && detail.Number<58000) throw new ApiFailure(422,detail.Message);
}
if (detail.Number != 50000) continue;
if ((MesWorkRoutes.ContainsKey(name) || MesPackageAction(name) || MesReportAction(name) || MesResultSets.ContainsKey(name)) && detail.State==22) throw new ApiFailure(422,detail.Message);
if ((name == ShortagePreview || IsPreview(name)) && (detail.State == 21 || detail.State == 22))
throw new ApiFailure(detail.State == 21 ? 409 : 422,detail.Message);
if ((IsLegacyHandoff(name) || IsMaterialCheck(name) || name == MaterialCoordination || name == ReceiptTaskBasis) && detail.State == 22)
@@ -1838,6 +1858,7 @@ namespace Jingyao.AIEmployee
" AND IS_ROLEMEMBER(N'db_datareader')=0 AND IS_ROLEMEMBER(N'db_datawriter')=0 THEN 1 ELSE 0 END", connection)) {
if (!Object.Equals(check.ExecuteScalar(), 1)) throw Unavailable();
}
if (SeikoDrillCase(name)) return RunSeikoDrill(command,name,connection);
command.Connection = connection;
if (name == SettlementCopy || name == SettlementDownload) return RunSettlementOutput(command, name, connection);
if (name == LegacySyncSave) return RunLegacySync(command,connection);
@@ -1847,7 +1868,7 @@ namespace Jingyao.AIEmployee
List<Dictionary<string,object>> result;
using (var reader=command.ExecuteReader()) {
result=ReadRows(reader,(OrderWrite(name) || QuoteWrite(name) || CustomerWrite(name) || name == RequirementSave || IsProductionWrite(name) || IsReviewWrite(name) || name==ReviewDraftCreate || name==GroupPublishSave || name==GroupRenumberSave) ? 1 : 200);
if (name==QuoteDirect) result=ReadDirectQuoteProof(reader,result);
if (name==QuoteDirect || name==QuoteReference+"保存") result=ReadDirectQuoteProof(reader,result);
if (result.Count==0 || reader.NextResult()) throw Unavailable();
}
tx.Commit();
@@ -1893,6 +1914,19 @@ namespace Jingyao.AIEmployee
if (reader.NextResult()) throw Unavailable();
return receipt;
}
if(AssemblyForms.ContainsKey(name)) return AssemblyDispositionReceipt(reader,command,name);
if (MesWorkRoutes.ContainsKey(name) || MesPackageAction(name) || MesReportAction(name)) return MesReportReceipt(reader);
string[] mesSets;
if (MesResultSets.TryGetValue(name,out mesSets)) {
var records=ReadMesLinkedQuery(reader,mesSets);
if (name=="ai_MES跨系统办理_本人权限与职责" && ApsWindowOpen()) records.Add(new Dictionary<string,object> { { "结果集", "window" }, { "状态", "enabled" } });
return records;
}
if (MesUnpaged(name)) {
var records=ReadRows(reader,100000);
if (reader.NextResult()) throw Unavailable();
return records;
}
bool suppliers = name == PurchaseFormSource && (string)command.Parameters["@来源类型"].Value == "供应商候选";
if (name==PreviewReceivers || name==LegacyPreviewReceivers) {
var candidates=ReadRows(reader,Int32.MaxValue);
@@ -1900,7 +1934,7 @@ namespace Jingyao.AIEmployee
return candidates;
}
if (OrderRead(name) || QuoteSubmitQuery(name) || name==QuoteReceipt || QuoteRead(name) || CustomerQuery(name) || name==RequirementAccess || name==RequirementReceipt || name==ShortagePreview || name==ShortageReceipt || name==LegacyScheduleReleaseBasis || name==LegacyScheduleReviewBasis || name==LegacyScheduleRead || name==LegacyScheduleBasis || name==LegacyScheduleSource || IsLegacyReceiptRead(name) || name==LegacyReleaseRead || name==LegacyHandoff || name==ReleaseSaveRead || IsPlanRead(name) || name==LegacyPreviewAccess || name==LegacyPreview || name==PreviewAccess || name==ReleasePreview || name==ReceiptRead || name==ReceiptTaskBasis || name==SeikoHandoff || name==ReleaseHeader || name==ProductionRead || name==ProductionBasis || name==ReviewDraftRead || IsReviewRecordRead(name)) {
var own=ReadRows(reader,1);
var own=ReadRows(reader,name==FormalEdit+"办理依据" ? 100 : 1);
if (reader.NextResult()) throw Unavailable();
return own;
}
@@ -1917,6 +1951,7 @@ namespace Jingyao.AIEmployee
bool paged = PagedQuoteLines(name) || name==LegacyScheduleVouchers || IsReleasePage(name) || name == ReviewBomItems || name == DatePlanVersions || name == ReceiptOrderChoices || suppliers || NavigationRoutes.ContainsKey(name) || ReviewRoute(name) != null || name == List || name == Investigation || name == Disposition;
int size = paged ? (int)command.Parameters["@每页条数"].Value : name == Receipts ? Int32.MaxValue : name == WorkflowPermissions ? 7 : 1;
var rows = ReadRows(reader, size);
if (IsMesNavigationRead(name)) foreach (var row in rows) FormatMesBinaryFields(row);
if (!paged) {
if ((name != Receipts && name != WorkflowPermissions && rows.Count != 1) || reader.NextResult()) throw Unavailable();
return rows;

View File

@@ -15,10 +15,23 @@ namespace Jingyao.AIEmployee
const string QuoteReceipt = "ai_报价管理_新建报价_草稿回执";
const string QuoteEdit = "ai_报价管理_修改报价_保存";
const string QuoteEditReceipt = "ai_报价管理_修改报价_保存回执";
const string QuoteReference = "ai_报价管理_参考历史报价_";
static bool IsQuoteReference(string name) {
return name==QuoteReference+"办理依据" || name==QuoteReference+"保存" || name==QuoteReference+"保存回执";
}
static void BindQuoteReference(SqlCommand cmd,string name,Dictionary<string,object> inputs) {
cmd.Parameters.Add("@参考流水号",SqlDbType.Int).Value=(int)Positive(inputs,"参考流水号",Int32.MaxValue,0);
cmd.Parameters.Add("@参考报价号",SqlDbType.NVarChar,100).Value=QuoteString(inputs,"参考报价号",100,true);
if (name==QuoteReference+"办理依据") { Only(inputs,"参考流水号","参考报价号"); return; }
var draft = new Dictionary<string,object>(inputs);
draft.Remove("参考流水号");
draft.Remove("参考报价号");
BindQuotationDraft(cmd,name==QuoteReference+"保存" ? QuoteDirect : QuoteDirectProof,draft);
}
const string QuoteDirect = "ai_报价管理_直接新建_保存";
const string QuoteDirectProof = "ai_报价管理_直接新建_保存回执";
const string QuoteDirectAccess = "ai_报价管理_直接新建_办理资格";
static bool QuoteFormWrite(string name) { return name==QuoteSave || name==QuoteEdit || name==QuoteDirect; }
static bool QuoteFormWrite(string name) { return name==QuoteSave || name==QuoteEdit || name==QuoteDirect || name==QuoteReference+"保存"; }
const string QuoteSubmit = "ai_报价管理_报价审批_提交";
const string QuoteSubmitBasis = "ai_报价管理_报价审批_提交依据";
const string QuoteSubmitReceipt = "ai_报价管理_报价审批_提交回执";
@@ -39,13 +52,54 @@ namespace Jingyao.AIEmployee
static bool ContractApproval(string name) {
return name==ContractReviewBasis || name==ContractReviewProof || name==ContractApprove || name==ContractReject;
}
const string LegacyRevision = "ai_合同管理_历史合同修订_";
static bool IsLegacyRevision(string name) {
return name==LegacyRevision+"办理依据" || name==LegacyRevision+"本人回执" || name==LegacyRevision+"保存";
}
static void BindLegacyRevision(SqlCommand cmd,string name,Dictionary<string,object> inputs) {
bool basis=name==LegacyRevision+"办理依据", saving=name==LegacyRevision+"保存";
if (basis) Only(inputs,"项目流水号","合同编号");
else if (saving) Only(inputs,"项目流水号","合同编号","原修订版本","合同表头Json","合同明细Json","客户端请求号");
else Only(inputs,"项目流水号","合同编号","客户端请求号");
cmd.Parameters.Add("@项目流水号",SqlDbType.BigInt).Value=Positive(inputs,"项目流水号",9007199254740991L,0);
cmd.Parameters.Add("@合同编号",SqlDbType.NVarChar,100).Value=QuoteString(inputs,"合同编号",100,true);
if (basis) return;
Guid request;
if (!Guid.TryParseExact(Text(inputs,"客户端请求号",36,null),"D",out request) || request==Guid.Empty) throw BadInput();
cmd.Parameters.Add("@客户端请求号",SqlDbType.UniqueIdentifier).Value=request;
if (!saving) return;
int version;
if (!Int32.TryParse(Text(inputs,"原修订版本",10,null),NumberStyles.None,Invariant,out version)) throw BadInput();
string header=Text(inputs,"合同表头Json",30000,null), lines=Text(inputs,"合同明细Json",100000,null);
var fields=Parse(header,false) as Dictionary<string,object>;
var rows=Parse(lines,false) as object[];
if (fields==null || rows==null || rows.Length==0) throw BadInput();
string[] editable={"客户名称","联系人","电话","地址","付款方式","交货期限","税率","经手人","签订日期","合同协议"};
Only(fields,editable);
foreach (string key in editable) {
if (!fields.ContainsKey(key) || !(fields[key] is string)) throw BadInput();
}
foreach (object item in rows) {
var line=item as Dictionary<string,object>;
if (line==null) throw BadInput();
QuoteString(line,"规格品名",4000,true);
QuoteDecimal(line,"数量",4,99999999999999.9999m,true);
QuoteDecimal(line,"单价",2,9999999999999999.99m,true);
QuoteDecimal(line,"金额",2,9999999999999999.99m,true);
}
cmd.Parameters.Add("@原修订版本",SqlDbType.Int).Value=version;
cmd.Parameters.Add("@合同表头Json",SqlDbType.NVarChar,-1).Value=header;
cmd.Parameters.Add("@合同明细Json",SqlDbType.NVarChar,-1).Value=lines;
string digest=QuoteFingerprint(cmd);
cmd.Parameters.Add("@请求指纹",SqlDbType.Char,64).Value=digest;
}
static bool ContractSubmission(string name) {
return name==ContractSubmit || name==ContractSubmitBasis || name==ContractSubmitProof || name==ContractActivate || name==ContractActivationBasis || name==ContractActivationProof;
return IsRequirementContract(name) || IsFormalEdit(name) || IsLegacyRevision(name) || name==ContractSubmit || name==ContractSubmitBasis || name==ContractSubmitProof || name==ContractActivate || name==ContractActivationBasis || name==ContractActivationProof;
}
static bool QuoteSubmitQuery(string name) {
return name==ContractActivationBasis || name==ContractActivationProof || name==ContractReviewBasis || name==ContractReviewProof || name==ContractSubmitBasis || name==ContractSubmitProof || name==ContractDraftProof || name==QuoteDirectAccess || name==QuoteDirectProof || name==QuoteEditReceipt || name==QuoteSubmitBasis || name==QuoteSubmitReceipt || name==QuoteReviewBasis || name==QuoteReviewReceipt;
return name==RequirementBasis || name==RequirementProof || name==FormalEdit+"办理依据" || name==FormalEdit+"本人回执" || name==QuoteReference+"办理依据" || name==QuoteReference+"保存回执" || name==LegacyRevision+"办理依据" || name==LegacyRevision+"本人回执" || name==ContractActivationBasis || name==ContractActivationProof || name==ContractReviewBasis || name==ContractReviewProof || name==ContractSubmitBasis || name==ContractSubmitProof || name==ContractDraftProof || name==QuoteDirectAccess || name==QuoteDirectProof || name==QuoteEditReceipt || name==QuoteSubmitBasis || name==QuoteSubmitReceipt || name==QuoteReviewBasis || name==QuoteReviewReceipt;
}
static bool QuoteWrite(string name) { return name==ContractActivate || name==ContractApprove || name==ContractReject || name==ContractSubmit || name==ContractDraftSave || QuoteFormWrite(name) || name==QuoteSubmit || name==QuoteApprove || name==QuoteReject; }
static bool QuoteWrite(string name) { return name==RequirementSaveDraft || name==FormalEdit+"保存" || name==LegacyRevision+"保存" || name==ContractActivate || name==ContractApprove || name==ContractReject || name==ContractSubmit || name==ContractDraftSave || QuoteFormWrite(name) || name==QuoteSubmit || name==QuoteApprove || name==QuoteReject; }
static void BindQuoteSubmit(SqlCommand cmd,string name,Dictionary<string,object> inputs)
{
string document=(ContractApproval(name) || ContractSubmission(name)) ? "合同流水号" : "报价流水号";

View File

@@ -11,9 +11,11 @@ namespace Jingyao.AIEmployee
{
const string ReworkAccept = "ai_供应商返工接收", ReworkStart = "ai_供应商返工启动准入",
ReworkAck = "ai_供应商返工接单回执", ReworkReturn = "ai_供应商返工完成回执";
const string InternalAccept = "ai_内部返工接收";
static string ReworkRoute(string name)
{
switch (name) {
case InternalAccept: case InternalAccept + "_责任域_登记": return "/mes/internal-rework-domain-acceptance";
case ReworkAccept: case ReworkAccept + "_责任域_登记": return "/erp/supplier-rework-domain-acceptance";
case ReworkStart: case ReworkStart + "_策略版本_登记": case ReworkStart + "_启动申请_提交":
case ReworkStart + "_启动申请_复核": return "/erp/supplier-rework-start-request";
@@ -25,7 +27,7 @@ namespace Jingyao.AIEmployee
static bool ReworkQuery(string name)
{
return name == ReworkAccept || name == ReworkStart || name == ReworkAck || name == ReworkReturn;
return name == InternalAccept || name == ReworkAccept || name == ReworkStart || name == ReworkAck || name == ReworkReturn;
}
static void ReworkDate(SqlCommand command, Dictionary<string,object> inputs, string field)
@@ -56,6 +58,7 @@ namespace Jingyao.AIEmployee
}
if (body.ContainsKey("pageList") || body.ContainsKey("pageSize")) throw BadInput();
switch (name) {
case InternalAccept + "_责任域_登记":
case ReworkAccept + "_责任域_登记":
Only(inputs,"执行契约流水号","接受结论","接受意见","接受依据","幂等键");
ReworkKey(command,inputs,"执行契约流水号");