Explorar o código

增加排产单类型修改功能。

klzhangweiya hai 1 ano
pai
achega
ae53398a29

+ 10 - 0
src_0nline/ShwasherSys/ShwasherSys.Application/ProductionOrderInfo/Dto/ProductionOrderUpdateDto.cs

@@ -90,4 +90,14 @@ namespace ShwasherSys.ProductionOrderInfo.Dto
 
         public decimal MaxQuantity { get; set; }
     }
+
+
+    public class ProductionTypeUpdateDto
+    {
+        public int Id { get; set; }
+
+        public string ProductionOrderNo { get; set; }
+
+        public string ProductionType { get; set; }
+    }
 }

+ 4 - 0
src_0nline/ShwasherSys/ShwasherSys.Application/ProductionOrderInfo/IProductionOrdersApplicationService.cs

@@ -71,5 +71,9 @@ namespace ShwasherSys.ProductionOrderInfo
 
 
         Task<EnterFailureRateDto> QueryEnterFailureRate(string productionOrderNo);
+
+
+        //变更排产单类型
+        Task<ProductionOrderDto> UpdateProductionType(ProductionTypeUpdateDto input);
     }
 }

+ 71 - 1
src_0nline/ShwasherSys/ShwasherSys.Application/ProductionOrderInfo/ProductionOrdersApplicationService.cs

@@ -190,7 +190,8 @@ namespace ShwasherSys.ProductionOrderInfo
                              OutsourcingFactoryName = oj.OutFactoryName,
                              EnterDate = u.EnterDate,
                              InspectDate = u.InspectDate,
-                             HasExported = u.HasExported
+                             HasExported = u.HasExported,
+                             MaxQuantity = u.MaxQuantity
                          };
             //逻辑删除也同时显示出来
             //var property = typeof(ProductionOrder).GetProperty("IsLock");
@@ -364,6 +365,7 @@ namespace ShwasherSys.ProductionOrderInfo
         {
             return await GetNewProductionOrderNo(0);
         }
+
         /// <summary>
         /// 获取新建排产单(外购单)的编号
         /// </summary>
@@ -416,6 +418,25 @@ namespace ShwasherSys.ProductionOrderInfo
             string[] scource = {"", "G", "H", "W", "J", "K", "L", "M", "N", "T", "P","Q","R"};
             return scource[liMonth];
         }
+        /// <summary>
+        /// 工厂生产和外购编码互换
+        /// </summary>
+        /// <returns></returns>
+        private string SwapOrderNo(string preOrderNo)
+        {
+            string[] source2 = { "G", "H", "W", "J", "K", "L", "M", "N", "T", "P", "Q", "R" };
+            string[] source1 = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C" };
+            var m = preOrderNo.Substring(2, 1);
+            if (string.IsNullOrEmpty(m))
+            {
+                return "";
+            }
+            int index1 = Array.IndexOf(source1, m);
+            int index2 = Array.IndexOf(source2, m);
+            m = index1 > -1 ? source2[index1] : source1[index2];
+            preOrderNo = preOrderNo.Substring(0, 2) + m + preOrderNo.Substring(3, 4);
+            return preOrderNo;
+        }
 
         [AbpAuthorize(PermissionNames.PagesProductionInfoProductionOrderMgUpdate), AuditLog("变更排产状态")]
         public async Task<ProductionOrderDto> ChangeProductionOrderStatus(ChangeProductionOrderStatusDto input)
@@ -1672,6 +1693,8 @@ namespace ShwasherSys.ProductionOrderInfo
             return result;
         }
 
+        
+
         /// <summary>
         /// 生产统计
         /// </summary>
@@ -2133,6 +2156,53 @@ namespace ShwasherSys.ProductionOrderInfo
         }
         #endregion
 
