using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Http;
using VueWebApi.DLL.BLL;
using VueWebApi.Tools;
namespace VueWebApi.Controllers
{
[RoutePrefix(prefix: "api/SystemSetting")]
[ControllerGroup("系统设置", "在线接口")]
public class SystemSettingController : ApiController
{
//定义全局信息返回变量
ToMessage mes = new ToMessage();
RedisHelper redis = new RedisHelper();
#region[编码规则查询]
///
/// 编码规则查询
///
/// 编码名称
/// 固定字符
/// 页码
/// 每页显示条数
/// 排序字段
/// 排序规则
///
[Route(template: "EncodingRules")]
[HttpGet]
public HttpResponseMessage EncodingRules(string rightname = null, string prefix = null, int page = 0, int rows = 0, string prop = null, string order = null)
{
int startNum = rows * (page - 1) + 1; //起始记录rowNum
int endNum = rows * page; //结束记录 rowNum
mes = SystemSettingBLL.EncodingRules(rightname, prefix,startNum, endNum, prop, order);
return TJson.toJson(mes);
}
#endregion
#region[编码规则编辑保存]
///
/// 编码规则编辑保存
///
/// 提交数据对象
///
[Route(template: "SaveEncodingRules")]
[HttpPost]
public HttpResponseMessage SaveEncodingRules([FromBody] JObject obj)
{
string rightcode = obj["rightcode"].ToString(); //功能编码
string rightname = obj["rightname"].ToString(); //功能名称
string prefix = obj["prefix"].ToString(); //固定字符
string filingdate = obj["filingdate"].ToString(); //提交日期
string incbit = obj["incbit"].ToString(); //自增位数
var lm_user = HttpContext.Current.Request.Cookies["admin"].Value.ToString(); //操作人员
mes = SystemSettingBLL.SaveEncodingRules(rightcode, rightname,prefix, filingdate, incbit, lm_user);
return TJson.toJson(mes);
}
#endregion
#region[获取规则生成的编码(固定)]
///
/// 获取规则生成的编码
///
/// 功能编码
///
[Route(template: "NewEncodingRules")]
[HttpGet]
public HttpResponseMessage NewEncodingRules(string rightcode=null)
{
mes = SystemSettingBLL.NewEncodingRules(rightcode);
return TJson.toJson(mes);
}
#endregion
#region[生成系统条码(自定义)]
///
/// 生成系统条码(自定义)
///
/// 功能编码
/// 物料编码
/// 数量
/// 单标签数量
///
[Route(template: "LabelBarCode")]
[HttpGet]
public HttpResponseMessage LabelBarCode(string rightcode, string partcode, string qty, string onelabqty)
{
mes = SystemSettingBLL.LabelBarCode(rightcode, partcode, qty, onelabqty);
return TJson.toJson(mes);
}
#endregion
#region[车间公告列表]
///
/// 车间公告列表
///
/// 车间编码
/// 公告主题
/// 公告内容
/// 是否撤销
/// 公告等级
/// 页码
/// 每页显示条数
/// 排序字段
/// 排序规则
///
[Route(template: "SystemAnnouncementSearch")]
[HttpGet]
public HttpResponseMessage SystemAnnouncementSearch(string wkspcode = null, string ancetitle = null,string ancecont=null,string cancel=null,string level=null, int page = 0, int rows = 0, string prop = null, string order = null)
{
int startNum = rows * (page - 1) + 1; //起始记录rowNum
int endNum = rows * page; //结束记录 rowNum
mes = SystemSettingBLL.SystemAnnouncementSearch(wkspcode, ancetitle, ancecont, cancel, level, startNum, endNum, prop, order);
return TJson.toJson(mes);
}
#endregion
#region[车间公告新增编辑提交]
///
/// 车间公告新增编辑提交
///
/// id
/// 车间集合
/// 公告主题
/// 公告内容
/// 公告等级
/// 是否撤销
/// 操作类型
///
[Route(template: "SystemAnnouncementAddUpdate")]
[HttpPost]
public HttpResponseMessage SystemAnnouncementAddUpdate(DataTable dt,string ancetitle,string ancecont,string level,string cancel,string opertype, string id = null)
{
var username = HttpContext.Current.Request.Cookies["admin"].Value.ToString(); //操作人员
mes = SystemSettingBLL.SystemAnnouncementAddUpdate(id,dt, ancetitle, ancecont, cancel, level, username, opertype);
return TJson.toJson(mes);
}
#endregion
#region[车间公告删除]
///
/// 车间公告删除
///
/// id
///
[Route(template: "SystemAnnouncementDelete")]
[HttpPost]
public HttpResponseMessage SystemAnnouncementDelete(string id)
{
mes = SystemSettingBLL.SystemAnnouncementDelete(id);
return TJson.toJson(mes);
}
#endregion
#region[获取单据号]
///
/// 获取单据号
///
/// 功能编码
///
[Route(template: "NewOrderCodeSearch")]
[HttpPost]
public HttpResponseMessage NewOrderCodeSearch(string rightcode)
{
mes = ProductionManagementBLL.ProductInHouseOrderCodeSearch(rightcode);
return TJson.toJson(mes);
}
#endregion
#region[App版本升级接口]
///
/// App版本升级接口
///
/// 设备id
/// App当前使用版本号
///
[Route(template: "AppUpgrade")]
[HttpPost]
public HttpResponseMessage AppUpgrade(string rid, string vision)
{
mes = SystemSettingBLL.AppUpgrade(rid, vision);
return TJson.toJson(mes);
}
#endregion
}
}