Esempio n. 1
0
        /// <summary>
        /// 作废
        /// </summary>
        /// <param name="id"></param>
        /// <param name="loginUser"></param>
        /// <returns></returns>
        public bool InvalidInfos(List <string> rowsKeyValues, string loginUser)
        {
            List <MaintainInhouseLogisticStandardInfo> maintainInhouseLogisticStandards = dal.GetList("[ID] in (" + string.Join(",", rowsKeyValues.ToArray()) + ")", string.Empty);

            if (maintainInhouseLogisticStandards.Count == 0)
            {
                throw new Exception("MC:0x00000213");///物料拉动信息数据错误
            }
            List <MaintainInhouseLogisticStandardInfo> maintainInhouseLogistics = maintainInhouseLogisticStandards.Where(d => d.Status == (int)BasicDataStatusConstants.Enable).ToList();

            ///物料拉动信息必须为已启用状态
            if (maintainInhouseLogisticStandards.Count != maintainInhouseLogistics.Count)
            {
                throw new Exception("MC:0x00000730");///物料拉动信息必须为已启用状态
            }
            ///零件拉动信息对应看板卡全部处于已作废状态⑫或没有看板卡数据
            int cnt = new KanbanCardDAL().GetCounts("" +
                                                    "[PART_BOX_CODE]  IN ('" + string.Join("','", maintainInhouseLogisticStandards.Select(w => w.InhousePartClass).ToArray()) + "') and" +
                                                    "[PART_NO] IN ('" + string.Join("','", maintainInhouseLogisticStandards.Select(w => w.PartNo).ToArray()) + "') and" +
                                                    "[STATUS] = " + (int)BasicDataStatusConstants.Enable + "");

            if (cnt > 0)
            {
                throw new Exception("MC:0x00000217");///启用看板卡数量大于零时不能作废
            }
            ///更新已创建状态的看板卡数据到已作废
            string sql = "update [LES].[TM_MPM_KANBAN_CARD] set " +
                         "[STATUS] = " + (int)BasicDataStatusConstants.Disabled + " where " +
                         "[PART_BOX_CODE] IN ('" + string.Join("','", maintainInhouseLogisticStandards.Select(w => w.InhousePartClass).ToArray()) + "') and " +
                         "[PART_NO] IN ('" + string.Join("','", maintainInhouseLogisticStandards.Select(w => w.PartNo).ToArray()) + "') and " +
                         "[STATUS] = " + (int)BasicDataStatusConstants.Created + ";" +
                         "update [LES].[TM_BAS_MAINTAIN_INHOUSE_LOGISTIC_STANDARD] set " +
                         "[STATUS] = " + (int)BasicDataStatusConstants.Disabled + "," +
                         "[MODIFY_USER] = N'" + loginUser + "'," +
                         "[MODIFY_DATE] = GETDATE() where " +
                         "[ID] in (" + string.Join(",", rowsKeyValues.ToArray()) + ");";

            using (TransactionScope trans = new TransactionScope())
            {
                CommonDAL.ExecuteNonQueryBySql(sql);
                trans.Complete();
            }
            return(true);
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <param name="loginUser"></param>
        /// <returns></returns>
        public bool LogicDeleteInfo(long id, string loginUser)
        {
            ///获取实体对象
            MaintainInhouseLogisticStandardInfo info = dal.GetInfo(id);

            if (info.Status != (int)BasicDataStatusConstants.Created)
            {
                throw new Exception("Err_:MC:0x00000415");/// 已创建状态才可进行删除
            }
            #region 当拉动方式为看板时进行校验
            if (int.Parse(info.InhouseSystemMode) == (int)PullModeConstants.Kanban)
            {
                ///零件拉动信息对应看板卡全部处于已作废状态或没有看板卡数据
                int cnt = new KanbanCardDAL().GetCounts(string.Format("[STATUS] in (" + (int)BasicDataStatusConstants.Created + "," + (int)BasicDataStatusConstants.Enable + ") "///看板卡创建时的状态也应该是BASIC_DATA_STATUS对应的值
                                                                      + "and [PART_NO] = N'{0}' and [PART_BOX_CODE] = N'{1}'", info.PartNo, info.InhousePartClass));
                if (cnt > 0)
                {
                    throw new Exception("Err_:MC:0x00000309");///存在有效看板不可删除
                }
            }
            #endregion

            return(dal.LogicDelete(id, loginUser) > 0 ? true : false);
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="fields"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool UpdateInfo(string fields, long id)
        {
            string inhousePartClass = CommonBLL.GetFieldValue(fields, "INHOUSE_PART_CLASS");
            ///在数据保存时将工厂代码②、车间代码③、生产线代码④同时写入数据库
            PartsBoxInfo partsBoxInfo = new PartsBoxDAL().GetInfoByPartBox(inhousePartClass);

            if (partsBoxInfo == null)
            {
                throw new Exception("MC:0x00000225");///拉动零件类数据错误
            }
            int    inhouseSystemMode = int.Parse(CommonBLL.GetFieldValue(fields, "INHOUSE_SYSTEM_MODE"));
            string min = CommonBLL.GetFieldValue(fields, "MIN");
            string max = CommonBLL.GetFieldValue(fields, "MAX");

            ///当所选拉动零件类⑥的拉动方式⑤为10时间窗且其配置为库存当量拉动时,MIN⑯和MAX⑰允许维护大于零的数据,且MIN⑯小于MAX⑰
            if (inhouseSystemMode == (int)PullModeConstants.Twd)///TODO:缺少库存当量拉动的判断,等TWD表结构
            {
                if (int.Parse(min) > int.Parse(max))
                {
                    throw new Exception("MC:0x00000404");///MIN值必须小于MAX
                }
            }
            ///当其被选为是时,需要校验层级拉动仓库⑩、层级拉动存储区⑪为必选项
            int    isTriggerPull = int.Parse(CommonBLL.GetFieldValue(fields, "IS_TRIGGER_PULL"));
            string wmNo          = CommonBLL.GetFieldValue(fields, "WM_NO");
            string zoneNo        = CommonBLL.GetFieldValue(fields, "ZONE_NO");

            if (isTriggerPull == 1)
            {
                if (string.IsNullOrEmpty(wmNo))
                {
                    throw new Exception("MC:0x00000405");///层级拉动仓库不允许为空
                }
                if (string.IsNullOrEmpty(zoneNo))
                {
                    throw new Exception("MC:0x00000406");///层级拉动存储区不允许为空
                }
            }

            string sql = string.Empty;

            #region  板相关验证
            if (inhouseSystemMode == (int)PullModeConstants.Kanban)
            {
                ///拉动方式为看板时看板环数必须大于等于一
                int kanbanCircleCnt = int.Parse(CommonBLL.GetFieldValue(fields, "KANBAN_CIRCLE_CNT"));
                if (kanbanCircleCnt < 1)
                {
                    throw new Exception("MC:0x00000307");///看板环数必须大于等于一
                }
                string partNo = CommonBLL.GetFieldValue(fields, "PART_NO");
                ///看板环数①必须大于等于一且大于等于对应状态为已创建或已启用看板卡数据量合计
                List <KanbanCardInfo> kanbanCardList = new KanbanCardDAL().GetList(string.Format("[STATUS] in (" + (int)BasicDataStatusConstants.Created + "," + (int)BasicDataStatusConstants.Enable + ") "///看板卡创建时的状态也应该是BASIC_DATA_STATUS对应的值
                                                                                                 + "and [PART_NO] = N'{0}' and [PART_BOX_CODE] = N'{1}'", partNo, inhousePartClass), string.Empty);
                if (kanbanCardList.Count > 0 && kanbanCircleCnt < kanbanCardList.Count)
                {
                    throw new Exception("MC:0x00000308");///看板环数必须大于等于对应状态为已创建或已启用看板卡数据量合计
                }
                ///同步更新对应看板卡的物料描述③⑦、供应商信息④⑧⑨、物料数量⑤⑩、包装器具信息⑥⑪
                if (kanbanCardList.Count > 0)
                {
                    string partCname           = CommonBLL.GetFieldValue(fields, "PART_CNAME");
                    string supplierNum         = CommonBLL.GetFieldValue(fields, "SUPPLIER_NUM");
                    string supplierName        = new SupplierDAL().GetSupplierName(supplierNum);
                    int    inboundPackage      = int.Parse(CommonBLL.GetFieldValue(fields, "INBOUND_PACKAGE"));
                    string inboundPackageModel = CommonBLL.GetFieldValue(fields, "INBOUND_PACKAGE_MODEL");
                    sql = "update [LES].[TM_MPM_KANBAN_CARD] "
                          + "set [PART_NAME] = N'" + partCname + "',[SUPPLIER_NAME] = N'" + supplierName + "',[PART_QTY] = " + inboundPackage + ",[PACKAGE_CODE] = N'" + inboundPackageModel + "' "
                          + "where [ID] in (" + string.Join(",", kanbanCardList.Select(d => d.Id).ToArray()) + ");";
                }
            }
            #endregion
            ///
            using (TransactionScope trans = new TransactionScope())
            {
                if (!string.IsNullOrEmpty(sql))
                {
                    CommonDAL.ExecuteNonQueryBySql(sql);
                }
                if (dal.UpdateInfo(fields + ",[PLANT] = N'" + partsBoxInfo.Plant + "',[WORKSHOP] = N'" + partsBoxInfo.Workshop + "',[ASSEMBLY_LINE] = N'" + partsBoxInfo.AssemblyLine + "'", id) == 0)
                {
                    return(false);
                }
                trans.Complete();
            }
            return(true);
        }