+        /// <summary>
+        /// 变更排产单类型
+        /// </summary>
+        /// <param name="input"></param>
+        /// <returns></returns>
+        public async Task<ProductionOrderDto> UpdateProductionType(ProductionTypeUpdateDto input)
+        {
+            var entity =await Repository.GetAsync(input.Id);
+            if (entity == null)
+            {
+                CheckErrors(IdentityResult.Failed("为查询到相应的排产单!"));
+            }
+            var arrWg = new string[]
+            {
+                ((int)ProductionOrderTypeEnum.OutFinish).ToString(),
+                ((int)ProductionOrderTypeEnum.RemovalProcess).ToString()
+            };
+            string preProductionType = entity.ProductionType;
+            string preProductionOrderNo = entity.ProductionOrderNo;
+            //类型一致,不更新
+            if (preProductionType == input.ProductionType)
+            {
+                return ObjectMapper.Map<ProductionOrderDto>(entity);
+            }
+            //更新单号
+            var newNo = SwapOrderNo(entity.ProductionOrderNo);
+            //如果类型变更是在外购成品和去料加工之间互换的,编号不做更新
+            if (arrWg.Contains(preProductionType) && arrWg.Contains(input.ProductionType))
+            {
+                newNo = preProductionOrderNo;
+            }
+            if (newNo.IsNullOrEmpty())
+            {
+                CheckErrors(IdentityResult.Failed("排产单号更新失败!"));
+            }
+            entity.ProductionOrderNo = newNo;
+            entity.ProductionType = input.ProductionType;
+            entity.TimeLastMod = Clock.Now;
+            entity.UserIDLastMod = AbpSession.UserId + "";
+            entity = await Repository.UpdateAsync(entity);
+            BusinessLogTypeEnum.SStore.WriteLog(LogRepository, "半产品排产单类型变更",
+                $"修改外协排产单[{entity.Id}],信息为:[{entity.Obj2String()}]",
+                $"原编号{preProductionOrderNo},原类型{preProductionType}", $"新编号{newNo},新类型{input.ProductionType}");
+
+            return MapToEntityDto(entity);
+        }
+
     }
 }
 

+ 10 - 0
src_0nline/ShwasherSys/ShwasherSys.Core/ShwasherCoreConsts.cs

@@ -421,4 +421,14 @@
         Downgrade = 5
     }
 
+    public enum ProductionOrderTypeEnum
+    {
+        //车间加工
+        MachineShop =0,
+        //外购成品
+        OutFinish = 1,
+        //去料加工
+        RemovalProcess = 2
+    }
+
 }

+ 51 - 7
src_0nline/ShwasherSys/ShwasherSys.Web/Views/ProductionInfo/ProductionOrderMg.cshtml

