Browse Source

fix: 核心目录下载测试通过

zhengjie 1 year ago
parent
commit
c6c2462ff6

+ 112 - 39
Business/Local/LocalMedDirDownloadProcess.cs

@@ -8,12 +8,13 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows.Forms;
 
 namespace PTMedicalInsurance.Business
 {
     class LocalMedDirDownloadProcess : AbstractProcess
     {
-        double maxNo = 0;
+        int maxNo = 0;
         /// <summary>
         /// 药品、诊疗目录
         /// </summary>
@@ -24,17 +25,24 @@ namespace PTMedicalInsurance.Business
             // sbjgbh传需要查询的社保局编号,济南医疗传370100(或37010101),工伤传37019L(或37019L01)省医保37000000
             if(!string.IsNullOrEmpty(input["ver"].Text()))
             {
-                maxNo = double.Parse(input["ver"].Text());
+                maxNo = int.Parse(input["ver"].Text());
             }
             bool hasMore = true;
+
             while (hasMore)
             {
-                var ret = FetchDirectory(TradeEnum.DirectoryDownload,"yyxm_ds");
+
+                var ret = FetchDirectory(TradeEnum.DirectoryDownloadCore, "ylxm_ds", "sxzfbl_ds", "xj_ds");
+
                 hasMore = ret.hasMore;
+
                 updateDirectory(ret.data);
+
+                updateLimitPrice(ret.limitData);
                 // 多自费项目
-                updateSelfPercent(ret.data);
+                updateSelfPercent(ret.percentData);
             }
+
             return IrisReturn("更新成功!", null);
         }
 
@@ -65,7 +73,7 @@ namespace PTMedicalInsurance.Business
             try
             {
 
-                joIn.Add(new JProperty("params", data));
+                joIn.Add("params", JArray.Parse(JsonHelper.toJsonString(data)));
                 joIn.Add("code", "09010035");
                 joIn.Add("updateUserID", Global.user.ID);
                 InvokeHelper invoker = new InvokeHelper();
@@ -82,22 +90,40 @@ namespace PTMedicalInsurance.Business
             }
         }
 
+        private (bool hasMore, JArray data, JArray percentData, JArray limitData) FetchDirectory(TradeEnum trade, string dsName)
+        {
+            return FetchDirectory(trade,dsName,null,null);
+        }
 
-        private (bool hasMore, JArray data) FetchDirectory(TradeEnum trade, string dsName)
+        private (bool hasMore, JArray data,JArray percentData,JArray limitData) FetchDirectory(TradeEnum trade, string dsName,string percentName,string limitName)
         {
             JObject joInput = new JObject();
-            joInput["p_sxh"] = maxNo; //全量下载0,后面传最大
+            joInput["p_sxh"] = maxNo.ToString(); //全量下载0,后面传最大
             Global.pat.insuplc_admdvs = "370100";
             JObject joRtn = invoker.invokeCenterService(trade, joInput);
             if ("0".Equals(JsonHelper.getDestValue(joRtn, "resultcode")))
             {
                 // 是否还有数据
-                bool hasMore = Boolean.Parse(JsonHelper.getDestValue(joRtn, "sfjxxz"));
+                bool hasMore = "1".Equals(JsonHelper.getDestValue(joRtn, "sfjxxz"));
                 JArray data = JArray.Parse(JsonHelper.getDestValue(joRtn, dsName));
-                return (hasMore, data);
+                JArray percent = new JArray();
+                if (!string.IsNullOrEmpty(percentName))
+                {
+                    percent = JArray.Parse(JsonHelper.getDestValue(joRtn, percentName));
+                }
+                JArray limit = new JArray();
+                if (!string.IsNullOrEmpty(limitName))
+                {
+                    limit = JArray.Parse(JsonHelper.getDestValue(joRtn, limitName));
+                }
+                return (hasMore, data, percent, limit);
+            }
+            else
+            { 
+                MessageBox.Show(JsonHelper.getDestValue(joRtn, "err_msg"));
             }
 
-            return (false, new JArray());
+            return (false, new JArray(), new JArray(), new JArray());
         }
 
         /// <summary>
