11
yanjinhui
2025-10-27 ca8edc868159070612f0d1c3258651bf0853569d
н¨Îļþ¼Ð/WIDESEA_WMSServer/ClassLibrary2/MaterielInfoService.cs
@@ -1,12 +1,18 @@
using System;
using HslCommunication;
using Newtonsoft.Json;
using Quartz.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Core;
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.BaseServices;
using WIDESEA_Core.Helper;
using WIDESEA_IWMsInfoServices;
using WIDESEA_Model.Models;
using static WIDESEA_DTO.SquareCabin.TowcsDto;
namespace WIDESEA_WMsInfoServices
{
@@ -15,5 +21,76 @@
        public MaterielInfoService(IRepository<Dt_MaterielInfo> BaseDal) : base(BaseDal)
        {
        }
        public IRepository<Dt_MaterielInfo> Repository => BaseDal;
        public override WebResponseContent DeleteData(object[] keys)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                if (keys.ToList().Count > 1) throw new Exception("一次只能选择一条数据");
                Dt_MaterielInfo goods = BaseDal.QueryFirst(x => keys.Contains(x.Id));
                var medicineDTO = new ProductInfo
                {
                    //用户code
                    customerCode = "905",
                    //物料类型
                    materialCode = "YY",
                    //产品编码
                    productCode = goods.MaterielCode,
                    //产品名
                    productName = goods.MaterielName,
                    //产品条码
                    productBarCode = goods.MaterielCode,
                    //规格
                    productSpecifications = goods.MaterielSpec,
                    //单位
                    unit = goods.MaterielUnit,
                    //长
                    singleProductLongNum = goods.MaterielLength.ToString(),
                    //宽
                    singleProductWideNum = goods.MaterielWide.ToString(),
                    //高
                    singleProductHighNum = goods.MaterielHeight.ToString(),
                    //重量
                    singleProductWeight = goods.MaterielWeight.ToString(),
                    //体积
                    singleProductVolume = goods.MaterielVolume.ToString(),
                    //是否取消 0是不删除,1删除
                    isDelete = "1"
                };
                var url = "http://172.16.1.2:9357/file-admin/api/product/productSynchronous";
                //var url = "http://172.16.1.245:9357/file-admin/api/product/productSynchronous";
                var result = HttpHelper.Post(url, medicineDTO.ToJsonString());
                var resp = JsonConvert.DeserializeObject<TowcsResponse<object>>(result);
                if (resp != null && resp.code == "0") return base.DeleteData(keys);
                return WebResponseContent.Instance.Error("删除失败请重试");
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            return content;
        }
        public override WebResponseContent UpdateData(SaveModel saveModel)
        {
            if (saveModel.MainData["goodStatusState"].ToString() != "未下发")
            {
                saveModel.MainData.Remove("goodStatusState");
                saveModel.MainData.Add("goodStatusState", "未下发");
            }
            // æ–¹æ³•2:或者直接比较字符串
            if (saveModel.MainData["boxQty"].ToString() == "0"|| saveModel.MainData["minQty"].ToString() == "0" )
            {
                // è¿™é‡Œæ·»åŠ ä½ çš„é€»è¾‘
                return WebResponseContent.Instance.Error("箱规和最小库存数不可已为0");
            }
            return base.UpdateData(saveModel);
        }
    }
}