public bool NoVillageTransferPerson(NoVillageTransferPerson request) { using (var db = DbFactory.Open()) { var adcdInfo = ZZTXManager.GetADCDInfoByADCD(request.adcd); var info = new VillageTransferPerson(); info.adcd = request.adcd; info.Year = DateTime.Now.Year; info.IfTransfer = 1; if (AuditNums != null) { info.AuditNums = AuditNums + 1; } //新数据 List <VillageTransferPerson> _newdata = new List <VillageTransferPerson>(); _newdata.Add(info); // operateLog log = new operateLog(); log.userName = RealName; log.operateTime = DateTime.Now; log.operateMsg = "" + DateTime.Now.Year + "年村" + adcdInfo.adnm + "提交了暂无危险区(点)转移人员的信息"; List <operateLog> listLog = new List <operateLog>(); listLog.Add(log); info.operateLog = JsonTools.ObjectToJson(listLog); var f = db.Single <VillageTransferPerson>(w => w.adcd == request.adcd && w.IfTransfer == 1); if (f == null) { var r = db.Insert(info) == 1; #region 日志 StringBuilder sb = new StringBuilder(); sb.Append("在栏目{组织责任/行政村危险区人员转移清单}下,新增数据{"); sb.Append("村ADCD:" + adcdInfo.adnm + ";"); sb.Append("},改村暂无危险区(点)转可移人员信息"); _ILogHelper.WriteLog(sb.ToString(), OperationTypeEnums.新增); #endregion return(r); } else { return(false); } } }
/// <summary> /// 保存行政村危险区转移人员信息 /// </summary> /// <param name="ids"></param> /// <returns></returns> public BaseResult SaveVillageTransferPerson(SaveVillageTransferPerson request) { using (var db = DbFactory.Open()) { var adcdInfo = ZZTXManager.GetADCDInfoByADCD(request.adcd); var info = new VillageTransferPerson(); info.adcd = request.adcd; info.DangerZoneName = request.DangerZoneName; info.DangerZoneType = request.DangerZoneType; info.DisasterPreventionManager = request.DisasterPreventionManager; info.DisasterPreventionManagerMobile = request.DisasterPreventionManagerMobile; info.DisasterPreventionName = request.DisasterPreventionName; info.HouseholderMobile = request.HouseholderMobile; info.HouseholderName = request.HouseholderName; info.HouseholderNum = request.HouseholderNum; info.Lat = request.Lat; info.Lng = request.Lng; info.PersonLiableMobile = request.PersonLiableMobile; info.PersonLiableName = request.PersonLiableName; info.PersonLiablePost = request.PersonLiablePost; info.Position = request.Position; info.SafetyIdentification = request.SafetyIdentification; info.WarnPersonLiableMobile = request.WarnPersonLiableMobile; info.WarnPersonLiablePost = request.WarnPersonLiablePost; info.WarnPersonLiableName = request.WarnPersonLiableName; info.Year = DateTime.Now.Year; info.Remark = request.Remark; //新数据 List <VillageTransferPerson> _newdata = new List <VillageTransferPerson>(); _newdata.Add(info); // operateLog log = new operateLog(); log.userName = RealName; log.operateTime = DateTime.Now; if (request.Id != 0) { #region 旧数据,新数据 //取出数据 //写入更新记录 var rf = db.Single <VillageTransferPerson>(w => w.ID == request.Id); var _olddata = new VillageTransferPerson() { adcd = rf.adcd, DangerZoneName = rf.DangerZoneName, DangerZoneType = rf.DangerZoneType, DisasterPreventionManager = rf.DisasterPreventionManager, DisasterPreventionManagerMobile = rf.DisasterPreventionManagerMobile, DisasterPreventionName = rf.DisasterPreventionName, HouseholderMobile = rf.HouseholderMobile, HouseholderName = rf.HouseholderName, HouseholderNum = rf.HouseholderNum, Lat = rf.Lat, Lng = rf.Lng, PersonLiableMobile = rf.PersonLiableMobile, PersonLiableName = rf.PersonLiableName, PersonLiablePost = rf.PersonLiablePost, Position = rf.Position, SafetyIdentification = rf.SafetyIdentification, WarnPersonLiableMobile = rf.WarnPersonLiableMobile, WarnPersonLiablePost = rf.WarnPersonLiablePost, WarnPersonLiableName = rf.WarnPersonLiableName, Year = rf.Year }; if (AuditNums != null) { List <VillageTransferPerson> _listOldData = new List <VillageTransferPerson>(); _listOldData.Add(_olddata); info.AuditNums = AuditNums.Value + 1; //旧数据写入实体 info.OldData = JsonTools.ObjectToJson(_listOldData); //新数据写入实体 info.NewData = JsonTools.ObjectToJson(_newdata); } #endregion //数据更新前取出历史数据 var rlist = db.Select <VillageTransferPerson>(w => w.ID == request.Id); // info.ID = request.Id; log.operateMsg = "更新" + request.Year + "年" + adcdInfo.adnm + ",名为:" + request.DangerZoneName + "危险区(点)转移人员信息"; List <operateLog> listLog = new List <operateLog>(); listLog.Add(log); info.operateLog = JsonTools.ObjectToJson(listLog); var r = db.Update(info) == 1; #region 日志 StringBuilder sb = new StringBuilder(); sb.Append("在栏目{组织责任/行政村危险区人员转移清单}下,更新数据{"); sb.Append("村ADCD:" + adcdInfo.adnm + ";"); sb.Append("危险区(点)名称:" + _olddata.DangerZoneName + ";"); sb.Append("类别:" + _olddata.DangerZoneType + ";"); sb.Append("避灾场所管理员:" + _olddata.DisasterPreventionManager + ";"); sb.Append("避灾场所管理员手机:" + _olddata.DisasterPreventionManagerMobile + ";"); sb.Append("避灾场所名称:" + _olddata.DisasterPreventionName + ";"); sb.Append("户主手机:" + _olddata.HouseholderMobile + ";"); sb.Append("户主姓名:" + _olddata.HouseholderName + ";"); sb.Append("居住人数:" + _olddata.HouseholderNum + ";"); sb.Append("纬度:" + _olddata.Lat + ";"); sb.Append("经度:" + _olddata.Lng + ";"); sb.Append("责任人手机:" + _olddata.PersonLiableMobile + ";"); sb.Append("责任人姓名:" + _olddata.PersonLiableName + ";"); sb.Append("责任人职务:" + _olddata.PersonLiablePost + ";"); sb.Append("位置:" + _olddata.Position + ";"); sb.Append("有无安全鉴定:" + _olddata.SafetyIdentification + ";"); sb.Append("预警责任人手机:" + _olddata.WarnPersonLiableMobile + ";"); sb.Append("预警责任人职务:" + _olddata.WarnPersonLiablePost + ";"); sb.Append("预警责任人姓名:" + _olddata.WarnPersonLiableName + ";"); sb.Append("年度:" + _olddata.Year + ";"); sb.Append("}为{"); sb.Append("村ADCD:" + adcdInfo.adnm + ";"); sb.Append("危险区(点)名称:" + info.DangerZoneName + ";"); sb.Append("类别:" + info.DangerZoneType + ";"); sb.Append("避灾场所管理员:" + info.DisasterPreventionManager + ";"); sb.Append("避灾场所管理员手机:" + info.DisasterPreventionManagerMobile + ";"); sb.Append("避灾场所名称:" + info.DisasterPreventionName + ";"); sb.Append("户主手机:" + info.HouseholderMobile + ";"); sb.Append("户主姓名:" + info.HouseholderName + ";"); sb.Append("居住人数:" + info.HouseholderNum + ";"); sb.Append("纬度:" + info.Lat + ";"); sb.Append("经度:" + info.Lng + ";"); sb.Append("责任人手机:" + info.PersonLiableMobile + ";"); sb.Append("责任人姓名:" + info.PersonLiableName + ";"); sb.Append("责任人职务:" + info.PersonLiablePost + ";"); sb.Append("位置:" + info.Position + ";"); sb.Append("有无安全鉴定:" + info.SafetyIdentification + ";"); sb.Append("预警责任人手机:" + info.WarnPersonLiableMobile + ";"); sb.Append("预警责任人职务:" + info.WarnPersonLiablePost + ";"); sb.Append("预警责任人姓名:" + info.WarnPersonLiableName + ";"); sb.Append("年度:" + info.Year + ";"); sb.Append("}"); _ILogHelper.WriteLog(sb.ToString(), OperationTypeEnums.更新); #endregion //if (r) //{ // //村 受灾点 受灾害影响人口 更新 // var oldNum = rlist.FirstOrDefault().HouseholderNum; // var newNum = request.HouseholderNum; // var newhouseholdernum = newNum - oldNum; // using (var dbADCDStatics = DbFactory.Open()) // { // var _year = request.Year == 0 ? DateTime.Now.Year : request.Year; // var dbbuilder = dbADCDStatics.From<ADCDDisasterInfo>().Where(w => w.adcd == request.adcd && w.Year==_year).Update(x => new { x.PopulationNum }); // dbADCDStatics.UpdateAdd(() => new ADCDDisasterInfo { PopulationNum = newhouseholdernum }, dbbuilder); // } //} BaseResult br = new BaseResult(); br.IsSuccess = r; return(br); } else { BaseResult br = null; var f = db.Single <VillageTransferPerson>(w => w.adcd == request.adcd && w.IfTransfer == 1); if (f != null) { br = new BaseResult(); br.IsSuccess = false; br.ErrorMsg = "保存失败!村被标记过无转移人员,新增人员时请先在已上报里删除村。"; return(br); } #region 旧数据,新数据 //写入更新记录 if (AuditNums != null) { info.AuditNums = AuditNums.Value + 1; } #endregion info.CreateTime = DateTime.Now; log.operateMsg = "新增" + request.Year + "年" + adcdInfo.adnm + ",名为:" + request.DangerZoneName + "危险区(点)转移人员信息"; List <operateLog> listLog = new List <operateLog>(); listLog.Add(log); info.operateLog = JsonTools.ObjectToJson(listLog); var r = db.Insert(info) == 1; #region 日志 StringBuilder sb = new StringBuilder(); sb.Append("在栏目{组织责任/行政村危险区人员转移清单}下,新增数据{"); sb.Append("村ADCD:" + adcdInfo.adnm + ";"); sb.Append("危险区(点)名称:" + info.DangerZoneName + ";"); sb.Append("类别:" + info.DangerZoneType + ";"); sb.Append("避灾场所管理员:" + info.DisasterPreventionManager + ";"); sb.Append("避灾场所管理员手机:" + info.DisasterPreventionManagerMobile + ";"); sb.Append("避灾场所名称:" + info.DisasterPreventionName + ";"); sb.Append("户主手机:" + info.HouseholderMobile + ";"); sb.Append("户主姓名:" + info.HouseholderName + ";"); sb.Append("居住人数:" + info.HouseholderNum + ";"); sb.Append("纬度:" + info.Lat + ";"); sb.Append("经度:" + info.Lng + ";"); sb.Append("责任人手机:" + info.PersonLiableMobile + ";"); sb.Append("责任人姓名:" + info.PersonLiableName + ";"); sb.Append("责任人职务:" + info.PersonLiablePost + ";"); sb.Append("位置:" + info.Position + ";"); sb.Append("有无安全鉴定:" + info.SafetyIdentification + ";"); sb.Append("预警责任人手机:" + info.WarnPersonLiableMobile + ";"); sb.Append("预警责任人职务:" + info.WarnPersonLiablePost + ";"); sb.Append("预警责任人姓名:" + info.WarnPersonLiableName + ";"); sb.Append("年度:" + info.Year + ";"); sb.Append("}"); _ILogHelper.WriteLog(sb.ToString(), OperationTypeEnums.新增); #endregion //if (r) //{ // //村 受灾点 受灾害影响人口 更新 // using (var dbADCDStatics = DbFactory.Open()) // { // var _year = request.Year == 0 ? DateTime.Now.Year : request.Year; // var dbbuilder = dbADCDStatics.From<ADCDDisasterInfo>().Where(w=>w.adcd==request.adcd && w.Year == _year).Update(x => new { x.PointNum, x.PopulationNum }); // dbADCDStatics.UpdateAdd(()=>new ADCDDisasterInfo { PointNum=1,PopulationNum=request.HouseholderNum }, dbbuilder); // } //} br = new BaseResult(); br.IsSuccess = r; return(br); } } }
/// <summary> /// 保存形势图路径等等 /// </summary> /// <param name="request"></param> /// <returns></returns> public bool SaveVillagePic(SaveVillagePic request) { using (var db = DbFactory.Open()) { if (string.IsNullOrEmpty(request.adcd)) { throw new Exception("行政区划编码不能为空"); } if (string.IsNullOrEmpty(request.filePath)) { throw new Exception("文件路径不能为空"); } if (request.Year == 0) { throw new Exception("年份异常"); } var log = new operateLog(); log.userName = RealName; log.operateTime = DateTime.Now; var logList = new List <operateLog>(); var list = GetVillagePicAdcd(new GetVillagePicAdcd() { adcd = request.adcd, year = request.Year, type = 1 }).rows; if (list.Count == 1) { log.operateMsg = "更新" + ZZTXManager.GetADCDInfoByADCD(request.adcd).adnm + "的防汛防台形势图"; logList.Add(log); #region 日志 StringBuilder sb = new StringBuilder(); sb.Append("在栏目{组织责任/行政村防汛防台形势图}下,更新了形势图{" + ZZTXManager.GetADCDInfoByADCD(request.adcd).adnm + "}"); _ILogHelper.WriteLog(sb.ToString(), OperationTypeEnums.更新); #endregion var _AuditNums = 0; if (AuditNums != null) { _AuditNums = AuditNums.Value + 1; } return(db.UpdateOnly( new VillagePic() { path = request.filePath, operateLog = JsonTools.ObjectToJson(logList), AuditNums = _AuditNums }, onlyFields: x => new { x.path, x.operateLog }, where : x => x.Id == list[0].Id) == 1); } else { var newInfo = new VillagePic2(); string[] arryFiles; string picNames = ""; if (request.filePath.Contains("|")) { arryFiles = request.filePath.Split('|'); foreach (var item in arryFiles) { JObject jo = (JObject)JsonConvert.DeserializeObject(item); picNames += Path.GetFileName(jo["fileSrc"].ToString().Replace("/", @"\")) + ","; } picNames = picNames.Substring(0, picNames.Length - 1); } else { JObject jo = (JObject)JsonConvert.DeserializeObject(request.filePath); picNames = Path.GetFileName(jo["fileSrc"].ToString().Replace("/", @"\")); } newInfo.Adcd = request.adcd; newInfo.Year = request.Year; newInfo.PicName = picNames; newInfo.CreatTime = DateTime.Now; newInfo.id = Guid.NewGuid().ToString(); var info = new VillagePic(); info.adcd = request.adcd; info.Year = request.Year; info.path = request.filePath; info.CreatTime = DateTime.Now; //写入更新记录 if (AuditNums != null) { info.AuditNums = AuditNums.Value + 1; newInfo.AuditNums = AuditNums.Value + 1; } else { newInfo.AuditNums = 0; } log.operateMsg = "新增" + ZZTXManager.GetADCDInfoByADCD(request.adcd).adnm + "的防汛防台形势图"; logList.Add(log); info.operateLog = JsonTools.ObjectToJson(logList); newInfo.operateLog = JsonTools.ObjectToJson(logList); #region 日志 StringBuilder sb = new StringBuilder(); sb.Append("在栏目{组织责任/行政村防汛防台形势图}下,新增了{" + ZZTXManager.GetADCDInfoByADCD(request.adcd).adnm + "}形势图"); _ILogHelper.WriteLog(sb.ToString(), OperationTypeEnums.新增); #endregion long a = db.Insert(info); string insertsql = "INSERT INTO VillagePic2(id, Adcd, PicName, isDelete, Year, operateLog, CreatTime, AuditNums) VALUES('" + newInfo.id + "','" + newInfo.Adcd + "', '" + newInfo.PicName + "', '" + newInfo.isDelete + "', '" + newInfo.Year + "', '" + newInfo.operateLog + "', '" + newInfo.CreatTime + "', '" + newInfo.AuditNums + "')"; long b = db.ExecuteSql(insertsql); return(b == 1); //return db.Insert(info) == 1; } } }
/// <summary> /// 删除行政村危险区转移人员信息 /// </summary> /// <param name="ids"></param> /// <returns></returns> public bool DelVillageTransferPerson(string ids) { using (var db = DbFactory.Open()) { ArrayList arr = new ArrayList(); string[] arrs = ids.Split(','); for (int i = 0; i < arrs.Length; i++) { var id = int.Parse(arrs[i]); arr.Add(id); #region 日志 var _vgr = db.Single <VillageTransferPerson>(w => w.ID == id); StringBuilder sb = new StringBuilder(); var adcdInfo = ZZTXManager.GetADCDInfoByADCD(_vgr.adcd); sb.Append("在栏目{组织责任/行政村危险区人员转移清单}下,删除了数据{"); sb.Append("村ADCD:" + adcdInfo.adnm + ";"); sb.Append("危险区(点)名称:" + _vgr.DangerZoneName + ";"); sb.Append("类别:" + _vgr.DangerZoneType + ";"); sb.Append("避灾场所管理员:" + _vgr.DisasterPreventionManager + ";"); sb.Append("避灾场所管理员手机:" + _vgr.DisasterPreventionManagerMobile + ";"); sb.Append("避灾场所名称:" + _vgr.DisasterPreventionName + ";"); sb.Append("户主手机:" + _vgr.HouseholderMobile + ";"); sb.Append("户主姓名:" + _vgr.HouseholderName + ";"); sb.Append("居住人数:" + _vgr.HouseholderNum + ";"); sb.Append("纬度:" + _vgr.Lat + ";"); sb.Append("经度:" + _vgr.Lng + ";"); sb.Append("责任人手机:" + _vgr.PersonLiableMobile + ";"); sb.Append("责任人姓名:" + _vgr.PersonLiableName + ";"); sb.Append("责任人职务:" + _vgr.PersonLiablePost + ";"); sb.Append("位置:" + _vgr.Position + ";"); sb.Append("有无安全鉴定:" + _vgr.SafetyIdentification + ";"); sb.Append("预警责任人手机:" + _vgr.WarnPersonLiableMobile + ";"); sb.Append("预警责任人职务:" + _vgr.WarnPersonLiablePost + ";"); sb.Append("预警责任人姓名:" + _vgr.WarnPersonLiableName + ";"); sb.Append("年度:" + _vgr.Year + ";"); sb.Append("}"); _ILogHelper.WriteLog(sb.ToString(), OperationTypeEnums.除); #endregion } string _newids = string.Join(",", arrs); //先取出数据 var rlist = db.Select <VillageTFStaictis>("select distinct(adcd),SUM(HouseholderNum) as HouseholderNum,COUNT(adcd) as PointNum from VillageTransferPerson where ID in(" + _newids + ") group by adcd "); //删除 var r = db.Delete <VillageTransferPerson>(x => Sql.In(x.ID, arr)) > 0; if (r) { //村 受灾点 受灾害影响人口 更新 foreach (VillageTFStaictis item in rlist) { using (var dbADCDStatics = DbFactory.Open()) { var dbbuilder = dbADCDStatics.From <ADCDDisasterInfo>().Where(w => w.adcd == item.adcd).Update(x => new { x.PointNum, x.PopulationNum }); dbADCDStatics.UpdateAdd(() => new ADCDDisasterInfo { PointNum = -item.PointNum, PopulationNum = -item.HouseholderNum }, dbbuilder); } } } return(r); } }
/// <summary> /// 保存形势图路径等等 /// </summary> /// <param name="request"></param> /// <returns></returns> public bool SaveVillagePic(SaveVillagePic request) { using (var db = DbFactory.Open()) { if (string.IsNullOrEmpty(request.adcd)) { throw new Exception("行政区划编码不能为空"); } if (string.IsNullOrEmpty(request.filePath)) { throw new Exception("文件路径不能为空"); } if (request.Year == 0) { throw new Exception("年份异常"); } var log = new operateLog(); log.userName = RealName; log.operateTime = DateTime.Now; var logList = new List <operateLog>(); var list = GetVillagePicAdcd(new GetVillagePicAdcd() { adcd = request.adcd, year = request.Year, type = 1 }).rows; if (list.Count == 1) { log.operateMsg = "更新" + ZZTXManager.GetADCDInfoByADCD(request.adcd).adnm + "的防汛防台形势图"; logList.Add(log); #region 日志 StringBuilder sb = new StringBuilder(); sb.Append("在栏目{组织责任/行政村防汛防台形势图}下,更新了形势图{" + ZZTXManager.GetADCDInfoByADCD(request.adcd).adnm + "}"); _ILogHelper.WriteLog(sb.ToString(), OperationTypeEnums.更新); #endregion var _AuditNums = 0; if (AuditNums != null) { _AuditNums = AuditNums.Value + 1; } return(db.UpdateOnly( new VillagePic() { path = request.filePath, operateLog = JsonTools.ObjectToJson(logList), AuditNums = _AuditNums }, onlyFields: x => new { x.path, x.operateLog }, where : x => x.Id == list[0].Id) == 1); } else { var info = new VillagePic(); info.adcd = request.adcd; info.Year = request.Year; info.path = request.filePath; info.CreatTime = DateTime.Now; //写入更新记录 if (AuditNums != null) { info.AuditNums = AuditNums.Value + 1; } log.operateMsg = "新增" + ZZTXManager.GetADCDInfoByADCD(request.adcd).adnm + "的防汛防台形势图"; logList.Add(log); info.operateLog = JsonTools.ObjectToJson(logList); #region 日志 StringBuilder sb = new StringBuilder(); sb.Append("在栏目{组织责任/行政村防汛防台形势图}下,新增了{" + ZZTXManager.GetADCDInfoByADCD(request.adcd).adnm + "}形势图"); _ILogHelper.WriteLog(sb.ToString(), OperationTypeEnums.新增); #endregion return(db.Insert(info) == 1); } } }