@@ -110,12 +136,12 @@ namespace PTMedicalInsurance.Business
             //sbjgbh传需要查询的社保局编号,济南医疗传370100(或37010101),工伤传37019L(或37019L01)
             if (!string.IsNullOrEmpty(input["ver"].Text()))
             {
-                maxNo = double.Parse(input["ver"].Text());
+                maxNo = int.Parse(input["ver"].Text());
             }
             bool hasMore = true;
             while (hasMore)
             {
-                var ret = FetchDirectory(TradeEnum.DiseaseDownload, "ybjb_ds");
+                var ret = FetchDirectory(TradeEnum.DirectoryDownloadCore, "ybjb_ds");
                 hasMore = ret.hasMore;
                 List<HBMedInsuDirectory> list = new List<HBMedInsuDirectory>();
                 foreach (var d in ret.data)
@@ -148,48 +174,55 @@ namespace PTMedicalInsurance.Business
         {
             string hisType = obj["ypbz"].Text() ?? "2";
             string hisTypeName = hisType.Equals("1") ? "药品" : "诊疗";             HBMedInsuDirectory insu = new HBMedInsuDirectory();
+
+            maxNo = Math.Max(maxNo, int.Parse(obj["sxh"].ToString()));
             insu.ID = "";
             insu.updateUserID = Global.user.ID;
             insu.HospitalDr = Global.inf.hospitalDr;
             insu.InterfaceDr = Global.inf.interfaceDr;
-            insu.Code = obj["yyxmbm"].Text();
-            insu.Name = obj["yyxmmc"].Text();
+            insu.Code = obj["ylxmbm"].Text();
+            insu.Name = obj["ylxmbzmc"].Text();
             insu.NationalCode = obj["gbxmbm"].Text();
             insu.NationalName = obj["gbxmmc"].Text();
             insu.HisType = hisType;
             insu.HisTypeName = hisTypeName;
-            insu.LocateCode = obj["ylxmbm"].Text();
-            insu.LocateName = "";
+            insu.LocateCode = obj["pms_id"].Text();
+            insu.LocateName = obj["pms_name"].Text();
             insu.DosageFormCode = obj["jxm"].Text();
             insu.DosageFormName = obj["jxm"].Text();
-            insu.CategoryCode = obj["yltclb"].Text();
+            insu.CategoryCode = obj["listtype"].Text();
             insu.CategoryName = "";
+            // 规格
             insu.Specification = obj["bzgg"].Text();
             insu.SpecificationCode = obj["gg"].Text();
             insu.UnitOfPackag = obj["dw"].Text();
-            insu.UnitOfValuation = "";
-            insu.StartDate = obj["qsrq"].Text();
-            insu.EndDate = obj["zzrq"].Text();
-            insu.PinyinSearchCode = "";
-            insu.Instructions = obj["sm"].Text();
-            insu.ExceptContent = "";
-            insu.Connotation = "";
+            insu.UnitOfValuation = obj["ms_charge_unit"].Text();
+            //insu.StartDate = obj["qsrq"].Text();
+            //insu.EndDate = obj["zzrq"].Text();
+            insu.PinyinSearchCode = obj["py"].Text();
+            insu.Instructions = obj["ms_explain"].Text();
+            insu.ExceptContent = obj["cwnr"].Text();
+            insu.Connotation = obj["xmnh"].Text();    
             insu.ValidFlag = obj["spbz"].Int();
             insu.Note = "";
             insu.VersionNO = obj["sxh"].Text();
             insu.VersionName = obj["sxh"].Text();
-            insu.UseFlag = 1;
-            insu.DrugSafetyStandardCode = "";
-            insu.ApprovalNO = "";
+            string cancelFlag = obj["zxbz"].Text();
+            insu.UseFlag = "1".Equals(cancelFlag)?0:1;
+            insu.DrugSafetyStandardCode = obj["ypbwm"].Text();
+            insu.ApprovalNO = obj["bzwh"].Text(); ;
             //insu.SpecialFlag = obj[""].Int();
             //insu.LimitFlag = obj[""].Int();
             //insu.LimitRange = obj[""].Text();
-            //insu.UniqueRecordNO = obj[""].Text();
+            insu.UniqueRecordNO = obj["sxh"].Text();
             insu.Manufacturers = obj["scqy"].Text();
             insu.SelfPercent = obj["zfbl"].Text(); 
-            //insu.ChargeItemLevelName = obj[""].Text();
-            insu.MinPackagingQuantity = obj["bzsl"].Text();
-            insu.MinPackagingUnit = obj["zxgg"].Text();
+            insu.ChargeItemLevelName = obj["mldj"].Text();
+            insu.MinPackagingQuantity = obj["zxbzsl"].Text();
+            insu.MinPackagingUnit = obj["gjjzxbzdw"].Text();
+
+            insu.UpdateTime = obj["gxsj"].Text();
+
             if (insu.SelfPercent == "100")
             {
                 insu.ChargeItemLevel = "01";
@@ -208,6 +241,48 @@ namespace PTMedicalInsurance.Business
 
             return insu;
         }
+
+        private int updateLimitPrice(JArray data)
+        {
+            if (data?.Count < 1) return 0;
+            string errMsg = "";
+            JArray joArray = new JArray();
+
+            try
+            {
+                foreach (var dir in data)
+                {
+                    dynamic joTmp = new JObject();
+                    joTmp.HospitalDr = Global.inf.hospitalDr;
+                    joTmp.InterfaceDr = Global.inf.interfaceDr;
+                    joTmp.updateUserID = Global.user.ID;
+                    joTmp.Code = dir["ylxmbm"].Text();
+                    joTmp.PersonnelType = dir["rqlb"].Text();  //人群类别
+                    joTmp.LimitType = dir["yltclb"].Text();     //限价类型(统筹类别)
+                    joTmp.BeginDate = Utils.ConvertShortDate(dir["qsrq"].Text());
+                    joTmp.EndDate = Utils.ConvertShortDate(dir["zzrq"].Text());
+                    joTmp.UpLimitAmount = dir["xj"].Text(); //限价
+                    joArray.Add(joTmp);
+                }
+                JObject joRtn = invoker.invokeInsuService(JsonHelper.setIrisInpar("09010084", joArray).ToString(), "更新限价信息");
+
+                if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
+                {
+                    return -1;
+                }
+                else
+                {
+                    outParam = joRtn.ToString();
+                    return 0;
+                }
+            }
+            catch (Exception ex)
+            {
+                outParam = "更新项目自费比例:" + ex.Message;
+                return -1;
+            }
+        }
+
         /// <summary>
         /// 如果存在同一个目录多个比例,则保存在比例扩展表
         /// </summary>
@@ -223,18 +298,16 @@ namespace PTMedicalInsurance.Business
             {
                 foreach (var dir in data)
                 {
-                    double rowNo = Double.Parse(dir["sxh"].ToString());
-                    maxNo = Math.Max(maxNo, rowNo);
-
                     dynamic joTmp = new JObject();
                     joTmp.HospitalDr = Global.inf.hospitalDr;
                     joTmp.InterfaceDr = Global.inf.interfaceDr;
                     joTmp.updateUserID = Global.user.ID;
-                    joTmp.Code = dir["yyxmbm"];
-                    joTmp.Name = dir["yyxmmc"];
-                    joTmp.PersonnelType = dir["rqlb"];    //人群类别
-                    joTmp.ProportionType = dir["yltclb"];      //自费类型(统筹类别)
-                    joTmp.Proportion = dir["zfbl"];
+                    joTmp.Code = dir["ylxmbm"].Text();
+                    joTmp.PersonnelType = "C";
+                    joTmp.ProportionType = "6";     //自费类型(统筹类别)
+                    joTmp.BeginDate = Utils.ConvertShortDate(dir["qsrq"].Text());
+                    joTmp.EndDate = Utils.ConvertShortDate(dir["zzrq"].Text());
+                    joTmp.Proportion = dir["sxzfbl"].Text();
                     joArray.Add(joTmp);
                  }
                 JObject joRtn = invoker.invokeInsuService(JsonHelper.setIrisInpar("09010085", joArray).ToString(), "更新项目自费比例");

+ 2 - 7
Common/ExpressionEvaluator.cs

@@ -18,8 +18,7 @@ namespace PTMedicalInsurance.Common
         public static string LongToDate(object timestamp)
         {
             string strValue = timestamp?.ToString();
-            DateTime dateTime = DateTimeOffset.FromUnixTimeMilliseconds(long.Parse(strValue)).DateTime;
-            return dateTime.ToString("yyyy-MM-dd");
+            return Utils.ConvertLongToDate(strValue);
         }
 
         /// <summary>
@@ -30,11 +29,7 @@ namespace PTMedicalInsurance.Common
         public static string ShortDate(object dateTime)
         {
             string strValue = (dateTime??"").ToString();
-            if (!strValue.Contains("-") && strValue.Length > 8)
-            {
-                return strValue.Substring(0, 4) + "-" + strValue.Substring(4,2) + "-"+strValue.Substring(6,2);
-            }
-            return strValue.Length > 10 ? strValue.Substring(0, 10) : strValue;
+            return Utils.ConvertShortDate(strValue);
         }
         /// <summary>
         /// 保存到扩展节点

+ 14 - 0
Common/Utils.cs

@@ -76,6 +76,20 @@ namespace PTMedicalInsurance.Common
 
         }
 
+        public static string ConvertLongToDate(string strValue)
+        {
+            DateTime dateTime = DateTimeOffset.FromUnixTimeMilliseconds(long.Parse(strValue)).DateTime;
+            return dateTime.ToString("yyyy-MM-dd");
+        }
+        public static string ConvertShortDate(string strValue)
+        {
+            if (!strValue.Contains("-") && strValue.Length >= 8)
+            {
+                return strValue.Substring(0, 4) + "-" + strValue.Substring(4, 2) + "-" + strValue.Substring(6, 2);
+            }
+            return strValue.Length > 10 ? strValue.Substring(0, 10) : strValue;
+        }
+
         #endregion
 
         #region BeanUtils

+ 1 - 1
Entity/Base/Server/HBMedInsuDirectory.cs

@@ -193,7 +193,7 @@ namespace PTMedicalInsurance.Entity
         /// <summary>
         /// 更新时间
         /// </summary>
-        public DateTime UpdateTime { get; set; }
+        public string UpdateTime { get; set; }
 
         /// <summary>
         /// 收费项目等级

+ 13 - 4
Helper/InvokeDllCenter.cs

@@ -22,15 +22,24 @@ namespace PTMedicalInsurance.Helper
                 Global.curEvt.msgid = Global.inf.hospitalNO + DateTime.Now.ToString("yyyyMMddHHmmssffff");
 
                 //调用业务函数
-                StringBuilder sbOut = new StringBuilder(40960);
+                StringBuilder sbOut = new StringBuilder(409600);
                 //insuplc_admdvs 社保清算机构
                 string orgCode = Global.pat.insuplc_admdvs;
                 string userCode = Global.user.ID;
                 string tradeNo = Global.curEvt.msgid;
                 string method = Global.curEvt.funNo;
                 string hospCode = Global.inf.hospitalNO;
-                int pRtn = BusinessHandle(orgCode,userCode,tradeNo,method,inputData, hospCode, sbOut);
-                outputData = sbOut.ToString();
+                hospCode = "011408";
+                userCode = "130046";
+                int pRtn = 0;
+                // com调用
+                cressWSDLLLib.DWCressCom comCls = new cressWSDLLLib.DWCressCom();
+                outputData = comCls.f_invoke_cress_com(orgCode, userCode, tradeNo, method, inputData, hospCode);
+
+                // dll调用
+                //pRtn = BusinessHandle(orgCode, userCode, tradeNo, method, inputData, hospCode, sbOut);
+                //outputData = sbOut.ToString();
+
                 return pRtn;
             }
             catch (Exception ex)
@@ -219,7 +228,7 @@ namespace PTMedicalInsurance.Helper
         /// <param name="outputData"></param>
         /// <returns></returns>     
         [DllImport("cressWSDLL.dll", EntryPoint = "f_invoke_cress", CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)] 
-        static extern int BusinessHandle(string sbjgbh, string czybh,string hisjyh,string method,string jsonPara,string yybm,StringBuilder outputData);
+        static extern int BusinessHandle(string sbjgbh, string czybh,string hisjyh,string method,string jsonPara,string yybm, StringBuilder outputData);
 
 
     }

