Commit 99679107 by yiyu.li
parents 4dde11b9 7de3387d
......@@ -620,7 +620,7 @@ export default {
getRoutesByProduct(val) {
// 选择产品查询工艺路径
let id = 0;
id = val.value?val.value:0;
id = val&&val.value?val.value:0;
var params = {
productId: id,
page: 1,
......
......@@ -256,7 +256,6 @@
</label>
<DatePicker
class="searchInput"
:disabled="type == 2 ? true : false"
v-model="addobj.deliverydate"
type="date"
></DatePicker>
......
......@@ -396,13 +396,12 @@ export default {
handleSuccess(res, file) {
if (res.ret == 1) {
this.$Message.success(this.$t("950398"));
this.getCategory();
this.search(1, 10);
this.tosearch();
} else {
if ((res.msg + "").indexOf(",") != -1) {
inittip(res.msg);
} else {
this.$Message.error(this.$t(res.data));
this.$Message.error(this.$t(res.msg));
}
}
},
......
......@@ -10,19 +10,23 @@ using Siger.Middlelayer.AccRepository.Response;
using Siger.ApiCommon.Result;
using Siger.Middlelayer.Common;
using Siger.Middlelayer.Share.Enum.ModuleEnum;
using Siger.Middlelayer.Repository;
using Siger.Middlelayer.Log;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace Siger.ApiACC.Controllers
{
public class AutomationStateController : BaseController
{
private readonly IUnitOfWork _unitOfWork;
private readonly ISigerProjectLevelSectionRepository _sigerProjectLevelSection;
private readonly IAutomationMachineStatus _automationMachineStatus;
private readonly IAutomationTaskListRepository _automationTaskList;
private readonly IAutomationFixtureMonitor _automationFixtureMonitor;
public AutomationStateController(ISigerProjectLevelSectionRepository sigerProjectLevelSection, IAutomationMachineStatus automationMachineStatus, IAutomationTaskListRepository automationTaskList, IAutomationFixtureMonitor automationFixtureMonitor)
public AutomationStateController(IUnitOfWork unitOfWork, ISigerProjectLevelSectionRepository sigerProjectLevelSection, IAutomationMachineStatus automationMachineStatus, IAutomationTaskListRepository automationTaskList, IAutomationFixtureMonitor automationFixtureMonitor)
{
_unitOfWork = unitOfWork;
_sigerProjectLevelSection = sigerProjectLevelSection;
_automationMachineStatus = automationMachineStatus;
_automationTaskList = automationTaskList;
......@@ -102,5 +106,24 @@ namespace Siger.ApiACC.Controllers
return new PagedObjectResult(resulst, resulst.Total, page, pageSize);
}
public IActionResult DeleteTask(int id)
{
var record = _automationTaskList.Get(f => f.id == id);
if (record == null)
{
throw new BadRequestException(CommonEnum.RecordNotFound);
}
_automationTaskList.Delete(record);
if (_unitOfWork.Commit() > 0)
{
Logger.WriteLineError($"手动任务创建成功-{Siger.Middlelayer.Common.Helpers.EnumHelper.GetEnumDesc(Automation.TaskAction.Step_LK_SXLW)}");
return new ObjectResult(CommonEnum.Succefull);
}
else
{
throw new BadRequestException(CommonEnum.Fail);
}
}
}
}
......@@ -320,16 +320,11 @@ namespace Siger.ApiACC.Controllers
private void CreateTaskList(int section, int productid, string productcode, string sn, int routeid)
{
if (section <= 0 || string.IsNullOrEmpty(sn) || string.IsNullOrEmpty(productcode) || productid <= 0)
var monitor = _fixtureMonitor.Get(f => f.section == section);
if (monitor==null)
{
return;
Logger.WriteLineInfo($"检验工站{section} monitor 为空");
}
var monitor = _fixtureMonitor.GetList(q => q.section == section && q.sn == sn).OrderByDescending(q => q.updatetime).FirstOrDefault();
if (monitor == null)
{
return;
}
var taskNo = _automationTaskList.CrateTaskNumber(Automation.TaskTrigerType.Manual);
_automationTaskList.Insert(new siger_automation_task_list
......@@ -357,6 +352,7 @@ namespace Siger.ApiACC.Controllers
programnumber = "",
remark = "质量检验",
});
monitor.taskno = taskNo;
_unitOfWork.Commit();
}
......
......@@ -64,8 +64,7 @@ namespace Siger.ApiACC.Controllers
[HttpGet]
public IActionResult GetSn(int sectionid)
{
var monitor = _fixtureMonitor.GetList(q => q.projectId == ProjectId && q.status == (int)RowState.Valid && q.section == sectionid).OrderByDescending(q => q.updatetime).
FirstOrDefault();
var monitor = _fixtureMonitor.Get(sectionid);
return new ObjectResult(monitor?.sn ?? "");
}
}
......
......@@ -50,11 +50,18 @@ namespace Siger.ApiACC.Tasks
if (attr == null)
return;
var fixtrue = dbhelper.GetFixture(task.fixtureguid);
if (fixtrue==null)
{
Logger.WriteLineError($"自动工装未找到");
return;
}
var sendToPLC = new RequestPLC
{
ProductCode=task.productcode,
LineID= levelsction.parentid,
RStation = attr.machine,
Fixture = task.fixtureguid,
Fixture = fixtrue.code,
RequestForm = task.no,
RobotStep = (int)task.action,
StorageNo = task.locationid,
......
......@@ -70,6 +70,10 @@ namespace Siger.ApiACC.Tasks
{
return AccDbContext.siger_project_machine_attribution.FirstOrDefault(f => f.station==section && f.status==1);
}
public siger_automation_fixture_tools GetFixture(string guid)
{
return AccDbContext.siger_automation_fixture_tools.FirstOrDefault(f => f.guid==guid && f.status == 1);
}
public void Dispose()
{
CncDbContext?.Dispose();
......
......@@ -16,6 +16,7 @@ using Siger.Middlelayer.Utility.Helpers;
using Siger.Middlelayer.Utility.ImportEntities;
using Siger.Middlelayer.WmsRepository.Entities;
using Siger.Middlelayer.WmsRepository.Repositories.Interface;
using Siger.Middlelayer.Common.Extensions;
namespace Siger.ApiWMS.Controllers
{
......@@ -116,10 +117,19 @@ namespace Siger.ApiWMS.Controllers
var locationTypes = _location_TypeRepository.GetList(q => q.projectid == ProjectId && q.status == (int)RowState.Valid).ToList();
if (!locationTypes.Any())
{
throw new BadRequestException(RequestEnum.LocationTypeNotFound);
return new CommonImportResult(0, string.Join(';', (int)RequestEnum.LocationTypeNotFound));
}
var sonLocationTypes = GetSonTypes(0, locationTypes).Select(q => new Tuple<int, string>(q.id, q.name)).ToList();
var checkResult = excelHelper.CheckExcel(sonLocationTypes);
if (checkResult.Any())
{
return new CommonImportResult(0, string.Join(';', checkResult));
}
var data = excelHelper.ConvertSheetToList(sonLocationTypes);
if (!data.Any())
{
return new CommonImportResult(0, string.Join(';', (int)CommonEnum.NoData));
}
var result = _locationRepository.ImportStorageLocations(data, ProjectId, UserId);
return result;
}
......
......@@ -148,5 +148,13 @@ namespace Siger.Middlelayer.Share.Enum.ModuleEnum
[Description("清洗机->加工中心")]
Step_QXJ_JGZX = 10,
}
public enum LocationStatus
{
[Description("在库内")]
In =1,
[Description("不在库内")]
Out =2
}
}
}
......@@ -6,6 +6,7 @@ using System.Reflection;
using System.Text.RegularExpressions;
using OfficeOpenXml;
using OfficeOpenXml.Style;
using Siger.Middlelayer.Common;
using Siger.Middlelayer.Utility.ExcelImport;
using Siger.Middlelayer.Utility.ImportEntities;
using ExcelColumn = Siger.Middlelayer.Utility.ExcelImport.ExcelColumn;
......@@ -117,6 +118,94 @@ namespace Siger.Middlelayer.Utility.Helpers
return collection;
}
public List<string> CheckExcel(List<Tuple<int, string>> locationTypes)
{
if (Sheet == null)
{
throw new ArgumentNullException(nameof(Sheet));
}
var messages = new List<string>();
var columns = new List<string> { "ID", "仓库名称" };
foreach (var item in locationTypes)
{
columns.Add(item.Item2);
}
var endRow = 2;
for (var row = 2; row <= Sheet.Dimension.Rows; row++)
{
var columnValues = new List<string>();
for (var i = 1; i <= columns.Count; i++)
{
var val = Sheet.Cells[row, i];
if (val != null)
{
columnValues.Add(val.Text);
}
}
if (columnValues.All(string.IsNullOrWhiteSpace))
{
endRow = row - 1;
break;
}
endRow = row;
}
IList<int> rows = new List<int>();
for (var i = 2; i <= endRow; i++)
{
rows.Add(i);
}
foreach (var row in rows)
{
var tnew = new ImportStorageLocations();
int i = 1;
foreach (var col in columns)
{
var cell = Sheet.Cells[row, i];
var val = cell == null ? "" : cell.Value?.ToString() ?? "";
if (i == 1)
{
if (string.IsNullOrEmpty(val))
{
messages.Add($"{row},{(int)RequestEnum.PleaseInputNotZeroIntID}");
return messages;
}
tnew.ID = val;
}
if (i == 2)
{
if (string.IsNullOrEmpty(val))
{
messages.Add($"{row},{(int)RequestEnum.PleaseInputStorageName}");
return messages;
}
tnew.StorageName = val;
}
if (i > 2)
{
var typeId = locationTypes.FirstOrDefault(q => q.Item2 == col);
if (string.IsNullOrEmpty(val))
{
messages.Add(typeId != null ? $"{row}, 请填写{typeId.Item2}" : $"{row}, {(int)RequestEnum.LocationImportFormatError}");
return messages;
}
tnew.Locations.Add(new LocationModels
{
LocationType = typeId == null ? 0 : typeId.Item1,
Location = val
});
}
i++;
}
}
return messages;
}
public void Dispose()
{
Sheet?.Dispose();
......
......@@ -167,5 +167,7 @@ namespace Siger.Middlelayer.AccRepository
public DbSet<siger_automation_produce_history> siger_automation_produce_history { get; set; }
public DbSet<siger_automation_fixture_tools_monitor> siger_automation_fixture_tools_moniter { get; set; }
public DbSet<siger_check_sn_trace_inspection> siger_check_sn_trace_inspection { get; set; }
}
}
......@@ -11,7 +11,7 @@ namespace Siger.Middlelayer.AccRepository.Entities
/// </summary>
public string fixtureguid { get; set; }
/// <summary>
/// 工装名称
/// 工装编号
/// </summary>
public string fixturename { get; set; }
/// <summary>
......@@ -50,5 +50,9 @@ namespace Siger.Middlelayer.AccRepository.Entities
public string productName { get; set; }
public int locationId { get; set; }
public int unixtime { get; set; }
/// <summary>
/// 当前任务
/// </summary>
public string taskno { get; set; }
}
}
......@@ -30,5 +30,10 @@ namespace Siger.Middlelayer.AccRepository.Entities
/// </summary>
public string program { get; set; }
/// <summary>
/// 1: 自动设备 0:上下料设备
/// </summary>
public int auto { get; set; }
}
}
......@@ -186,28 +186,34 @@ namespace Siger.Middlelayer.AccRepository.Repositories
if (string.IsNullOrEmpty(item.ParentFixtureTool))
{
errors.Add($"{rowIndex},{(int)RequestEnum.PleaseInputParentFixtureCode}");
return new CommonImportResult(0, string.Join(";", errors));
}
if (string.IsNullOrEmpty(item.FixtureTool))
{
errors.Add($"{rowIndex},{(int)RequestEnum.PleaseInputSonFixtureCode}");
return new CommonImportResult(0, string.Join(";", errors));
}
if (string.IsNullOrEmpty(item.Status))
{
errors.Add($"{rowIndex},{(int)RequestEnum.PleaseInputStatus}");
return new CommonImportResult(0, string.Join(";", errors));
}
if (item.ParentFixtureTool == item.FixtureTool)
{
errors.Add($"{rowIndex},{(int)RequestEnum.ParentSonSame}");
return new CommonImportResult(0, string.Join(";", errors));
}
var parent = _context.siger_automation_fixture_tools.FirstOrDefault(q => q.code == item.ParentFixtureTool && q.projectId == projectid);
if (parent == null)
{
errors.Add($"{rowIndex},{(int)RequestEnum.FixtureToolNotFound}");
return new CommonImportResult(0, string.Join(";", errors));
}
var son = _context.siger_automation_fixture_tools.FirstOrDefault(q => q.code == item.FixtureTool && q.projectId == projectid);
if (son == null)
{
errors.Add($"{rowIndex},{(int)RequestEnum.FixtureToolNotFound}");
return new CommonImportResult(0, string.Join(";", errors));
}
var parentGuid = parent.guid;
if(son != null && parent != null)
......@@ -216,16 +222,19 @@ namespace Siger.Middlelayer.AccRepository.Repositories
if (exsit != null)
{
errors.Add($"{rowIndex},{(int)RequestEnum.DataExist}");
return new CommonImportResult(0, string.Join(";", errors));
}
}
if (list.Count(q => q.FixtureTool == item.FixtureTool && q.ParentFixtureTool == item.ParentFixtureTool) > 1)
{
errors.Add($"{rowIndex},{(int)RequestEnum.DataExist}");
return new CommonImportResult(0, string.Join(";", errors));
}
var parentExsit = _context.siger_automation_fixture_tools_assembly.FirstOrDefault(q => q.projectId == projectid && q.son == parentGuid);
if (parentExsit != null && !string.IsNullOrEmpty(parentExsit.parent))
{
errors.Add($"{rowIndex},{(int)RequestEnum.LevelCountError}");
return new CommonImportResult(0, string.Join(";", errors));
}
if (errors.Any())
......
......@@ -121,7 +121,8 @@ namespace Siger.Middlelayer.AccRepository.Repositories
{
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
where q.projectId == projectId && q.guid == guid && l.locationid == loactionId
&& l.status == 1
select new ResponseProductFixtureInfo
{
FixtureGuid=q.guid,
......
......@@ -212,7 +212,8 @@ namespace Siger.Middlelayer.AccRepository.Repositories
var entity = new siger_automation_location
{
guid = Guid.NewGuid().ToString(),
locationid = location.id,
location_cid = location.id,
locationid = location.locationid,
fixturetools = fixturetool.guid,
attachment = "",
filename = "",
......
......@@ -29,7 +29,6 @@ namespace Siger.Middlelayer.AccRepository.Repositories
{
//已经下发,并且任务完成
var taskObjs = _context.siger_automation_task_list.Where(f => f.projectId == projectId && f.send==0 );
if (taskObjs.Any())
{
return false;
......@@ -90,7 +89,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories
}
public IPagedCollectionResult<ResponseAutomationTasklist> GetTasklistPagedList(List<int> sections, int taskType, string productCode, string TaskNo, string sn, int status, int actionType, string tiggertime, string comptime, int projectid, int page, int pagesize)
public IPagedCollectionResult<ResponseAutomationTasklist> GetTasklistPagedList(List<int> sections, int taskType, string productCode, string TaskNo, string sn, int status, int actionType, string tirbeigin, string triend, string compbegin, string compend, int projectid, int page, int pagesize)
{
var query = from q in _context.siger_automation_task_list
join t in _context.siger_automation_fixture_tools on q.fixtureguid equals t.guid
......@@ -120,7 +119,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories
productCode=q.productcode,
program=q.programnumber,
route=r!=null?$"{r.serialNumber}-{r.name}":"",
send=q.send,
tasktype=EnumHelper.GetEnumDesc(q.tasktype),
status=q.status,
......@@ -156,15 +155,15 @@ namespace Siger.Middlelayer.AccRepository.Repositories
actionTypeExpression = q => q.actionTypeid==actionType;
}
Expression<Func<ResponseAutomationTasklist, bool>> triggerTimeTypeExpression = f => true;
if (!string.IsNullOrEmpty(tiggertime))
if (!string.IsNullOrEmpty(triend) && !string.IsNullOrEmpty(tirbeigin))
{
triggerTimeTypeExpression = q => q.triggervalue == tiggertime.ToDateTime();
triggerTimeTypeExpression = q => q.triggervalue >= tirbeigin.ToDateTime() && q.triggervalue<=triend.ToDateTime();
}
Expression<Func<ResponseAutomationTasklist, bool>> comptimeExpression = f => true;
if (!string.IsNullOrEmpty(comptime))
if (!string.IsNullOrEmpty(compbegin) && !string.IsNullOrEmpty(compend))
{
comptimeExpression = q => q.complatevalue == comptime.ToDateTime();
comptimeExpression = q => q.complatevalue >= compbegin.ToDateTime() && q.complatevalue <= compend.ToDateTime();
}
var expression = sectonsExpression.And(taskTypeExpression).And(productCodeExpression).And(tasknoExpression).And(snExpression)
......
......@@ -26,6 +26,6 @@ namespace Siger.Middlelayer.AccRepository.Repositories.Interface
string CreateRandonSn(string productCode);
IPagedCollectionResult<ResponseAutomationTasklist> GetTasklistPagedList(List<int> sections, int taskType, string productCode, string TaskNo, string sn, int status, int actionType, string tiggertime, string comptime, int projectid, int page, int pagesize);
IPagedCollectionResult<ResponseAutomationTasklist> GetTasklistPagedList(List<int> sections, int taskType, string productCode, string TaskNo, string sn, int status, int actionType, string tirbeigin,string triend,string compbegin, string compend, int projectid, int page, int pagesize);
}
}
......@@ -9,7 +9,7 @@ namespace Siger.Middlelayer.AccRepository.Request
{
[Required(ErrorMessage = "guidNotNull")]
/// <summary>
/// 任务列表GUID
/// 任务列表taskNo
/// </summary>
public string guid { get; set; }
[Required(ErrorMessage = "status")]
......
......@@ -6,6 +6,7 @@ namespace Siger.Middlelayer.AccRepository.Request
{
public class RequestPLC
{
public string ProductCode { get; set; }
/// <summary>
/// 工件唯一识别SN
/// </summary>
......
......@@ -46,5 +46,6 @@ namespace Siger.Middlelayer.AccRepository.Response
public string triggerTime { get; set; }
public DateTime? complatevalue { get; set; }
public string complatetime { get; set; }
public int send { get; set; }
}
}
......@@ -375,6 +375,7 @@ CREATE TABLE `siger_automation_machine_status` (
`machineid` int NOT NULL DEFAULT '0' COMMENT '工位对应设备ID',
`projectid` int NOT NULL DEFAULT '0',
`enable` int NOT NULL DEFAULT '1' COMMENT '设备可用状态 0:不可用 1:可用',
`auto` int NOT NULL DEFAULT '1' COMMENT '设备可用状态 0:上下料设备 1:自动设备',
`status` int NOT NULL DEFAULT '1' COMMENT '完工状态 0:取消 1:待生产 2:生产中 3:生产完成 ',
`updatetime` datetime DEFAULT NULL COMMENT '操作时间',
`program` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '程序号',
......@@ -445,6 +446,8 @@ CREATE TABLE `siger_automation_fixture_tools_moniter` (
`productCode` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '产品CODE',
`productName` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '产品名称',
`locationId` int(11) NOT NULL DEFAULT 0,
`unixtime` int(1) NOT NULL DEFAULT 1 COMMENT 'task时间',
`taskno` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '当前任务单',
`status` int(1) NOT NULL DEFAULT 1 COMMENT '',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
......
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