Beispiel #1
0
        /*
         * 1)check是否入库
         * 2)未入库则入库,更新数据
         */
        public static string CheckMaterialPutInStorage(Queue <string[]> queue)
        {
            var array        = queue.Dequeue();
            var materialCode = array[0];
            var teamLeader   = array[1];
            var admin        = array[2];
            var selectSQL    = $"SELECT {DbTable.F_Material.MATERIAL_STATE} FROM " +
                               $"{DbTable.F_MATERIAL_NAME} WHERE {DbTable.F_Material.MATERIAL_CODE} = '{materialCode}'";

            LogHelper.Log.Info("【查询入库记录】" + selectSQL);
            var dt = SQLServer.ExecuteDataSet(selectSQL).Tables[0];

            if (dt.Rows.Count > 0)
            {
                //查询有记录,已经入过库
                return(ConvertCheckMaterialPutInStorage(MaterialCheckPutStorageEnum.STATUS_IS_PUTED_IN_STORAGE));
            }
            //记录不存在-未入库
            //更新入库记录:
            //插入物料信息-更新物料状态1+更新物料库存
            //
            var insertSQL = $"INSERT INTO {DbTable.F_MATERIAL_NAME}(" +
                            $"{DbTable.F_Material.MATERIAL_CODE}," +
                            $"{DbTable.F_Material.MATERIAL_STOCK}," +
                            $"{DbTable.F_Material.MATERIAL_TEAM_LEADER}," +
                            $"{DbTable.F_Material.MATERIAL_ADMIN}," +
                            $"{DbTable.F_Material.MATERIAL_UPDATE_DATE}) VALUES(" +
                            $"'{materialCode}'," +
                            $"'{MaterialCodeMsg.GetMaterialDetail(materialCode).MaterialQTY}'," +
                            $"'{teamLeader}'," +
                            $"'{admin}'," +
                            $"'{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}')";

            LogHelper.Log.Info("【入库】" + insertSQL);
            var iRes = SQLServer.ExecuteNonQuery(insertSQL);

            if (iRes == 1)//新入库成功
            {
                LogHelper.Log.Info("【入库】入库成功");
                //更新物料PN
                UpdateMaterialPN(MaterialCodeMsg.GetMaterialPN(materialCode));
                return(ConvertCheckMaterialPutInStorage(MaterialCheckPutStorageEnum.STATUS_IS_NEW_PUT_INT_STORAGE));
            }
            LogHelper.Log.Info("【入库失败】");
            return(ConvertCheckMaterialPutInStorage(MaterialCheckPutStorageEnum.STATUS_IS_PUT_IN_FAIL_STORAGE));
        }
Beispiel #2
0
        private static string CheckMaterialUseState(string productTypeNo, string materialCode)
        {
            if (!materialCode.Contains("&"))
            {
                return(ConvertCheckMaterialStateCode(MaterialStateReturnCode.ERROR_FORMAT_MATERIAL_CODE));
            }
            //查询当前物料是否使用完成,完成返回1
            LogHelper.Log.Info("【物料数量防错开始查询】");
            var stateValue = SelectCurrentMaterialState(materialCode);

            LogHelper.Log.Info("【物料数量防错开始查询-状态=】" + stateValue);
            if (stateValue == "2" || stateValue == "3")
            {
                return(ConvertCheckMaterialStateCode(MaterialStateReturnCode.STATUS_COMPLETE_NORMAL));
            }
            var materialPN = MaterialCodeMsg.GetMaterialPN(materialCode);

            //根据物料号+产品型号查询是否有统计计数记录
            var selectRecordSQL = $"SELECT {DbTable.F_Material_Statistics.MATERIAL_CODE} FROM " +
                                  $"{DbTable.F_MATERIAL_STATISTICS_NAME} WHERE " +
                                  $"{DbTable.F_Material_Statistics.PRODUCT_TYPE_NO} = '{productTypeNo}' AND " +
                                  $"{DbTable.F_Material_Statistics.MATERIAL_CODE} like '%{materialPN}%'";
            var dt = SQLServer.ExecuteDataSet(selectRecordSQL).Tables[0];

            if (dt.Rows.Count > 0)
            {
                /* 有统计记录
                 * 查询统计记录中的所有物料编码
                 * 比对传入物料编码在统计记录中是否存在
                 */
                bool IsSameMaterialCode = false;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    var mCode = dt.Rows[i][0].ToString();
                    if (materialCode == mCode)
                    {
                        IsSameMaterialCode = true;
                    }
                }
                if (IsSameMaterialCode)
                {
                    //存在相同编码
                    LogHelper.Log.Info("【物料数量防错-存在相同编码】");
                    return(SelectMaterialState(materialCode));
                }
                else
                {
                    /* 不存在相同编码
                     * 则说明传入物料编码为新扫描编码
                     * 则查询所有已知编码的状态,是否都是使用完成状态,否则提示不能继续使用新扫描的物料
                     */
                    LogHelper.Log.Info("【物料数量防错-不存在相同编码】");
                    bool IsUseComplete = true;//默认使用完成
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        var mCode = dt.Rows[i][0].ToString();

                        var selectSQl = $"SELECT {DbTable.F_Material.MATERIAL_STATE} " +
                                        $"FROM {DbTable.F_MATERIAL_NAME} WHERE " +
                                        $"{DbTable.F_Material.MATERIAL_CODE} = '{mCode}'";
                        var mdt = SQLServer.ExecuteDataSet(selectSQl).Tables[0];
                        if (mdt.Rows.Count > 0)
                        {
                            var mState = mdt.Rows[0][0].ToString();
                            if (mState == "1")
                            {
                                //有物料未使用完,请使用完了在扫描别的箱使用
                                IsUseComplete = false;
                            }
                        }
                    }
                    if (IsUseComplete)
                    {
                        //使用完成-其他物料都使用完成,则当前物料
                        LogHelper.Log.Info("【物料数量防错-不存在相同编码】-" + 0);
                        return(ConvertCheckMaterialStateCode(MaterialStateReturnCode.STATUS_OTHER_COMPLETE));
                    }
                    else
                    {
                        //有未使用完成物料
                        return(ConvertCheckMaterialStateCode(MaterialStateReturnCode.STATUS_USING));
                    }
                }
            }
            else
            {
                /* 无统计记录/为防止改物料在之前未进行物料号防错,此步骤可再次验证物料防错
                 * 则为第一次扫描该物料编码
                 * 直接查询物料信息表中该物料状态反馈即可
                 */
                LogHelper.Log.Info("【物料防错-状态-无统计记录-直接查询状态】");
                //string cRes = CheckMaterialTypeMatch(productTypeNo, materialPN, materialCode);
                //if (cRes == ConvertCheckMaterialMatch(MaterialCheckMatchReturnCode.IS_NOT_MATCH))
                //{
                //    LogHelper.Log.Info("【物料防错-状态-物料号与当前产品不匹配】");
                //    return ConvertCheckMaterialStateCode(MaterialStateReturnCode.ERROR_MATRIAL_CODE_IS_NOT_MATCH_WITH_PRODUCT_TYPENO);
                //}
                return(SelectMaterialState(materialCode));
            }
        }