Commit 0b6df559 by yiyu.li
parents d4f8c6cb e333ca53
......@@ -425,7 +425,13 @@ export default {
});
},
Export() {
this.request("/wms/Location/ExportLocation", "", "get").then(
let data = {
page: this.page,
pageSize: this.pagesize,
id: this.whid, // 仓库id
isWavehouse: 1,
};
this.request("/wms/Location/ExportLocation", data, "get").then(
(res) => {
if (res.data.ret === 1) {
window.location.href =
......
......@@ -150,9 +150,13 @@ namespace Siger.ApiACC.Controllers
[HttpGet]
public IActionResult GetLoadingState(int section)
{
var monitor = _automationFixtureMonitor.Get(f => f.section == section);
var state = (int)Automation.TaskResultStatus.Waiting;
if (monitor!=null)
{
var taskobj = _automationTaskList.Get(f => f.extend1 == monitor.unixtime.ToStr());
state = taskobj != null ? taskobj.status : (int)Automation.TaskResultStatus.Waiting;
}
var result = new ResponsePlanlFixtureInfo
{
OrderNumber = monitor!=null? monitor.ordernumber:"",
......@@ -161,7 +165,7 @@ namespace Siger.ApiACC.Controllers
ProductCode = monitor != null ? monitor.productCode:"",
ProductName = monitor != null ? monitor.productName:"",
Sn = monitor != null ? monitor.sn:"",
status = monitor != null ? monitor.status:(int)Automation.MachineStatus.Waiting,
status = state,
Location = monitor != null ? monitor.locationId:0,
};
return new ObjectResult(result);
......@@ -353,7 +357,7 @@ namespace Siger.ApiACC.Controllers
throw new BadRequestException(CncEnum.PlanHasExist);
}
//检查工装
var fixtureToolsObj = _automationFixtureTools.GetProductFixtureLocation(ProjectId,loading.guid);
var fixtureToolsObj = _automationFixtureTools.GetProductFixtureLocation(ProjectId,loading.guid,loading.locationid);
//var fixtureToolsObj = _automationFixtureToolsProduct.GetFixtureInfoByProductCode(ProjectId, plan.product_code);
if (fixtureToolsObj == null)
{
......@@ -362,6 +366,7 @@ namespace Siger.ApiACC.Controllers
var taskNo = _automationTaskList.CrateTaskNumber(Automation.TaskTrigerType.Manual);
var sn = _automationTaskList.CreateRandonSn(plan.product_code);
var unixtime = UnixTimeHelper.GetNow();
_automationTaskList.Insert(new siger_automation_task_list
{
no=taskNo,
......@@ -387,6 +392,7 @@ namespace Siger.ApiACC.Controllers
processid=0,
programnumber="",
remark ="手动任务-准备上料",
extend1= unixtime.ToString()
});
......@@ -396,19 +402,20 @@ namespace Siger.ApiACC.Controllers
{
_automationFixtureMonitor.Insert(new siger_automation_fixture_tools_monitor
{
fixtureguid=fixtureToolsObj.FixtureGuid,
fixturename=fixtureToolsObj.FixtureName,
projectId=ProjectId,
section=loading.section,
sn=sn,
createtime=DateTime.Now,
updatetime=DateTime.Now,
status=(int)Automation.MachineStatus.Produce,
productId=plan.product_id,
productCode=plan.product_code,
productName=plan.product_name,
ordernumber=plandts.OrderNumber,
locationId= fixtureToolsObj.Location
fixtureguid = fixtureToolsObj.FixtureGuid,
fixturename = fixtureToolsObj.FixtureName,
projectId = ProjectId,
section = loading.section,
sn = sn,
createtime = DateTime.Now,
updatetime = DateTime.Now,
status = (int)Automation.MachineStatus.Produce,
productId = plan.product_id,
productCode = plan.product_code,
productName = plan.product_name,
ordernumber = plandts.OrderNumber,
locationId = fixtureToolsObj.Location,
unixtime = unixtime
});
}
else
......@@ -422,7 +429,7 @@ namespace Siger.ApiACC.Controllers
monitor.productCode = plan.product_code;
monitor.ordernumber = plandts.OrderNumber;
monitor.locationId = fixtureToolsObj.Location;
monitor.unixtime = unixtime;
_automationFixtureMonitor.Update(monitor);
}
......@@ -544,6 +551,8 @@ namespace Siger.ApiACC.Controllers
{
throw new BadRequestException(AccEnum.TaskProcessing);
}
var unixtime = UnixTimeHelper.GetNow();
//TODO
//1. 有检验状态 (立库-》检验工位)
//2. 无检验状态 (立库-》上下料工位)
......@@ -573,6 +582,7 @@ namespace Siger.ApiACC.Controllers
processid = 0,
programnumber = "",
remark = "手动任务-准备上料",
extend1= unixtime.ToStr()
});
var monitor = _automationFixtureMonitor.Get(f => f.section == unloading.section);
......@@ -592,7 +602,8 @@ namespace Siger.ApiACC.Controllers
productCode = location.productcode,
productName = location.productname,
ordernumber = location.ordernumber,
locationId = location.locationid
locationId = location.locationid,
unixtime= unixtime
});
}
else
......@@ -606,7 +617,7 @@ namespace Siger.ApiACC.Controllers
monitor.productCode = location.productcode;
monitor.ordernumber = location.ordernumber;
monitor.locationId = location.locationid;
monitor.unixtime = unixtime;
_automationFixtureMonitor.Update(monitor);
}
......@@ -651,6 +662,14 @@ namespace Siger.ApiACC.Controllers
}
//移出 上料位
monitor.section = 0;
var location = _automationLocation.Get(f => f.id == monitor.locationId);
if (location!=null)
{
location.sn = "";
_automationLocation.Update(location);
}
var taskNo = _automationTaskList.CrateTaskNumber(Automation.TaskTrigerType.Manual);
_automationTaskList.Insert(new siger_automation_task_list
{
......
......@@ -690,9 +690,9 @@ namespace Siger.ApiWMS.Controllers
/// </summary>
/// <returns></returns>
[HttpGet]
public IActionResult ExportLocation()
public IActionResult ExportLocation(int id = 0, int isWavehouse = 0)
{
var data = SearchLocation(0, 0, out int count, false);
var data = SearchLocation(0, 0, out int count, false, id, isWavehouse);
var titleData = new List<string>()
{
"仓库名称"
......@@ -995,6 +995,7 @@ namespace Siger.ApiWMS.Controllers
}
var ids = new List<int>();
var delIds = new List<int>();
var parentid = 0;
foreach (var locationType in sonLocationTypes)
{
......@@ -1028,7 +1029,7 @@ namespace Siger.ApiWMS.Controllers
status = req.status == (int)RowState.Valid ? (int)RowState.Valid : (int)RowState.Invalid,
locationid = Location.id == locationTypeId ? req.storeID.ToInt() : 0
};
parentid = InsertLocation(tmp, waveHouse.name);
parentid = InsertLocation(tmp, waveHouse.name, delIds);
if (parentid > 0)
{
ids.Add(parentid);
......@@ -1043,7 +1044,7 @@ namespace Siger.ApiWMS.Controllers
{
tmp.status = req.status == (int)RowState.Valid ? (int)RowState.Valid : (int)RowState.Invalid;
tmp.locationid = Location.id == locationTypeId ? req.storeID.ToInt() : 0;
parentid = InsertLocation(tmp, waveHouse.name);
parentid = InsertLocation(tmp, waveHouse.name, delIds);
if (parentid > 0)
{
continue;
......@@ -1056,7 +1057,7 @@ namespace Siger.ApiWMS.Controllers
}
return new ObjectResult(CommonEnum.Succefull);
}
private int InsertLocation(siger_wms_storage_location tmp, string waveHouseName)
private int InsertLocation(siger_wms_storage_location tmp, string waveHouseName, List<int> delIds)
{
int id = tmp.id;
if(id == 0)
......@@ -1066,6 +1067,10 @@ namespace Siger.ApiWMS.Controllers
{
return id;
}
else
{
delIds.Add(tmp.id);
}
}
//更新编号、层级名称
......@@ -1165,19 +1170,24 @@ namespace Siger.ApiWMS.Controllers
//}
}
var ids = new List<int>();//只有新增的数据才会加进这个列表,可以用于判断是否有新增数据
var ids = new List<int>();
var delIds = new List<int>();
var parentid = 0;
foreach (var locationType in sonLocationTypes)
{
var Location = req.storeArr.FirstOrDefault(q => q.id == locationType.id);
if (Location == null)
{
DelInsertFailLocations(delIds);
throw new BadRequestException(CommonEnum.Fail);
}
var tmp = location.Get(q => q.projectid == ProjectId && q.status == (int)RowState.Valid && q.realname == Location.val &&
q.typeid == locationType.id && q.parentid == parentid && q.storageid == req.warehouseid);
if (tmp != null && tmp.typeid == locationTypeId && !ids.Any() && tmp.name == Location.val && tmp.id != Location.locationid.ToInt())
var tmp1 = location.Get(q => q.projectid == ProjectId && q.status == (int)RowState.Valid && q.realname == Location.val &&
q.typeid == locationType.id && q.parentid == parentid && q.storageid == req.warehouseid && q.id != Location.locationid.ToInt());
var tmp = location.Get(q => q.projectid == ProjectId && q.status == (int)RowState.Valid && (q.realname != Location.val && q.typeid == locationType.id ||
q.realname == Location.val) && q.typeid == locationType.id && q.parentid == parentid && q.storageid == req.warehouseid && q.id == Location.locationid.ToInt());
if (tmp1 != null && tmp1.typeid == locationTypeId && !ids.Any() && tmp1.name == Location.val)
{
DelInsertFailLocations(delIds);
throw new BadRequestException(RequestEnum.DataExist);
}
if (tmp == null)
......@@ -1199,7 +1209,17 @@ namespace Siger.ApiWMS.Controllers
status = req.status == (int)RowState.Valid ? (int)RowState.Valid : (int)RowState.Invalid,
locationid = Location.id == locationTypeId ? req.storeID.ToInt() : 0
};
parentid = InsertLocation(tmp, waveHouse.name);
if (Location.id == locationTypeId)
{
var locationIdExist = location.Get(q => q.projectid == ProjectId && q.status == (int)RowState.Valid && q.typeid == locationTypeId &&
q.locationid == req.storeID.ToInt() && q.storageid == req.warehouseid);
if (locationIdExist != null)
{
DelInsertFailLocations(delIds);
throw new BadRequestException(RequestEnum.IDExist);
}
}
parentid = InsertLocation(tmp, waveHouse.name, delIds);
if (parentid > 0)
{
ids.Add(parentid);
......@@ -1207,26 +1227,66 @@ namespace Siger.ApiWMS.Controllers
}
else
{
DelInsertFailLocations(delIds);
throw new BadRequestException(CommonEnum.Fail);
}
}
else
{
if (Location.id == locationTypeId && !delIds.Any())//如果父级无新增,delIds无数据代表父级无新增
{
var locationIdExist = location.Get(q => q.projectid == ProjectId && q.status == (int)RowState.Valid && q.typeid == locationTypeId &&
q.locationid == req.storeID.ToInt() && q.id != Location.locationid.ToInt() && q.storageid == req.warehouseid);
if (locationIdExist != null)
{
DelInsertFailLocations(delIds);
throw new BadRequestException(RequestEnum.IDExist);
}
var locationIdExist1 = location.Get(q => q.projectid == ProjectId && q.status == (int)RowState.Valid && q.typeid == locationTypeId &&
q.realname == Location.val && q.id != Location.locationid.ToInt() && q.storageid == req.warehouseid);
if (locationIdExist1 != null)
{
DelInsertFailLocations(delIds);
throw new BadRequestException(RequestEnum.DataExist);
}
}
else if (Location.id == locationTypeId)//如果父级有新增
{
var locationIdExist = location.Get(q => q.projectid == ProjectId && q.status == (int)RowState.Valid && q.typeid == locationTypeId &&
q.locationid == req.storeID.ToInt() && q.id != Location.locationid.ToInt() && q.storageid == req.warehouseid);
if (locationIdExist != null)
{
DelInsertFailLocations(delIds);
throw new BadRequestException(RequestEnum.IDExist);
}
}
tmp.status = req.status == (int)RowState.Valid ? (int)RowState.Valid : (int)RowState.Invalid;
tmp.locationid = Location.id == locationTypeId ? req.storeID.ToInt() : 0;
parentid = InsertLocation(tmp, waveHouse.name);
tmp.realname = Location.val;
parentid = InsertLocation(tmp, waveHouse.name, delIds);
if (parentid > 0)
{
continue;
}
else
{
DelInsertFailLocations(delIds);
throw new BadRequestException(CommonEnum.Fail);
}
}
}
return new ObjectResult(CommonEnum.Succefull);
}
private void DelInsertFailLocations(List<int> DelIds)
{
foreach(var id in DelIds)
{
var entity = location.Get(q => q.projectid == ProjectId && q.status == (int)RowState.Valid && id == q.id);
entity.status = (int)RowState.Invalid;
location.Update(entity);
_unitOfWork.Commit();
}
}
private IEnumerable<siger_wms_storage_location_type> GetSonTypes(int id, List<siger_wms_storage_location_type> types)
{
var query = from c in types where c.parentid == id select c;
......
......@@ -49,5 +49,6 @@ namespace Siger.Middlelayer.AccRepository.Entities
public string productCode { get; set; }
public string productName { get; set; }
public int locationId { get; set; }
public int unixtime { get; set; }
}
}
......@@ -235,7 +235,8 @@ namespace Siger.Middlelayer.AccRepository.Repositories
ProductName = p.product_name,
Url = pd.image,
FixtureName = t.name,
FixtureGuid = t.code,
FixtureGuid = t.guid,
FixtureCode =t.code,
ProductCode = q != null ? q.productcode : "",
Location = l != null ? l.locationid : 0,
Sn=l.sn
......
......@@ -117,10 +117,11 @@ namespace Siger.Middlelayer.AccRepository.Repositories
return entities;
}
public ResponseProductFixtureInfo GetProductFixtureLocation(int projectId, string guid)
public ResponseProductFixtureInfo GetProductFixtureLocation(int projectId, string guid,int loactionId)
{
var query = from q in _context.siger_automation_fixture_tools
join l in _context.siger_automation_location on q.guid equals l.fixturetools
where q.projectId ==projectId && q.guid==guid && l.locationid==loactionId
select new ResponseProductFixtureInfo
{
FixtureGuid=q.guid,
......
......@@ -243,6 +243,10 @@ namespace Siger.Middlelayer.AccRepository.Repositories
join l in _context.siger_wms_storage_location on q.location_cid equals l.id
join w in _context.siger_wms_storage on l.storageid equals w.id
where q.projectId==projectId
&& q.status==(int)RowState.Valid
&& t.status==(int)RowState.Valid
&& l.status==(int)RowState.Valid
&& w.status==(int)RowState.Valid
select new ResponseAutomationLocationList
{
......
......@@ -14,7 +14,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories.Interface
IEnumerable<ResponseFixtureTools> GetDataList(List<int> categoryid, int projectid);
ResponseProductFixtureInfo GetProductFixtureLocation(int projectId, string guid);
ResponseProductFixtureInfo GetProductFixtureLocation(int projectId, string guid, int loactionId);
CommonImportResult ImportData(IEnumerable<FixtureToolsTemplate> list, int projectid, int userid);
}
......
......@@ -15,6 +15,10 @@ namespace Siger.Middlelayer.AccRepository.Request
/// 工装GUID
/// </summary>
public string guid { get; set; }
/// <summary>
/// 储位ID
/// </summary>
public int locationid { get; set; }
}
/// <summary>
......
......@@ -42,6 +42,7 @@ namespace Siger.Middlelayer.AccRepository.Response
public int status { get; set; }
public string FixtureName { get; set; }
public string FixtureGuid { get; set; }
public string FixtureCode { get; set; }
public int Location { get; set; }
public string Sn { get; set; }
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment