123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307 |
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Data.SqlClient;
- using System.Linq;
- using System.Threading.Tasks;
- using Common.Model;
- using CoreEntity.DAL;
- using CoreEntity.Entity;
- using JCSoft.WX.Framework.Api;
- using LigerRM.Common;
- using Microsoft.AspNetCore.Http;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.Extensions.Caching.Memory;
- using Newtonsoft.Json;
- using Newtonsoft.Json.Converters;
- using Newtonsoft.Json.Serialization;
- using PublicLibrary.Json;
- using PublicLibrary.Model;
- using SupplierWeb.Codes.mvc;
- using ZcPeng.PublicLibrary;
- namespace SupplierWeb.Controllers
- {
- [Route("web/payplan")]
- [ApiController]
- public class PayPlanController : BaseController
- {
- public PayPlanController(IMemoryCache cache, IApiClient client) : base(cache, client)
- {
- }
- ////添加内部管理人员账户,采购员账号
- [AuthPermission]
- [HttpPost, Route("add")]
- public JsonResult add([FromBody]dynamic data, Int32 IsDelete = 0
- )
- {
- string SaleManId = string.Empty;
- string ContactId = string.Empty;
- string SuppliersId = string.Empty;
- decimal PTaxAmount = 0;
- string Remark = string.Empty;
- string PayType = string.Empty;
- List<APGoodsMT> apgoodsmt = new List<APGoodsMT>(0);
- if (data != null)
- {
- //Newtonsoft.Json.Linq.JArray
- ContactId = data.ContactId;
- SuppliersId = data.SuppliersId;
- PTaxAmount = data.PTaxAmount;
- Remark = data.Remark;
- PayType = data.PayType;
- if (data.apgoodsmt != null)
- {
- var list = JsonConvert.SerializeObject(data.apgoodsmt);
- apgoodsmt = JsonConvert.DeserializeObject<List<APGoodsMT>>(list);
- }
- else
- apgoodsmt = new List<APGoodsMT> { };
- //apgoodsmt = data.apgoodsmt == null ? new List < APGoodsMT > { } : data.apgoodsmt.ToObject<List<APGoodsMT>>(); ;
- }
- string result = string.Empty;
- //采购员默认第一个单的采购
- Object obj = null;
- string result1 = "";
- APGoodsMT apgmt = null;
- if (apgoodsmt != null && apgoodsmt.Count > 0)
- {
- apgmt = apgoodsmt[0];
- var success1 = DataAccess.GetOneValue("select SaleManId from PurInMT where BillNo = " + apgoodsmt[0].BillNo, out obj, out result1);
- SaleManId = obj.ToString();
- }
- else {
- return Json(new
- {
- success = false,
- msg = "没有选择应付单据"
- });
- }
- //整单付款
- //一次只能选同一个供应商申请付款
- bool success = PlanMTDAL.addPayPlan(
- SaleManId, ContactId, SuppliersId,
- 0, Remark,
- PayType,
- apgoodsmt,
- out result,
- apgmt.EntId,
- apgmt.OrgId,
- apgmt.DeptId);
- return Json(new
- {
- success = success,
- msg = result,
- result1 = result1
- });
- }
- [HttpPost]
- [Route("getData")]
- public JsonResult GetData(string[] filters, Int32 pageIndex, Int32 pageSize,
- string sortField, Int32 sortDirection, string[] sumFields, [FromBody] dynamic data)
- {
- List<QueryFilter> filterList = new List<QueryFilter>();
- if (data != null)
- {
- if (data.filters.Count > 0)
- {
- var list = JsonConvert.SerializeObject(data.filters);
- filterList = JsonConvert.DeserializeObject<List<QueryFilter>>(list);
- }
- pageIndex = data.pageIndex;
- pageSize = data.pageSize;
- sortField = data.sortField;
- sortDirection = data.sortDirection;
- sumFields = data.sumFields.ToObject<string[]>();
- }
- var isAce = sortDirection == 0;
- var queryCondition = string.Empty;
- var param = new List<SqlParameter>(0);
- var start = (pageIndex - 1) * pageSize;
- var end = (start + 1 + pageSize);
- var dt = new DataTable();
- if (filterList != null)
- {
- queryCondition = QueryFilter.getFilterSqlParam(filterList.ToArray(), out param, new PlanMT(), "C.");
- }
- sortField = "C." + sortField;
- var sql =
- $"select * from " +
- $"(select *,row_number() over (order by " + sortField + " " + sortDirection + ") as rowNum " +
- $"from PlanMT C " +
- $"where 1 = 1 {queryCondition}" +
- $") R" +
- $" where rowNum > {start} and rowNum < {end}";
- DataAccess.GetValues(sql, ref dt, param.ToArray(), out var msg);
- IList<PlanMT> result = new List<PlanMT>();
- if (dt != null && dt.Rows.Count > 0)
- {
- result = ModelConvertHelper<PlanMT>.ConvertToModel(dt);
- }
- var jsonData = JsonConvert.SerializeObject(result);
- var countSql =
- $"select count(1) from " +
- $"(select * from PlanMT C " +
- $"where 1 = 1 {queryCondition}) R";
- var count = DataAccess.GetRowCountDefine(countSql, param.ToArray(), out var msg1);
- return Json(new
- {
- items = result,
- sum = new { },
- totalCount = count,
- msg
- });
- }
- [HttpPost]
- [Route("getDataBill")]
- public JsonResult GetDataBill(string[] filters, Int32 pageIndex, Int32 pageSize,
- string sortField, Int32 sortDirection, string[] sumFields, [FromBody] dynamic data)
- {
- List<QueryFilter> filterList = new List<QueryFilter>();
- if (data != null)
- {
- if (data.filters.Count > 0)
- {
- var list = JsonConvert.SerializeObject(data.filters);
- filterList = JsonConvert.DeserializeObject<List<QueryFilter>>(list);
- }
- pageIndex = data.pageIndex;
- pageSize = data.pageSize;
- sortField = data.sortField;
- sortDirection = data.sortDirection;
- sumFields = data.sumFields.ToObject<string[]>();
- }
- var isAce = sortDirection == 0;
- var queryCondition = string.Empty;
- var param = new List<SqlParameter>(0);
- var start = (pageIndex - 1) * pageSize;
- var end = (start + 1 + pageSize);
- var dt = new DataTable();
- if (filterList != null)
- {
- queryCondition = QueryFilter.getFilterSqlParam(filterList.ToArray(), out param, new PlanBillDT(), "C.");
- }
- sortField = "C." + sortField;
- var sql =
- $"select * from " +
- $"(select *,row_number() over (order by " + sortField + " " + sortDirection + ") as rowNum " +
- $"from PlanBillDT C " +
- $"where 1 = 1 {queryCondition}" +
- $") R" +
- $" where rowNum > {start} and rowNum < {end}";
- DataAccess.GetValues(sql, ref dt, param.ToArray(), out var msg);
- IList<PlanBillDT> result = new List<PlanBillDT>();
- if (dt != null && dt.Rows.Count > 0)
- {
- result = ModelConvertHelper<PlanBillDT>.ConvertToModel(dt);
- }
- var jsonData = JsonConvert.SerializeObject(result);
- var countSql =
- $"select count(1) from " +
- $"(select * from PlanBillDT C " +
- $"where 1 = 1 {queryCondition}) R";
- var count = DataAccess.GetRowCountDefine(countSql, param.ToArray(), out var msg1);
- return Json(new
- {
- items = result,
- sum = new { },
- totalCount = count,
- msg
- });
- }
- [HttpPost]
- [Route("getDataDT")]
- public JsonResult GetDataDT(string[] filters, Int32 pageIndex, Int32 pageSize,
- string sortField, Int32 sortDirection, string[] sumFields, [FromBody] dynamic data)
- {
- List<QueryFilter> filterList = new List<QueryFilter>();
- if (data != null)
- {
- if (data.filters.Count > 0)
- {
- var list = JsonConvert.SerializeObject(data.filters);
- filterList = JsonConvert.DeserializeObject<List<QueryFilter>>(list);
- }
- pageIndex = data.pageIndex;
- pageSize = data.pageSize;
- sortField = data.sortField;
- sortDirection = data.sortDirection;
- sumFields = data.sumFields.ToObject<string[]>();
- }
- var isAce = sortDirection == 0;
- var queryCondition = string.Empty;
- var param = new List<SqlParameter>(0);
- var start = (pageIndex - 1) * pageSize;
- var end = (start + 1 + pageSize);
- var dt = new DataTable();
- if (filterList != null)
- {
- queryCondition = QueryFilter.getFilterSqlParam(filterList.ToArray(), out param, new PlanGoodsDT(), "C.");
- }
- sortField = "C." + sortField;
- var sql =
- $"select * from " +
- $"(select *,row_number() over (order by " + sortField + " " + sortDirection + ") as rowNum " +
- $"from PlanGoodsDT C " +
- $"where 1 = 1 {queryCondition}" +
- $") R" +
- $" where rowNum > {start} and rowNum < {end}";
- DataAccess.GetValues(sql, ref dt, param.ToArray(), out var msg);
- IList<PlanGoodsDT> result = new List<PlanGoodsDT>();
- if (dt != null && dt.Rows.Count > 0)
- {
- result = ModelConvertHelper<PlanGoodsDT>.ConvertToModel(dt);
- }
- var jsonData = JsonConvert.SerializeObject(result);
- var countSql =
- $"select count(1) from " +
- $"(select * from PlanMT C " +
- $"where 1 = 1 {queryCondition}) R";
- var count = DataAccess.GetRowCountDefine(countSql, param.ToArray(), out var msg1);
- return Json(new
- {
- items = result,
- sum = new { },
- totalCount = count,
- msg
- });
- }
- }
- }
|