ldj/WcfService1/Android.svc.cs

2149 lines
60 KiB
C#
Raw Permalink Normal View History

2023-05-23 16:13:17 +08:00
using System;
using System.Collections.Generic;
using System.Data;
2023-09-04 22:41:19 +08:00
using System.Drawing;
using System.IO;
2023-05-23 16:13:17 +08:00
using System.Linq;
2023-09-04 22:41:19 +08:00
using System.Net;
2023-05-23 16:13:17 +08:00
using System.Runtime.Serialization;
using System.ServiceModel;
2023-09-04 22:41:19 +08:00
using System.ServiceModel.Web;
2023-05-23 16:13:17 +08:00
using System.Text;
2023-11-21 19:18:23 +08:00
using System.Transactions;
2023-09-04 22:41:19 +08:00
using System.Web;
2023-05-23 16:13:17 +08:00
using DeiNiu.Utils;
using DeiNiu.wms.Data.Model;
using DeiNiu.wms.Data.Model.Wcf;
using DeiNiu.wms.Logical;
using Newtonsoft.Json;
using WcfServiceAuthentication;
namespace DeiNiu.Wcf
{
// 注意: 使用“重构”菜单上的“重命名”命令可以同时更改代码、svc 和配置文件中的类名“Android”。
// 注意: 为了启动 WCF 测试客户端以测试此服务,请在解决方案资源管理器中选择 Android.svc 或 Android.svc.cs然后开始调试。
[DataContract]
2023-09-04 22:41:19 +08:00
public class FormatedResult
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
private int code = 0;
2023-05-23 16:13:17 +08:00
private Object data = null;
private string message = string.Empty;
2023-09-04 22:41:19 +08:00
public FormatedResult(string data, int code = 0, string message = "")
2023-05-23 16:13:17 +08:00
{
this.data = data;
this.code = code;
this.message = message;
}
2023-09-04 22:41:19 +08:00
public FormatedResult(Exception er)
{
this.code = 400;
this.message = er.Message;
}
public FormatedResult( int code = 0, string message = "")
{
this.code = code;
this.message = message;
}
public FormatedResult(DataTable dt, int code = 0, string message = "")
2023-05-23 16:13:17 +08:00
{
this.data = JsonConvert.SerializeObject(Android.DataTableToDicList(dt));
this.code = code;
this.message = message;
}
2023-09-04 22:41:19 +08:00
public FormatedResult(Object obj )
{
this.data = JsonConvert.SerializeObject(obj);
}
2023-05-23 16:13:17 +08:00
[DataMember]
public int Code { get => code; set => code = value; }
[DataMember]
public Object Data { get => data; set => data = value; }
[DataMember]
public string Message { get => message; set => message = value; }
}
public class Android : basicService, IAndroid
{
2023-09-04 22:41:19 +08:00
2023-05-23 16:13:17 +08:00
private int operId = 0;
2023-09-04 22:41:19 +08:00
static log4net.ILog log = log4net.LogManager.GetLogger("androidSvc");
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
static internal List<Dictionary<string, string>> DataTableToDicList(DataTable dt)
2023-05-23 16:13:17 +08:00
{
List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
Dictionary<string, string> map = new Dictionary<string, string>();
for (int j = 0; j < dt.Columns.Count; j++)
{
map.Add((string)dt.Columns[j].ColumnName, dt.Rows[i][j].ToString().TrimEnd());
}
list.Add(map);
}
}
return list;
}
string DataTableToJson2(DataTable dt, string tableName = "table0")
{
2023-09-04 22:41:19 +08:00
2023-05-23 16:13:17 +08:00
StringBuilder Json = new StringBuilder();
Json.Append("{\"" + tableName + "\":[");
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
Json.Append("{");
for (int j = 0; j < dt.Columns.Count; j++)
{
Json.Append("\"" + dt.Columns[j].ColumnName.ToString() + "\":\"" + dt.Rows[i][j].ToString() + "\"");
if (j < dt.Columns.Count - 1)
{
Json.Append(",");
}
}
Json.Append("}");
if (i < dt.Rows.Count - 1)
{
Json.Append(",");
}
}
}
Json.Append("]}");
//var jsonObj= JsonConvert.DeserializeObject(Json.ToString());
return Json.ToString().Replace("\\", "");
}
2023-09-04 22:41:19 +08:00
string DataTableToJson1(DataTable dt, string tableName = "table0")
2023-05-23 16:13:17 +08:00
{
StringBuilder Json = new StringBuilder();
Json.Append("{\"" + tableName + "\":[");
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
Json.Append("{");
for (int j = 0; j < dt.Columns.Count; j++)
{
Json.Append("\"" + dt.Columns[j].ColumnName.ToString().TrimEnd() + "\":\"" + dt.Rows[i][j].ToString().TrimEnd() + "\"");
if (j < dt.Columns.Count - 1)
{
Json.Append(",");
}
}
Json.Append("}");
if (i < dt.Rows.Count - 1)
{
Json.Append(",");
}
}
}
Json.Append("]}");
2023-09-04 22:41:19 +08:00
return Json.ToString();
2023-05-23 16:13:17 +08:00
}
//-------------------------user validation
public FormatedResult validUser(string userId, string passwd)
{
2023-09-04 22:41:19 +08:00
try
{
Employee emp = new Employee();
return new FormatedResult(emp.ValidUser(userId, passwd) + "");
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
2023-05-23 16:13:17 +08:00
}
public FormatedResult validRole(string account, string passwd, string role)
{
throw new NotImplementedException();
}
protected void validUser(int operId, string token)
{
bool isValid = AuthenticationInspector.validUser(operId, token);
if (!isValid)
{
// throw new Exception("非授权用户访问");
}
setOperId(operId, token);
}
protected void setOperId(int operId, string token)
{
this.operId = operId;
this.token = token;
}
2023-09-04 22:41:19 +08:00
List<string> getAuthLst(int userId, string type = "")
2023-05-23 16:13:17 +08:00
{
Dictionary<String, List<Authority>> auths = new LAuthority().getMobileAuthorities(userId);
List<string> auth = new List<string>();
2023-09-04 22:41:19 +08:00
if (string.IsNullOrEmpty(type))
{
2023-05-23 16:13:17 +08:00
if (auths.Keys.Contains("移动设备"))
{
List<Authority> portAuth = auths["移动设备"];
foreach (Authority au in portAuth)
{
auth.Add(au.auth_name);
}
}
if (auths.Keys.Contains("细分权限"))
{
List<Authority> portAuth = auths["细分权限"];
2023-09-04 22:41:19 +08:00
/* foreach (Authority au in portAuth)
{
auth.Add(au.auth_name);
}
*/
List<string> tmp = new List<string>();
2023-05-23 16:13:17 +08:00
foreach (Authority au in portAuth)
{
2023-09-04 22:41:19 +08:00
tmp.Add(au.auth_name);
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
auth.AddRange(tmp);
2023-11-21 19:18:23 +08:00
getOperId();
2023-09-04 22:41:19 +08:00
ConstAuthourity.setSpecialAuths(userId, tmp);
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
}
else
{
2023-05-23 16:13:17 +08:00
if (auths.Keys.Contains(type))
{
List<Authority> portAuth = auths[type];
foreach (Authority au in portAuth)
{
auth.Add(au.auth_name);
}
}
}
return auth;
}
2023-09-04 22:41:19 +08:00
2023-05-23 16:13:17 +08:00
public FormatedResult getPortAuths(int userId, string token)
{
validUser(userId, token); //针对wince访问手动验证用户
2023-09-04 22:41:19 +08:00
try
{
return new FormatedResult(JsonConvert.SerializeObject(getAuthLst(userId)));
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
2023-11-21 19:18:23 +08:00
public FormatedResult getTmpAuthCode()
{
int randomCode = ConstAuthourity.userKeyPares.ContainsKey(getOperId())
? ConstAuthourity.userKeyPares[getOperId()] : 0;
return new FormatedResult( randomCode +"");
}
2023-05-23 16:13:17 +08:00
public FormatedResult login(string account, string passwd)
{
2024-05-21 17:28:35 +08:00
2023-05-23 16:13:17 +08:00
LAuthority auth = new LAuthority();
Employee em = auth.login(account, passwd);
AuthenticationInspector.authCach[em.ID] = em.token;
2024-05-21 17:28:35 +08:00
2023-11-21 19:18:23 +08:00
List<string> tmp = new List<string>();
foreach (Authority au in em.AuthSpecials)
{
tmp.Add(au.auth_name);
}
ConstAuthourity.setSpecialAuths(em.ID, tmp);
// return new FormatedResult(JsonConvert.SerializeObject(em));
2024-05-21 17:28:35 +08:00
// em.extrMsg = "this is test";
if (WmsConstants.IS_ONLINE_RESTRICT)
{
if(WmsConstants.SYSTEM_VALID_LEFT_DAYS <= 0)
{
em = new Employee();
}else if( WmsConstants.SYSTEM_VALID_LEFT_DAYS <20)
{
log.Debug(string.Format("Warrning is expiring... IS_ONLINE_RESTRICT: {0}, SYSTEM_VALID_LEFT_DAYS: {1}, SYSTEM_VALID_DATE {2} ",
WmsConstants.IS_ONLINE_RESTRICT, WmsConstants.SYSTEM_VALID_LEFT_DAYS, WmsConstants.SYSTEM_VALID_DATE));
2024-05-24 19:11:48 +08:00
em.extrMsg = String.Format("警告:系统将在{0}天后到期停用", WmsConstants.SYSTEM_VALID_LEFT_DAYS);
2024-05-21 17:28:35 +08:00
}
// log.Debug("login user " + em.ToString());
}
2023-11-21 19:18:23 +08:00
return new FormatedResult(em);
2023-09-04 22:41:19 +08:00
}
public List<String> getSpecialAuths(int userId, int warehouse = -1)
{
List<String> lst = new List<string>();
Dictionary<String, List<Authority>> auths = new LAuthority().getCatedAuthorities(userId, warehouse);
foreach (String cate in auths.Keys)
{
foreach (Authority link in auths[cate])
{
if (link.auth_special)
{
lst.Add(link.auth_name);
}
}
}
return lst;
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
2023-05-23 16:13:17 +08:00
/*
public WcfEmployee login2(string account, string passwd)
{
Employee em = new Employee();
string token = null;
if (em.login(account, passwd))
{
token = em.token;
AuthenticationInspector.authCach[em.ID] = token;
}
WcfEmployee wcf = new WcfEmployee();
return wcf.getWcfObject(em);
}
*/
public FormatedResult getDictionary()
{
DataTable dt = new lNode().QueryByFlags();
return new FormatedResult(JsonConvert.SerializeObject(DataTableToDicList(dt)));
}
2023-09-04 22:41:19 +08:00
FormatedResult IAndroid.getNodesByFlag(int flag)
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
return new FormatedResult(new Node().queryChildsByFlag(flag));
2023-05-23 16:13:17 +08:00
}
//------------------------- stock location begin ------------------------------------------------------------------------------------------
private static lWmslocation _loc;
private static lWmsStock _stock;
private static lWmsStockPandian _pandian;
lWmsStockPandian pandian
{
get
{
if (_pandian == null || _pandian.operId != getOperId())
{
_pandian = new lWmsStockPandian(getOperId());
}
return _pandian;
}
}
lWmsStock lstock
{
get
{
if (_stock == null || _stock.operId != getOperId())
{
_stock = new lWmsStock(getOperId());
}
return _stock;
}
}
lWmslocation loc
{
get
{
if (_loc == null || _loc.operId != getOperId())
{
_loc = new lWmslocation(getOperId());
}
return _loc;
}
}
public FormatedResult getLines(string custName)
{
DataTable dt = new lTmsLineDetail().getAllLines(custName);
2023-09-04 22:41:19 +08:00
/*
List<string> lines = new List<string>();
foreach (DataRow dr in dt.Rows)
{
lines.Add(dr["id"].ToString() + WmsConstants.SPLIT + dr["name"].ToString());
}
*/
try
{
return new FormatedResult(JsonConvert.SerializeObject(DataTableToDicList(dt)));
}
catch (Exception e)
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
log.Error(e);
return new FormatedResult(e);
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
2023-05-23 16:13:17 +08:00
}
/// <summary>
///取所属货区
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public FormatedResult getPartions(int userId)
{
/*
DataTable dt = lport.getPartions(userId);
List<string> partions = new List<string>();
foreach (DataRow dr in dt.Rows)
{
partions.Add(dr["partion"].ToString() + WmsConstants.SPLIT + dr["partName"].ToString());
}
return partions;
*/
2023-09-04 22:41:19 +08:00
try
{
return new FormatedResult(JsonConvert.SerializeObject(DataTableToDicList(lport.getPartions(userId))));
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
2023-05-23 16:13:17 +08:00
public FormatedResult getStockLocation(string locId)
2023-09-04 22:41:19 +08:00
{
2023-05-23 16:13:17 +08:00
/*
List<Dictionary<string, string >> list = DataTableToDicList(lstock.getStockLocation(locId));
string json = JsonConvert.SerializeObject(list);
return new FormatedResut(json);
*/
2023-09-04 22:41:19 +08:00
try
{
2023-12-03 22:13:49 +08:00
return new FormatedResult(JsonConvert.SerializeObject(DataTableToDicList(lstock.getStockLocation(locId.Trim()))));
2023-09-04 22:41:19 +08:00
}
catch (Exception e)
{
log.Error(e);
2023-12-03 22:13:49 +08:00
log.Debug(" authcation error :" + e.Message);
2023-09-04 22:41:19 +08:00
return new FormatedResult(e);
}
2023-12-03 22:13:49 +08:00
2023-05-23 16:13:17 +08:00
}
public FormatedResult getStockLocationsByBarcode(string barcode)
{
2023-09-04 22:41:19 +08:00
// return DataTableToJson1(lstock.wmsStock.queryByGoodsBarcode(barcode).Tables[0]);
2023-05-23 16:13:17 +08:00
/*DataTable dt = lstock.wmsStock.queryByGoodsBarcode(barcode).Tables[0];
List<WcfWmsLocation> list = new List<WcfWmsLocation>();
foreach (DataRow dr in dt.Rows)
{
list.Add( new WcfWmsLocation(dr));
}
return list;
*/
2023-09-04 22:41:19 +08:00
try
{
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
return new FormatedResult(JsonConvert.SerializeObject(DataTableToDicList(lstock.wmsStock.queryByGoodsBarcode(barcode).Tables[0])));
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
public FormatedResult updateStockLocation(string locId, string goodsId, int skuId, string batch, decimal count, string reason, int type)
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
try
{
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
bool result = lstock.updateStockLocation(locId, goodsId, skuId, batch, count, reason, (enumStockRecordType)type);
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
return new FormatedResult(JsonConvert.SerializeObject(result));
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
public FormatedResult initialStockIn(string goodsId, string locId, decimal batchCount, string prodDate, string validDate, string batch)
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
try
{
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
enumRepResult result = lstock.initialStockIn(goodsId, locId, batchCount, prodDate, batch);
return new FormatedResult(result.ToString());
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
public FormatedResult clearLocation(string locId, string reason)
2023-05-23 16:13:17 +08:00
{
try
{
2023-09-04 22:41:19 +08:00
bool result = lstock.clearLocation(locId, reason);
return new FormatedResult(JsonConvert.SerializeObject(result));
2023-05-23 16:13:17 +08:00
}
catch (Exception e)
{
2023-09-04 22:41:19 +08:00
log.Error(e);
return new FormatedResult(e);
2023-05-23 16:13:17 +08:00
}
}
2023-09-04 22:41:19 +08:00
public FormatedResult upLocationStatus(string locId, int status)
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
try
{
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
bool result = lstock.updateLocationStatus(locId, status);
return new FormatedResult(JsonConvert.SerializeObject(result));
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
public FormatedResult updateGoodsLocationVolume(string goodsId, int volType, decimal volume)
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
try
{
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
bool result = lstock.updateGoodsLocationVolume(goodsId, volType, volume);
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
return new FormatedResult(JsonConvert.SerializeObject(result));
}
catch (Exception e)
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
log.Error(e);
return new FormatedResult(e);
2023-05-23 16:13:17 +08:00
}
}
2023-09-04 22:41:19 +08:00
public FormatedResult getLocation(string locId)
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
try
{
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
var result = DataTableToDicList(loc.getWmslocation.getLocations(locId));
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
return new FormatedResult(JsonConvert.SerializeObject(result));
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
public FormatedResult getStockCompareErp(string goodsId, string barcode)
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
try
{
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
var result = DataTableToDicList(lstock.wmsStock.getStockLocationCompareErp(goodsId, barcode));
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
return new FormatedResult(JsonConvert.SerializeObject(result));
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
catch (Exception e)
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
log.Error(e);
return new FormatedResult(e);
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
}
2023-05-23 16:13:17 +08:00
2023-11-21 19:18:23 +08:00
public FormatedResult upDownStockLocation(string locId, string goodsId, int skuId, string batch, decimal count, int type, int oldRecId,string flowNo)
2023-09-04 22:41:19 +08:00
{
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
try
{
2023-05-23 16:13:17 +08:00
2023-11-21 19:18:23 +08:00
var result = lstock.upDownGoodsCountWithLocation(locId, goodsId, skuId, batch, count, "", (enumStockRecordType)type, oldRecId,flowNo).ToString();
2023-09-04 22:41:19 +08:00
return new FormatedResult(JsonConvert.SerializeObject(result));
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
2023-05-23 16:13:17 +08:00
}
2023-11-21 19:18:23 +08:00
public FormatedResult getDownStockList4Up(int operId, string flowNo)
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
try
{
2023-11-21 19:18:23 +08:00
var result = DataTableToDicList(lstock.wmsStock.getLocationDownList4UpFlow(operId,flowNo));
2023-09-04 22:41:19 +08:00
return new FormatedResult(JsonConvert.SerializeObject(result));
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
2023-11-21 19:18:23 +08:00
2023-09-04 22:41:19 +08:00
public FormatedResult locationEleIdCombine(string locId, int eleId)
{
try
{
var result = loc.locationEleIdCombine(locId, eleId);
return new FormatedResult(JsonConvert.SerializeObject(result));
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
public FormatedResult repItemIn(string locId, string goodsId, int skuId, string batch, decimal count, int portId)
{
try
{
var result = (int)lstock.repItemIn(locId, goodsId, skuId, batch, count, portId);
return new FormatedResult(JsonConvert.SerializeObject(result));
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
public FormatedResult getLocations(int skuId, string skuCode, string goodsId, string batch, decimal count)
{
try
{
DataTable dt = lstock.getBulkLocations(skuId, skuCode, goodsId, batch, count);
var result = DataTableToDicList(dt);
return new FormatedResult(JsonConvert.SerializeObject(result));
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
public FormatedResult getGoodsStockLocations(string barcode)
{
try
{
var result = DataTableToDicList(lstock.wmsStock.getGoodsStockLocations(barcode));
return new FormatedResult(JsonConvert.SerializeObject(result));
}
catch (Exception er)
{
log.Error(er);
return new FormatedResult(er);
}
}
2024-02-06 19:36:47 +08:00
2023-09-04 22:41:19 +08:00
public FormatedResult getGoodsERPStoreByBarcode(string barcode)
{
try
{
var result = DataTableToDicList(lstock.wmsStock.getGoodsERPStoreByBarcode(barcode));
return new FormatedResult(JsonConvert.SerializeObject(result));
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
public FormatedResult getPandianOrders(int ownerId, int status)
{
try
{
var result = DataTableToDicList(pandian.getWmsStockPandian.getPandianOrders(ownerId, status));
return new FormatedResult(JsonConvert.SerializeObject(result));
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
public FormatedResult getPandianItem(string orderNo, string locationId)
{
try
{
2023-11-21 19:18:23 +08:00
var result = DataTableToDicList(pandian.getPandianResultItem(orderNo, locationId));
2023-09-04 22:41:19 +08:00
return new FormatedResult(JsonConvert.SerializeObject(result));
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
2023-11-21 19:18:23 +08:00
public FormatedResult postPandianItem(int mirrorId, decimal count)
{
try
{
var result = pandian.postPandianItem( mirrorId, count);
return new FormatedResult(JsonConvert.SerializeObject(result));
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
public FormatedResult newPandianItem(string orderNo, string locationId, int mirrroId, string goodsId, string prdDate, string batch, decimal count)
{
try
{
var result = pandian.newPandianItem(orderNo, locationId, mirrroId, goodsId, prdDate, batch, count);
return new FormatedResult(JsonConvert.SerializeObject(result));
2023-09-04 22:41:19 +08:00
2023-11-21 19:18:23 +08:00
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
2023-09-04 22:41:19 +08:00
2023-11-21 19:18:23 +08:00
public FormatedResult getPandianTargetItem(string orderNo, string locationId)
{
2023-09-04 22:41:19 +08:00
try
{
2023-11-21 19:18:23 +08:00
var result = pandian.getPandianTargetItem(orderNo, locationId );
2023-09-04 22:41:19 +08:00
return new FormatedResult(JsonConvert.SerializeObject(result));
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
2024-02-06 19:36:47 +08:00
public FormatedResult getPandianTasksByLoc( string locationId)
{
try
{
var result = pandian.getPandianTasksByLoc( locationId);
2023-09-04 22:41:19 +08:00
2024-02-06 19:36:47 +08:00
return new FormatedResult(JsonConvert.SerializeObject(result));
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
2023-09-04 22:41:19 +08:00
//------------------------- stock In Request begin ------------------------------------------------------------------------------------------
static lWmsInRequest _lir;
lWmsInRequest lir
{
get
{
if (_lir == null || _lir.operId != getOperId())
{
_lir = new lWmsInRequest(getOperId());
}
return _lir;
}
}
FormatedResult IAndroid.getPreInDetail(string preInNo)
{
try
{
2023-11-21 19:18:23 +08:00
return new FormatedResult(lir.getPreInSumary(preInNo));
2023-09-04 22:41:19 +08:00
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
FormatedResult IAndroid.receiveDetail(string preInNo, string goodsId, decimal arriveNumber, decimal receiveNumber, int inType, string inRemark, decimal temperature, bool isCache, int cachePartion)
{
// return lir.receiveDetail(preInNo, id, arriveNumber, receiveNumber, inType, inRemark, shipId, isCache, cachePartion);
try
{
return new FormatedResult(lir.receivePreDetail(preInNo, goodsId, arriveNumber, receiveNumber, inType, inRemark, isCache, cachePartion, temperature) + "");
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
FormatedResult IAndroid.getGoodsInfo(string keywords)
{
try
{
return new FormatedResult(lgood.queryByKeyWords(keywords));
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
2023-09-04 22:41:19 +08:00
FormatedResult IAndroid.getGoodsPackByBarcode(string barcode)
{
try
{
return new FormatedResult(lir.getGoodsDetailByBarcode(barcode));
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
2023-11-21 19:18:23 +08:00
static lWmsGoods _lgood;
lWmsGoods lgood
{
get
{
if (_lgood == null || _lgood.operId != getOperId())
{
_lgood = new lWmsGoods(getOperId());
}
return _lgood;
}
}
2023-09-04 22:41:19 +08:00
FormatedResult IAndroid.getGoodsPacking(string goodsId)
{
try
{
return new FormatedResult(new WmsGoods().queryPacking(goodsId));
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
2024-02-06 19:36:47 +08:00
FormatedResult IAndroid.goodsMaintain(string goodsId,decimal fullMax, decimal bulkMax, decimal batch1Max, decimal batch2Max, decimal batch3Max, int ABC, int storeType, string barcode, int expiredDays ,bool canSeedOut)
2023-09-04 22:41:19 +08:00
{
2023-11-21 19:18:23 +08:00
2023-09-04 22:41:19 +08:00
try
{
2024-02-06 19:36:47 +08:00
lgood.goodsMaintain(goodsId,fullMax, bulkMax, batch1Max, batch2Max, batch3Max, ABC, storeType, barcode, expiredDays, canSeedOut);
2023-09-04 22:41:19 +08:00
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
2023-11-21 19:18:23 +08:00
return new FormatedResult(true + "");
2023-09-04 22:41:19 +08:00
}
2023-11-21 19:18:23 +08:00
FormatedResult IAndroid.goodsPacking(int id, string goodsId, string barcode, int packingQty, string manufacturer2, string spec, decimal chang, decimal kuan, decimal gao, decimal weight, int stackLayers, int stackLayNums, bool isDelete)
2023-09-04 22:41:19 +08:00
{
try
{
2023-11-21 19:18:23 +08:00
lgood.updatePackInfo(id,goodsId,barcode,packingQty,manufacturer2,spec,chang,kuan,gao,weight, stackLayers, stackLayNums,isDelete);
2023-09-04 22:41:19 +08:00
}
catch (Exception er)
{
log.Error(er);
return new FormatedResult(er);
}
2023-11-21 19:18:23 +08:00
return new FormatedResult(true + "");
2023-09-04 22:41:19 +08:00
}
FormatedResult IAndroid.getReceiveDetailByBarcode(string preInOrder, string barcode)
{
try
{
return new FormatedResult(lir.getReceiveDetailByBarcode(preInOrder, barcode));
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
FormatedResult IAndroid.getValidSeedsCnt(string goodsId, decimal batchCount)
{
try
{
return new FormatedResult(lir.getValidSeedsCnt(goodsId, batchCount) + "");
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
FormatedResult IAndroid.isFlowNoValid(string preInOrder, string flowNo)
2023-05-23 16:13:17 +08:00
{
throw new NotImplementedException();
}
2023-09-04 22:41:19 +08:00
2023-05-23 16:13:17 +08:00
/// <summary>
/// 取消上架任务,重新验货入库
/// 同批次的,同托盘的其他任务一起取消
/// </summary>
/// <param name="flowNo"></param>
/// <param name="jobId"></param>
/// <returns></returns>
FormatedResult IAndroid.retrieveValidIn(int jobId)
{
2023-09-04 22:41:19 +08:00
try
{
return new FormatedResult(lir.retrieveValidByJobId(jobId) + "");
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
public FormatedResult retrieveValidByDetailId(int detailId)
{
try
{
return new FormatedResult(lir.retrieveValidByDetailId(detailId) + "");
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
public FormatedResult retrieveValidBySkuId(string preInNo, int skuId)
{
try
{
return new FormatedResult(lir.retrieveValidByPreNo(preInNo, skuId) + "");
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
FormatedResult IAndroid.validIn(string preInNo, string flowNo, string goodsId, decimal batchCount, decimal seedsCount,
string prdDate, string validDate, string batch, string entiId, bool isPass, bool isIsuLocations, bool isVirtualIn, int secondValidUserId, bool isFlowUni,
2024-02-06 19:36:47 +08:00
bool isZhitong = false, string pickOrderNo = null, int zhitongPartion = 0, int outPickDetailId = 0, int purch_d_id = 0,bool isOnce=false)
2023-09-04 22:41:19 +08:00
{
// lir.receivePreDetail(preInNo, goodsId, batchCount, receiveNumber, inType, inRemark, isCache, cachePartion, temperature);
Dictionary<string, string> sku = new Dictionary<string, string>();
sku.Add(WmsConstants.SKU_RESEVRED_PRDDATE_ATTNAME, prdDate);
sku.Add(WmsConstants.SKU_RESEVRED_EXPIREDATE_ATTNAME, validDate);
sku.Add(WmsConstants.SKU_RESEVRED_BATCH_ATTNAME, batch);
sku.Add(WmsConstants.SKU_RESEVRED_ENTI_ATTNAME, entiId);
try
{
// throw new Exception("test....");
2024-02-06 19:36:47 +08:00
enumValidInResult result = lir.validIn(preInNo, flowNo, goodsId.Trim(), batchCount, seedsCount, sku, isPass, isIsuLocations, isVirtualIn, secondValidUserId, 0, true, isFlowUni, isZhitong, pickOrderNo, zhitongPartion, outPickDetailId, purch_d_id,isOnce);
2023-09-04 22:41:19 +08:00
FormatedResult rs = new FormatedResult(result.ToString(), (int)result, result.ToString());
return rs;
}
catch (Exception e)
{
2023-11-21 19:18:23 +08:00
2023-09-04 22:41:19 +08:00
log.Error(e);
return new FormatedResult(400, e.Message);
}
}
FormatedResult IAndroid.getPreValidResult(string preInNo, string flowNo, bool showAllUsers)
{
try
{
return new FormatedResult(lir.getPreValidResult4Wince(preInNo, flowNo, showAllUsers));
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
FormatedResult IAndroid.getValidInDetail(string preInNo, string flowNo)
{
try { return new FormatedResult(lir.getValidInDetail(preInNo, flowNo)); } catch (Exception e) { log.Error(e); return new FormatedResult(e); }
}
FormatedResult IAndroid.finishUpShelfItem(string flowNo, int id, decimal count, string locationId, string reason)
{
try
{
enumRepResult result = lir.finishUpShelfItem(flowNo, id, count, locationId, reason);
DataTable dt = lir.getPortStockInDetailByPortId(id);
return new FormatedResult(dt, (int)result, result.ToString());
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
FormatedResult IAndroid.getZhiTongOrderDetail(string flowNo)
{
try
{
return new FormatedResult(lir.getZhiTongOrderDetail(flowNo));
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
2023-11-21 19:18:23 +08:00
FormatedResult IAndroid.getZhiTongOrderByCust(string preNo, string barcode, string orderBy)
2023-09-04 22:41:19 +08:00
{
try
{
2023-11-21 19:18:23 +08:00
return new FormatedResult(lir.getZhiTongOrderByCust(preNo, orderBy, barcode));
2023-09-04 22:41:19 +08:00
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
FormatedResult IAndroid.zhiTongSeedOut(int outDetailId, int inDetailId, decimal seedCnt, string flowNo)
{
try
{
enumRepResult result = lir.zhiTongSeedOut(outDetailId, inDetailId, seedCnt, flowNo);
return new FormatedResult(result.ToString());
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
FormatedResult IAndroid.newPackBarcode(string goodsId, string barcode, decimal packingQty, decimal chang, decimal kuan, decimal gao, decimal weight)
{
try
{
enumRepResult result = lir.newBarcode(goodsId, barcode, packingQty, chang, kuan, gao, weight);
return new FormatedResult(result.ToString());
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
FormatedResult IAndroid.stackDone(string preInNo, string flowNo)
{
try
{
enumRepResult result = lir.stackDone(preInNo, flowNo);
return new FormatedResult(result.ToString());
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
2024-02-06 19:36:47 +08:00
FormatedResult IAndroid.preInDone(string preInNo,bool isZhitongAuto)
2023-09-04 22:41:19 +08:00
{
try
2023-11-21 19:18:23 +08:00
{
2024-02-06 19:36:47 +08:00
return new FormatedResult(lir.preInDone(preInNo, isZhitongAuto).ToString());
2023-09-04 22:41:19 +08:00
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
//stock out -------begin-----------
private static lWmsOutPickRequest _lop;
private static lWmsOutPickPort _lport;
lWmsOutPickRequest lop
{
get
{
if (_lop == null || _lop.operId != getOperId())
{
_lop = new lWmsOutPickRequest(getOperId());
}
return _lop;
}
}
lWmsOutPickPort lport
{
get
{
if (_lport == null || _lport.operId != getOperId())
{
_lport = new lWmsOutPickPort(getOperId());
}
return _lport;
}
}
FormatedResult IAndroid.getStockInPortDetail(int portId)
{
try
{
throw new NotImplementedException();
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
FormatedResult IAndroid.getStockInDetails(string flowNo)
{
try
{
throw new NotImplementedException();
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
FormatedResult IAndroid.getBatchPickOrders4Valid()
{
try
{
return new FormatedResult(lop.getBatchPickOrders4Validate());
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
FormatedResult IAndroid.getPickOrderDetails(string orderNo)
{
try
{
throw new NotImplementedException();
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
2023-12-03 22:13:49 +08:00
FormatedResult IAndroid.getPickDetail(int id, bool isAssignToMe)
2023-09-04 22:41:19 +08:00
{
try
{
2023-12-03 22:13:49 +08:00
DataTable dt = lop.getPortOutPickOrderDetail(id, isAssignToMe);
2023-11-21 19:18:23 +08:00
dt.Columns.Remove("id128");
return new FormatedResult(dt);
2023-09-04 22:41:19 +08:00
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
FormatedResult IAndroid.finishPickItem(string flowNo, string waveNo, string pickOrderNo, int id, decimal pickCount)
{
try
{
return new FormatedResult(lop.finishPickItem(flowNo, waveNo, pickOrderNo, id, pickCount) + "");
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
FormatedResult IAndroid.finishBatchValidateItem(string pickOrderNo, int id, int operId, int checkBy2, string token)
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
try
{
throw new NotImplementedException();
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
int IAndroid.batchPickCount4Valid(string pickOrderNo)
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
try
{
throw new NotImplementedException();
}
catch (Exception e)
{
log.Error(e);
return 2;
}
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
FormatedResult IAndroid.repTodayDetails4Pick(int userId)
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
try
{
throw new NotImplementedException();
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
FormatedResult IAndroid.repInDetailsByFlowNo(string flowNo)
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
try
{
throw new NotImplementedException();
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
2024-02-06 19:36:47 +08:00
FormatedResult IAndroid.getTaskAssigned(int operId,string locationId, int partion, int lineId, bool batchOnly, int orderType, int taskId,int state)
2023-05-23 16:13:17 +08:00
{
2023-12-03 22:13:49 +08:00
2023-09-04 22:41:19 +08:00
try
{
2024-02-06 19:36:47 +08:00
DataTable dt = lport.getAssignedOutTasks(operId,locationId, partion, lineId, batchOnly, (enumOrderType)orderType,taskId,state);
2023-11-21 19:18:23 +08:00
dt.Columns.Remove("id128");
return new FormatedResult(dt);
2023-09-04 22:41:19 +08:00
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
FormatedResult IAndroid.taskAssign(int takeBy, int partion, int lineId, bool batchOnly, int orderType)
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
try
{
2023-11-21 19:18:23 +08:00
lport.taskAssignByJob(takeBy, partion, lineId, 0, 0, WmsConstants.OUT_TASK_ASSIGN_BATCH_ONLY, (enumOrderType)orderType);
2024-02-06 19:36:47 +08:00
DataTable dt = lport.getAssignedOutTasks(getOperId(),"", partion, lineId, batchOnly, (enumOrderType)orderType);
2023-11-21 19:18:23 +08:00
dt.Columns.Remove("id128");
return new FormatedResult(dt);
2023-09-04 22:41:19 +08:00
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
FormatedResult IAndroid.taskResign(int partion, int lineId, bool batchOnly, int orderType)
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
try
{
throw new NotImplementedException();
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
2023-12-03 22:13:49 +08:00
public FormatedResult taskAssignByLocation(string lastJobNo, string locationId, int warehouse)
{
try
2024-02-06 19:36:47 +08:00
{
2023-12-03 22:13:49 +08:00
lport.taskAssignByJob(lastJobNo, locationId,warehouse);
2024-02-06 19:36:47 +08:00
DataTable dt = lport.getAssignedOutTasks(getOperId(), locationId);
2023-12-03 22:13:49 +08:00
dt.Columns.Remove("id128");
return new FormatedResult(dt);
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
2023-09-04 22:41:19 +08:00
FormatedResult IAndroid.getSeedsPickDetail(string flowNo, bool isOrderByCust)
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
try
{
return new FormatedResult(lport.getSeedsPickDetail(flowNo, isOrderByCust));
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
2023-05-23 16:13:17 +08:00
}
2024-02-06 19:36:47 +08:00
FormatedResult IAndroid.seedsPickOut(string flowNo, int skuId, string productDate, string batch, int outDetailId, decimal seedCnt,
string toFlowNo,int inDetailId,bool isForceClose)
2023-05-23 16:13:17 +08:00
{
2024-02-06 19:36:47 +08:00
2023-09-04 22:41:19 +08:00
try
{
2024-02-06 19:36:47 +08:00
enumRepResult result = lport.seedsPickOut(flowNo, skuId, productDate, batch, outDetailId, seedCnt, toFlowNo, inDetailId,isForceClose);
2024-03-06 20:48:05 +08:00
2023-09-04 22:41:19 +08:00
return new FormatedResult(result.ToString());
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
2023-05-23 16:13:17 +08:00
}
2024-03-06 20:48:05 +08:00
FormatedResult IAndroid.seedsPickOut2(string flowNo, int skuId, string productDate, string batch, int outDetailId, decimal seedCnt,
string toFlowNo, int inDetailId, bool isForceClose)
{
try
{
decimal seeded = new WmsOutPickDetail(outDetailId).seeded;
enumRepResult rs = lport.seedsPickOut(flowNo, skuId, productDate, batch, outDetailId, seedCnt, toFlowNo, inDetailId, isForceClose);
seeded = new WmsOutPickDetail(outDetailId).seeded - seeded;
return new FormatedResult(rs.ToString(),0,seeded+"");
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
2023-09-04 22:41:19 +08:00
public FormatedResult upValidImage(string preNo, string goodsId, Stream fileContent)
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
/*
try
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
byte[] buffer = new byte[1024];
FileStream fs = new FileStream(@"d:\test13.txt" , FileMode.Create, FileAccess.Write);
int count = 0;
while ((count = fileContent.Read(buffer, 0, buffer.Length)) > 0)
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
fs.Write(buffer, 0, count);
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
//清空缓冲区
fs.Flush();
//关闭流
fs.Close();
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
catch (Exception ex)
{
log.Error(ex);
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
}
*/
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
try
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
string date = string.Format("{0}{1:D2}", DateTime.Now.Year, DateTime.Now.Month);
2023-11-21 19:18:23 +08:00
string sitePath = "c:/image/validation/" + date + "/";
2023-09-04 22:41:19 +08:00
if (!Directory.Exists(sitePath)) Directory.CreateDirectory(sitePath);
var fileName = "";
string imgFileName = ""; //string.Format("{0}.{1}.{2}.jpg", preNo, purch_d_id, fileName);
string imgPath = "";// Path.Combine(sitePath, imgFileName);
using (var ms = new MemoryStream())
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
fileContent.CopyTo(ms);
ms.Position = 0;
Encoding encoding = System.Text.Encoding.UTF8;
var reader = new StreamReader(ms, encoding);
var headerLength = 0;
string firstLine = reader.ReadLine();
log.Debug("first lien is:-->" + firstLine);
if (firstLine.Contains("--"))
{
headerLength += encoding.GetBytes(firstLine).Length + 2;
//读第二行,含上传文件名称
var secondLine = reader.ReadLine();
log.Debug(secondLine);
headerLength += encoding.GetBytes(secondLine).Length + 2;
fileName = new System.Text.RegularExpressions.Regex("filename=\"(?<fn>.*)\"").Match(secondLine).Groups["fn"].Value;
log.Debug("file name is " + fileName);
imgFileName = string.Format("{0}.{1}.{2}", preNo, goodsId, fileName);
imgPath = Path.Combine(sitePath, imgFileName);
while (true)
{
var line = reader.ReadLine();
if (line == null)
{
break;
}
headerLength += encoding.GetBytes(line).Length + 2;
if (line == "")
{
break;
}
}
}
ms.Position = headerLength;//正文开始
if (firstLine.Contains("--"))
{
ms.SetLength(ms.Length - encoding.GetBytes(firstLine).LongLength - 3 * 2);
}
else
{
ms.SetLength(ms.Length);
}
using (FileStream fs = new FileStream(imgPath, FileMode.Create, FileAccess.Write))
{
ms.CopyTo(fs);
fs.Close();
fs.Dispose();
}
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
string imgUrl = date + "/" + imgFileName;
log.Debug("imgUrl is " + imgUrl);
Erp_purch_receive_pre_valid preValid = new Erp_purch_receive_pre_valid();
preValid.preInOrderNo = preNo;
preValid.goodsId = goodsId;
preValid.imagePath = imgUrl;
preValid.operater = operId;
int id = preValid.Add();
return new FormatedResult(imgUrl);
}
catch (Exception er)
{
log.Error(er);
return new FormatedResult(er);
2023-05-23 16:13:17 +08:00
}
}
2023-09-04 22:41:19 +08:00
private byte[] readRequest(Stream fileContents, int bites)
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
System.IO.MemoryStream memStream = new System.IO.MemoryStream();
int BUFFER_SIZE = bites;
int iRead = 0;
int idx = 0;
Int64 iSize = 0;
memStream.SetLength(BUFFER_SIZE);
while (true)
{
byte[] reqBuffer = new byte[BUFFER_SIZE];
try
{
iRead = fileContents.Read(reqBuffer, 0, BUFFER_SIZE);
}
catch (System.Exception e)
{
System.Diagnostics.Debug.WriteLine(e.Message);
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
if (iRead == 0)
{
break;
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
iSize += iRead;
memStream.SetLength(iSize);
memStream.Write(reqBuffer, 0, iRead);
idx += iRead;
}
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
byte[] content = memStream.ToArray();
memStream.Close();
return content;
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
Bitmap GetBitmap(byte[] buf)
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
Int16 width = BitConverter.ToInt16(buf, 18);
Int16 height = BitConverter.ToInt16(buf, 22);
2023-05-23 16:13:17 +08:00
2023-09-04 22:41:19 +08:00
Bitmap bitmap = new Bitmap(width, height);
int imageSize = width * height * 4;
int headerSize = BitConverter.ToInt16(buf, 10);
System.Diagnostics.Debug.Assert(imageSize == buf.Length - headerSize);
int offset = headerSize;
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
bitmap.SetPixel(x, height - y - 1, Color.FromArgb(buf[offset + 3], buf[offset], buf[offset + 1], buf[offset + 2]));
offset += 4;
}
}
return bitmap;
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
public FormatedResult upValidImage(RemoteFileInfo request)
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
const string sitePath = "/image/validation/";
string imgFileName = string.Format("{0}.{1}.jpg", request.preNo, request.purch_d_id);
string imgUrl = Path.Combine(sitePath, imgFileName);
string path = System.Web.HttpContext.Current.Server.MapPath(sitePath);
if (!Directory.Exists(path)) Directory.CreateDirectory(path);
string imgFilePath = Path.Combine(path, imgFileName);
Image bmp = Bitmap.FromStream(request.FileByteStream);
bmp.Save(imgFilePath);
Erp_purch_receive_pre_valid preValid = new Erp_purch_receive_pre_valid();
preValid.preInOrderNo = request.preNo;
preValid.purch_d_id = request.purch_d_id;
preValid.imagePath = imgUrl;// imgFilePath
preValid.operater = operId;
int id = preValid.Add();
return new FormatedResult((id > 0) + "");
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
public FormatedResult upValidImageByStr(string preNo, string purch_d_id, string imagefile)
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
try
{
/*
imagefile = imagefile.Replace(@"\n", "");
if (imagefile.Length % 4 != 0)
// we may have 0, 1 or 2 padding '='
imagefile += new string('=', 4 - imagefile.Length % 4);
*/
byte[] buf = System.Convert.FromBase64String(imagefile);
Bitmap bmp = GetBitmap(buf);
const string sitePath = "C:/inetpub/wwwroot/restService/image/validation/";
string imgFileName = string.Format("{0}.{1}.{2}.jpg", preNo, purch_d_id, DateTime.Now.ToUniversalTime());
string imgUrl = Path.Combine(sitePath, imgFileName);
Erp_purch_receive_pre_valid preValid = new Erp_purch_receive_pre_valid();
preValid.preInOrderNo = preNo;
preValid.purch_d_id = Convert.ToInt32(purch_d_id);
preValid.imagePath = imgUrl;// imgFilePath
preValid.operater = operId;
int id = preValid.Add();
return new FormatedResult(imgUrl);
}
catch (Exception er)
{
log.Error(er);
return new FormatedResult(er);
}
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
public FormatedResult validImages(string preNo, string goodsId)
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
try
{
List<string> list = new List<string>();
DataTable dt = new Erp_purch_receive_pre_valid().queryImages(preNo, goodsId);
foreach (DataRow dr in dt.Rows)
{
list.Add(dr["imagePath"].ToString());
}
return new FormatedResult(JsonConvert.SerializeObject(list));
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
//-------------容器管理--------------------------------------
lWmsPlate _lplate = new lWmsPlate();
lWmsPlate lplate
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
get
{
if (_lplate == null || _lplate.operId != getOperId())
{
_lplate = new lWmsPlate(getOperId());
}
return _lplate;
}
2023-05-23 16:13:17 +08:00
}
2024-02-06 19:36:47 +08:00
public FormatedResult getRegistedPlate(string flowNo)
{
try
{
return new FormatedResult(lplate.queryRegistedPlate(flowNo));
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
public FormatedResult getFromPlate(string flowNo)
2023-11-21 19:18:23 +08:00
{
try
{
2024-02-06 19:36:47 +08:00
return new FormatedResult(lplate.getFromPlate(flowNo));
2023-11-21 19:18:23 +08:00
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
2024-02-06 19:36:47 +08:00
2023-09-04 22:41:19 +08:00
public FormatedResult getPlateContents(string flowNo, bool isShowSubs)
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
try
{
return new FormatedResult(lplate.getPateJobsDt(flowNo, isShowSubs));
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
2023-05-23 16:13:17 +08:00
}
2024-02-06 19:36:47 +08:00
public FormatedResult getUnLoadTruckStks(string toPlate, int cnt)
{
try
{
return new FormatedResult(lplate.getUnLoadTruckStks(toPlate,cnt) );
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
public FormatedResult getLoadContent(string flowNo)
{
try
{
return new FormatedResult(lplate.getLoadContent(flowNo));
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
2023-09-04 22:41:19 +08:00
public FormatedResult getParentPlate(string flowNo)
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
try
{
return new FormatedResult(lplate.getWmsPlate.getParentPlate(flowNo));
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
2023-11-21 19:18:23 +08:00
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
public FormatedResult getSubPlates(string flowNo)
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
try
{
2023-11-21 19:18:23 +08:00
return new FormatedResult(lplate.getWmsPlate.getSubPlateIds(flowNo));
2023-09-04 22:41:19 +08:00
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
2023-11-21 19:18:23 +08:00
}
public FormatedResult putPlateIntoPlate(string fromPlate, string toPlate)
{
try
{
return new FormatedResult(lplate.putPlateIntoPlate(fromPlate, toPlate).ToString());
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
2023-12-03 22:13:49 +08:00
public FormatedResult mergePlate(string fromPlate, string toPlate)
{
try
{
return new FormatedResult(lplate.mergePlate(fromPlate, toPlate).ToString());
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
2023-11-21 19:18:23 +08:00
public FormatedResult takeOutPlate(string fromPlate, string plate)
{
try
{
return new FormatedResult(lplate.takeOutPlate(fromPlate, plate).ToString());
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
2023-05-23 16:13:17 +08:00
}
2023-11-21 19:18:23 +08:00
2024-02-06 19:36:47 +08:00
public FormatedResult plateValidation(string plateId,int portId, int skuId, string productDate, string validDate, string batch, decimal validationCnt, string validReason, bool finialValidation)
2023-11-21 19:18:23 +08:00
{
try
{
log.Debug(string.Format("do validation .."));
2024-02-06 19:36:47 +08:00
return new FormatedResult(lplate.plateValidation(plateId, portId, skuId, productDate, validDate, batch, validationCnt, validReason, finialValidation).ToString());
2023-11-21 19:18:23 +08:00
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
public FormatedResult startTran(string plateId)
{
try
{
log.Debug(string.Format("do startTran .."));
return new FormatedResult(lplate.startTran(plateId).ToString());
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
public FormatedResult loadTruck(string fromPlate, string toPlate)
{
try
{
log.Debug(string.Format("do loadTruck .."));
return new FormatedResult(lplate.loadTruck(fromPlate, toPlate).ToString());
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
2024-02-06 19:36:47 +08:00
public FormatedResult getLatestPlate(string custId, string goodsId)
{
try
{
return new FormatedResult(lplate.getLatestPlate(custId, goodsId) );
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
2023-11-21 19:18:23 +08:00
//-----------------light pick
2024-02-06 19:36:47 +08:00
public FormatedResult getGoodsById(string goodsId)
{
try
{
2024-02-06 19:36:47 +08:00
return new FormatedResult(lplate.getGoodsById( goodsId));
}
catch (Exception e)
{
log.Error(e);
return new FormatedResult(e);
}
}
2023-11-21 19:18:23 +08:00
2023-05-23 16:13:17 +08:00
}
}