From 14a48ba934fabee90b5d52471ca47883f6007732 Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期三, 20 七月 2022 11:40:39 +0800
Subject: [PATCH] Excel 角色清单导入,工序检验扫码
---
VueWebApi/DLL/DAL/BasicSettingDAL.cs | 96 +++++++++++++++++++++++++++++++++++++++++------
1 files changed, 83 insertions(+), 13 deletions(-)
diff --git a/VueWebApi/DLL/DAL/BasicSettingDAL.cs b/VueWebApi/DLL/DAL/BasicSettingDAL.cs
index 94c473a..711a850 100644
--- a/VueWebApi/DLL/DAL/BasicSettingDAL.cs
+++ b/VueWebApi/DLL/DAL/BasicSettingDAL.cs
@@ -154,7 +154,19 @@
{
if (operType == "Add")
{
- sql = @"insert into TOrganization(parent_id,org_code,org_name,lm_user,lm_date,description)
+ sql = @"select * from TOrganization where org_code=@organCode";
+ dynamicParams.Add("@organCode", organCode);
+ var data = DapperHelper.selectdata(sql, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏂板鎿嶄綔澶辫触,缂栫爜閲嶅!";
+ mes.data = null;
+ return mes;
+ }
+
+ sql = @"insert into TOrganization(parent_id,org_code,org_name,lm_user,lm_date,description)
values(@supUnit,@organCode,@organName,@Operator,@CreateDate,@organType)";
list.Add(new { str = sql, parm = new { supUnit = supUnit, organCode= organCode, organName= organName, Operator= Operator, CreateDate= DateTime.Now.ToString(), organType= organType } });
//sql = @"update T_CodeRules set value=@cunm2 where rightcode=@RightCode";
@@ -423,6 +435,18 @@
{
if (OperType == "Add")
{
+ var sql0 = @"select * from TUser where usercode=@UserCode";
+ dynamicParams.Add("@UserCode", UserCode);
+ var data = DapperHelper.selectdata(sql0, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鏂板鎿嶄綔澶辫触,缂栫爜閲嶅!";
+ mes.data = null;
+ return mes;
+ }
+
var sql = @"insert into TUser(usercode,username,password,enable,mobile,lm_date,email,lm_user,stu_torgcode,wagetype,usergroup_code)
values(@UserCode,@UserName,@password,@Enable,@Mobile,@CreateDate,@Email,@Operator,@StuOrg,@wagetype,@groupcode)";
dynamicParams.Add("@UserCode", UserCode);
@@ -761,6 +785,17 @@
//寰幆鍐欏叆鐢ㄦ埛缁勮〃
for (int i = 0; i < json.Count; i++)
{
+ var sql0 = @"select * from TGroup where group_code=@group_code";
+ dynamicParams.Add("@group_code", json[i].code);
+ var data = DapperHelper.selectdata(sql0, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触,缂栫爜閲嶅!";
+ mes.data = null;
+ return mes;
+ }
sql = @"insert into TGroup(group_code,group_name,description,lm_user,lm_date) values(@groupcode,@groupename,@description,@lm_user,@lm_date)";
list.Add(new
{
@@ -896,6 +931,17 @@
//寰幆鍐欏叆瑙掕壊绫诲瀷琛�
for (int i = 0; i < json.Count; i++)
{
+ var sql0 = @"select * from TRoleType where roletype_code=@roletype_code";
+ dynamicParams.Add("@roletype_code", json[i].code);
+ var data = DapperHelper.selectdata(sql0, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触,缂栫爜閲嶅!";
+ mes.data = null;
+ return mes;
+ }
sql = @"insert into TRoleType(roletype_code,roletype_name) values(@roletypecode,@roletypename)";
list.Add(new
{
@@ -1021,7 +1067,7 @@
}
if (CreateUser != "" && CreateUser != null)
{
- search += "and A.lm_user like '%'+@CreateUser+'%' ";
+ search += "and T.username like '%'+@CreateUser+'%' ";
dynamicParams.Add("@CreateUser", CreateUser);
}
if (search == "")
@@ -1031,9 +1077,10 @@
//search = search.Substring(3);//鎴彇绱㈠紩2鍚庨潰鐨勫瓧绗�
// --------------鏌ヨ鎸囧畾鏁版嵁--------------
var total = 0; //鎬绘潯鏁�
- var sql = @"select A.id,A.role_code,A.role_name,b.roletype_code,B.roletype_name,A.description,A.lm_user,A.lm_date,A.is_user,A.is_right
+ var sql = @"select A.id,A.role_code,A.role_name,b.roletype_code,B.roletype_name,A.description,T.username as lm_user,A.lm_date,A.is_user,A.is_right
from TRole A
left join TRoleType B on A.roletype_code=B.roletype_code
+ left join TUser T on A.lm_user=T.usercode
where A.is_delete<>'1' " + search;
var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
mes.code = "200";
@@ -1060,6 +1107,17 @@
{
if (OperType == "Add")
{
+ var sql0 = @"select * from TRole where role_code=@role_code";
+ dynamicParams.Add("@role_code", RoleCode);
+ var data = DapperHelper.selectdata(sql0, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触,缂栫爜閲嶅!";
+ mes.data = null;
+ return mes;
+ }
var sql = @"insert into TRole(role_code,role_name,lm_user,lm_date,roletype_code,description)
values(@RoleCode,@RoleName,@Usercode,@CreateDate,@RoleTypeCode,@description)";
dynamicParams.Add("@RoleCode", RoleCode);
@@ -1428,12 +1486,12 @@
{
if (cuntUnitCode != "" && cuntUnitCode != null)
{
- search += "and code like '%'+@cuntUnitCode+'%' ";
+ search += "and A.code like '%'+@cuntUnitCode+'%' ";
dynamicParams.Add("@cuntUnitCode", cuntUnitCode);
}
if (cuntUnitName != "" && cuntUnitName != null)
{
- search += "and name like '%'+@cuntUnitName+'%' ";
+ search += "and A.name like '%'+@cuntUnitName+'%' ";
dynamicParams.Add("@cuntUnitName", cuntUnitName);
}
if (unitAttr != "" && unitAttr != null)
@@ -1441,22 +1499,22 @@
switch (unitAttr)
{
case "WG": //澶栬喘
- search += "and mtype=@unitAttr ";
+ search += "and A.mtype=@unitAttr ";
dynamicParams.Add("@unitAttr", unitAttr);
break;
case "WX": //澶栧崗
- search += "and btype=@unitAttr ";
+ search += "and A.btype=@unitAttr ";
dynamicParams.Add("@unitAttr", unitAttr);
break;
default: //瀹㈡埛
- search += "and htype=@unitAttr ";
+ search += "and A.htype=@unitAttr ";
dynamicParams.Add("@unitAttr", unitAttr);
break;
}
}
if (createUser != "" && createUser != null)
{
- search += "and lm_user like '%'+@createUser+'%' ";
+ search += "and T.username like '%'+@createUser+'%' ";
dynamicParams.Add("@createUser", createUser);
}
if (search == "")
@@ -1465,8 +1523,9 @@
}
// --------------鏌ヨ鎸囧畾鏁版嵁--------------
var total = 0; //鎬绘潯鏁�
- var sql = @"select id,code,name,mtype,btype,htype,conttacts,conttphone,addr,lm_user,lm_date from TCustomer
- where is_delete<>'1' " + search;
+ var sql = @"select A.id,A.code,A.name,A.mtype,A.btype,A.htype,A.conttacts,A.conttphone,A.addr,T.username as lm_user,A.lm_date from TCustomer A
+ left join TUser T on A.lm_user=T.usercode
+ where A.is_delete<>'1' " + search;
var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total);
mes.code = "200";
mes.Message = "鏌ヨ鎴愬姛!";
@@ -1492,6 +1551,17 @@
{
if (OperType == "Add")
{
+ var sql0 = @"select * from TCustomer where code=@code";
+ dynamicParams.Add("@unitcode", unitcode);
+ var data = DapperHelper.selectdata(sql0, dynamicParams);
+ if (data.Rows.Count > 0)
+ {
+ mes.code = "300";
+ mes.count = 0;
+ mes.Message = "鎿嶄綔澶辫触,缂栫爜閲嶅!";
+ mes.data = null;
+ return mes;
+ }
var sql = @"insert into TCustomer(code,name,mtype,btype,htype,conttacts,conttphone,addr,lm_user,lm_date)
values(@unitcode,@unitname,@mtypecode,@btypecode,@htypecode,@person,@contact,@description,@usercode,@CreateDate)";
dynamicParams.Add("@unitcode", unitcode);
@@ -1581,8 +1651,8 @@
mes.data = null;
return mes;
}
- //鍒犻櫎(鏇存柊鐘舵��)寰�鏉ュ崟浣嶈〃
- sql = @"update TCustomer set is_delete='1' where code=@unitcode";
+ //鍒犻櫎寰�鏉ュ崟浣嶈〃
+ sql = @"delete TCustomer where code=@unitcode";
list.Add(new { str = sql, parm = new { unitcode = unitcode } });
bool aa = DapperHelper.DoTransaction(list);
if (aa)
--
Gitblit v1.9.3