From a770206c91e495b802b3e9371e06834586ad7715 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期四, 30 十月 2025 20:17:30 +0800
Subject: [PATCH] 1
---
新建文件夹/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/MedicineGoodsServices.cs | 205 +++++++++++++++++++++++++++++++++------------------
1 files changed, 132 insertions(+), 73 deletions(-)
diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/MedicineGoodsServices.cs" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/MedicineGoodsServices.cs"
index 2429882..7746d1b 100644
--- "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/MedicineGoodsServices.cs"
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/MedicineGoodsServices.cs"
@@ -7,6 +7,7 @@
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
+using WIDESEA_Common;
using WIDESEA_Core;
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.BaseServices;
@@ -26,7 +27,7 @@
}
public IRepository<Dt_MedicineGoods> Repository => BaseDal;
- static string SearchDate = "";
+ static string SearchDate = "2025-10-1 20:45:16";
/// <summary>
/// 鑾峰彇鑽搧鍩虹淇℃伅鍚屾鎺ュ彛
@@ -37,27 +38,27 @@
var responseContent = new WebResponseContent();
try
{
-
- var url = "http://121.37.118.63:80/GYZ2/95fck/goodsInfo";
+
+ var url = "http://121.37.118.63:80/GYZ2/95fck/goodsInfo";
- if (string.IsNullOrEmpty(SearchDate)) SearchDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+ //if (string.IsNullOrEmpty(SearchDate)) SearchDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
//璇锋眰鍙傛暟
- var requestData = new
- {
- searchDate = "2022-10-10 20:45:16" // 姝g‘鐨勬牸寮�
- };
- //if (string.IsNullOrEmpty(SearchDate))
- //{
- // // 榛樿鏌ヨ杩囧幓24灏忔椂鐨勬暟鎹�
- // SearchDate = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
- //}
- //// 璇锋眰鍙傛暟
//var requestData = new
//{
- // searchDate = SearchDate
+ // searchDate = "2009-01-10 20:45:16" // 姝g‘鐨勬牸寮�
//};
- //SearchDate = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
+ if (string.IsNullOrEmpty(SearchDate))
+ {
+ // 榛樿鏌ヨ杩囧幓24灏忔椂鐨勬暟鎹�
+ SearchDate = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
+ }
+ // 璇锋眰鍙傛暟
+ var requestData = new
+ {
+ searchDate = SearchDate
+ };
+ SearchDate = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
// 鍙戣捣璇锋眰
var result = HttpHelper.Post(url, requestData.ToJsonString());
@@ -67,7 +68,7 @@
if (response.resultCode != "0")
{
// 璋冪敤寮傚父鎺ュ彛
- SendErrorToUpstream(5, "", response.resultMsg ?? "涓婃父鎺ュ彛杩斿洖澶辫触", "");
+ //SendErrorToUpstream(5, "", response.resultMsg ?? "涓婃父鎺ュ彛杩斿洖澶辫触", "");
return responseContent.Error(response.resultMsg ?? "涓婃父鎺ュ彛杩斿洖澶辫触");
}
if (response.data == null || !response.data.Any())
@@ -76,28 +77,32 @@
}
//鑾峰彇鎵�鏈夊凡瀛樺湪鐨勫晢鍝佺紪鍙�
- var existingGoodsNos = BaseDal.Db.Queryable<Dt_MedicineGoods>()
- .Select(g => g.Goods_no)
+ var existingGoodsNos = BaseDal.Db.Queryable<Dt_MaterielInfo>()
+ .Select(g => g.MaterielCode)
.ToList();
// 鏀堕泦鎵�鏈夎鎻掑叆鐨勫疄浣�
- var entityList = response.data.Where(Medicat => !existingGoodsNos.Contains(Medicat.goods_no)).Select(Medicat => new Dt_MedicineGoods
+ var entityList = response.data.Where(Medicat => !existingGoodsNos.Contains(Medicat.goods_no)).Select(Medicat => new Dt_MaterielInfo
{
- Goods_no = Medicat.goods_no,
- MaterialCode=Medicat.materialCode,
- Goods_spm = Medicat.goods_spm,
- Model = Medicat.model,
+ MaterielCode = Medicat.goods_no,
+ MaterielErpType = Medicat.goods_type,
+ item = Medicat.goods_tym, //閫氱敤鍚�
+ MaterielName = Medicat.goods_spm,//鐗╂枡鍚嶇О
+ Dosage_form = GetDosageForm(Medicat.dosage_form),//鑽墏
+ Barcode = Medicat.barcode,//鏉″舰鍚�
+ MaterielSpec = Medicat.model,
Factory = Medicat.factory,
- Unit = Medicat.unit,
+ MaterielUnit = Medicat.unit,//鍗曚綅
+ MaterielSourceType=MaterielSourceTypeEnum.PurchasePart,
// 浣跨敤 ?? 杩愮畻绗︽彁渚涢粯璁ゅ��
- Item_Iength = Medicat.item_length ,
- Item_width = Medicat.item_width,
- Item_hight = Medicat.item_hight,
- Item_volumn = Medicat.item_volumn,
- Item_weight = Medicat.item_weight,
- Storage_cond = Medicat.storage_cond,
+ MaterielLength = (float?)Medicat.item_length,
+ MaterielWide = (float?)Medicat.item_width,
+ MaterielHeight = (float?)Medicat.item_hight,
+ MaterielVolume = (float?)Medicat.item_volumn,
+ MaterielWeight = (float?)Medicat.item_weight,
+ MaterielStoragecondition = float.TryParse(Medicat.storage_confition, out var val) ? val : null, //鍌ㄥ瓨鏉′欢
Remark = Medicat.remark,
- GoodStatus = "鏈笅鍙�",
+ GoodStatusState = "鏈笅鍙�",
ModifyDate = Medicat.modify_date
}).ToList();
// 涓�娆℃�ф壒閲忔彃鍏ユ暟鎹簱
@@ -106,10 +111,10 @@
ProductSynchronous();
return responseContent.OK("鍚屾鎴愬姛");
}
-
+
catch (Exception ex)
{
- SendErrorToUpstream(5, "", ex.Message, "");
+ //SendErrorToUpstream(5, "", ex.Message, "");
return responseContent.Error(ex.Message);
}
}
@@ -123,8 +128,9 @@
{
try
{
- //鍏堟壘鍒版墍鏈夋湭涓嬪彂鐨勮嵂鍝�
- var list = BaseDal.QueryData(x => x.GoodStatus == "鏈笅鍙�").ToList();
+ //鎶婂皬浠舵湭涓嬪彂鐨勭殑淇℃伅鍜岀瑙勪负0锛屾渶浣庡簱瀛樹负0鐨勮繃婊ゆ帀
+ //var list = BaseDal.Db.Queryable<Dt_MaterielInfo>().Where(x => x.GoodStatusState == "鏈笅鍙�" && x.MaterielSourceType == MaterielSourceTypeEnum.SelfMadePart).ToList();
+ var list = BaseDal.Db.Queryable<Dt_MaterielInfo>().Where(x =>x.MaterielSourceType == MaterielSourceTypeEnum.SelfMadePart&&x.BoxQty!=0&&x.MinQty!=0&& x.GoodStatusState == "鏈笅鍙�").ToList();
if (list == null || !list.Any())
{
return new WebResponseContent().OK("鏃犳湭涓嬪彂鑽搧");
@@ -137,28 +143,31 @@
//鐢ㄦ埛code
customerCode = "905",
//鐗╂枡绫诲瀷
- materialCode =item.MaterialCode,
+ materialCode = item.MaterielErpType,
//浜у搧缂栫爜
- productCode= item.Goods_no,
+ productCode = item.MaterielCode,
//浜у搧鍚�
- productName =item.Goods_spm ,
+ productName = item.MaterielName,
//浜у搧鏉$爜
- productBarCode= item.Goods_no,
+ productBarCode = item.Barcode,
+
+ //鑽墏
+ medicine = item.Dosage_form,//杩欓噷瑕佽皟鐢ㄦ柟娉曪紝杞寲鏂规硶
//瑙勬牸
- productSpecifications=item.Model,
+ productSpecifications = item.MaterielSpec,
//鍗曚綅
- unit = item.Unit,
+ unit = item.MaterielUnit,
//闀�
- singleProductLongNum = item.Item_Iength.ToString(),
+ singleProductLongNum = (item.MaterielLength ?? 0).ToString(),
//瀹�
- singleProductWideNum = item.Item_weight.ToString(),
+ singleProductWideNum = (item.MaterielWide ?? 0).ToString(),
//楂�
- singleProductHighNum = item.Item_hight.ToString(),
+ singleProductHighNum = (item.MaterielHeight ?? 0).ToString(),
//閲嶉噺
- singleProductWeight = item.Item_weight.ToString(),
+ singleProductWeight = (item.MaterielWeight ?? 0).ToString(),
//浣撶Н
- singleProductVolume = item.Item_volumn.ToString(),
+ singleProductVolume = (item.MaterielVolume ?? 0).ToString(),
//鏄惁鍙栨秷 0鏄笉鍒犻櫎锛�1鍒犻櫎
isDelete = "0"
};
@@ -166,19 +175,19 @@
var result = HttpHelper.Post(url, medicineDTO.ToJsonString());
var resp = JsonConvert.DeserializeObject<TowcsResponse<object>>(result);
- if (resp!=null&&resp.code=="0")
+ if (resp != null && resp.code == "0")
{
//鏇存柊鑽搧鐘舵��-宸插畬鎴�
- BaseDal.Db.Updateable<Dt_MedicineGoods>()
- .SetColumns(x => x.GoodStatus == "涓嬪彂瀹屾垚")
- .Where(x => x.Goods_no == item.Goods_no)
- .ExecuteCommand();
+ BaseDal.Db.Updateable<Dt_MaterielInfo>()
+ .SetColumns(x => x.GoodStatusState == "涓嬪彂瀹屾垚")
+ .Where(x => x.MaterielCode == item.MaterielCode)
+ .ExecuteCommand();
}
else
{
- SendErrorToUpstream(5, medicineDTO.materialCode, resp?.msg ?? "WCS鑽搧淇℃伅鍚屾澶辫触", "");
-
- return new WebResponseContent { Status = false, Message = "璁㈠崟鎺ㄩ�佸け璐�" };
+ //SendErrorToUpstream(5, medicineDTO.materialCode, resp?.msg ?? "WCS鑽搧淇℃伅鍚屾澶辫触", "");
+ //return new WebResponseContent { Status = false, Message = "璁㈠崟鎺ㄩ�佸け璐�" };
+ continue;
}
}
@@ -199,10 +208,9 @@
/// <returns></returns>
public WebResponseContent DeleteProduct(string goodsno)
{
-
try
{
- var goods = BaseDal.QueryData(x => x.Goods_no == goodsno).FirstOrDefault();
+ var goods = BaseDal.Db.Queryable<Dt_MaterielInfo>().Where(x => x.MaterielCode == goodsno).First();
if (goods == null)
{
return new WebResponseContent
@@ -218,26 +226,26 @@
//鐗╂枡绫诲瀷
materialCode = "YY",
//浜у搧缂栫爜
- productCode = goods.Goods_no,
+ productCode = goods.MaterielCode,
//浜у搧鍚�
- productName = goods.Goods_spm,
+ productName = goods.MaterielName,
//浜у搧鏉$爜
- productBarCode = goods.Goods_no,
+ productBarCode = goods.MaterielCode,
//瑙勬牸
- productSpecifications = goods.Model,
+ productSpecifications = goods.MaterielSpec,
//鍗曚綅
- unit = goods.Unit,
+ unit = goods.MaterielUnit,
//闀�
- singleProductLongNum = goods.Item_Iength.ToString(),
+ singleProductLongNum = goods.MaterielLength.ToString(),
//瀹�
- singleProductWideNum = goods.Item_weight.ToString(),
+ singleProductWideNum = goods.MaterielWide.ToString(),
//楂�
- singleProductHighNum = goods.Item_hight.ToString(),
+ singleProductHighNum = goods.MaterielHeight.ToString(),
//閲嶉噺
- singleProductWeight = goods.Item_weight.ToString(),
+ singleProductWeight = goods.MaterielWeight.ToString(),
//浣撶Н
- singleProductVolume = goods.Item_volumn.ToString(),
+ singleProductVolume = goods.MaterielVolume.ToString(),
//鏄惁鍙栨秷 0鏄笉鍒犻櫎锛�1鍒犻櫎
isDelete = "1"
};
@@ -249,17 +257,14 @@
if (resp != null && resp.code == "0")
{
//鎴戣嚜宸变篃鍒犻櫎
- BaseDal.DeleteData(goods);
+ base.Db.Deleteable<Dt_MaterielInfo>().Where(x => x.MaterielCode == goodsno);
return new WebResponseContent { Status = true, Message = "鍒犻櫎鎴愬姛" };
}
return new WebResponseContent { Status = false, Message = "鍒犻櫎澶辫触璇烽噸璇�" };
-
-
}
catch (Exception ex)
{
-
- return new WebResponseContent { Status=false,Message = ex.Message };
+ return WebResponseContent.Instance.Error(ex.Message);
}
}
@@ -290,7 +295,61 @@
Console.WriteLine("寮傚父鎺ュ彛鎺ㄩ�佸け璐ワ細" + e.Message);
}
}
+ /// <summary>
+ /// 鍒涘缓鑽墏瀛楀吀
+ /// </summary>
+ private static readonly Dictionary<string, string> _dosageFormMap = new Dictionary<string, string>
+ {
+ {"001", "鐗囧墏"}, {"002", "鐗囧墏"}, {"003", "鐗囧墏"}, {"004", "鐗囧墏"}, {"005", "鐗囧墏"},
+ {"006", "鐗囧墏"}, {"007", "鐗囧墏"}, {"008", "鐗囧墏"}, {"009", "鐗囧墏"}, {"010", "鐗囧墏"},
+ {"011", "鍏跺畠"}, {"012", "鐗囧墏"}, {"013", "鍏跺畠"}, {"014", "鐗囧墏"}, {"015", "鐗囧墏"},
+ {"016", "鐗囧墏"}, {"017", "鐗囧墏"}, {"018", "鍏跺畠"}, {"019", "鍏跺畠"}, {"020", "鍏跺畠"},
+ {"021", "閽堝墏"}, {"022", "閽堝墏"}, {"023", "閽堝墏"}, {"024", "閽堝墏"}, {"025", "涓垚鑽�"},
+ {"026", "涓垚鑽�"}, {"027", "鍏跺畠"}, {"028", "鍏跺畠"}, {"029", "鍏跺畠"}, {"030", "鍏跺畠"},
+ {"031", "鍏跺畠"}, {"032", "鍏跺畠"}, {"033", "鍏跺畠"}, {"034", "涓垚鑽�"}, {"035", "涓垚鑽�"},
+ {"036", "涓垚鑽�"}, {"037", "涓垚鑽�"}, {"038", "鍏跺畠"}, {"039", "鍏跺畠"}, {"040", "鍏跺畠"},
+ {"041", "涓垚鑽�"}, {"042", "涓垚鑽�"}, {"043", "涓垚鑽�"}, {"044", "鍏跺畠"}, {"045", "涓垚鑽�"},
+ {"046", "涓垚鑽�"}, {"047", "涓垚鑽�"}, {"048", "涓垚鑽�"}, {"049", "涓垚鑽�"}, {"050", "涓垚鑽�"},
+ {"051", "涓垚鑽�"}, {"052", "涓垚鑽�"}, {"053", "涓垚鑽�"}, {"054", "涓垚鑽�"}, {"055", "涓垚鑽�"},
+ {"056", "鍏跺畠"}, {"057", "鍏跺畠"}, {"058", "鍏跺畠"}, {"059", "鍏跺畠"}, {"060", "鍏跺畠"},
+ {"061", "鍏跺畠"}, {"062", "鍏跺畠"}, {"063", "鍏跺畠"}, {"064", "鍏跺畠"}, {"065", "鍏跺畠"},
+ {"066", "鍏跺畠"}, {"067", "涓垚鑽�"}, {"068", "涓垚鑽�"}, {"069", "涓垚鑽�"}, {"070", "鍏跺畠"},
+ {"071", "鍏跺畠"}, {"072", "鍏跺畠"}, {"073", "涓垚鑽�"}, {"074", "鍏跺畠"}, {"075", "鍏跺畠"},
+ {"076", "涓垚鑽�"}, {"077", "鍏跺畠"}, {"078", "鍏跺畠"}, {"079", "涓垚鑽�"}, {"080", "涓垚鑽�"},
+ {"081", "涓垚鑽�"}, {"082", "涓垚鑽�"}, {"083", "鍏跺畠"}, {"084", "涓垚鑽�"}, {"085", "鍏跺畠"},
+ {"086", "涓垚鑽�"}, {"087", "鍏跺畠"}, {"088", "鍏跺畠"}, {"089", "涓垚鑽�"}, {"090", "涓垚鑽�"},
+ {"091", "鍏跺畠"}, {"092", "鍏跺畠"}, {"093", "鍏跺畠"}, {"094", "涓垚鑽�"}, {"095", "鍏跺畠"},
+ {"096", "鍏跺畠"}, {"097", "鍏跺畠"}, {"098", "鍏跺畠"}, {"099", "鍏跺畠"}, {"100", "鍏跺畠"},
+ {"101", "鍏跺畠"}, {"102", "鍏跺畠"}, {"103", "鍏跺畠"}, {"104", "鍏跺畠"}, {"105", "鍏跺畠"},
+ {"106", "鍏跺畠"}, {"107", "鍏跺畠"}, {"108", "鍏跺畠"}, {"109", "鍏跺畠"}, {"110", "鍏跺畠"},
+ {"111", "鍏跺畠"}, {"112", "鍏跺畠"}, {"113", "鍏跺畠"}, {"114", "鍏跺畠"}, {"115", "鍏跺畠"},
+ {"116", "鍏跺畠"}, {"117", "鍏朵粬"}
+ };
-
+ /// <summary>
+ /// 鏍规嵁鍓傚瀷缂栧彿鑾峰彇鍓傚瀷鍒嗙被
+ /// </summary>
+ /// <param name="dosageCode">鍓傚瀷缂栧彿(001-117)</param>
+ /// <returns>鍓傚瀷鍒嗙被(鐗囧墏/閽堝墏/涓垚鑽�/鍏跺畠/鍏朵粬)</returns>
+ public static string GetDosageForm(string dosageCode)
+ {
+ if (string.IsNullOrEmpty(dosageCode))
+ return "鏈煡";
+
+ // 澶勭悊缂栧彿鏍煎紡锛岀‘淇濇槸3浣嶆暟瀛�
+ if (dosageCode.Length == 1)
+ dosageCode = "00" + dosageCode;
+ else if (dosageCode.Length == 2)
+ dosageCode = "0" + dosageCode;
+
+ if (_dosageFormMap.TryGetValue(dosageCode, out string form))
+ {
+ return form;
+ }
+
+ return "鏈煡";
+ }
+
+
}
}
--
Gitblit v1.9.3