@@ -109,7 +109,7 @@ new SelectListItem{Text = @"去料加工",Value = "2"},
                     @Html.Partial("Modals/_ModalHeader", new ModalHeaderViewModel("排产单"))
                     @{
                         var inputs = new List<InputViewModel>
-                                {
+                        {
                             new InputViewModel("id", hide:true),
                             new InputViewModel("productionOrderNo",displayName:"流转单编号").SetOuterBefore("<div class=\"type2\">"),
                             new InputViewModel("semiProductNo", displayName: "半成品编码").SetSearchIcon("query_semiProduct_modal","#modal"),
@@ -142,6 +142,27 @@ new SelectListItem{Text = @"去料加工",Value = "2"},
                 </div>
             </div>
         </div>
+        
+        
+        <div class="modal fade" id="changeTypeModal" role="dialog" tabindex="-1" aria-labelledby="ModalLabel" aria-hidden="true">
+            <div class="modal-dialog  modal-dialog-centered" role="document">
+                <div class="modal-content">
+                    @Html.Partial("Modals/_ModalHeader", new ModalHeaderViewModel("变更排产单类型", ""))
+                    @{
+
+                        var inputs3 = new List<InputViewModel>
+                        {
+                            //new InputViewModel("currentProductStoreHouseNo", hide:true),
+                            new InputViewModel("id", hide:true),
+                            new InputViewModel("productionOrderNo", displayName: "流转单号"),
+                            new InputViewModel("productionType",InputTypes.List, "排产单类型").SetSelectOptions(productionType),
+                        };
+                    }
+                    @Html.Partial("Modals/_ModalBody", new ModalBodyViewModel(inputs3))
+                    @Html.Partial("Modals/_ModalFooter", "0")
+                </div>
+            </div>
+        </div>
     </section>
 
   
@@ -172,6 +193,7 @@ new SelectListItem{Text = @"去料加工",Value = "2"},
             //showHours: true,
             //minuteStep: 10
         };
+        var isUpdate
         $(function () {
             //$("#planProduceDate").datetimepicker(datePickerOpt).on('show',
             //    function (event) {
@@ -234,8 +256,8 @@ new SelectListItem{Text = @"去料加工",Value = "2"},
                         return;
                     }
 
-                    //$("#productionType").off("change.productionType");
-					$("#productionType").off("change.productionType").on("change.productionType", ChangeProductionType);
+                    $("#productionType").off("change.productionType");
+					//$("#productionType").off("change.productionType").on("change.productionType", ChangeProductionType);
                     if (rows[0].productionOrderStatus === 2) {
                         $(".type2").css("display", "none");
                     } else {
@@ -267,12 +289,13 @@ new SelectListItem{Text = @"去料加工",Value = "2"},
                                 data.surfaceColor = res.surfaceColor;
                             }
                             let isValidate = rows[0].productionOrderStatus !== 2;
+                            data.kgWeight = data.kgWeight == 0 ? "" : data.kgWeight;
                             BtnUpdate({
                                 readonly: "semiProductNo",
                                 data: data,
                                 isValidate: isValidate,
                                 disabled:
-                                    "productionOrderNo,model,material,rigidity,surfaceColor,partNo,timeCreated"
+                                    "productionOrderNo,model,material,rigidity,surfaceColor,productionType,partNo,timeCreated"
                             });
 
 
@@ -323,6 +346,7 @@ new SelectListItem{Text = @"去料加工",Value = "2"},
 
 
             $("#Tool1").append(
+                '<button type="button" class="btn btn-default menu-btn" onclick="f_changeOrderType()"><i class="iconfont icon-model"></i>修改排产单类型</button>'+
                 '<div  class="tool-radio"><input name="proType" type="radio" id="allProduction" checked value=""/><label for="allProduction">全部</label></div>' +
                 '<div  class="tool-radio"><input name="proType" type="radio" id="machineShop" value="0"/><label for="machineShop">车间加工</label></div>' +
                 '<div  class="tool-radio"><input name="proType" type="radio" id="outFinish" value="1"/><label for="outFinish">外购成品</label></div>' +
@@ -433,11 +457,31 @@ new SelectListItem{Text = @"去料加工",Value = "2"},
     </script>
 
     <script type="text/javascript">
-
-        function ChangeProductionType() {
+        function f_changeOrderType() {
+            var rows = config.table.bootstrapTable("getSelections");
+			if (rows.length === 1) {
+				if (rows[0].isLock == 'Y') {
+					abp.message.warn("排产单已删除,不可进行更改!");
+					return;
+				}
+				if (rows[0].productionOrderStatus > 1 && rows[0].productionOrderStatus !== 7) {
+					abp.message.warn("排产单已审核或者生产入库,不可进行更改!");
+					return;
+                }
+				var data = rows[0];
+				OpenModal(window.appUrl + "ProductionOrders/UpdateProductionType",
+					{
+						data: data,
+                        modal: $("#changeTypeModal"),
+						disabled:"productionOrderNo",
+						success: function () { $("#changeTypeModal").modal("hide"); RefreshTable(); }
+					});
+			}
+        }
+		function ChangeProductionType() {
             var type = $("#productionType").val();
             abp.ajax({
-                url: window.appUrl + 'ProductionOrders/GetNewProductionOrderNo?isOutsourcing=' + type,
+				url: window.appUrl + 'ProductionOrders/GetNewProductionOrderNo?isOutsourcing=' + type,
                 async: true,
                 type: "Post",
                 contentType: 'application/x-www-form-urlencoded; charset=UTF-8',