StableVersion4.3/HL_FristAidPlatform_Bussiness/TranService/CallAndDispatchTranBLL.cs

111 lines
4.3 KiB
C#

using HL_FristAidPlatform_DataBase;
using HL_FristAidPlatform_Help;
using HL_FristAidPlatform_IDataBase;
using HL_FristAidPlatform_Models;
using System;
using System.Collections.Generic;
namespace HL_FristAidPlatform_Bussiness
{
/// <summary>
/// 接警至派单
/// </summary>
public class CallAndDispatchTranBLL
{
ICallAndDispatchTranService IService = new CallAndDispatchTranService();
private IT_Base_Hospital hospitalIService = new T_Base_HospitalDB();
/// <summary>
/// 点击保存并打印派车单 事务
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public MessageModel<bool> SaveDispatchListTran(T_Service_FirstAid_Call model)
{
//1.查询医院是否存在
if (hospitalIService.GethospitalGUID(model.HospitalGuid) == null)
{
return new MessageModel<bool> { Success = false, Msg = "HospitalGUID不存在" };
}
//2.
T_Service_FirstAid_Call call = new T_Service_FirstAid_Call();
//call.HandoverState = 0;
call.TaskState = -1;
call = model;
call.DeleteFlag = 0;
call.CreateTime = DateTime.Now;
////2.派遣多辆车,拆成多条数据 人员可绑定车辆
//List<T_Service_FirstAid_Call> callList = new List<T_Service_FirstAid_Call>();
//string[] callStr = model.VehicleGUID.Split(new char[] { ',' });
//for (int i = 0; i < callStr; i++)
//{
// T_Service_FirstAid_Call call = new T_Service_FirstAid_Call();
// call.GUID = model.GUID;
// call.TaskState = -1;
// call = model;
// call.DeleteFlag = 0;
// call.CreateTime = DateTime.Now;
//}
//3.T_Service_FistAid_Personnel 人员状态修改 T_Service_FristAid_DrivingRecord
List<T_Service_FirstAid_Personnel> perList = new List<T_Service_FirstAid_Personnel>();
List<T_Service_FirstAid_DrivingRecord> recordList = new List<T_Service_FirstAid_DrivingRecord>();
string[] after = model.AccompanyinPersonnel.Split(new char[] { ',' });
for (int i = 0; i < after.Length; i++)
{
T_Service_FirstAid_Personnel personnel = new T_Service_FirstAid_Personnel();
personnel.GUID = after[i];
perList.Add(personnel);
T_Service_FirstAid_DrivingRecord record = new T_Service_FirstAid_DrivingRecord();
record.PersonnelGUID = after[i];
record.HospitalGuid = model.HospitalGuid;
recordList.Add(record);
}
//4.T_Service_FristAid_DrivingCensus 出车统计新增
T_Service_FirstAid_DrivingCensus dringCensus = new T_Service_FirstAid_DrivingCensus();
dringCensus.CreateUser = model.CreateUser;
dringCensus.PersonnelSum = after.Length;
dringCensus.PatientSum = model.PatientNumber;
dringCensus.DrivingSum = 1;
dringCensus.HospitalGuid = model.HospitalGuid;
//5.T_Base_WristStrap 更新
T_Base_WristStrap wristStrap = new T_Base_WristStrap();
if (model.WristStrapID > 0)
{
wristStrap.ID = Convert.ToInt32(model.WristStrapID);
}
//6.T_Base_Ambulance 更新
string[] vehicle = model.VehicleGUID.Split(new char[] { ',' });
List<T_Base_Ambulance> ambulancesList = new List<T_Base_Ambulance>();
if (vehicle.Length>0)
{
for (int i = 0; i < vehicle.Length; i++)
{
T_Base_Ambulance ambulance = new T_Base_Ambulance();
ambulance.GUID = vehicle[i];
ambulancesList.Add(ambulance);
}
}
if (IService.SaveDispatchListTran(call, perList, dringCensus, recordList, wristStrap, ambulancesList))
{
return new MessageModel<bool> { Success = true, Msg = "操作成功" };
}
else
{
return new MessageModel<bool> { Success = false, Msg = "操作失败" };
}
}
}
}