+ 11 - 2
Helper/InvokeHelper.cs

@@ -31,7 +31,7 @@ using PTMedicalInsurance.Common;
 
 namespace PTMedicalInsurance.Helper
 {
-    class InvokeHelper
+    public class InvokeHelper
     {
         private string serviceURL;
         private string authorization;
@@ -185,7 +185,16 @@ namespace PTMedicalInsurance.Helper
             if (iInt == 0)
             {
                 iInt = center.Business(data, ref outputData, ref errMsg);
-                joRtn = JObject.Parse(outputData);
+                if (iInt == 0 && !string.IsNullOrEmpty(outputData))
+                {
+                    joRtn = JObject.Parse(outputData);
+                }
+                else
+                {
+                    joRtn.Add("infcode", iInt);
+                    joRtn.Add("err_msg", outputData);
+                    return joRtn;
+                }
                 return joRtn;
             }
             else

+ 9 - 9
JiNanMI.csproj

@@ -41,15 +41,6 @@
       <SpecificVersion>False</SpecificVersion>
       <HintPath>..\..\FastReport\FastReport.dll</HintPath>
     </Reference>
-    <Reference Include="FastReport.Bars">
-      <HintPath>..\..\FastReport\FastReport.Bars.dll</HintPath>
-    </Reference>
-    <Reference Include="FastReport.Compat">
-      <HintPath>..\..\FastReport\FastReport.Compat.dll</HintPath>
-    </Reference>
-    <Reference Include="FastReport.Editor">
-      <HintPath>..\..\FastReport\FastReport.Editor.dll</HintPath>
-    </Reference>
     <Reference Include="FastReportFrom">
       <HintPath>..\..\FastReport\FastReportFrom.dll</HintPath>
     </Reference>
@@ -483,6 +474,15 @@
     </None>
   </ItemGroup>
   <ItemGroup>
+    <COMReference Include="cressWSDLLLib">
+      <Guid>{5D6A3723-712A-46C4-9ED8-326F52C4B0A7}</Guid>
+      <VersionMajor>1</VersionMajor>
+      <VersionMinor>0</VersionMinor>
+      <Lcid>0</Lcid>
+      <WrapperTool>tlbimp</WrapperTool>
+      <Isolated>False</Isolated>
+      <EmbedInteropTypes>True</EmbedInteropTypes>
+    </COMReference>
     <COMReference Include="stdole">
       <Guid>{00020430-0000-0000-C000-000000000046}</Guid>
       <VersionMajor>2</VersionMajor>