yuanrf 3 weeks ago
parent
commit
2d126c5130

+ 181 - 1
OASystem/OASystem.Api/Controllers/MarketCustomerResourcesController.cs

@@ -341,21 +341,143 @@ namespace OASystem.API.Controllers
             return keyValuePairs;
         }
 
+        private Dictionary<int, List<int>> MCRSecondSetting()
+        {
+            Dictionary<int, List<int>> keyValuePairs = new Dictionary<int, List<int>>();
+
+            // 四川
+            keyValuePairs.Add(349, new List<int>() { 376, 378, 381, 387, 389, 1296 }); // 四川省级
+            keyValuePairs.Add(350, new List<int>() { 377, 382, 388, 390, 1303 }); // 成都市级
+            keyValuePairs.Add(348, new List<int>() { 387 }); // 四川地市州 - Explicitly assigning to ensure all source2 IDs are used
+            keyValuePairs.Add(701, new List<int>() { 388 }); // 成都区市县
+
+            // 云南
+            keyValuePairs.Add(399, new List<int>() { 407, 408, 409, 410, 451 }); // 云南省级
+            keyValuePairs.Add(400, new List<int>() { 449, 452, 453, 1297, 1304 }); // 昆明市级
+            keyValuePairs.Add(450, new List<int>() { 410 }); // 云南地市州
+            keyValuePairs.Add(566, new List<int>() { 567 }); // 昆明区市县
+
+            // 贵州
+            keyValuePairs.Add(401, new List<int>() { 424, 426, 427, 428, 1298 }); // 贵州省级
+            keyValuePairs.Add(402, new List<int>() { 425, 429, 1306, 1307 }); // 贵阳市级
+            keyValuePairs.Add(414, new List<int>() { 428 }); // 贵州地市州
+            keyValuePairs.Add(1305, new List<int>() { /* Add relevant IDs if available */ }); // 贵阳区市县 - Placeholder for now
+
+
+            // 重庆
+            keyValuePairs.Add(403, new List<int>() { 417, 418, 454, 456 }); // 重庆市级
+            keyValuePairs.Add(404, new List<int>()); // 重庆区县 - No direct match in source1
+            keyValuePairs.Add(1313, new List<int>()); // 重庆地市州 - No direct match in source1
+
+
+            // 西藏
+            keyValuePairs.Add(405, new List<int>() { 415 }); // 西藏自治区
+            keyValuePairs.Add(406, new List<int>() { 455 }); // 拉萨市级
+            keyValuePairs.Add(413, new List<int>() { 416 }); // 西藏地市州
+
+
+            // 青海
+            keyValuePairs.Add(579, new List<int>() { 581, 582, 583, 1300 }); // 青海省级
+            keyValuePairs.Add(580, new List<int>() { 1299 }); // 青海市州县  (Includes 地市州)
+
+
+            // 陕西
+            keyValuePairs.Add(585, new List<int>() { 588, 589, 590, 591, 1301 }); // 陕西省级
+            keyValuePairs.Add(586, new List<int>() { 589 }); // 陕西地市州
+            keyValuePairs.Add(587, new List<int>() { 592, 593, 1309, 1310 }); // 西安市级
+            keyValuePairs.Add(1308, new List<int>() { /* Add relevant IDs if available */ }); // 西安区市县 - Placeholder
+
+
+            // 宁夏
+            keyValuePairs.Add(594, new List<int>() { 597, 598, 599, 600, 601 }); // 宁夏自治区 (Includes 地市州 and 区级)
+            keyValuePairs.Add(595, new List<int>() { 597 }); // 宁夏地市州
+            keyValuePairs.Add(596, new List<int>() { 598, 599, 600, 603, 604 }); // 银川市级 (Includes 区级)
+            keyValuePairs.Add(602, new List<int>()); // 银川区市县 - No direct match, but could be considered covered by "区级"
+
+
+            // 甘肃
+            keyValuePairs.Add(614, new List<int>() { 617, 618, 619, 620, 621, 1302 }); // 甘肃省级
+            keyValuePairs.Add(615, new List<int>() { 618 }); // 甘肃地市州
+            keyValuePairs.Add(616, new List<int>() { 622, 623, 624, 1312 }); // 兰州市级
+            keyValuePairs.Add(1311, new List<int>() { /* Add relevant IDs if available */ }); // 兰州区市县 - Placeholder
+
+
+            // 新疆
+            keyValuePairs.Add(627, new List<int>() { 630, 631, 632 }); // 新疆自治区级
+            keyValuePairs.Add(628, new List<int>() { /*No Direct Match*/ }); // 新疆地市州 - No direct match
+            keyValuePairs.Add(629, new List<int>() { 633 }); // 乌鲁木齐市级
+
+            // 中央直属企业 (Special case)
+            keyValuePairs.Add(351, new List<int>() { 754 }); //  Using "未分级" for 中央直属企业
+
+
+            return keyValuePairs;
+        }
+
+        private Dictionary<int, List<int>> MCRLvSetting()
+        {
+            var keyValuePairs = new Dictionary<int, List<int>>();
+
+            // 四川 (419)
+            keyValuePairs.Add(419, new List<int>() { 348, 349, 350, 701 }); // Includes all Sichuan-related IDs from source2
+
+            // 云南 (420)
+            keyValuePairs.Add(420, new List<int>() { 399, 400, 450, 566 }); // Includes all Yunnan-related IDs
+
+            // 贵州 (421)
+            keyValuePairs.Add(421, new List<int>() { 401, 402, 414 });
+
+            // 西藏 (422)
+            keyValuePairs.Add(422, new List<int>() { 405, 406, 413 });
+
+            // 重庆 (423)
+            keyValuePairs.Add(423, new List<int>() { 403, 404 });
+
+            // 青海 (578)
+            keyValuePairs.Add(578, new List<int>() { 579, 580, 626 }); // Includes 市州县 and 西宁市级
+
+            // 陕西 (605)
+            keyValuePairs.Add(605, new List<int>() { 585, 586, 587 });
+
+            // 宁夏 (606)
+            keyValuePairs.Add(606, new List<int>() { 594, 595, 596 });
+
+            // 甘肃 (625)
+            keyValuePairs.Add(625, new List<int>() { 614, 615, 616 });
+
+            // 新疆 (634)
+            keyValuePairs.Add(634, new List<int>() { 627, 628, 629 });
+
+            // 未分级 (351) -  You'll likely want to remove this as it's no longer a primary key.
+            //  keyValuePairs.Add(351, new List<int>());  //Remove this line.
+
+            return keyValuePairs;
+        }
+
+
         [HttpPost]
         
         public IActionResult QueryClientType(QueryClientTypeDto Dto)
         {
             var jw = JsonView(true,"获取成功!");
 
+            var dic_lv = MCRLvSetting();
             var keyValuePairs = MCRSetting();
             ArrayList arr = new ArrayList();
+            ArrayList lvArr = new ArrayList();
             var ids = new List<int>();
+            var lvids = new List<int>();
             foreach (var item in Dto.SetDataIdArr)
             {
                 if (keyValuePairs.Keys.Contains(item))
                 {
                     ids.AddRange(keyValuePairs[item]);
                 }
+
+                if (dic_lv.Keys.Contains(item))
+                {
+                    lvids.AddRange(dic_lv[item]);
+                }
             }
 
             arr.AddRange(_sqlSugar.Queryable<Sys_SetData>()
@@ -376,11 +498,69 @@ namespace OASystem.API.Controllers
             // 使用ArrayList.Sort方法和自定义比较器对arr进行排序
             arr.Sort(remakeComparer);
 
-            jw.Data = arr;
+            var rangelv = _sqlSugar.Queryable<Sys_SetData>()
+                       .Where(u => lvids.Contains(u.Id) && u.IsDel == 0)
+                       .Select(x => new { x.Id, x.Name })
+                       .ToList();
+
+            lvArr.AddRange(rangelv);
+
+            if (lvArr.Count == 0)
+            {
+                lvArr.AddRange(_sqlSugar.Queryable<Sys_SetData>()
+                        .Where(u => u.STid == 33 && u.IsDel == 0)
+                        .Select(x => new { x.Id, x.Name}).ToList());
+            }
+
+            jw.Data = new
+            {
+                TypeArr = arr,
+                LvArr = lvArr,
+            };
             
             return Ok(jw);
         }
 
+        [HttpPost]
+
+        public IActionResult QueryClientTypeSecond(QueryClientTypeDto Dto)
+        {
+            var jw = JsonView(true, "获取成功!");
+
+            var keyValuePairs = MCRSecondSetting();
+            ArrayList arr = new ArrayList();
+            var ids = new List<int>();
+            foreach (var item in Dto.SetDataIdArr)
+            {
+                if (keyValuePairs.Keys.Contains(item))
+                {
+                    ids.AddRange(keyValuePairs[item]);
+                }
+            }
+
+            arr.AddRange(_sqlSugar.Queryable<Sys_SetData>()
+                       .Where(u => ids.Contains(u.Id) && u.IsDel == 0)
+                       .Select(x => new { x.Id, x.Name, x.Remark })
+                       .ToList());
+
+            if (arr.Count == 0)
+            {
+                arr.AddRange(_sqlSugar.Queryable<Sys_SetData>()
+                        .Where(u => u.STid == 37 && u.IsDel == 0)
+                        .Select(x => new { x.Id, x.Name, x.Remark }).ToList());
+            }
+
+            // 创建比较器实例
+            IComparer remakeComparer = new RemakeComparer();
+
+            // 使用ArrayList.Sort方法和自定义比较器对arr进行排序
+            arr.Sort(remakeComparer);
+
+            jw.Data = arr;
+
+            return Ok(jw);
+        }
+
         [HttpPost]
         public IActionResult SynchronizationData()
         {

+ 5 - 0
OASystem/OASystem.Domain/Dtos/CRM/NewClientDataQueryDto.cs

@@ -230,6 +230,11 @@ namespace OASystem.Domain.Dtos.CRM
         public List<int> SetDataIdArr { get; set; }
     }
 
+    public class MCRLvSettingDto
+    {
+        public List<int> SetDataIdArr { get; set; }
+    }
+
     public class RemakeComparer : IComparer
     {
         public int Compare(object x, object y)