ldj/WcfService1/ScheduledService.svc.cs

403 lines
9.6 KiB
C#
Raw Normal View History

2023-05-23 16:13:17 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using DeiNiu.wms.Logical;
using System.Transactions;
using DeiNiu.wms.Data.Model;
using DeiNiu.Utils;
2023-09-04 22:41:19 +08:00
using System.Net;
2023-05-23 16:13:17 +08:00
namespace DeiNiu.Wcf
{
// 注意: 使用“重构”菜单上的“重命名”命令可以同时更改代码、svc 和配置文件中的类名“ScheduledService”。
2023-09-04 22:41:19 +08:00
public class ScheduledService : basicService,IScheduledService
2023-05-23 16:13:17 +08:00
{
2023-11-21 19:18:23 +08:00
static int syncOperId = 3335;
2023-05-23 16:13:17 +08:00
static lWmsInRequest _lir;
static WmsGoods _wgoods;
WmsGoods wgoods
{
get
{
if (_wgoods == null )
{
_wgoods = new WmsGoods();
}
return _wgoods;
}
}
lWmsInRequest lir
{
get
{
if (_lir == null )
{
_lir = new lWmsInRequest(syncOperId);
}
return _lir;
}
}
private static lWmsOutRequest _lor;
lWmsOutRequest lor
{
get
{
if (_lor == null )
{
_lor = new lWmsOutRequest(syncOperId);
}
return _lor;
}
}
private static lOwner _lOwner;
lOwner lOwnerObj
{
get
{
if (_lOwner == null )
{
_lOwner = new lOwner(syncOperId);
}
return _lOwner;
}
}
private static lCustomer _lcust;
lCustomer lcust
{
get
{
if (_lcust == null)
{
_lcust = new lCustomer(syncOperId);
}
return _lcust;
}
}
private static lWmsOutPickRequest _lop ;
lWmsOutPickRequest lop
{
get
{
if (_lop == null)
{
_lop = new lWmsOutPickRequest(syncOperId);
}
return _lop;
}
}
private static lWmsOutPickPort _lopp;
lWmsOutPickPort lopp
{
get
{
if (_lopp == null )
{
_lopp = new lWmsOutPickPort(syncOperId );
}
return _lopp;
}
}
/*
public void syncOutRequest()
{
lor.syncOrders();
}
/// <summary>
/// sync out request,create pickorders
/// </summary>
public void preProcessOutOrders()
{
lor.preProcessOutOrders();
}
*/
/// <summary>
/// sync inrequests
/// 启用入库收货、验收模块后不再自动同步入库数据
/// </summary>
public void syncInRequest()
{
// lir.syncOrders();
}
public void syncGoods()
{
2023-09-04 22:41:19 +08:00
log.Debug("start syncGoods ");
try
{
wgoods.syncGoods();
}
catch (Exception e)
{
log.Error(e);
}
2023-05-23 16:13:17 +08:00
}
public int syncNewOwners()
{
2023-09-04 22:41:19 +08:00
log.Debug("start syncOwner ");
try
{
return lOwnerObj.syncOwner();
}
catch (Exception e)
{
log.Error(e);
}
return 0;
2023-05-23 16:13:17 +08:00
}
public int syncCustomer()
{
2023-09-04 22:41:19 +08:00
log.Debug("start syncCustomer ");
try
{
return lcust.syncCustomer();
}
catch (Exception e)
{
log.Error(e);
}
return 0;
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
public string processOut(enumOutStockRequestStatus status)
2023-05-23 16:13:17 +08:00
{
2023-09-04 22:41:19 +08:00
2023-11-21 19:18:23 +08:00
if(lor.isErpWorking())
{
return "ERP transfering data to wms, sleep a while...";
}
2024-03-06 20:48:05 +08:00
if (!String.IsNullOrEmpty(WmsConstants.CURRENT_PANDIAN_ORDER))
{
return "盘点进行中。。。。" + WmsConstants.CURRENT_PANDIAN_ORDER;
}
2023-11-21 19:18:23 +08:00
2023-09-04 22:41:19 +08:00
log.Debug("start sync and create pickoutrequest ,status " +status);
string result = "任务完成。。。";
try
{
lor.processOutOrders(status);
}
catch (Exception e)
{
log.Error(e);
result += " | processOutOrders error:" + e.Message;
}
log.Debug("start createPDAPickTasks ");
try
{
lop.createPDAPickTasks();
}
catch (Exception e)
{
log.Error(e);
result += " | createPDAPickTasks error:" + e.Message;
}
try
{
log.Debug("start createPickWaves ");
bool rt = lopp.createPickWaves(); ;
log.Debug("end createPickWaves ,success? " + rt);
}
catch (Exception e)
{
log.Error(e);
result += " | createPickWaves error:" + e.Message;
}
return result;
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
/*
public void createPDAPickTasks()
{
log.Debug ("begin ---to create pick out pda task data");
if (isProcessBatchWaveing)
{
log.Debug("!!!!!!!!!!!!!!!!! create pick out pda data ... is processing... return ....");
return;
}
isProcessBatchWaveing = true;
try
{
lop.createPDAPickTasks();
LogHelper.debug(typeof(WmsOutPickRequestService), "end ---to create pick out pda task data");
isProcessBatchWaveing = false;
}
catch (Exception e)
{
throw e;
}
finally
{
isProcessBatchWaveing = false;
}
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 void syncAndCreatePickRequest(enumOutStockRequestStatus status)
{
lor.preProcessOutOrdersImp(status);
}
static bool isCreateWaveing = false;
public bool createPickWaves()
{
2023-09-04 22:41:19 +08:00
log.Debug( "begin to createPickWaves...");
2023-05-23 16:13:17 +08:00
if (isCreateWaveing)
{
2023-09-04 22:41:19 +08:00
log.Debug ( "!!!!!!!!!!!!!!!!! new pick wave ... is processing... return ....");
2023-05-23 16:13:17 +08:00
return false;
}
isCreateWaveing = true;
2023-09-04 22:41:19 +08:00
2023-05-23 16:13:17 +08:00
try
{
bool ok = lopp.createPickWaves();
2023-09-04 22:41:19 +08:00
2023-05-23 16:13:17 +08:00
isCreateWaveing = false;
return ok;
}
catch (Exception e)
{
2023-09-04 22:41:19 +08:00
log.Error(e);
2023-05-23 16:13:17 +08:00
}
finally
{
isCreateWaveing = false;
}
2023-09-04 22:41:19 +08:00
isCreateWaveing = false;
return true;
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 int[] getJobInterVal()
{
_lop = new lWmsOutPickRequest(syncOperId);
2023-11-21 19:18:23 +08:00
int[] a = new int[5];
2023-05-23 16:13:17 +08:00
a[0] = WmsConstants.JOB_OUT_REQUEST_INTERVAL;
2023-11-21 19:18:23 +08:00
a[1] = WmsConstants.JOB_TEST_REQUEST_INTERVAL;
2023-05-23 16:13:17 +08:00
a[2] = WmsConstants.JOB_BASIC_INFO_SYNC_INTERVAL;
a[3] = WmsConstants.JOB_OUT_REQUEST_NO_STOCK_CHECK_INTERVAL;
2023-11-21 19:18:23 +08:00
a[4] = WmsConstants.JOB_NOTICE_ERP;
2023-05-23 16:13:17 +08:00
return a;
}
public int getWaveInterval()
{
WaveRule wr = new WaveRule() .getCurrentActiveRule(enumWaveRuleType.);
return wr.interval;
}
public void truncateDataForTestOnly()
{
2023-09-04 22:41:19 +08:00
try {
lir.createDataForTestOnly();
}catch(Exception er)
{
log.Error(er);
}
2023-05-23 16:13:17 +08:00
}
2023-09-04 22:41:19 +08:00
public string noticeErp()
{
2023-11-21 19:18:23 +08:00
log.Debug("start noticeErp ---------------->>");
2023-09-04 22:41:19 +08:00
string rt = "";
// to notice purch in
try
{
lir.retryNoticeErpValidIn();
2023-11-21 19:18:23 +08:00
}
catch (Exception er)
{
rt = er.Message;
log.Error(er);
}
// to notice sale out
try
{
2024-02-06 19:36:47 +08:00
// lop.unloadPickrequests(); //already do it when start truck
2023-11-21 19:18:23 +08:00
2023-09-04 22:41:19 +08:00
}
catch (Exception er)
{
rt = er.Message;
log.Error(er);
}
2023-11-21 19:18:23 +08:00
try
{
2023-09-04 22:41:19 +08:00
2024-03-06 20:48:05 +08:00
if (WmsConstants.ERP_NOTICE_STOCK_OUT_DOING)
{
log.Debug(" 正在同步工作中,稍后再试");
return " 正在同步工作中,稍后再试";
}
2023-11-21 19:18:23 +08:00
lop.retryNoticeErp();
}
catch (Exception er)
{
rt = er.Message;
log.Error(er);
}
try
{
lop.retryNoticeErpOrder();
}
catch (Exception er)
{
rt = er.Message;
log.Error(er);
}
2023-09-04 22:41:19 +08:00
// to notice Obsolete
// to notice 盘点
2023-11-21 19:18:23 +08:00
log.Debug("end noticeErp ------------<< ");
2023-09-04 22:41:19 +08:00
return rt;
}
2023-05-23 16:13:17 +08:00
}
}