yanjinhui
10 天以前 b330b8ff1b5315684b25afb534f74044dea1654b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
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
{
    public class MaterielInfoService : ServiceBase<Dt_MaterielInfo, IRepository<Dt_MaterielInfo>>, IMaterielInfoService
    {
        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", "未下发");
            }
            // 如果现在这个物料信息是小件并且箱规或者最低库存为0,那么就要提示他
            if (saveModel.MainData["materielSourceType"].ToString() == "SelfMadePart" && (saveModel.MainData["boxQty"].ToString() =="0"|| saveModel.MainData["minQty"].ToString()=="0"))
            {
                // 这里添加你的逻辑
                return WebResponseContent.Instance.Error("箱规和最小库存数不可已为0");
            }
            return base.UpdateData(saveModel);
        }
    }
}