From b20a34e8277267124f9708c2c97e92ed1052fa08 Mon Sep 17 00:00:00 2001
From: username@email.com <yzy2002yzy@163.com>
Date: 星期六, 12 十一月 2022 14:43:48 +0800
Subject: [PATCH] 自动抓取中标项目
---
zhengcaioa/zhengcaioa/Controllers/BusinessOrder/OrderBanciOrderController.cs | 448 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 429 insertions(+), 19 deletions(-)
diff --git a/zhengcaioa/zhengcaioa/Controllers/BusinessOrder/OrderBanciOrderController.cs b/zhengcaioa/zhengcaioa/Controllers/BusinessOrder/OrderBanciOrderController.cs
index 6d66d4f..83c6d9d 100644
--- a/zhengcaioa/zhengcaioa/Controllers/BusinessOrder/OrderBanciOrderController.cs
+++ b/zhengcaioa/zhengcaioa/Controllers/BusinessOrder/OrderBanciOrderController.cs
@@ -18,6 +18,10 @@
using CommonToolsCore;
using Services;
using System.Transactions;
+using Microsoft.Extensions.Configuration;
+using Newtonsoft.Json.Linq;
+using System.Net.Http.Headers;
+using System.IdentityModel.Tokens.Jwt;
namespace zhengcaioa.Controllers.BusinessOrder
{
@@ -29,10 +33,18 @@
private readonly IOrderBanciDtlService _orderBanciDtlService;
private readonly IOrderBanciOrderService _orderBanciOrderService;
private readonly IFiOrderrecievemoneyService _fiOrderrecievemoneyService;
+ private readonly ICooperOrderService _cooperOrderService;
+ private readonly IConfiguration _configuration;
+ private readonly IHttpClientFactory _clientFactory;
+ private readonly IPltPageService _pltPageService;
public OrderBanciOrderController(ILogger<OrderBanciOrderController> logger, ILiaotianService liaotianService, IOrderBanciService orderBanciService, IOrderBanciDtlService orderBanciDtlService
,IOrderBanciOrderService orderBanciOrderService
- , IFiOrderrecievemoneyService fiOrderrecievemoneyService)
+ , IFiOrderrecievemoneyService fiOrderrecievemoneyService
+ , ICooperOrderService cooperOrderService
+ , IConfiguration configuration
+ , IHttpClientFactory clientFactory
+ , IPltPageService pltPageService)
{
_logger = logger;
_liaotianService = liaotianService;
@@ -40,6 +52,10 @@
_orderBanciDtlService = orderBanciDtlService;
_fiOrderrecievemoneyService = fiOrderrecievemoneyService;
_orderBanciOrderService = orderBanciOrderService;
+ _cooperOrderService = cooperOrderService;
+ _configuration = configuration;
+ _clientFactory = clientFactory;
+ _pltPageService = pltPageService;
}
[CheckLogin]
@@ -62,28 +78,41 @@
//actionEntity1.PageIco = "fa fa-plus";
//actionEntity1.ActionName = "鏂板";
//actionlist.Add(actionEntity1);
- ActionEntity actionEntity3 = new ActionEntity();
- actionEntity3.OpenType = 0;
- actionEntity3.ActionUrl = "";
- actionEntity3.ActionFun = "Print";
- actionEntity3.PageIco = "fa fa-print";
- actionEntity3.ActionName = "鎵撳嵃";
- actionlist.Add(actionEntity3);
+ //ActionEntity actionEntity3 = new ActionEntity();
+ //actionEntity3.OpenType = 0;
+ //actionEntity3.ActionUrl = "";
+ //actionEntity3.ActionFun = "Print";
+ //actionEntity3.PageIco = "fa fa-print";
+ //actionEntity3.ActionName = "鎵撳嵃";
+ //actionlist.Add(actionEntity3);
- ActionEntity actionEntity4 = new ActionEntity();
- actionEntity4.OpenType = 0;
- actionEntity4.ActionUrl = "";
- actionEntity4.ActionFun = "Duanxin";
- actionEntity4.PageIco = "";
- actionEntity4.ActionName = "鍙戦�佺煭淇�";
- actionlist.Add(actionEntity4);
+ //ActionEntity actionEntity4 = new ActionEntity();
+ //actionEntity4.OpenType = 0;
+ //actionEntity4.ActionUrl = "";
+ //actionEntity4.ActionFun = "Duanxin";
+ //actionEntity4.PageIco = "";
+ //actionEntity4.ActionName = "鍙戦�佺煭淇�";
+ //actionlist.Add(actionEntity4);
+ var pageEntities = _pltPageService.GetUserPage(curentuser.Id, "/OrderBanciOrder/Index/");
+ var pageEntities1 = pageEntities.Where(x => x.PageMethod == "01").ToList();
+ foreach (var pageEntity in pageEntities1)
+ {
+ ActionEntity actionEntity1 = new ActionEntity();
+ actionEntity1.OpenType = pageEntity.OpenType;
+ actionEntity1.ActionUrl = "";
+ actionEntity1.ActionFun = pageEntity.PageShortcut;
+ actionEntity1.PageIco = pageEntity.PageIco;
+ actionEntity1.ActionName = pageEntity.PageName;
+ actionlist.Add(actionEntity1);
+ }
ViewData["ActionInfo"] = actionlist;
- ViewBag.kechengleixing = _liaotianService.GetSYScode("order_banci_order", "kechengleixing_id").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
+ ViewBag.kechengleixing = _liaotianService.GetSYScode("order_banci_order", "kechengleixing_id").Where(x=>x.CodeSn=="3").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
-
+ ViewBag.Baomingtimebegin = DateTime.Now.AddYears(-1).ToString("yyyy-MM-dd");
+ ViewBag.Baomingtimeend = DateTime.Now.ToString("yyyy-MM-dd");
return View();
@@ -95,7 +124,156 @@
return new JsonResult(_orderBanciOrderService.SearchByPaging(search));
}
+ [CheckLogin]
+ public IActionResult Indexzhuanjia()
+ {
+ var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
+ ViewData["curentuser"] = curentuser;
+ List<ActionEntity> actionlist = new List<ActionEntity>();
+ ActionEntity actionEntity = new ActionEntity();
+ actionEntity.OpenType = 0;
+ actionEntity.ActionUrl = "";
+ actionEntity.ActionFun = "Search";
+ actionEntity.PageIco = "fa fa-search";
+ actionEntity.ActionName = "鏌ヨ";
+ actionlist.Add(actionEntity);
+ //ActionEntity actionEntity1 = new ActionEntity();
+ //actionEntity1.OpenType = 0;
+ //actionEntity1.ActionUrl = "";
+ //actionEntity1.ActionFun = "Add";
+ //actionEntity1.PageIco = "fa fa-plus";
+ //actionEntity1.ActionName = "鏂板";
+ //actionlist.Add(actionEntity1);
+ //ActionEntity actionEntity3 = new ActionEntity();
+ //actionEntity3.OpenType = 0;
+ //actionEntity3.ActionUrl = "";
+ //actionEntity3.ActionFun = "Print";
+ //actionEntity3.PageIco = "fa fa-print";
+ //actionEntity3.ActionName = "鎵撳嵃";
+ //actionlist.Add(actionEntity3);
+
+ //ActionEntity actionEntity4 = new ActionEntity();
+ //actionEntity4.OpenType = 0;
+ //actionEntity4.ActionUrl = "";
+ //actionEntity4.ActionFun = "Duanxin";
+ //actionEntity4.PageIco = "";
+ //actionEntity4.ActionName = "鍙戦�佺煭淇�";
+ //actionlist.Add(actionEntity4);
+
+ var pageEntities = _pltPageService.GetUserPage(curentuser.Id, "/OrderBanciOrder/Indexzhuanjia/");
+ var pageEntities1 = pageEntities.Where(x => x.PageMethod == "01").ToList();
+ foreach (var pageEntity in pageEntities1)
+ {
+ ActionEntity actionEntity1 = new ActionEntity();
+ actionEntity1.OpenType = pageEntity.OpenType;
+ actionEntity1.ActionUrl = "";
+ actionEntity1.ActionFun = pageEntity.PageShortcut;
+ actionEntity1.PageIco = pageEntity.PageIco;
+ actionEntity1.ActionName = pageEntity.PageName;
+ actionlist.Add(actionEntity1);
+ }
+
+ ViewData["ActionInfo"] = actionlist;
+
+ var pageEntities2 = pageEntities.Where(x => x.PageMethod == "02").ToList();
+ ViewData["ActionInfo2"] = pageEntities2;
+
+ ViewBag.kechengleixing = _liaotianService.GetSYScode("order_banci_order", "kechengleixing_id").Where(x => x.CodeSn != "3" && x.CodeSn != "7").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
+
+ ViewBag.Baomingtimebegin = DateTime.Now.AddYears(-1).ToString("yyyy-MM-dd");
+ ViewBag.Baomingtimeend = DateTime.Now.ToString("yyyy-MM-dd");
+
+ return View();
+
+ }
+
+
+ [CheckLogin]
+ public IActionResult IndexGuwen()
+ {
+ var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
+ ViewData["curentuser"] = curentuser;
+ List<ActionEntity> actionlist = new List<ActionEntity>();
+ ActionEntity actionEntity = new ActionEntity();
+ actionEntity.OpenType = 0;
+ actionEntity.ActionUrl = "";
+ actionEntity.ActionFun = "Search";
+ actionEntity.PageIco = "fa fa-search";
+ actionEntity.ActionName = "鏌ヨ";
+ actionlist.Add(actionEntity);
+ //ActionEntity actionEntity1 = new ActionEntity();
+ //actionEntity1.OpenType = 0;
+ //actionEntity1.ActionUrl = "";
+ //actionEntity1.ActionFun = "Add";
+ //actionEntity1.PageIco = "fa fa-plus";
+ //actionEntity1.ActionName = "鏂板";
+ //actionlist.Add(actionEntity1);
+ //ActionEntity actionEntity3 = new ActionEntity();
+ //actionEntity3.OpenType = 0;
+ //actionEntity3.ActionUrl = "";
+ //actionEntity3.ActionFun = "Print";
+ //actionEntity3.PageIco = "fa fa-print";
+ //actionEntity3.ActionName = "鎵撳嵃";
+ //actionlist.Add(actionEntity3);
+
+
+ //ActionEntity actionEntity4 = new ActionEntity();
+ //actionEntity4.OpenType = 0;
+ //actionEntity4.ActionUrl = "";
+ //actionEntity4.ActionFun = "Duanxin";
+ //actionEntity4.PageIco = "";
+ //actionEntity4.ActionName = "鍙戦�佺煭淇�";
+ //actionlist.Add(actionEntity4);
+ var pageEntities = _pltPageService.GetUserPage(curentuser.Id, "/OrderBanciOrder/IndexGuwen/");
+ var pageEntities1 = pageEntities.Where(x => x.PageMethod == "01").ToList();
+ foreach (var pageEntity in pageEntities1)
+ {
+ ActionEntity actionEntity1 = new ActionEntity();
+ actionEntity1.OpenType = pageEntity.OpenType;
+ actionEntity1.ActionUrl = "";
+ actionEntity1.ActionFun = pageEntity.PageShortcut;
+ actionEntity1.PageIco = pageEntity.PageIco;
+ actionEntity1.ActionName = pageEntity.PageName;
+ actionlist.Add(actionEntity1);
+ }
+
+ ViewData["ActionInfo"] = actionlist;
+
+ ViewBag.kechengleixing = _liaotianService.GetSYScode("order_banci_order", "kechengleixing_id").Where(x => x.CodeSn == "7").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
+
+ ViewBag.Baomingtimebegin = DateTime.Now.AddYears(-1).ToString("yyyy-MM-dd");
+ ViewBag.Baomingtimeend = DateTime.Now.ToString("yyyy-MM-dd");
+
+ return View();
+
+ }
+
+
+ [CheckLogin]
+ public IActionResult Printhetong(string id = null)
+ {
+ var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
+ ViewData["curentuser"] = curentuser;
+
+ //鎶曡瘔涔�
+ var orderBanciOrderDTO = _orderBanciOrderService.Get(id);
+
+ orderBanciOrderDTO.XuefeiName = MoneyToUpperHelper.MoneyToUpper(orderBanciOrderDTO.Xuefei.Value.ToString("0.##"));
+
+
+ var frameworkUser = _cooperOrderService.GetFrameworkUsers(orderBanciOrderDTO.PersonId);
+ if (frameworkUser != null)
+ {
+ orderBanciOrderDTO.Xingming = frameworkUser.Name;
+ orderBanciOrderDTO.Lianxidianhua = frameworkUser.Itcode;
+ }
+
+
+
+ ViewData.Model = orderBanciOrderDTO;
+ return View();
+ }
[CheckLogin]
public IActionResult print(OrderBanciOrderDTOSearch search)
@@ -160,7 +338,7 @@
resultEntity.Message = "鏃犺仈绯讳汉";
}
- string sss = SMSHelper.PushWToUserMES(number.ToString(), neirong);
+ string sss = SMSHelper.PushWToUserMES(number.ToString(), neirong );
if (int.Parse(sss) <= 0)
{
resultEntity.Result = false;
@@ -257,6 +435,196 @@
}
+ /// <summary>
+ /// 淇濆瓨
+ /// </summary>
+ /// <param name="data">宀椾綅瀹炰綋绫诲璞�</param>
+ /// <returns></returns>
+ ///
+ [HttpPost]
+ public IActionResult JifenSave([FromBody] OrderBanciOrderDTO data)
+ {
+ //var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
+ //ViewData["curentuser"] = curentuser;
+ ReturnMsg<OrderBanciOrderDTO> returnMsg = new ReturnMsg<OrderBanciOrderDTO>();
+ returnMsg.code = 2;
+ try
+ {
+ string userid = "";
+ var headers = Request.Headers;
+ if (headers != null)
+ {
+ //string SecurityKey = _configuration.GetSection("SecurityKey").Value;
+ var keyId = headers["Authorization"].FirstOrDefault();
+ if (string.IsNullOrEmpty("keyId"))
+ {
+ returnMsg.code = 2;
+ returnMsg.error = "娌℃湁鑾峰彇鍒皌oken";
+ returnMsg.count = 0;
+
+ return new JsonResult(returnMsg);
+ }
+
+
+ JwtSecurityToken jwt = null;
+ var handler = new JwtSecurityTokenHandler();
+ var key1 = keyId.Replace("Bearer", "").Trim();
+ jwt = handler.ReadJwtToken(key1);
+ System.Security.Claims.Claim sss = jwt.Claims.Where(x => x.Type == "id").FirstOrDefault();
+ userid = sss.Value;
+
+ }
+ else
+ {
+ returnMsg.code = 2;
+ returnMsg.error = "娌℃湁鑾峰彇鍒皌oken";
+ returnMsg.count = 0;
+ return new JsonResult(returnMsg);
+ }
+
+ using (TransactionScope scope = new TransactionScope())
+ {
+ data.RecStatus = "A";
+ if (String.IsNullOrEmpty(data.Id))
+ {
+ data.Creater = "1";
+ data.Createtime = DateTime.Now;
+ }
+ data.Modifier = "1";
+ data.Modifytime = DateTime.Now;
+ data.PersonId = userid;
+ //OrderBanciOrderDTOSearch search = new OrderBanciOrderDTOSearch();
+ //search.page = 1;
+ //search.rows = 1000;
+ //search.BanciId = data.BanciId;
+ //ResultDataEntity<OrderBanciOrderDTO> resultDataEntity = _orderBanciOrderService.SearchByPaging(search);
+
+ if (data.Baomingrenshu.HasValue)
+ {
+ //if (resultDataEntity.DataList.Count > 0)
+ //{
+ // var orderBanciOrderDTO = resultDataEntity.DataList.OrderByDescending(x => x.Baomingrenshu).FirstOrDefault();
+
+ // data.Baomingrenshu += orderBanciOrderDTO.Baomingrenshu;
+ //}
+ }
+ else
+ {
+ //if (resultDataEntity.DataList.Count > 0)
+ //{
+ // var orderBanciOrderDTO = resultDataEntity.DataList.OrderByDescending(x => x.Baomingrenshu).FirstOrDefault();
+
+ // data.Baomingrenshu = orderBanciOrderDTO.Baomingrenshu+1;
+ //}
+ //else
+ //{
+ data.Baomingrenshu = 1;
+ //}
+ }
+ //data.Jine = resultDataEntity.DataList.Sum(x => x.Xuefei);
+ //data.Jine += data.Xuefei;
+ ResultEntity resultEntity = _orderBanciOrderService.save(data);
+ if (resultEntity.Result)
+ {
+ returnMsg.code = 1;
+ returnMsg.count = 1;
+ returnMsg.returnObj = data;
+ }
+ else
+ {
+ returnMsg.error = resultEntity.Message;
+ }
+ int OnePorints = 0;
+ var orderBanciDTO = _orderBanciService.Get(data.BanciId);
+ var orderBanciDtlDTO = _orderBanciDtlService.GetList(data.BanciId).Where(x=>x.Shangxiawu == data.KechengleixingId).FirstOrDefault();
+ if(orderBanciDtlDTO!=null&& orderBanciDtlDTO.Jifen.HasValue)
+ {
+ OnePorints = decimal.ToInt32(orderBanciDtlDTO.Jifen.Value); ;
+ }
+ else
+ {
+ returnMsg.code = 2;
+ returnMsg.error = "璇ョ彮娆′笉鑳界Н鍒嗗厬鎹�";
+ returnMsg.count = 0;
+ return new JsonResult(returnMsg);
+ }
+ string huiyuanurl = _configuration.GetSection("huiyuanurl").Value;
+ string GetYGYaoQingYonghu = _configuration.GetSection("PassPoints").Value;
+ Uri postUrl2 = new Uri(huiyuanurl + GetYGYaoQingYonghu);
+ JObject questions2 = new JObject();
+ questions2.Add("UserID", data.PersonId);
+ questions2.Add("GoodsName", data.Peixunbanci);
+ questions2.Add("Content", data.Peixunbanci);
+ questions2.Add("ToatlPorints", data.Baomingrenshu.Value* OnePorints);//璁$畻
+ questions2.Add("OnePorints", OnePorints);//璁$畻
+ questions2.Add("Count", data.Baomingrenshu);
+ questions2.Add("OderID", data.Id);
+ questions2.Add("describe", data.Peixunbanci +"绉垎鎶ュ悕");
+
+ string requestJson2 = questions2.ToString();
+ string result2 = string.Empty;
+
+ result2 = HttpClientRequest.HttpClientPost(postUrl2.ToString(), "POST", requestJson2);
+
+ //using (HttpContent httpContent = new StringContent(requestJson2))
+ //{
+ // httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+
+ // var httpClient2 = _clientFactory.CreateClient();
+ // httpClient2.Timeout = new TimeSpan(0, 0, 60);
+ // var Result2 = await httpClient2.PostAsync(postUrl2, httpContent);
+ // result2 = Result2.Content.ReadAsStringAsync().Result;
+ //}
+
+ _logger.LogInformation("result2:" + result2);
+ JObject jobjectresult = (JObject)JsonConvert.DeserializeObject(result2);
+
+ if (jobjectresult["code"] != null && jobjectresult["code"].ToString() == "1")
+ {
+ string OaWriteTrainClassOder = _configuration.GetSection("OaWriteTrainClassOder").Value;
+ Uri postUrl = new Uri(huiyuanurl + OaWriteTrainClassOder);
+ JObject questions = new JObject();
+ questions.Add("UserID", data.PersonId);
+ questions.Add("TrainClass", data.Peixunbanci);
+ questions.Add("TrainClassType", int.Parse(data.KechengleixingId));
+ questions.Add("Name", data.Xingming);//璁$畻
+ questions.Add("IdentificationNumber", data.Shenfenzheng);//璁$畻
+ questions.Add("PhoneNo", data.Lianxidianhua);
+ questions.Add("StartTime", orderBanciDTO.Shijian.Value.ToString("yyyy-MM-dd HH:mm:ss"));
+ questions.Add("BanciId", data.BanciId);
+ questions.Add("BanciAddr", orderBanciDTO.Didian);
+ questions.Add("PersonCount", data.Baomingrenshu);
+ questions.Add("Ptions", data.Baomingrenshu.Value * OnePorints);
+ string requestJson = questions.ToString();
+ string result = string.Empty;
+
+ result = HttpClientRequest.HttpClientPost(postUrl.ToString(), "POST", requestJson);
+ _logger.LogInformation("result:" + result);
+ scope.Complete();
+ }
+ else
+ {
+ returnMsg.code = 2;
+ returnMsg.error = jobjectresult["msg"].ToString();
+ returnMsg.count = 0;
+ return new JsonResult(returnMsg);
+ }
+
+
+ }
+ }
+ catch (Exception ex)
+ {
+ returnMsg.code = 2;
+ returnMsg.error = "娌℃湁鑾峰彇鍒皌oken";
+ returnMsg.count = 0;
+
+ }
+
+ return new JsonResult(returnMsg);
+ }
+
+
//鑾峰彇褰撳墠鐨勬姤鍚嶇殑浜烘暟
public IActionResult GetBaoMingRenShu([FromBody] OrderBanciOrderDTOSearch search)
@@ -322,7 +690,7 @@
{
search.page = 1;
- search.rows = 1;
+ search.rows = 10000;
search.Fkzt = "03";
ResultDataEntity<FiOrderrecievemoneyDTO> resultDataEntity = _fiOrderrecievemoneyService.SearchByPaging(search);
@@ -341,5 +709,47 @@
return new JsonResult(returnMsg);
}
+
+ /// <summary>
+ /// 淇濆瓨
+ /// </summary>
+ /// <param name="data">宀椾綅瀹炰綋绫诲璞�</param>
+ /// <returns></returns>
+ ///
+ public IActionResult Delete(string OrderId)
+ {
+ //var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
+ //ViewData["curentuser"] = curentuser;
+ ReturnMsg<OrderBanciOrderDTO> returnMsg = new ReturnMsg<OrderBanciOrderDTO>();
+ returnMsg.code = 2;
+ try
+ {
+
+ ResultEntity resultEntity = _orderBanciOrderService.DeleteStatus(OrderId);
+ if (resultEntity.Result)
+ {
+ returnMsg.code = 1;
+ returnMsg.count = 1;
+ returnMsg.returnObj = null;
+ }
+ else
+ {
+ returnMsg.error = resultEntity.Message;
+ }
+
+ }
+ catch (Exception ex)
+ {
+ returnMsg.code = 2;
+ returnMsg.error = "娌℃湁鑾峰彇鍒皌oken";
+ returnMsg.count = 0;
+
+ }
+
+ return new JsonResult(returnMsg);
+ }
+
+
+
}
}
--
Gitblit v1.9.1