Commit ad0b828a by yiyu.li
parents 38f5f173 9f261137
...@@ -255,12 +255,6 @@ export default { ...@@ -255,12 +255,6 @@ export default {
filename: '',//文件名称 filename: '',//文件名称
fileurl:'',//文件路径 fileurl:'',//文件路径
UploadAction: this.axios.publicPath + "config/upload/UploadImage", UploadAction: this.axios.publicPath + "config/upload/UploadImage",
headers: {
token: localStorage.getItem("token"),
timestamp: localStorage.getItem("timestamp"),
nonce: localStorage.getItem("nonce"),
sign: localStorage.getItem("sign"),
},
spinShow:false, spinShow:false,
} }
}, },
......
...@@ -289,12 +289,6 @@ export default { ...@@ -289,12 +289,6 @@ export default {
filename: '',//文件名称 filename: '',//文件名称
fileurl:'',//文件路径 fileurl:'',//文件路径
UploadAction: this.axios.publicPath + "config/upload/UploadImage", UploadAction: this.axios.publicPath + "config/upload/UploadImage",
headers: {
token: localStorage.getItem("token"),
timestamp: localStorage.getItem("timestamp"),
nonce: localStorage.getItem("nonce"),
sign: localStorage.getItem("sign"),
},
spinShow:false, spinShow:false,
} }
}, },
......
...@@ -14,19 +14,12 @@ ...@@ -14,19 +14,12 @@
</div> </div>
<div class="filter"> <div class="filter">
<label>{{ $t(5500316) }}</label> <label>{{ $t(5500316) }}</label>
<Select v-model="storageid" label-in-value clearable filterable filter-by-label class="searchSelect"> <Cascader class="searchSelect" :data="storageTree" clearable change-on-select @on-change="changeStorage"></Cascader>
<Option
v-for="(item,index) in storageList"
:value="item.id"
:key="index"
:label="item.name"
>{{ item.name }}</Option>
</Select>
</div> </div>
<div class="searchBtn"> <div class="searchBtn">
<Button type="primary" class="twoWord" icon="ios-search" @click="tosearch()">{{ $t(1001) }}</Button> <Button type="primary" class="twoWord" icon="ios-search" @click="tosearch()">{{ $t(1001) }}</Button>
<Button type="success" class="twoWord" icon="md-add-circle" @click="add()">{{$t('1002')}}</Button> <Button type="success" class="twoWord" icon="md-add-circle" @click="add()">{{$t('1002')}}</Button>
<!-- <Button type="warning" class="twoWord" icon="ios-create-outline" @click="edit()">{{$t('1003')}}</Button> <Button type="warning" class="twoWord" icon="ios-create-outline" @click="edit()">{{$t('1003')}}</Button>
<Button type="error" class="twoWord intervalRight" icon="md-close-circle" @click="dele()">{{ $t(1004) }}</Button> <Button type="error" class="twoWord intervalRight" icon="md-close-circle" @click="dele()">{{ $t(1004) }}</Button>
<Button type="primary" class="fourWord" icon="md-download" @click="loadexcel()">{{$t('1005')}}</Button> <Button type="primary" class="fourWord" icon="md-download" @click="loadexcel()">{{$t('1005')}}</Button>
<Upload <Upload
...@@ -47,7 +40,7 @@ ...@@ -47,7 +40,7 @@
icon="md-cloud-upload" icon="md-cloud-upload"
>{{$t('1006')}}</Button> >{{$t('1006')}}</Button>
</Upload> </Upload>
<Button type="primary" class="fourWord" icon="ios-cloud-download" @click="Export()">{{$t('1007')}}</Button> --> <Button type="primary" class="fourWord" icon="ios-cloud-download" @click="search(1)">{{$t('1007')}}</Button>
</div> </div>
</div> </div>
<div class="divborder newTableDiv"> <div class="divborder newTableDiv">
...@@ -96,16 +89,8 @@ ...@@ -96,16 +89,8 @@
</div> </div>
<div class="filter"> <div class="filter">
<label><i>*</i>{{ $t(5500316) }}</label> <label><i>*</i>{{ $t(5500316) }}</label>
<Select v-model="addstorageid" label-in-value clearable filterable filter-by-label class="searchSelect"> <Cascader class="searchSelect" :data="addstorageTree" v-model="addstorageList" clearable change-on-select @on-change="changeStorage1"></Cascader>
<Option
v-for="(item,index) in storageList1"
:value="item.id"
:key="index"
:label="item.name"
>{{ item.name }}</Option>
</Select>
</div> </div>
<div class="filter"> <div class="filter">
<label><i>*</i>工装类型:</label> <label><i>*</i>工装类型:</label>
<Cascader class="searchSelect" :data="frockTypeTree" v-model="parentType" change-on-select @on-change="changeFrockType1"></Cascader> <Cascader class="searchSelect" :data="frockTypeTree" v-model="parentType" change-on-select @on-change="changeFrockType1"></Cascader>
...@@ -161,7 +146,7 @@ export default { ...@@ -161,7 +146,7 @@ export default {
whdata:[],//仓库列表 whdata:[],//仓库列表
warehouseid:"",//仓库id warehouseid:"",//仓库id
//储位 //储位
storageList:[], storageTree:[],
storageid:"",//储位id storageid:"",//储位id
//列表 //列表
...@@ -183,47 +168,61 @@ export default { ...@@ -183,47 +168,61 @@ export default {
}, },
{ {
title:'仓库名称', title:'仓库名称',
key:'warehouse_name' key:'wavehouse'
}, },
{ {
title:'储位信息', title:'储位信息',
key:'storage_info' key:'location'
}, },
{ {
title:'储位ID', title:'储位ID',
key:'storage_id' key:'locationid'
}, },
{ {
title:'工装类别', title:'工装类别',
key:'frock_type' key:'category'
}, },
{ {
title:'工装编号', title:'工装编号',
key:'frock_code' key:'code'
}, },
{ {
title:'工装名称', title:'工装名称',
key:'frock_name' key:'fixturetool'
}, },
{ {
title:'工装规格', title:'工装规格',
key:'frock_spec' key:'specfication'
}, },
{ {
title:'工件编号', title:'工件编号',
key:'workpiece_code' key:'sn'
}, },
{ {
title:'工序顺序', title:'工序顺序',
key:'process_seq' key:'routenumber'
}, },
{ {
title:'工序名称', title:'工序名称',
key:'process_name' key:'route'
}, },
{ {
title:'物料状态', title:'物料状态',
key:'material_status' key:'materialstate',
render:(h,params)=>{
let str = '';
//materialstate:1:有工装无工件2:有工装有工件3:无工装无工件4:无工装有工件
if(params.row.materialstate===1){
str = '有工装无工件';
}else if(params.row.materialstate===2){
str = '有工装有工件';
}else if(params.row.materialstate===2){
str = '无工装无工件';
}else if(params.row.materialstate===2){
str = '无工装有工件';
}
return h('span',str);
}
}, },
{ {
title:'备注', title:'备注',
...@@ -231,15 +230,32 @@ export default { ...@@ -231,15 +230,32 @@ export default {
}, },
{ {
title:'附件', title:'附件',
key:'file_url' key:'filename',
render:(h,params)=>{
return h('span',{
style:{
color:'#2b85e4',
cursor:'pointer'
},
on:{
click:()=>{
let name = params.row.filename;
let url = params.row.fileurl;
if(url){
this.downFile(url,name);
}
}
}
},params.row.filename);
}
}, },
{ {
title:'维护人', title:'维护人',
key:'user' key:'updator'
}, },
{ {
title:'维护时间', title:'维护时间',
key:'datetime' key:'updatetime'
} }
], ],
...@@ -247,8 +263,11 @@ export default { ...@@ -247,8 +263,11 @@ export default {
addmodal:false, //添加弹窗 addmodal:false, //添加弹窗
addwarehouseid:'',//仓库id addwarehouseid:'',//仓库id
type:1, type:1,
storageList1:[],//储位列表 addstorageTree:[],//储位列表
addstorageList:[],
addstorageid:'',//储位id addstorageid:'',//储位id
storagelevelnum:0,//储位层级数
frockTypeTree:[],//工装类型 frockTypeTree:[],//工装类型
parentType:[], parentType:[],
addfrockList:[],//工装列表 addfrockList:[],//工装列表
...@@ -256,6 +275,7 @@ export default { ...@@ -256,6 +275,7 @@ export default {
addremark:'',//备注 addremark:'',//备注
filename:'', filename:'',
fileurl:'', fileurl:'',
action: this.axios.publicPath + "wms/Upload/Submit?templateName=StorageLocation",
UploadAction: this.axios.publicPath + "config/upload/UploadImage", UploadAction: this.axios.publicPath + "config/upload/UploadImage",
headers: { headers: {
token: localStorage.getItem("token"), token: localStorage.getItem("token"),
...@@ -270,9 +290,11 @@ export default { ...@@ -270,9 +290,11 @@ export default {
created(){ created(){
this.initWarehouse();//仓库 this.initWarehouse();//仓库
this.initStorage(); this.initStorage();
this.tosearch();
this.tableColumns1 = this.$time.initTableTitle(this.tableColumns1); this.tableColumns1 = this.$time.initTableTitle(this.tableColumns1);
}, },
methods:{ methods:{
/*************搜索 start************ */
//仓库下拉框 //仓库下拉框
initWarehouse(){ initWarehouse(){
let params = { let params = {
...@@ -305,60 +327,112 @@ export default { ...@@ -305,60 +327,112 @@ export default {
this.initStorage(); this.initStorage();
} }
}, },
changeWarehouse1(value){
this.storageList1 = [];
this.addstorageid = "";
if(value != undefined){
this.addwarehouseid = value.value;
this.addinitStorage();
}
},
//储位 //储位
initStorage(){ initStorage(){
let params = { let params = {
page: 1, warehouseid: this.warehouseid,
pageSize: 1000000,
id: this.warehouseid, // 仓库id
isWarehouse: 1,
}; };
this.axios.request({ this.axios.request({
url: "/wms/Location/GetLocationList", url: "/wms/Location/GetLocationTree",
params, params,
method: "get", method: "get",
}) })
.then( .then((res) => {
(res) => { if (res.data.ret == 1) {
this.storageList = []; let arr = res.data.data;
let data = res.data.data; this.contentTree(arr);
if (res.data.ret == 1 &&Array.isArray(data)&&data.length) { this.storageTree = arr;
this.storageList = res.data.data; }
});
},
contentTree (arr) {
arr.forEach(ele => {
ele.disabled = false;
ele.value = ele.id;
ele.label = ele.name;
if (
ele.children != undefined &&
ele.children != null &&
ele.children.length != 0
) {
this.contentTree(ele.children);
}else{
ele.children = []
}
});
},
//切换储位
changeStorage(){
this.storageid = "";
if(value != undefined && value.length){
this.storageid = value[value.length - 1];
} }
},
/*************搜索 end************ */
/***************弹窗 start***************** */
//弹窗-切换仓库
changeWarehouse1(value){
this.addstorageTree = [];
this.addstorageid = "";
if(value != undefined){
this.addwarehouseid = value.value;
this.addinitStorage();
} }
);
}, },
//弹窗-获取储位
addinitStorage(){ addinitStorage(){
let params = { let params = {
page: 1, warehouseid: this.addwarehouseid,
pageSize: 1000000,
id: this.addwarehouseid, // 仓库id
isWarehouse: 1,
}; };
this.axios.request({ this.axios.request({
url: "/wms/Location/GetLocationList", url: "/wms/Location/GetLocationTree",
params, params,
method: "get", method: "get",
}) })
.then( .then((res) => {
(res) => { if (res.data.ret == 1) {
this.storageList1 = []; let arr = res.data.data;
let data = res.data.data; this.contentTree1(arr);
if (res.data.ret == 1 &&Array.isArray(data)&&data.length) { this.addstorageTree = arr;
this.storageList1 = res.data.data; }
});
},
contentTree1 (arr) {
let max = 0;
function eachfun(arr,floor){
arr.forEach(ele => {
ele.disabled = false;
ele.value = ele.id;
ele.label = ele.name;
if (floor > max) {
max = floor;
} }
if (
ele.children != undefined &&
ele.children != null &&
ele.children.length != 0
) {
eachfun(ele.children,floor+1);
}else{
ele.children = []
}
});
}
eachfun(arr, 1);
this.storagelevelnum = max;
return arr;
},
//弹窗-切换储位
changeStorage1(value){
this.addstorageid = "";
if(Array.isArray(value)&&value.length == this.storagelevelnum){
this.addstorageid = value[value.length - 1];
}
else{
this.addstorageList = [];
} }
);
}, },
//工装类型 //弹窗-工装类型
initFrockType(){ initFrockType(){
this.axios.request({ this.axios.request({
url: "/acc/FixtureTools/GetCategoryList", url: "/acc/FixtureTools/GetCategoryList",
...@@ -367,12 +441,12 @@ export default { ...@@ -367,12 +441,12 @@ export default {
.then((res) => { .then((res) => {
if (res.data.ret == 1) { if (res.data.ret == 1) {
let arr = res.data.data; let arr = res.data.data;
this.contentTree(arr); this.contentTree2(arr);
this.frockTypeTree = arr; this.frockTypeTree = arr;
} }
}); });
}, },
contentTree (arr) { contentTree2(arr) {
arr.forEach(ele => { arr.forEach(ele => {
ele.disabled = false; ele.disabled = false;
if ( if (
...@@ -380,21 +454,23 @@ export default { ...@@ -380,21 +454,23 @@ export default {
ele.children != null && ele.children != null &&
ele.children.length != 0 ele.children.length != 0
) { ) {
this.contentTree(ele.children); this.contentTree2(ele.children);
}else{ }else{
ele.children = [] ele.children = []
} }
}); });
}, },
//弹窗-工装类型变更
changeFrockType1(value){ changeFrockType1(value){
this.parentTypeid = ""; this.parentTypeid = "";//工装类型清空
this.parentType = []; this.addfrockList = [];//工装清空
this.addfrockid = '';//工装id清空
if(value!=undefined && value.length){ if(value!=undefined && value.length){
this.parentTypeid = value[value.length - 1]; this.parentTypeid = value[value.length - 1];
this.parentType = value;
this.getFrocksChange(); this.getFrocksChange();
} }
}, },
//弹窗-获取工装
getFrocksChange(){ getFrocksChange(){
this.addfrockid = ''; this.addfrockid = '';
let params = { let params = {
...@@ -419,6 +495,7 @@ export default { ...@@ -419,6 +495,7 @@ export default {
} }
}); });
}, },
/***************弹窗 end***************** */
tosearch(){ tosearch(){
this.page = 1; this.page = 1;
this.pagesize = 10; this.pagesize = 10;
...@@ -460,17 +537,175 @@ export default { ...@@ -460,17 +537,175 @@ export default {
}, },
add(){ add(){
this.type = 1; this.type = 1;
this.addwarehouseid = '';//仓库id
this.addstorageTree = [];
this.addstorageList = [];
this.addstorageid = '';//储位id
this.initFrockType();//工装类型 this.initFrockType();//工装类型
this.addstorageid = '';//仓库id
this.parentType = [];//工装类型 this.parentType = [];//工装类型
this.parentTypeid = '';//工装类型id this.parentTypeid = '';//工装类型id
this.addfrockid = '';//工装id this.addfrockid = '';//工装id
this.addremark = '';//备注 this.addremark = '';//备注
this.filename = ''; this.filename = '';
this.fileurl = ''; this.fileurl = '';
this.addmodal = true; this.addmodal = true;
}, },
//编辑
edit(){
if(!this.detailobj || !this.detailobj.id){
this.$Message.error(this.$t('1017'));
return false;
}
this.type = 2;
this.addwarehouseid = this.detailobj.wavehouseid;//仓库id
//获取储位
this.addinitStorage();
this.addstorageList = this.detailobj.locationIds;
this.addstorageid = this.detailobj.locationid;
//获取工装类型
this.initFrockType();//工装类型
this.parentType = this.detailobj.categoryIds;//工装类型
let categoryIds = this.detailobj.categoryIds;
if(Array.isArray(categoryIds)&& categoryIds.length){
this.parentTypeid = categoryIds[categoryIds.length -1];
this.getFrocksChange();
}
this.addfrockid = this.detailobj.fixturetoolid;//工装id
this.addremark = this.detailobj.remark?this.detailobj.remark:'';//备注
this.filename = this.detailobj.filename;
this.fileurl = this.detailobj.fileurl;
this.addmodal = true;
},
addPost(){
if(!this.addstorageid){
this.$Message.error("储位信息不能为空");
return false;
}
if(!this.addfrockid){
this.$Message.error("工装名称不能为空");
return false;
}
let url = '';
let id = '';
if(this.type === 1){
url = '/acc/AutomationLocation/Add';
id = 0;
}
else{
url = '/acc/AutomationLocation/Update';
id = this.detailobj.id;
}
let data = {
id:id,
locationid:this.addstorageid,//储位ID,前端填写的那个
fixturetoolid:this.addfrockid,//工装ID
fileurl:this.fileurl,//url
filename:this.filename,//附件名称
remark:this.addremark//备注
}
this.axios.request({
url: url,
data,
method: "post",
}).then((res) => {
if (res.data.ret == 1) {
this.addmodal = false;
if(this.type===1){
this.tosearch();
this.$Message.success(this.$t('1055'));
}
else{
this.$Message.success(this.$t('1060'));
this.search(0);
}
} else {
this.$Message.error(this.$t(res.data.msg+''));
}
});
},
//删除
dele(){
if (
this.detailobj.id === undefined ||
this.detailobj.id === null
) {
this.$Message.error(this.$t("1017"));
return false;
} else {
var params = {
id: this.detailobj.id,
};
this.$Modal.confirm({
title: this.$t("1018"),
content: "",
width: "290px",
closable: true,
okText: this.$t("1004"),
onOk: () => {
this.axios.request({
url: "/acc/AutomationLocation/Delete",
params,
method: "get",
})
.then((res) => {
if (res.data.ret === 1) {
this.$Message.success(this.$t("1058"));
this.search(0);
} else {
this.$Message.error(this.$t(res.data.msg));
}
});
},
});
}
},
//导出模板
loadexcel() {
// this.axios.request({
// url: "/config/Download/GetTemplate?name=StorageLocation",
// method: "get",
// })
// .then((res) => {
// if (res.data.ret === 1) {
// window.location.href =
// this.axios.publicPath + "" + res.data.data;
// } else {
// this.$Message.error(this.$t(res.data.msg));
// }
// });
},
/*********文件上传 start******** */ /*********文件上传 start******** */
//下载文件
downFile(url,fileName){
let params = {
url: url,
name:fileName
};
this.axios.request({
url: "/config/Download/DownloadFileByUrl",
params,
method: "get",
responseType: "blob"
})
.then((res) => {
if (res.status == 200) {
let url;
let link = document.createElement("a");
url = window.URL.createObjectURL(res.data);
link.style.display = "none";
link.href = url;
link.setAttribute("download", fileName);
document.body.appendChild(link);
link.click();
}
}).catch(error=>{
this.$Message.error('请求错误')
});
},
handleBeforeUpload(file){ handleBeforeUpload(file){
this.spinShow = true; this.spinShow = true;
if(!file){ if(!file){
...@@ -509,6 +744,26 @@ export default { ...@@ -509,6 +744,26 @@ export default {
this.page = value; this.page = value;
this.search(0); this.search(0);
}, },
handleFormatError(file) {
this.$Message.error(
this.$t("950396") + file.name + this.$t("950397")
);
},
handleSuccess(res, file) {
if (res.ret == 1) {
this.$Message.success(this.$t("950398"));
this.tosearch();
} else {
if ((res.msg + "").indexOf(",") != -1) {
inittip(res.msg);
} else {
this.$Message.error(this.$t(res.data));
}
}
},
handleError() {
this.$Message.error(this.$t("2010006") + "!");
},
} }
} }
</script> </script>
......
...@@ -44,7 +44,8 @@ namespace Siger.ApiACC.Controllers ...@@ -44,7 +44,8 @@ namespace Siger.ApiACC.Controllers
var data = _autoLocationRepository.GetPagedList(wavehouseid.ToInt(), locationid.ToInt(), ProjectId, page, pagesize); var data = _autoLocationRepository.GetPagedList(wavehouseid.ToInt(), locationid.ToInt(), ProjectId, page, pagesize);
var list = new List<ResponseAutomationLocation>(); var list = new List<ResponseAutomationLocation>();
var locations = _autoLocationRepository.GetLocationList(ProjectId); var locations = _autoLocationRepository.GetLocationList(ProjectId);
foreach(var item in data.Data) var categorys = _toolsCategoryRepository.GetList(q => q.projectId == ProjectId && q.status == (int)RowState.Valid).ToList();
foreach (var item in data.Data)
{ {
if(item.fixturetoolid > 0 && string.IsNullOrEmpty(item.sn)) if(item.fixturetoolid > 0 && string.IsNullOrEmpty(item.sn))
{ {
...@@ -68,11 +69,26 @@ namespace Siger.ApiACC.Controllers ...@@ -68,11 +69,26 @@ namespace Siger.ApiACC.Controllers
{ {
var locas = GetParentLocations(loca.id, locations); var locas = GetParentLocations(loca.id, locations);
var locationIds = locas.Select(q => q.id).ToList(); var locationIds = locas.Select(q => q.id).ToList();
locationIds.Distinct().Reverse(); locationIds = locationIds.Distinct().ToList();
locationIds.Reverse();
item.locationIds = locationIds; item.locationIds = locationIds;
} }
var cates = GetParentCategoryList(item.cate_guid, categorys);
var cateIds = cates.Select(q => q.id).ToList();
cateIds.Reverse();
item.categoryIds = cateIds;
list.Add(item);
}
return new PagedObjectResult(list, data.Total, page, pagesize);
} }
return new PagedObjectResult(data.Data, data.Total, page, pagesize);
private IEnumerable<siger_automation_fixture_tools_category> GetParentCategoryList(string parentId, List<siger_automation_fixture_tools_category> sections)
{
var query = from c in sections where c.guid == parentId select c;
return query.ToList().Concat(query.ToList().SelectMany(t => GetParentCategoryList(t.parent, sections)));
} }
private IEnumerable<siger_wms_storage_location> GetParentLocations(int pid, IEnumerable<siger_wms_storage_location> types) private IEnumerable<siger_wms_storage_location> GetParentLocations(int pid, IEnumerable<siger_wms_storage_location> types)
......
...@@ -183,19 +183,33 @@ namespace Siger.ApiACC.Controllers ...@@ -183,19 +183,33 @@ namespace Siger.ApiACC.Controllers
{ {
throw new BadRequestException(CommonEnum.RecordNotFound); throw new BadRequestException(CommonEnum.RecordNotFound);
} }
var machineStatus = _automationMachineStatus.Get(f => f.machineid==machineAttr.machine); var machineStatus = _automationMachineStatus.Get(f => f.machineid == machineAttr.machine);
if (machineStatus==null) if (machineStatus == null)
{ {
throw new BadRequestException(CommonEnum.RecordNotFound); // throw new BadRequestException(CommonEnum.RecordNotFound);
//上料设备状态与PLC 无关,
//需要手动插入
_automationMachineStatus.Insert(new siger_automation_machine_status
{
enable = 1,
section = loading.section,
machineid = machineAttr.machine,
projectId = ProjectId,
status = (int)Automation.MachineStatus.Produce,
updatetime = DateTime.Now
});
} }
if (machineStatus.enable==0) else
{
if (machineStatus.enable == 0)
{ {
throw new BadRequestException(AccEnum.MachineDisable); throw new BadRequestException(AccEnum.MachineDisable);
} }
if(machineStatus.status!=(int)Automation.MachineStatus.Waiting) if (machineStatus.status != (int)Automation.MachineStatus.Waiting)
{ {
throw new BadRequestException(AccEnum.MachineBusy); throw new BadRequestException(AccEnum.MachineBusy);
} }
}
if (!_automationTaskList.CanTask(ProjectId,loading.section)) if (!_automationTaskList.CanTask(ProjectId,loading.section))
{ {
throw new BadRequestException(AccEnum.TaskProcessing); throw new BadRequestException(AccEnum.TaskProcessing);
......
...@@ -53,7 +53,7 @@ namespace Siger.ApiACC.Controllers ...@@ -53,7 +53,7 @@ namespace Siger.ApiACC.Controllers
list.Add(item); list.Add(item);
} }
return new PagedObjectResult(data.Data, data.Total, page, pagesize); return new PagedObjectResult(list, data.Total, page, pagesize);
} }
private IEnumerable<siger_automation_fixture_tools_category> GetParentCategoryList(string parentId, List<siger_automation_fixture_tools_category> sections) private IEnumerable<siger_automation_fixture_tools_category> GetParentCategoryList(string parentId, List<siger_automation_fixture_tools_category> sections)
...@@ -78,30 +78,49 @@ namespace Siger.ApiACC.Controllers ...@@ -78,30 +78,49 @@ namespace Siger.ApiACC.Controllers
{ {
throw new BadRequestException(RequestEnum.ParameterMiss); throw new BadRequestException(RequestEnum.ParameterMiss);
} }
if(!string.IsNullOrEmpty(req.parentid) && !string.IsNullOrEmpty(req.fixturetoolid) && if(req.parentid == req.fixturetoolid)
req.parentid == req.fixturetoolid)
{ {
throw new BadRequestException(RequestEnum.ParentSonSame); throw new BadRequestException(RequestEnum.ParentSonSame);
} }
var parent = _toolsRepository.Get(q => q.id == req.parentid.ToInt() && q.projectId == ProjectId); var parent = _toolsRepository.Get(q => q.id == req.parentid.ToInt() && q.projectId == ProjectId);
if (parent == null)
{
throw new BadRequestException(RequestEnum.FixtureToolNotFound);
}
var son = _toolsRepository.Get(q => q.id == req.fixturetoolid.ToInt() && q.projectId == ProjectId); var son = _toolsRepository.Get(q => q.id == req.fixturetoolid.ToInt() && q.projectId == ProjectId);
if (son == null) if (son == null)
{ {
throw new BadRequestException(RequestEnum.FixtureToolNotFound); throw new BadRequestException(RequestEnum.FixtureToolNotFound);
} }
var parentGuid = parent?.guid ?? ""; var parentGuid = parent.guid;
var exsit = _toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.son == son.guid && q.parent == parentGuid); var exsit = _toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.son == son.guid && q.parent == parentGuid);
if (exsit != null) if (exsit != null)
{ {
throw new BadRequestException(RequestEnum.DataExist); throw new BadRequestException(RequestEnum.DataExist);
} }
if (!string.IsNullOrEmpty(parentGuid))
{
var parentExsit = _toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.son == parentGuid); var parentExsit = _toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.son == parentGuid);
if(parentExsit != null) if(parentExsit != null)
{ {
throw new BadRequestException(RequestEnum.LevelCountError); throw new BadRequestException(RequestEnum.LevelCountError);
} }
if (_toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.son == parentGuid) == null)
{
var parentEntity = new siger_automation_fixture_tools_assembly
{
guid = Guid.NewGuid().ToString(),
parent = "",
son = parent.guid,
creator = UserId,
createtime = DateTime.Now,
attachment = req.fileurl,
filename = req.filename,
projectId = ProjectId,
updatetime = DateTime.Now,
updator = UserId,
status = req.status.ToInt() == (int)RowState.Valid ? (int)RowState.Valid : (int)RowState.Invalid,
};
_toolsAssemblyRepository.Insert(parentEntity);
} }
var entity = new siger_automation_fixture_tools_assembly var entity = new siger_automation_fixture_tools_assembly
...@@ -147,25 +166,45 @@ namespace Siger.ApiACC.Controllers ...@@ -147,25 +166,45 @@ namespace Siger.ApiACC.Controllers
throw new BadRequestException(CommonEnum.RecordNotFound); throw new BadRequestException(CommonEnum.RecordNotFound);
} }
var parent = _toolsRepository.Get(q => q.id == req.parentid.ToInt() && q.projectId == ProjectId); var parent = _toolsRepository.Get(q => q.id == req.parentid.ToInt() && q.projectId == ProjectId);
if (parent == null)
{
throw new BadRequestException(RequestEnum.FixtureToolNotFound);
}
var son = _toolsRepository.Get(q => q.id == req.fixturetoolid.ToInt() && q.projectId == ProjectId); var son = _toolsRepository.Get(q => q.id == req.fixturetoolid.ToInt() && q.projectId == ProjectId);
if (son == null) if (son == null)
{ {
throw new BadRequestException(RequestEnum.FixtureToolNotFound); throw new BadRequestException(RequestEnum.FixtureToolNotFound);
} }
var parentGuid = parent?.guid ?? ""; var parentGuid = parent.guid;
var exsit = _toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.son == son.guid && q.parent == parentGuid && var exsit = _toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.son == son.guid && q.parent == parentGuid &&
q.id != req.id); q.id != req.id);
if (exsit != null) if (exsit != null)
{ {
throw new BadRequestException(RequestEnum.DataExist); throw new BadRequestException(RequestEnum.DataExist);
} }
if (!string.IsNullOrEmpty(parentGuid))
{
var parentExsit = _toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.son == parentGuid); var parentExsit = _toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.son == parentGuid);
if (parentExsit != null) if (parentExsit != null)
{ {
throw new BadRequestException(RequestEnum.LevelCountError); throw new BadRequestException(RequestEnum.LevelCountError);
} }
if (_toolsAssemblyRepository.Get(q => q.projectId == ProjectId && q.son == parentGuid) == null)
{
var parentEntity = new siger_automation_fixture_tools_assembly
{
guid = Guid.NewGuid().ToString(),
parent = "",
son = parent.guid,
creator = UserId,
createtime = DateTime.Now,
attachment = req.fileurl,
filename = req.filename,
projectId = ProjectId,
updatetime = DateTime.Now,
updator = UserId,
status = req.status.ToInt() == (int)RowState.Valid ? (int)RowState.Valid : (int)RowState.Invalid,
};
_toolsAssemblyRepository.Insert(parentEntity);
} }
entity.parent = parent?.guid ?? ""; entity.parent = parent?.guid ?? "";
......
...@@ -36,10 +36,28 @@ namespace Siger.ApiACC.Controllers ...@@ -36,10 +36,28 @@ namespace Siger.ApiACC.Controllers
_productRepository = productRepository; _productRepository = productRepository;
} }
[HttpGet]
public IActionResult GetPageList(string category, string tool, string product, int page, int pagesize) public IActionResult GetPageList(string category, string tool, string product, int page, int pagesize)
{ {
var data = _toolsProductRepository.GetPagedList(category.ToInt(), tool.ToInt(), product.ToInt(), ProjectId, page, pagesize); var data = _toolsProductRepository.GetPagedList(category.ToInt(), tool.ToInt(), product.ToInt(), ProjectId, page, pagesize);
return new PagedObjectResult(data.Data, data.Total, page, pagesize); var categorys = _toolsCategoryRepository.GetList(q => q.projectId == ProjectId && q.status == (int)RowState.Valid).ToList();
var list = new List<ResponseAumationFixtureToolsProduct>();
foreach(var item in data.Data)
{
var cates = GetParentCategoryList(item.cate_guid, categorys);
var cateIds = cates.Select(q => q.id).ToList();
cateIds.Reverse();
item.categoryids = cateIds;
list.Add(item);
}
return new PagedObjectResult(list, data.Total, page, pagesize);
}
private IEnumerable<siger_automation_fixture_tools_category> GetParentCategoryList(string parentId, List<siger_automation_fixture_tools_category> sections)
{
var query = from c in sections where c.guid == parentId select c;
return query.ToList().Concat(query.ToList().SelectMany(t => GetParentCategoryList(t.parent, sections)));
} }
[HttpPost] [HttpPost]
......
...@@ -22,7 +22,6 @@ namespace Siger.Middlelayer.AccRepository.Entities ...@@ -22,7 +22,6 @@ namespace Siger.Middlelayer.AccRepository.Entities
/// 附件 /// 附件
/// </summary> /// </summary>
public string attachment { get; set; } public string attachment { get; set; }
public string fileurl { get; set; }
/// <summary> /// <summary>
/// 附件名称 /// 附件名称
/// </summary> /// </summary>
......
...@@ -16,6 +16,10 @@ namespace Siger.Middlelayer.AccRepository.Entities ...@@ -16,6 +16,10 @@ namespace Siger.Middlelayer.AccRepository.Entities
public string no { get; set; } public string no { get; set; }
/// <summary> /// <summary>
/// 工装GUID
/// </summary>
public string fixtureguid { get; set; }
/// <summary>
/// 工位ID /// 工位ID
/// </summary> /// </summary>
public int sectionid { get; set; } public int sectionid { get; set; }
...@@ -55,10 +59,7 @@ namespace Siger.Middlelayer.AccRepository.Entities ...@@ -55,10 +59,7 @@ namespace Siger.Middlelayer.AccRepository.Entities
/// 储位位置 /// 储位位置
/// </summary> /// </summary>
public int locationid { get; set; } public int locationid { get; set; }
/// <summary>
/// 工装GUID
/// </summary>
public string fixtureguid { get; set; }
/// <summary> /// <summary>
/// Task 执行动作类型 1 手动 2 自动 /// Task 执行动作类型 1 手动 2 自动
......
...@@ -26,7 +26,8 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -26,7 +26,8 @@ namespace Siger.Middlelayer.AccRepository.Repositories
var query = from q in _context.siger_automation_fixture_tools_assembly var query = from q in _context.siger_automation_fixture_tools_assembly
join t1 in _context.siger_automation_fixture_tools on q.parent equals t1.guid into tt1 join t1 in _context.siger_automation_fixture_tools on q.parent equals t1.guid into tt1
from t1 in tt1.DefaultIfEmpty() from t1 in tt1.DefaultIfEmpty()
join c1 in _context.siger_automation_fixture_tools_category on t1.category equals c1.guid join c1 in _context.siger_automation_fixture_tools_category on t1.category equals c1.guid into cc1
from c1 in cc1.DefaultIfEmpty()
join t2 in _context.siger_automation_fixture_tools on q.son equals t2.guid join t2 in _context.siger_automation_fixture_tools on q.son equals t2.guid
join c2 in _context.siger_automation_fixture_tools_category on t2.category equals c2.guid join c2 in _context.siger_automation_fixture_tools_category on t2.category equals c2.guid
join u in _context.siger_project_user on q.updator equals u.mid into uu join u in _context.siger_project_user on q.updator equals u.mid into uu
......
...@@ -61,7 +61,8 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -61,7 +61,8 @@ namespace Siger.Middlelayer.AccRepository.Repositories
filename = q.filename, filename = q.filename,
partnumber = t.partnumber, partnumber = t.partnumber,
specfication = t.specification, specfication = t.specification,
productcode = p.code productcode = p.code,
cate_guid = c.guid ?? ""
}; };
Expression<Func<ResponseAumationFixtureToolsProduct, bool>> categoryExpression = f => true; Expression<Func<ResponseAumationFixtureToolsProduct, bool>> categoryExpression = f => true;
if (category > 0) if (category > 0)
......
...@@ -56,7 +56,8 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -56,7 +56,8 @@ namespace Siger.Middlelayer.AccRepository.Repositories
updatetime = q.updatetime.HasValue && q.updatetime > DateTime.MinValue ? q.updatetime.Value.ToString(ParameterConstant.DateTimeFormat) : "", updatetime = q.updatetime.HasValue && q.updatetime > DateTime.MinValue ? q.updatetime.Value.ToString(ParameterConstant.DateTimeFormat) : "",
sn = m.sn ?? "", sn = m.sn ?? "",
route = r.name ?? "", route = r.name ?? "",
routenumber = r == null ? "" : r.serialNumber.ToString() routenumber = r == null ? "" : r.serialNumber.ToString(),
cate_guid = c.guid ?? ""
}; };
Expression<Func<ResponseAutomationLocation, bool>> wavehouseidExpression = f => true; Expression<Func<ResponseAutomationLocation, bool>> wavehouseidExpression = f => true;
if (wavehouseid > 0) if (wavehouseid > 0)
...@@ -97,6 +98,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -97,6 +98,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories
select new ResponseAutomationLocationList select new ResponseAutomationLocationList
{ {
id = q.id, id = q.id,
fixtureguid = t.guid,
locationid = l.locationid, locationid = l.locationid,
location = l.realname, location = l.realname,
locationcode = l.serial_number, locationcode = l.serial_number,
......
...@@ -111,6 +111,10 @@ namespace Siger.Middlelayer.AccRepository.Response ...@@ -111,6 +111,10 @@ namespace Siger.Middlelayer.AccRepository.Response
public string updatetime { get; set; } public string updatetime { get; set; }
public string fileurl { get; set; } public string fileurl { get; set; }
public string filename { get; set; } public string filename { get; set; }
public string cate_guid { get; set; }
public List<int> categoryids { get; set; } = new List<int>();
} }
public class ResponseAumationFixtureToolsAssembly public class ResponseAumationFixtureToolsAssembly
......
...@@ -50,6 +50,8 @@ namespace Siger.Middlelayer.AccRepository.Response ...@@ -50,6 +50,8 @@ namespace Siger.Middlelayer.AccRepository.Response
public int status { get; set; } public int status { get; set; }
public List<int> locationIds { get; set; } = new List<int>(); public List<int> locationIds { get; set; } = new List<int>();
public List<int> categoryIds { get; set; } = new List<int>();
public string cate_guid { get; set; }
} }
public class ResponseAutomationLocationList public class ResponseAutomationLocationList
...@@ -74,6 +76,7 @@ namespace Siger.Middlelayer.AccRepository.Response ...@@ -74,6 +76,7 @@ namespace Siger.Middlelayer.AccRepository.Response
/// 工装ID /// 工装ID
/// </summary> /// </summary>
public int fixturetoolid { get; set; } public int fixturetoolid { get; set; }
public string fixtureguid { get; set; }
public string code { get; set; } public string code { get; set; }
public string name { get; set; } public string name { get; set; }
public string materialsn { get; set; } public string materialsn { get; set; }
......
...@@ -324,17 +324,17 @@ CREATE TABLE IF NOT EXISTS `siger_automation_section_route` ( ...@@ -324,17 +324,17 @@ CREATE TABLE IF NOT EXISTS `siger_automation_section_route` (
CREATE TABLE IF NOT EXISTS `siger_automation_task_list` ( CREATE TABLE IF NOT EXISTS `siger_automation_task_list` (
`id` int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
`no` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, `no` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`fixtureguid` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, `fixtureguid` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '工装GUID',
`sectionid` int(11) NOT NULL DEFAULT 0 COMMENT '工位ID', `sectionid` int(11) NOT NULL DEFAULT 0 COMMENT '工位ID',
`trigger` int(1) NOT NULL DEFAULT 0 COMMENT '触发方', `trigger` int(1) NOT NULL DEFAULT 0 COMMENT '触发方',
`tasktype` int(1) NOT NULL DEFAULT 0 COMMENT '任务类型', `tasktype` int(1) NOT NULL DEFAULT 0 COMMENT '任务类型',
`materialid` int(11) NOT NULL DEFAULT 0 COMMENT '工件ID', `sn` int(11) NOT NULL DEFAULT 0 COMMENT '工件ID',
`ordercode` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '工单号', `ordercode` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '工单号',
`productid` int(11) NOT NULL DEFAULT 0 COMMENT '产品ID', `productid` int(11) NOT NULL DEFAULT 0 COMMENT '产品ID',
`productcode` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '产品CODE',
`processid` int(11) NOT NULL DEFAULT 0 COMMENT '工序ID', `processid` int(11) NOT NULL DEFAULT 0 COMMENT '工序ID',
`programnumber` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '程序号', `programnumber` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '程序号',
`locationid` int(11) NOT NULL COMMENT '储位位置', `locationid` int(11) NOT NULL COMMENT '储位位置',
`fixturetools` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '工装GUID',
`action` int(1) NOT NULL DEFAULT 0 COMMENT '动作', `action` int(1) NOT NULL DEFAULT 0 COMMENT '动作',
`actiontype` int(11) NOT NULL DEFAULT 0 COMMENT '动作类型', `actiontype` int(11) NOT NULL DEFAULT 0 COMMENT '动作类型',
`projectid` int(11) NOT NULL DEFAULT 0, `projectid` int(11) NOT NULL DEFAULT 0,
......
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