Exemple #1
0
        public ModelInvokeResult <ResidentIDNoRequisitionPK> IsRequisitionPass(string strRequisitionId, ResidentIDNoRequisition residentIDNoRequisition)
        {
            ModelInvokeResult <ResidentIDNoRequisitionPK> result = new ModelInvokeResult <ResidentIDNoRequisitionPK> {
                Success = true
            };

            try
            {
                List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>();
                Guid?_RequisitionId = strRequisitionId.ToGuid();
                if (_RequisitionId == null)
                {
                    result.Success   = false;
                    result.ErrorCode = 59996;
                    return(result);
                }
                residentIDNoRequisition.RequisitionId = _RequisitionId;
                /***********************begin 自定义代码*******************/
                residentIDNoRequisition.OperatedBy = NormalSession.UserId.ToGuid();
                residentIDNoRequisition.OperatedOn = DateTime.Now;
                residentIDNoRequisition.ConfirmBy  = NormalSession.UserId.ToGuid();
                residentIDNoRequisition.ConfirmOn  = DateTime.Now;
                /***********************end 自定义代码*********************/
                statements.Add(new IBatisNetBatchStatement {
                    StatementName = residentIDNoRequisition.GetUpdateMethodName(), ParameterObject = residentIDNoRequisition.ToStringObjectDictionary(false), Type = SqlExecuteType.UPDATE
                });
                if (residentIDNoRequisition.DoStatus == 1)
                {
                    /***********************begin 更改区级库的身份证号码*******************/
                    List <IBatisNetBatchStatement> statements_oldManBaseInfo = new List <IBatisNetBatchStatement>();
                    OldManBaseInfo oldManBaseInfo = new OldManBaseInfo();
                    oldManBaseInfo.OldManId   = residentIDNoRequisition.ResidentId;
                    oldManBaseInfo.OperatedBy = NormalSession.UserId.ToGuid();
                    oldManBaseInfo.OperatedOn = DateTime.Now;
                    oldManBaseInfo.DataSource = GlobalManager.DIKey_00012_ManualEdit;
                    oldManBaseInfo.IDNo       = residentIDNoRequisition.IDNoNew;
                    statements_oldManBaseInfo.Add(new IBatisNetBatchStatement {
                        StatementName = oldManBaseInfo.GetUpdateMethodName(), ParameterObject = oldManBaseInfo.ToStringObjectDictionary(false), Type = SqlExecuteType.UPDATE
                    });
                    BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements_oldManBaseInfo);
                    /***********************end 更改区级库的身份证号码*********************/

                    /***********************begin 更改城市库的身份证号码*******************/
                    List <IBatisNetBatchStatement> statements_residentBaseInfo = new List <IBatisNetBatchStatement>();
                    ResidentBaseInfo residentBaseInfo = new ResidentBaseInfo();
                    residentBaseInfo.ResidentId = residentIDNoRequisition.ResidentId;
                    residentBaseInfo.OperatedBy = NormalSession.UserId.ToGuid();
                    residentBaseInfo.OperatedOn = DateTime.Now;
                    residentBaseInfo.DataSource = GlobalManager.DIKey_00012_ManualEdit;
                    residentBaseInfo.IDNo       = residentIDNoRequisition.IDNoNew;
                    statements_residentBaseInfo.Add(new IBatisNetBatchStatement {
                        StatementName = residentBaseInfo.GetUpdateMethodName(), ParameterObject = residentBaseInfo.ToStringObjectDictionary(false), Type = SqlExecuteType.UPDATE
                    });
                    BuilderFactory.DefaultBulder(GetHttpHeader("ConnectId")).ExecuteNativeSqlNoneQuery(statements_residentBaseInfo);
                    /***********************end 更改城市库的身份证号码*********************/
                }
                BuilderFactory.DefaultBulder(GetHttpHeader("ConnectId")).ExecuteNativeSqlNoneQuery(statements);

                /***********************begin 添加居民活动信息*******************/
                string sql_str = " insert into Bas_ResidentActivityLog (CheckInTime,ResidentId,ActivityTime,ActivityType,ActivityData,ActivityDescription,ActivityChangeType)"
                                 + " select  GETDATE() CheckInTime,a.ResidentId,GETDATE() ActivityTime,'00001' ActivityType"
                                 + ",'{\"Source\":\"07\",\"from\":\"07\",\"to\":\"07\",\"Operate\":\"变更身份证\",\"NewIDNo\":\"'+CAST( IDNoNew as varchar(20))+'\",\"OldIDNo\":\"'+CAST( IDNoOld as varchar(20))+'\",\"OperatedBy\":\"'+ISNULL(CAST( ConfirmBy as varchar(36)),'')+'\",\"AreaId\":\"'+CAST( b.AreaId as varchar(36))+'\",\"DoStatus\":\"" + residentIDNoRequisition.DoStatus + "\"}' ActivityData"
                                 + ",'变更身份证:结果\"" + (residentIDNoRequisition.DoStatus == 1 ? "通过" : "不通过") + "\",原身份证\"'+IDNoOld+'\"变更为\"'+IDNoNew+'\",\"所在辖区\":\"'+ItemName+'\"' ActivityDescription,'00001' ActivityChangeType"
                                 + " from Bas_ResidentIDNoRequisition a inner join Bas_ResidentBaseInfo b on a.ResidentId=b.ResidentId   inner join Sys_DictionaryItem c on b.AreaId=c.ItemId"
                                 + " where c.DictionaryId='00005' and RequisitionId='" + strRequisitionId + "'";
                BuilderFactory.DefaultBulder(GetHttpHeader("ConnectId")).ExecuteNativeSqlNoneQuery(sql_str);
                /***********************end 添加居民活动信息*******************/

                result.instance = new ResidentIDNoRequisitionPK {
                    RequisitionId = _RequisitionId
                };
            }
            catch (Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Charset     = "utf-8";
            HttpPostedFile file = context.Request.Files["Filedata"];

            if (file != null)
            {
                string AreaId        = context.Request.Form["AreaId"];
                string retFailInfo   = "";
                int    relationOfMan = 99999;
                int    count         = 0;

                IList <StringObjectDictionary> datas      = NPOIManager.GetSheetData(file.InputStream, 0, true);
                List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>();
                List <IBatisNetBatchStatement> oldmanconfig_statements = new List <IBatisNetBatchStatement>();
                List <IBatisNetBatchStatement> familymember_statements = new List <IBatisNetBatchStatement>();
                List <IBatisNetBatchStatement> oldmanfamily_statements = new List <IBatisNetBatchStatement>();

                //获取图片
                //NPOI.HSSF.UserModel.HSSFWorkbook hssfworkbook = new NPOI.HSSF.UserModel.HSSFWorkbook(file.InputStream);
                //NPOI.SS.UserModel.ISheet sheet = hssfworkbook.GetSheetAt(0);
                //Dictionary<string, Byte[]> picDataDictionary = getSheetPictrues03((NPOI.HSSF.UserModel.HSSFSheet)sheet);
                //获取所有老人基本信息
                IList <OldManBaseInfo> oldManBaseInfoList = RetExistsIdNo(AreaId);
                //获取所有老人配置终端信息
                IList <OldManConfigInfo> oldManConfigInfoList = RetAllConfigCallNo();
                //获取所有老人的亲属资料
                IList <StringObjectDictionary> familyMemberList = RetAllFamilyMember();
                //获取所有街道社区信息
                IList <Area> AreaList = RetAllStreetCommunity();
                //保存图片地址
                //基本信息
                IList <StringObjectDictionary> basedatas = RetEffectiveDatas(datas, ref retFailInfo);
                OldManBaseInfo baseInfo = new OldManBaseInfo()
                {
                    DataSource = GlobalManager.DIKey_00012_UploadFile, OperatedBy = NormalSession.UserId.ToGuid(), OperatedOn = DateTime.Now, AreaId = AreaId
                };
                OldManConfigInfo oldmanconfig = new OldManConfigInfo();
                FamilyMember     familymember = new FamilyMember()
                {
                    Gender = "M", IDNo = "", Status = 1
                };
                OldManFamilyInfo oldmanfamily = new OldManFamilyInfo();

                foreach (var data in basedatas)
                {
                    //老人基本资料
                    baseInfo.OldManId = Guid.NewGuid();
                    count             = oldManBaseInfoList.Count(s => s.IDNo == data["IDNo"].ToString());
                    if (count > 0)
                    {
                        baseInfo.OldManId = oldManBaseInfoList.First(s => s.IDNo == data["IDNo"].ToString()).OldManId;
                    }
                    baseInfo.Status = 1;
                    baseInfo.HealthInsuranceFlag = Convert.ToByte(data["HealthInsuranceNumber"] != null);
                    baseInfo.SocialInsuranceFlag = Convert.ToByte(data["SocialInsuranceNumber"] != null);
                    StringObjectDictionary       sod      = baseInfo.ToStringObjectDictionary(false);
                    IDictionary <string, object> dataItem = sod.MixInObject(data, false, e0571.web.core.Other.CaseSensitive.NORMAL);

                    var tmpArea = AreaList.FirstOrDefault(s => s.AreaName.IndexOf(dataItem["AreaId2"].ToString()) > -1);
                    if (dataItem.ContainsKey("AreaId2") && dataItem["AreaId2"] != null && tmpArea != null)
                    {
                        dataItem["AreaId2"] = tmpArea.AreaId != null?tmpArea.AreaId.ToString().ToUpper() : "";
                    }
                    else
                    {
                        dataItem.Remove("AreaId2");
                    }
                    tmpArea = AreaList.FirstOrDefault(s => s.AreaName.IndexOf(dataItem["AreaId3"].ToString()) > -1);
                    if (dataItem.ContainsKey("AreaId3") && dataItem["AreaId3"] != null && tmpArea != null)
                    {
                        dataItem["AreaId3"] = tmpArea.AreaId != null?tmpArea.AreaId.ToString().ToUpper() : "";
                    }
                    else
                    {
                        dataItem.Remove("AreaId3");
                    }

                    if (count > 0)
                    {
                        statements.Add(new IBatisNetBatchStatement {
                            StatementName = baseInfo.GetUpdateMethodName(), ParameterObject = dataItem, Type = SqlExecuteType.UPDATE
                        });
                    }
                    else
                    {
                        statements.Add(new IBatisNetBatchStatement {
                            StatementName = baseInfo.GetCreateMethodName(), ParameterObject = dataItem, Type = SqlExecuteType.INSERT
                        });
                    }
                    //老人呼叫设备资料,存在则跳过
                    if (dataItem.ContainsKey("CallNo") && dataItem["CallNo"] != null)
                    {
                        if (oldManConfigInfoList.Count(s => s.CallNo == dataItem["CallNo"].ToString()) == 0)
                        {
                            var configinfoitem = oldManConfigInfoList.FirstOrDefault(s => s.OldManId.ToString() == dataItem["OldManId"].ToString());
                            if (configinfoitem != null && configinfoitem.OldManId != null)
                            {
                                oldmanconfig_statements.Add(new IBatisNetBatchStatement {
                                    StatementName = oldmanconfig.GetUpdateMethodName(), ParameterObject = dataItem, Type = SqlExecuteType.UPDATE
                                });
                            }
                            else
                            {
                                oldmanconfig_statements.Add(new IBatisNetBatchStatement {
                                    StatementName = oldmanconfig.GetCreateMethodName(), ParameterObject = dataItem, Type = SqlExecuteType.INSERT
                                });
                            }
                        }
                    }

                    //获取亲人信息
                    StringObjectDictionary sod2 = new StringObjectDictionary();
                    for (int i = 0; i < 3; i++)
                    {
                        string familyName = "FamilyName" + (i + 1).ToString();
                        string callNo     = "CallNo" + (i + 1).ToString();
                        if (!data.ContainsKey(familyName) || data[familyName] == null)
                        {
                            continue;
                        }
                        if (!data.ContainsKey(callNo) || data[callNo] == null)
                        {
                            continue;
                        }

                        oldmanfamily.RelationIdOfFamily = (relationOfMan - i).ToString();
                        oldmanfamily.RelationIdOfOldMan = (relationOfMan - i).ToString();

                        string callNoData = data[callNo].ToString();
                        familymember.FamilyMemberId   = Guid.NewGuid();
                        familymember.FamilyMemberName = data[familyName].ToString();
                        //匹配手机号
                        familymember.Mobile = System.Text.RegularExpressions.Regex.Match(callNoData, @"0*[1][358]\d{9}").Value;
                        if (familymember.Mobile.Length > 0)
                        {
                            callNoData = callNoData.Replace(familymember.Mobile, "");
                        }
                        //匹配座机
                        familymember.Tel = System.Text.RegularExpressions.Regex.Match(callNoData, @"((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))").Value;

                        if (count > 0)
                        {
                            sod2 = familyMemberList.FirstOrDefault(s => s["OldManId"].ToString() == baseInfo.OldManId.ToString() && s["RelationIdOfFamily"].ToString() == oldmanfamily.RelationIdOfFamily);
                            if (sod2 != null && sod2.Count > 0)
                            {
                                if (familyMemberList.Count(s => s["FamilyMemberName"].ToString() == familymember.FamilyMemberName && s["Mobile"].ToString() == familymember.Mobile && s["Tel"].ToString() == familymember.Tel) > 0)
                                {
                                    continue;
                                }
                                familymember.FamilyMemberId = sod2["FamilyMemberId"].ToString().ToGuid();
                            }
                        }
                        sod      = baseInfo.ToStringObjectDictionary(false);
                        dataItem = sod.MixInObject(familymember, false, e0571.web.core.Other.CaseSensitive.NORMAL);
                        if (sod2 != null && sod2.Count > 0)
                        {
                            familymember_statements.Add(new IBatisNetBatchStatement {
                                StatementName = familymember.GetUpdateMethodName(), ParameterObject = dataItem, Type = SqlExecuteType.UPDATE
                            });
                        }
                        else
                        {
                            familymember_statements.Add(new IBatisNetBatchStatement {
                                StatementName = familymember.GetCreateMethodName(), ParameterObject = dataItem, Type = SqlExecuteType.INSERT
                            });
                            dataItem = sod.MixInObject(oldmanfamily, false, e0571.web.core.Other.CaseSensitive.NORMAL);
                            oldmanfamily_statements.Add(new IBatisNetBatchStatement {
                                StatementName = oldmanfamily.GetCreateMethodName(), ParameterObject = dataItem, Type = SqlExecuteType.INSERT
                            });
                        }
                    }
                }

                BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements);
                BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(oldmanconfig_statements);
                BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(familymember_statements);
                BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(oldmanfamily_statements);


                /*string saveName = @context.Request["saveName"];
                 * string fileType = file.FileName.Substring(file.FileName.LastIndexOf("."));
                 * string uploadPath = HttpContext.Current.Server.MapPath(@context.Request["folder"]);
                 * FileAdapter.EnsurePath(uploadPath);
                 * if (string.IsNullOrEmpty(saveName))
                 * {
                 *  file.SaveAs(uploadPath + file.FileName);
                 * }
                 * else
                 * {
                 *  file.SaveAs(uploadPath + saveName + fileType);
                 * }
                 */
                //下面这句代码缺少的话,上传成功后上传队列的显示不会自动消失
                context.Response.Write("1");
            }
            else
            {
                context.Response.Write("0");
            }
        }