| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293 |
- using RMYY_CallCenter_Api.Controllers.CarManage;
- using RMYY_CallCenter_Api.DB;
- using RMYY_CallCenter_Api.Model;
- using RMYY_CallCenter_Api.Models.Dto;
- using RMYY_CallCenter_Api.Models.Enum;
- using RMYY_CallCenter_Api.Utility;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Web.Mvc;
- namespace RMYY_CallCenter_Api.Controllers.WorkOrder
- {
- public class WorkCommonController : BaseController
- {
- private BLL.T_Wo_CommonBase basebll = new BLL.T_Wo_CommonBase();
- private Bll.T_Sys_GongDan gdbll = new Bll.T_Sys_GongDan();
- private Bll.AddLogBll logbll = new Bll.AddLogBll();
- private static InternalMessagesController msg = new InternalMessagesController();
- /// <summary>
- /// 我的提交
- /// </summary>
- /// <param name="keyword"></param>
- /// <param name="starttime"></param>
- /// <param name="endtime"></param>
- /// <param name="pageindex"></param>
- /// <param name="pagesize"></param>
- /// <param name="state"></param>
- /// <returns></returns>
- public ActionResult GetSubmitList(string starttime = "", string endtime = "", string keyword = "", int pageindex = 1, int pagesize = 10, int state = -1, int type = 0, int loweltype = 0, string wocode = "")
- {
- if (User != null)
- {
- int recordCount = 0;
- string sql = $" and (F_ProposerDept='{User.F_DeptId}' or F_DealDept='{User.F_DeptId}' ) and F_IsDelete = 0";
- if (!string.IsNullOrEmpty(wocode))
- {
- sql += $" and F_WoCode like'%{wocode}%'";
- }
- if (type > 0)
- {
- sql += $" and F_Type={type}";
- }
- if (loweltype > 0)
- {
- sql += $" and F_SonType={loweltype}";
- }
- if (state >= 0)
- {
- sql += $" and F_IsDone={state}";
- }
- if (!string.IsNullOrEmpty(starttime))
- {
- sql += $" and F_CreateTime>='{starttime}'";
- }
- if (!string.IsNullOrEmpty(endtime))
- {
- sql += $" and F_CreateTime<'{endtime}'";
- }
- if (!string.IsNullOrEmpty(keyword))
- {
- sql += $" and F_Content like '%{keyword}%'";
- }
- DataTable datatable = Bll.PagerBll.GetListPager
- ("T_Wo_CommonBase ",
- "F_WoCode",
- "*,[dbo].[GetUserName](F_Proposer) F_ProposerName,[dbo].[GetUserName](F_DealUser) F_DealUserName",
- sql,
- "order by F_CreateTime desc",
- pagesize,
- pageindex,
- true,
- out recordCount
- );
- datatable = WorkOrderBase.SetOtherField(datatable, MENUENUM.我的提交,User.F_UserCode, User.F_RoleId);
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = datatable,
- total = recordCount
- };
- return Content(obj.ToJson());
- }
- return Error("无操作权限!");
- }
- /// <summary>
- /// 综合查询
- /// </summary>
- /// <param name="keyword"></param>
- /// <param name="starttime"></param>
- /// <param name="endtime"></param>
- /// <param name="pageindex"></param>
- /// <param name="pagesize"></param>
- /// <param name="state"></param>
- /// <returns></returns>
- public ActionResult GetComList(int? myd, string starttime = "",string phone="", string endtime = "", string keyword = "", int pageindex = 1, int pagesize = 10, int state = -1, int type = 0, int loweltype = 0, string wocode = "", int isdc = 0)
- {
- if (User != null)
- {
- int recordCount = 0;
- string sql = $" and F_IsDelete = 0 and F_Status>=0 ";
- if (!string.IsNullOrEmpty(wocode))
- {
- sql += $" and F_WoCode like'%{wocode}%'";
- }
- if (type > 0)
- {
- sql += $" and F_Type={type}";
- }
- if (myd != null)
- {
- sql += $" and MYD={myd}";
- }
- sql += "and F_Type !=4000";
- if (loweltype > 0)
- {
- sql += $" and F_SonType={loweltype}";
- }
- if (state >= 0)
- {
- sql += $" and F_IsDone={state}";
- }
- if (!string.IsNullOrEmpty(starttime))
- {
- sql += $" and F_CreateTime>='{starttime}'";
- }
- if (!string.IsNullOrEmpty(endtime))
- {
- sql += $" and F_CreateTime<'{endtime}'";
- }
- if (!string.IsNullOrEmpty(keyword))
- {
- sql += $" and F_Content like '%{keyword}%'";
- }
- if (!string.IsNullOrEmpty(phone))
- {
- sql += $" and F_Phone = '{phone}'";
- }
- if (isdc > 0)
- {
- var dtdc = DbHelperSQL.Query(" select F_WoCode 工单编号,[dbo].[GetUserName](F_Proposer) 姓名, dbo.GetGongDanNameByID(F_SonType) 工单类别, F_Content 工单内容, F_Status 工单状态, (case when MYD =0 then '满意' when MYD =1 then '基本满意' when MYD =2 then '不满意' else '' end ) MYD, F_CreateTime 创建时间 from T_Wo_CommonBase "
- + " WITH(NOLOCK) where 1=1 " + sql + "ORDER BY F_CreateTime desc").Tables[0];
- var msg = new NPOIHelper().ExportToExcel("工单列表", dtdc);
- if (msg == "")
- {
- return Success("导出成功");
- }
- else
- {
- return Error("导出失败");
- }
- }
- DataTable datatable = Bll.PagerBll.GetListPager
- ("T_Wo_CommonBase ",
- "F_WoCode",
- "*,[dbo].[GetUserName](F_Proposer) F_ProposerName,[dbo].[GetUserName](F_DealUser) F_DealUserName, (case when MYD = 0 then '不满意' when MYD = 1 then '满意' else '' end) MYD ",
- sql,
- "order by F_CreateTime desc",
- pagesize,
- pageindex,
- true,
- out recordCount
- );
- datatable = WorkOrderBase.SetOtherField(datatable, MENUENUM.工单列表,User.F_UserCode, User.F_RoleId);
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = datatable,
- total = recordCount
- };
- return Content(obj.ToJson());
- }
- return Error("无操作权限!");
- }
- //催单按钮 urge 类型 1是调度员催单 2 是申请人催单
- // 申请人:提交完工单只要工单未完成都可催单
- //调度人:已派单,没有完成状态能催单; 催单按钮在添加的时候 汉字写 催单
- public ActionResult UrgeWorkOrder(string workordercode,string reason, int urgetype = 0)
- {
- if (urgetype ==0)
- {
- return Error("需要传urgetype参数");
- }
- Model.T_Wo_CommonBase ordermodel= basebll.GetModel(workordercode);
- //工单类型上增加可催办次数字段,=0不允许催办,=-1不限制催办次数,
- //其他的 =几就是可以催办几次
-
- Model.T_Sys_GongDan gdmodel = gdbll.GetModel(ordermodel.F_SonType);
- if (gdmodel.F_CanUrgeCount == 0)
- {
- return Error("该工单类型不允许催办");
- }
- int nowcount = ordermodel.F_UrgeCount + 1;
- if (gdmodel.F_CanUrgeCount != -1 && nowcount > gdmodel.F_CanUrgeCount)
- {
- return Error("催办次数已经用光了");
- }
- ordermodel.F_UrgeCount = nowcount;
- ordermodel.F_UpdateTime = DateTime.Now;
- basebll.Update(ordermodel);
- string content = "催办了工单,催单原因"+reason;
- // string touser = "";
- EnumSmsType smytype = new EnumSmsType();
- List<string> touserlist = new List<string>();
- //获取调度中心值班人员
- // 添加日志
- switch (ordermodel.F_Type)
- {
- case 1000:
- Bll.T_Con_WorkOrder conbll = new Bll.T_Con_WorkOrder();
- Model.T_Con_WorkOrder conmodel= conbll.GetModelByCode(workordercode);
- logbll.AddLog(conmodel.F_ID, conmodel.F_State.Value, (int)conmodel.F_type1, content, (int)EnumItemType.urge, 0, User.F_UserCode, 0, User.F_UserCode);
- smytype = EnumSmsType.consulting;
- break;
- case 2000:
- SchedulingController sc = new SchedulingController();
- sc.AddOperatorLogNew(content, (int)EnumOperatorType.urge, workordercode,User.F_UserCode);
- smytype = EnumSmsType.comprehensive ;
- break;
- case 3000:
- FaultRepairController cc = new FaultRepairController();
- cc.AddOperatorLogNew(content, (int)EnumOperatorType.urge, workordercode,User.F_UserCode);
- smytype = EnumSmsType.repair;
- break;
- case 4000:
- T_Car_WorkOrderController car = new T_Car_WorkOrderController();
- car.AddOperation(content, User.F_UserCode, ordermodel.F_Status, workordercode, 0);
- smytype = EnumSmsType.car;
- break;
- }
- //发送消息
- // 点击催单给对应人发消息,如果单子在调度中心,调度中心当日值班人员都可收到消息
- if (urgetype == 1)
- {
- touserlist.Add(ordermodel.F_DealUser.Value.ToString());
- }
- else if (urgetype == 2)
- {
- if (ordermodel.F_Status == 0)
- {
- //调度中心当天的值班人员
- var GroupClass = new Bll.T_Sys_GroupClass().GetModelList("F_IsDelete=0 and datediff(day , F_Date , getdate())= 0 " +
- "and F_DeptId= ( select F_DeptId from T_Sys_Department where F_deptcode='ZHDDZX') order by F_Id asc");
- touserlist = GroupClass.Select(x => x.F_UserCode).ToList();
- }
- else
- {
- touserlist.Add(ordermodel.F_DealUser.Value.ToString());
- }
- }
- if (touserlist != null && touserlist.Count > 0)
- {
- foreach (var item in touserlist)
- {
- msg.AddInternalMessagesInfo("催单", "催单" + "工单编号:" + workordercode + "," + content, item, User.F_UserCode, smytype, 0, workordercode);
- }
- }
-
-
- return Success("成功催办");
- }
- }
- }
|