示例#1
0
        public ActionResult Form(SD_EKPI_INFO_VIEWMODEL model)
        {
            var sdId = ProjectProvider.Instance.Current.SD_ID;

            if (_kpiService.Exists(r => r.SD_EKPI_ID == model.SD_EKPI_ID))
            {
                var entity = _kpiService.GetWithTrace(r => r.SD_EKPI_ID == model.SD_EKPI_ID);
                entity.SD_EKPI_CODE      = model.SD_EKPI_CODE;
                entity.SD_EKPI_NAME      = model.SD_EKPI_NAME;
                entity.SD_EKPI_ALIAS     = model.SD_EKPI_ALIAS;
                entity.ORDER_NO          = model.ORDER_NO;
                entity.SD_EKPI_CAT       = model.SD_EKPI_CAT;
                entity.IS_POSITIVE       = model.IS_POSITIVE;
                entity.SD_EKPI_ALGO      = model.SD_EKPI_ALGO.Replace("'", "”");
                entity.SD_EKPI_DESC      = model.SD_EKPI_DESC == null ? null : model.SD_EKPI_DESC.Replace("'", "”");
                entity.VALID_FLAG        = model.VALID_FLAG;
                entity.IS_RSN            = (model.IS_RSN == true) ? 1 : 0;
                entity.IS_DISTRIBUTION   = (model.IS_DISTRIBUTION == true) ? 1 : 0;
                entity.IS_TREND          = (model.IS_TREND == true) ? 1 : 0;
                entity.NUM_PRECISION     = model.NUM_PRECISION;
                entity.SD_EKPI_TYPE      = model.SD_EKPI_TYPE;
                entity.IS_NUM            = model.IS_NUM;
                entity.VALUE_TABLE_ID    = model.VALUE_TABLE_ID;// ProjectProvider.Instance.Current.SD_TYPE_CODE==0?1: model.SD_EKPI_TYPE;
                entity.IS_DYNAMIC        = model.IS_DYNAMIC;
                entity.SD_EKPI_CONVER    = model.SD_EKPI_CONVER;
                entity.SD_EKPI_UNIT      = model.SD_EKPI_UNIT;
                entity.SD_EKPI_PLATONAME = model.SD_EKPI_PLATONAME;
                var row = _kpiService.Update(entity);
                //先清除参数
                _ekpiItemService.ExDelete(i => i.SD_EKPI_ID == model.SD_EKPI_ID);
                if (!string.IsNullOrWhiteSpace(model.SD_EKPI_ITEM))
                {
                    //更新显示参数
                    var sdEkpiItem = JsonConvert.DeserializeObject <List <SD_EKPI_ITEM> >(model.SD_EKPI_ITEM);
                    foreach (var item in sdEkpiItem)
                    {
                        item.SD_EKPI_ID  = model.SD_EKPI_ID;
                        item.UPD_DATE    = DateTime.Now;
                        item.UPD_USER_ID = OperatorProvider.Instance.Current.UserId;
                    }
                    _ekpiItemService.BulkInsert(sdEkpiItem);
                }
                //_kpiService.RefreshOrder();
                return(row > 0 ? Success() : Error());
            }
            else
            {
                SD_EKPI_INFO value = new SD_EKPI_INFO()
                {
                    SD_EKPI_ID        = model.SD_EKPI_ID,
                    SD_ID             = sdId,
                    SD_CODE           = ProjectProvider.Instance.Current.SD_CODE,
                    SD_EKPI_CODE      = _projectService.GetCurrentSD().SD_CODE + "_TEST",////model.SD_EKPI_CODE,
                    SD_EKPI_NAME      = model.SD_EKPI_NAME,
                    SD_EKPI_ALIAS     = model.SD_EKPI_ALIAS,
                    ORDER_NO          = model.ORDER_NO,
                    SD_EKPI_CAT       = model.SD_EKPI_CAT,
                    IS_POSITIVE       = model.IS_POSITIVE,
                    SD_EKPI_ALGO      = model.SD_EKPI_ALGO.Replace("'", "“"),
                    SD_EKPI_DESC      = model.SD_EKPI_DESC == null ? null : model.SD_EKPI_DESC.Replace("'", "”"),
                    VALID_FLAG        = 0,
                    IS_RSN            = (model.IS_RSN == true) ? 1 : 0,
                    IS_DISTRIBUTION   = (model.IS_DISTRIBUTION == true) ? 1 : 0,
                    IS_TREND          = (model.IS_TREND == true) ? 1 : 0,
                    NUM_PRECISION     = model.NUM_PRECISION,
                    SD_EKPI_TYPE      = model.SD_EKPI_TYPE,
                    IS_NUM            = model.IS_NUM,
                    IS_DYNAMIC        = model.IS_DYNAMIC,
                    SD_EKPI_PLATONAME = model.SD_EKPI_PLATONAME,
                    VALUE_TABLE_ID    = model.VALUE_TABLE_ID,// ProjectProvider.Instance.Current.SD_TYPE_CODE == 0 ? 1 : model.SD_EKPI_TYPE,
                    SD_EKPI_CONVER    = model.SD_EKPI_CONVER,
                    SD_EKPI_UNIT      = model.SD_EKPI_UNIT
                };

                var entity = _kpiService.Insert(value);
                entity.SD_EKPI_CODE = entity.SD_EKPI_CODE.Replace("TEST", entity.SD_EKPI_ID.ToString());
                _kpiService.Update(entity);
                _procStateService.KPINonExcute(sdId, entity.SD_EKPI_ID.ToString());
                _procLogService.Insert(new PDP_PROC_LOG()
                {
                    PROC_CONTENT_ID = entity.SD_EKPI_ID.ToString(),
                    SD_ID           = sdId,
                    PROC_CAT_CODE   = "3",
                    PROC_STAT_CODE  = 1,
                });
                //编码由病种编码+ID组成
                //entity.SD_EKPI_CODE = $"{entity.SD_CODE}_{entity.SD_EKPI_ID}";
                //var row = _kpiService.Update(entity);
                //_kpiService.RefreshOrder();

                //更新展示参数
                if (!string.IsNullOrWhiteSpace(model.SD_EKPI_ITEM))
                {
                    var sdEkpiItem = JsonConvert.DeserializeObject <List <SD_EKPI_ITEM> >(model.SD_EKPI_ITEM);
                    foreach (var item in sdEkpiItem)
                    {
                        item.SD_EKPI_ID  = entity.SD_EKPI_ID;
                        item.UPD_DATE    = DateTime.Now;
                        item.UPD_USER_ID = OperatorProvider.Instance.Current.UserId;
                    }
                    _ekpiItemService.BulkInsert(sdEkpiItem);
                }
                return(entity != null?Success() : Error());
            }
        }