Commit 1ed21e65 by xin.yang
parents 8127a445 73e7b9f0
<template> <template>
<div class="testdiv"> <div class="testdiv">
<div class="divborder newSearchDiv" style="margin:0px;"> <div class="divborder newSearchDiv" style="margin: 0px">
<div class="filter">
<label>{{$t('1132')}}</label>
<Cascader
:data="datalevel"
:value="leveldata"
trigger="click"
change-on-select
class="searchSelect"
@on-change="getlevel"
style="width:220px"
></Cascader>
</div>
<div class="filter">
<label>{{$t('100088')}}</label>
<Input class="searchSelect" type="text" v-model="productname" />
</div>
<div class="filter">
<label>{{$t('100090')}}</label>
<Input class="searchSelect" type="text" v-model="drawcode" />
</div>
<div class="searchBtn">
<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="warning" class="twoWord" icon="ios-build" @click="edit()">{{$t('1003')}}</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>
<Upload
style="display:inline-block"
ref="upload"
:action="action"
name="excel-file"
:headers="headers"
:show-upload-list="false"
:on-format-error="handleFormatError"
:on-success="handleSuccess"
:on-error="handleError"
:format="['xlsx']"
>
<Button type="primary" class="fourWord" icon="md-cloud-upload">{{$t('1006')}}</Button>
</Upload>
</div>
</div>
<div class="divborder newTableDiv">
<Table
class="tableClass"
@on-current-change="handleRowChange"
highlight-row
:data="tableData1"
@on-selection-change="handleSelectRow"
:columns="tableColumns1"
></Table>
<div class="pageDiv">
<div class="pageDirection">
<Page
:total="total"
:current="page"
@on-change="changePage"
show-elevator
show-sizer
show-total
@on-page-size-change="handlePageSize"
:page-size-opts="[10,20,30,40,100]"
></Page>
</div>
</div>
<Modal class="newModalClass" :title="$t('1002')" v-model="addmodal" :styles="{width:'700px'}">
<div class="modal_body" style="height:430px!important;">
<div style="width:280px;float:left;height:400px;overflow-y:scroll">
<template>
<Tree :data="treeContents" ref="tree" @on-select-change="getList()"></Tree>
</template>
</div>
<div style="width:360px;float:left;height:400px;padding-left:5px;">
<div class="filter">
<label>
<i>*</i>
{{this.$t('500107')}}:
</label>
<Input class="searchInput" type="text" v-model="addobj.program_number" />
</div>
<div class="filter">
<label>
<i>*</i>
{{this.$t('100088')}}:
</label>
<Select
v-model="addobj.product"
label-in-value
clearable
filterable
class="searchSelect"
>
<Option v-for="item in products" :value="item.id" :key="item.id">{{ item.name }}</Option>
</Select>
</div>
<div class="filter">
<label>
<i>*</i>
{{this.$t('900880')}}:
</label>
<Input class="searchInput" type="text" v-model="addobj.route_number" />
</div>
<div class="filter">
<label>
<i>*</i>
{{this.$t('900967')}}:
</label>
<Input class="searchInput" type="text" v-model="addobj.route_name" />
</div>
<div class="filter">
<label>
<i>*</i>
{{this.$t('500098')}}:
</label>
<InputNumber
:min="0"
class="searchInput"
type="number"
v-model="addobj.standard_besat"
onkeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))"
/>
<span>{{this.$t('1104')}}</span>
</div>
<div class="filter">
<label>
<i>*</i>
{{this.$t('500221')}}:
</label>
<InputNumber
:min="0"
class="searchInput"
type="number"
v-model="addobj.updown_besat"
onkeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))"
/>
<span>{{this.$t('1104')}}</span>
</div>
<div class="filter"> <div class="filter">
<label> <label>{{ $t("1132") }}</label>
<i>*</i> <Cascader
{{this.$t('800281')}}: :data="datalevel"
</label> :value="leveldata"
<InputNumber trigger="click"
:min="0" change-on-select
class="searchInput" class="searchSelect"
type="number" @on-change="getlevel"
v-model="addobj.daily_standard_output" style="width: 220px"
onkeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" ></Cascader>
/>
<span>{{this.$t('901087')}}</span>
</div> </div>
<div class="filter"> <div class="filter">
<label>{{this.$t('810000')}}:</label> <label>{{ $t("100088") }}</label>
<InputNumber <Input class="searchSelect" type="text" v-model="productname" />
:min="0"
class="searchInput"
type="number"
v-model="addobj.time_num"
onkeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))"
/>
<span>{{this.$t('1104')}}</span>
</div> </div>
<div class="filter"> <div class="filter">
<label> <label>{{ $t("100090") }}</label>
<i>*</i> <Input class="searchSelect" type="text" v-model="drawcode" />
{{this.$t('950009')}}:
</label>
<InputNumber
:min="1"
class="searchInput"
type="number"
v-model="addobj.yieldrate"
value="1"
onkeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))"
/>
</div> </div>
<div class="filter"> <div class="searchBtn">
<label> <Button
<!-- <i>*</i> --> type="primary"
{{this.$t('1049')}}: class="twoWord"
</label> icon="ios-search"
<DatePicker type="date" v-model="addobj.start_time" class="searchInput"></DatePicker> @click="tosearch()"
</div> >{{ $t("1001") }}</Button
<div class="filter"> >
<label> <Button
<!-- <i>*</i> --> type="success"
{{this.$t('1050')}}: class="twoWord"
</label> icon="md-add-circle"
<DatePicker type="date" v-model="addobj.end_time" class="searchInput"></DatePicker> @click="add()"
>{{ $t("1002") }}</Button
>
<Button
type="warning"
class="twoWord"
icon="ios-build"
@click="edit()"
>{{ $t("1003") }}</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
>
<Upload
style="display: inline-block"
ref="upload"
:action="action"
name="excel-file"
:headers="headers"
:show-upload-list="false"
:on-format-error="handleFormatError"
:on-success="handleSuccess"
:on-error="handleError"
:format="['xlsx']"
>
<Button
type="primary"
class="fourWord"
icon="md-cloud-upload"
>{{ $t("1006") }}</Button
>
</Upload>
</div> </div>
</div>
</div> </div>
<div slot="footer"> <div class="divborder newTableDiv">
<Button type="text" size="large" @click="closeadd()">{{$t('1033')}}</Button> <Table
<Button type="primary" size="large" @click="adddata()">{{$t('1011')}}</Button> class="tableClass"
</div> @on-current-change="handleRowChange"
</Modal> highlight-row
<Modal :data="tableData1"
class="newModalClass" @on-selection-change="handleSelectRow"
:title="$t('1003')" :columns="tableColumns1"
v-model="editmodal" ></Table>
:styles="{width:'500px'}" <div class="pageDiv">
> <div class="pageDirection">
<div class="modal_body" style="height:400px!important;"> <Page
<div class="filter"> :total="total"
<label>{{this.$t('200003')}}:</label> :current="page"
<label class="labelInfo">{{sectionname}}</label> @on-change="changePage"
</div> show-elevator
<div class="filter"> show-sizer
<label>{{this.$t('500107')}}:</label> show-total
<label class="labelInfo">{{editobj.process_number}}</label> @on-page-size-change="handlePageSize"
</div> :page-size-opts="[10, 20, 30, 40, 100]"
<div class="filter"> ></Page>
<label>{{this.$t('100088')}}:</label> </div>
<label class="labelInfo">{{editobj.product_name_text}}</label> </div>
</div> <Modal
<div class="filter"> class="newModalClass"
<label>{{this.$t('900967')}}:</label> :title="$t('1002')"
<label class="labelInfo">{{editobj.route_name}}</label> v-model="addmodal"
</div> :styles="{ width: '700px' }"
<div class="filter"> >
<label>{{this.$t('900880')}}:</label> <div class="modal_body" style="height: 430px !important">
<label class="labelInfo">{{editobj.route_number}}</label> <div
</div> style="
<div class="filter"> width: 280px;
<label> float: left;
<i>*</i> height: 400px;
{{this.$t('500098')}}: overflow-y: scroll;
</label> "
<InputNumber >
:min="0" <template>
class="searchInput" <Tree
type="text" :data="treeContents"
v-model="editobj.standard_besat" ref="tree"
onkeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" @on-select-change="getList()"
/> ></Tree>
<span>{{this.$t('1104')}}</span> </template>
</div> </div>
<div class="filter"> <div
<label> style="
<i>*</i> width: 360px;
{{this.$t('500221')}}: float: left;
</label> height: 400px;
<InputNumber padding-left: 5px;
:min="0" "
class="searchInput" >
type="text" <div class="filter">
v-model="editobj.updown_besat" <label>
onkeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" <i>*</i>
/> {{ this.$t("500107") }}:
<span>{{this.$t('1104')}}</span> </label>
</div> <Input
<div class="filter"> class="searchInput"
<label> type="text"
<i>*</i> v-model="addobj.program_number"
{{this.$t('800281')}}: />
</label> </div>
<InputNumber <div class="filter">
:min="0" <label>
class="searchInput" <i>*</i>
type="text" {{ this.$t("100088") }}:
v-model="editobj.daily_standard_output" </label>
onkeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" <Select
/> v-model="addobj.product"
<span>{{this.$t('901087')}}</span> label-in-value
</div> clearable
<div class="filter"> filterable
<label>{{this.$t('810000')}}:</label> class="searchSelect"
<InputNumber @on-change="getRoutesByProduct"
:min="0" >
class="searchInput" <Option
type="text" v-for="item in products"
v-model="editobj.time_num" :value="item.id"
onkeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" :key="item.id"
/> >{{ item.name }}</Option
<span>{{this.$t('1104')}}</span> >
</div> </Select>
<div class="filter"> </div>
<label> <!-- <div class="filter">
<i>*</i> <label>
{{this.$t('950009')}}: <i>*</i>
</label> {{ this.$t("900880") }}:
<InputNumber </label>
:min="1" <Input
class="searchInput" class="searchInput"
type="text" type="text"
v-model="editobj.yieldrate" v-model="addobj.route_number"
value="1" />
onkeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" </div> -->
/> <div class="filter">
</div> <label>
<div class="filter"> <i>*</i>
<label> {{ this.$t("900967") }}:
<!-- <i>*</i> --> </label>
{{this.$t('1049')}}: <!-- <Input
</label> class="searchInput"
<DatePicker type="date" v-model="editobj.start_time" class="searchInput"></DatePicker> type="text"
</div> v-model="addobj.route_name"
<div class="filter"> /> -->
<label> <Select
<!-- <i>*</i> --> v-model="addobj.route_id"
{{this.$t('1050')}}: label-in-value
</label> clearable
<DatePicker type="date" v-model="editobj.end_time" class="searchInput"></DatePicker> filterable
</div> class="searchSelect"
</div> >
<div slot="footer"> <Option
<Button type="text" size="large" @click="closeedit()">{{$t('1033')}}</Button> v-for="item in routeList"
<Button type="primary" size="large" @click="editdata()">{{$t('1011')}}</Button> :value="item.id"
:key="item.id"
>{{ item.serialnumber+'-'+item.name }}</Option
>
</Select>
</div>
<div class="filter">
<label>
<i>*</i>
{{ this.$t("500098") }}:
</label>
<InputNumber
:min="0"
class="searchInput"
type="number"
v-model="addobj.standard_besat"
onkeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))"
/>
<span>{{ this.$t("1104") }}</span>
</div>
<div class="filter">
<label>
<i>*</i>
{{ this.$t("500221") }}:
</label>
<InputNumber
:min="0"
class="searchInput"
type="number"
v-model="addobj.updown_besat"
onkeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))"
/>
<span>{{ this.$t("1104") }}</span>
</div>
<div class="filter">
<label>
<i>*</i>
{{ this.$t("800281") }}:
</label>
<InputNumber
:min="0"
class="searchInput"
type="number"
v-model="addobj.daily_standard_output"
onkeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))"
/>
<span>{{ this.$t("901087") }}</span>
</div>
<div class="filter">
<label>{{ this.$t("810000") }}:</label>
<InputNumber
:min="0"
class="searchInput"
type="number"
v-model="addobj.time_num"
onkeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))"
/>
<span>{{ this.$t("1104") }}</span>
</div>
<div class="filter">
<label>
<i>*</i>
{{ this.$t("950009") }}:
</label>
<InputNumber
:min="1"
class="searchInput"
type="number"
v-model="addobj.yieldrate"
value="1"
onkeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))"
/>
</div>
<div class="filter">
<label>
<!-- <i>*</i> -->
{{ this.$t("1049") }}:
</label>
<DatePicker
type="date"
v-model="addobj.start_time"
class="searchInput"
></DatePicker>
</div>
<div class="filter">
<label>
<!-- <i>*</i> -->
{{ this.$t("1050") }}:
</label>
<DatePicker
type="date"
v-model="addobj.end_time"
class="searchInput"
></DatePicker>
</div>
</div>
</div>
<div slot="footer">
<Button type="text" size="large" @click="closeadd()">{{
$t("1033")
}}</Button>
<Button type="primary" size="large" @click="adddata()">{{
$t("1011")
}}</Button>
</div>
</Modal>
<Modal
class="newModalClass"
:title="$t('1003')"
v-model="editmodal"
:styles="{ width: '500px' }"
>
<div class="modal_body" style="height: 400px !important">
<div class="filter">
<label>{{ this.$t("200003") }}:</label>
<label class="labelInfo">{{ sectionname }}</label>
</div>
<div class="filter">
<label>{{ this.$t("500107") }}:</label>
<label class="labelInfo">{{
editobj.process_number
}}</label>
</div>
<div class="filter">
<label>{{ this.$t("100088") }}:</label>
<label class="labelInfo">{{
editobj.product_name_text
}}</label>
</div>
<div class="filter">
<label>{{ this.$t("900967") }}:</label>
<label class="labelInfo">{{
editobj.route_name
}}</label>
</div>
<div class="filter">
<label>{{ this.$t("900880") }}:</label>
<label class="labelInfo">{{
editobj.route_number
}}</label>
</div>
<div class="filter">
<label>
<i>*</i>
{{ this.$t("500098") }}:
</label>
<InputNumber
:min="0"
class="searchInput"
type="text"
v-model="editobj.standard_besat"
onkeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))"
/>
<span>{{ this.$t("1104") }}</span>
</div>
<div class="filter">
<label>
<i>*</i>
{{ this.$t("500221") }}:
</label>
<InputNumber
:min="0"
class="searchInput"
type="text"
v-model="editobj.updown_besat"
onkeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))"
/>
<span>{{ this.$t("1104") }}</span>
</div>
<div class="filter">
<label>
<i>*</i>
{{ this.$t("800281") }}:
</label>
<InputNumber
:min="0"
class="searchInput"
type="text"
v-model="editobj.daily_standard_output"
onkeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))"
/>
<span>{{ this.$t("901087") }}</span>
</div>
<div class="filter">
<label>{{ this.$t("810000") }}:</label>
<InputNumber
:min="0"
class="searchInput"
type="text"
v-model="editobj.time_num"
onkeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))"
/>
<span>{{ this.$t("1104") }}</span>
</div>
<div class="filter">
<label>
<i>*</i>
{{ this.$t("950009") }}:
</label>
<InputNumber
:min="1"
class="searchInput"
type="text"
v-model="editobj.yieldrate"
value="1"
onkeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))"
/>
</div>
<div class="filter">
<label>
<!-- <i>*</i> -->
{{ this.$t("1049") }}:
</label>
<DatePicker
type="date"
v-model="editobj.start_time"
class="searchInput"
></DatePicker>
</div>
<div class="filter">
<label>
<!-- <i>*</i> -->
{{ this.$t("1050") }}:
</label>
<DatePicker
type="date"
v-model="editobj.end_time"
class="searchInput"
></DatePicker>
</div>
</div>
<div slot="footer">
<Button type="text" size="large" @click="closeedit()">{{
$t("1033")
}}</Button>
<Button type="primary" size="large" @click="editdata()">{{
$t("1011")
}}</Button>
</div>
</Modal>
</div> </div>
</Modal>
</div> </div>
</div>
</template> </template>
<script> <script>
import axios from "@/libs/api.request"; import axios from "@/libs/api.request";
export default { export default {
name: "producetime", // 组件不刷新 name: "producetime", // 组件不刷新
data() { data() {
return { return {
action: action:
axios.publicPath + "cnc/upload/submit?templateName=BeatAllocation", axios.publicPath +
headers: { "cnc/upload/submit?templateName=BeatAllocation",
token: localStorage.getItem("token"), headers: {
timestamp: localStorage.getItem("timestamp"), token: localStorage.getItem("token"),
nonce: localStorage.getItem("nonce"), timestamp: localStorage.getItem("timestamp"),
sign: localStorage.getItem("sign"), nonce: localStorage.getItem("nonce"),
}, sign: localStorage.getItem("sign"),
leveldata: [], // 产线层级集合 },
levelid: 0, // 产线层级id leveldata: [], // 产线层级集合
datalevel: [], levelid: 0, // 产线层级id
tableData1: [], datalevel: [],
total: 0, tableData1: [],
page: 1, total: 0,
pagesize: 10, page: 1,
addmodal: false, pagesize: 10,
detailobj: {}, addmodal: false,
editmodal: false, detailobj: {},
addobj: {}, editmodal: false,
editobj: {}, addobj: {},
selectids: "", editobj: {},
treeContents: [], selectids: "",
timetype: "time", treeContents: [],
sectionId: "", timetype: "time",
sectionname: "", sectionId: "",
productname: "", sectionname: "",
drawcode: "", productname: "",
products: [], drawcode: "",
machineId: 0, products: [],
map: { routeList:[], //工序列表
value: "value", machineId: 0,
label: "label", map: {
children: "children", value: "value",
expand: true, label: "label",
selected: false, children: "children",
}, expand: true,
tableColumns1: [ selected: false,
{ },
type: "selection", tableColumns1: [
width: 50, {
align: "center", type: "selection",
}, width: 50,
{ align: "center",
type: "index2", },
title: this.$t("1008"), {
key: "xuhao", type: "index2",
render: (h, params) => { title: this.$t("1008"),
return h( key: "xuhao",
"span", render: (h, params) => {
params.index + (this.page - 1) * this.pagesize + 1 return h(
"span",
params.index + (this.page - 1) * this.pagesize + 1
);
},
width: "60px",
},
{
title: this.$t("900868"),
key: "stationName",
width: "120px",
},
{
title: this.$t("800278"),
key: "sectionName",
width: "120px",
},
{
title: this.$t("800279"),
key: "process_number",
width: "100px",
},
{
title: this.$t("100088"),
key: "product_name_text",
},
{
title: this.$t("600567"),
key: "drawing_number",
},
{
title: this.$t("900967"),
key: "routeName",
},
{
title: this.$t("500135"),
key: "standard_besat",
width: 150,
},
{
title: this.$t("500223"),
key: "updown_besat",
width: 150,
},
{
title: this.$t("900869"),
key: "daily_standard_output",
width: 150,
},
{
title: this.$t("900870"),
key: "time_num",
width: 150,
},
{
title: this.$t("950009"),
key: "yieldrate",
},
],
};
},
created() {
this.initlevel();
// this.tosearch();
// 格式化表格样式
this.tableColumns1 = this.$time.initTableTitle(this.tableColumns1);
},
methods: {
handleFormatError(file) {
this.$Message.error(
this.$t("950396") + file.name + this.$t("950397")
); );
},
width: "60px",
}, },
{ handleSuccess(res, file) {
title: this.$t("900868"), if (res.ret == 1) {
key: "stationName", this.$Message.success(this.$t("950398"));
width: "120px", this.search(this.page, this.pagesize);
} else {
if ((res.msg + "").indexOf(",") != -1) {
this.page = 1;
this.search(this.page, this.pagesize);
inittip(res.msg);
} else {
this.$Message.error(this.$t(res.msg));
}
}
}, },
{ handleError() {
title: this.$t("800278"), this.$Message.error(this.$t("2010006") + "!");
key: "sectionName",
width: "120px",
}, },
{ // 产线层级
title: this.$t("800279"), initlevel() {
key: "process_number", axios
width: "100px", .request({
url: "config/ProjectLevelSection/GetSectionTree",
method: "get",
})
.then((res) => {
const arr = [];
this.datalevel = res.data.data;
let sdata = res.data.data;
if (
sdata != null &&
sdata != undefined &&
sdata &&
sdata.length > 0
) {
arr.push(res.data.data[0].value);
this.levelid = res.data.data[0].value;
}
this.leveldata = arr;
this.tosearch();
});
}, },
{ getproduct() {
title: this.$t("100088"), axios
key: "product_name_text", .request({
url:
"/config/ProjectProduct/GetProductsByCode?code=&name=&count=99",
method: "get",
})
.then((res) => {
this.products = res.data.data;
});
}, },
{ getRoutesByProduct(val) {
title: this.$t("600567"), // 选择产品查询工艺路径
key: "drawing_number", let id = 0;
id = val.value?val.value:0;
var params = {
productId: id,
page: 1,
pagesize: 100,
};
axios
.request({
url: "/config/ProductRoute/GetPagedRoutes",
params,
method: "get",
})
.then((res) => {
if (res.data.ret == 1) {
this.routeList = res.data.data;
}
});
}, },
{ // 产线层级选择
title: this.$t("900967"), getlevel: function (data) {
key: "routeName", this.levelid = data[data.length - 1];
}, },
{ tosearch() {
title: this.$t("500135"), this.page = 1;
key: "standard_besat", this.pageszie = 10;
width: 150, this.search();
}, },
{ search() {
title: this.$t("500223"), var params = {
key: "updown_besat", sectionID: this.levelid,
width: 150, product_name_text: this.productname,
drawing_number: this.drawcode,
page: this.page,
pagesize: this.pagesize,
};
this.detailobj = {};
this.selectids = [];
axios
.request({
url: "/cnc/BeatAllocation/ShowBeatAllocation",
params,
method: "get",
})
.then((res) => {
this.total = res.data.total;
this.mockTableData1(res.data.data);
});
}, },
{ mockTableData1(tablelist) {
title: this.$t("900869"), let data = [];
key: "daily_standard_output", tablelist.forEach((item) => {
width: 150, if (item) {
data.push({
stationName: item.stationName,
sectionName: item.sectionName,
process_number: item.process_number,
product_name_text: item.product_name_text,
drawing_number: item.drawing_number,
routeName: item.routeName,
route_number: item.route_number,
standard_besat: item.standard_besat,
updown_besat: item.updown_besat,
daily_standard_output: item.daily_standard_output,
time_num: item.time_num,
yieldrate: item.yieldrate,
machineID: item.machineID,
start_time: item.start_time,
end_time: item.end_time,
id: item.id,
});
}
});
this.tableData1 = data;
}, },
{ handleSelectRow: function (data) {
title: this.$t("900870"), var ids = [];
key: "time_num", for (var i in data) {
width: 150, ids.push(data[i].id);
}
this.selectids = ids;
}, },
{ handleRowChange(currentRow, oldCurrentRow) {
title: this.$t("950009"), this.detailobj = currentRow;
key: "yieldrate",
}, },
], handlePageSize(value) {
}; this.pagesize = value;
}, this.search();
created() { },
this.initlevel(); changePage(value) {
// this.tosearch(); this.page = value;
// 格式化表格样式 this.search();
this.tableColumns1 = this.$time.initTableTitle(this.tableColumns1); },
}, add() {
methods: { this.addmodal = true;
handleFormatError(file) { this.addobj = {
this.$Message.error(this.$t("950396") + file.name + this.$t("950397")); program_number: "",
}, product: "",
handleSuccess(res, file) { route_number: "",
if (res.ret == 1) { route_name: "",
this.$Message.success(this.$t("950398")); standard_besat: 0,
this.search(this.page, this.pagesize); updown_besat: 0,
} else { daily_standard_output: 0,
if ((res.msg + "").indexOf(",") != -1) { time_num: 0,
this.page = 1; yieldrate: 1,
this.search(this.page, this.pagesize); start_time: "",
inittip(res.msg); end_time: "",
} else { };
this.$Message.error(this.$t(res.msg)); this.sectionId = "";
} this.machineId = 0;
} this.inittree();
}, this.getproduct();
handleError() { },
this.$Message.error(this.$t("2010006") + "!"); inittree() {
},
// 产线层级
initlevel() {
axios
.request({
url: "config/ProjectLevelSection/GetSectionTree",
method: "get",
})
.then((res) => {
const arr = [];
this.datalevel = res.data.data;
let sdata = res.data.data
if(sdata!=null&&sdata!=undefined&&sdata&&sdata.length >0){
arr.push(res.data.data[0].value)
this.levelid = res.data.data[0].value;
}
this.leveldata = arr;
this.tosearch();
});
},
getproduct() {
axios
.request({
url: "/config/ProjectProduct/GetProductsByCode?code=&name=&count=99",
method: "get",
})
.then((res) => {
this.products = res.data.data;
});
},
// 产线层级选择
getlevel: function (data) {
this.levelid = data[data.length - 1];
},
tosearch() {
this.page = 1;
this.pageszie = 10;
this.search();
},
search() {
var params = {
sectionID: this.levelid,
product_name_text: this.productname,
drawing_number: this.drawcode,
page: this.page,
pagesize: this.pagesize,
};
this.detailobj = {};
this.selectids = [];
axios
.request({
url: "/cnc/BeatAllocation/ShowBeatAllocation",
params,
method: "get",
})
.then((res) => {
this.total = res.data.total;
this.mockTableData1(res.data.data);
});
},
mockTableData1(tablelist) {
let data = [];
tablelist.forEach((item) => {
if (item) {
data.push({
stationName: item.stationName,
sectionName: item.sectionName,
process_number: item.process_number,
product_name_text: item.product_name_text,
drawing_number: item.drawing_number,
routeName: item.routeName,
route_number: item.route_number,
standard_besat: item.standard_besat,
updown_besat: item.updown_besat,
daily_standard_output: item.daily_standard_output,
time_num: item.time_num,
yieldrate: item.yieldrate,
machineID: item.machineID,
start_time: item.start_time,
end_time: item.end_time,
id: item.id,
});
}
});
this.tableData1 = data;
},
handleSelectRow: function (data) {
var ids = [];
for (var i in data) {
ids.push(data[i].id);
}
this.selectids = ids;
},
handleRowChange(currentRow, oldCurrentRow) {
this.detailobj = currentRow;
},
handlePageSize(value) {
this.pagesize = value;
this.search();
},
changePage(value) {
this.page = value;
this.search();
},
add() {
this.addmodal = true;
this.addobj = {
program_number: "",
product: "",
route_number: "",
route_name: "",
standard_besat: 0,
updown_besat: 0,
daily_standard_output: 0,
time_num: 0,
yieldrate: 1,
start_time: "",
end_time: "",
};
this.sectionId = "";
this.machineId = 0;
this.inittree();
this.getproduct();
},
inittree() {
axios
.request({
url: "/config/ProjectLevelSection/GetSectionTree",
method: "get",
})
.then((res) => {
if (res.data.ret == 1) {
this.treeContents = res.data.data;
this.contentTree(this.treeContents);
} else {
this.$Message.error(this.$t(res.data.msg));
}
});
},
// 树形数据转换
contentTree(arr) {
arr.forEach((ele) => {
ele.title = ele.label;
ele.expand = true;
if (
ele.children.length != 0 &&
ele.children != undefined &&
ele.children != null
) {
this.contentTree(ele.children);
}
});
},
// 获取树id
getList() {
let node = this.$refs.tree.getSelectedNodes();
if (node.length > 0) {
if (node[0].children && node[0].children.length > 0) {
this.$Message.error("请选择具体工位");
} else {
// this.machine = node[0].title;
this.sectionId = node[0].value;
this.getmachine();
}
}
},
getmachine() {
axios
.request({
url: "/config/Machine/GetmachineidBySection?id=" + this.sectionId,
method: "get",
})
.then((res) => {
if (res.data.ret === 1) {
this.machineId = res.data.data.machine_id;
}
});
},
closeadd() {
this.addmodal = false;
},
adddata() {
if (this.sectionId === "" || this.sectionId === undefined) {
this.$Message.error(this.$t(1052));
return false;
}
if (this.machineId === 0) {
this.$Message.error(this.$t(100177));
return false;
}
// 验证非空
if (
this.addobj.program_number === "" ||
this.addobj.program_number === undefined
) {
this.$Message.error(this.$t(800291));
return false;
}
if (this.addobj.product === "" || this.addobj.product === undefined) {
this.$Message.error(this.$t("100064"));
return false;
}
if (
this.addobj.route_number == "" ||
this.addobj.route_number == undefined
) {
this.$Message.error(this.$t(666620));
return false;
}
if (
this.addobj.route_name === "" ||
this.addobj.route_name === undefined
) {
this.$Message.error(this.$t("901088"));
return false;
}
if (
this.addobj.standard_besat === "" ||
this.addobj.standard_besat === undefined ||
this.addobj.standard_besat === 0
) {
this.$Message.error(this.$t("800294"));
return false;
}
if (
this.addobj.updown_besat === "" ||
this.addobj.updown_besat === undefined ||
this.addobj.updown_besat === 0
) {
this.$Message.error(this.$t("500222"));
return false;
}
if (
this.addobj.daily_standard_output === "" ||
this.addobj.daily_standard_output === undefined ||
this.addobj.daily_standard_output === 0
) {
this.$Message.error(this.$t("800295"));
return false;
}
if (
this.addobj.yieldrate === "" ||
this.addobj.yieldrate === undefined ||
this.addobj.yieldrate === 0
) {
this.$Message.error(this.$t("950156"));
return false;
}
// if (
// this.addobj.start_time === "" ||
// this.addobj.start_time === undefined
// ) {
// this.$Message.error(this.$t("9000127"));
// return false;
// }
// if (this.addobj.end_time === "" || this.addobj.end_time === undefined) {
// this.$Message.error(this.$t("9000128"));
// return false;
// }
if (this.addobj.start_time && this.addobj.end_time && this.addobj.start_time > this.addobj.end_time) {
this.$Message.error(this.$t("100218"));
return false;
}
let data = {
sectionid: this.sectionId,
machineid: this.machineId,
program_number: this.addobj.program_number,
product_name_text: "",
product_name: this.addobj.product,
drawing_number: "",
standard_besat: this.addobj.standard_besat,
daily_standard_output: this.addobj.daily_standard_output,
time_num: this.addobj.time_num,
route_name: this.addobj.route_name,
route_number: this.addobj.route_number,
updown_besat: this.addobj.updown_besat, // 上下料节拍
yieldratio: this.addobj.yieldrate, // 产量系数
start_time: this.addobj.start_time,
end_time: this.addobj.end_time,
};
axios
.request({
url: "/cnc/BeatAllocation/AddBeatAllocation",
data,
method: "post",
})
.then((res) => {
if (res.data.ret === 1) {
this.$Message.success(this.$t("1055"));
this.addmodal = false;
this.tosearch();
} else {
this.$Message.error(this.$t(res.data.msg));
}
});
},
dele() {
if (
this.selectids === undefined ||
this.selectids === "" ||
this.selectids === []
) {
this.$Message.error(this.$t("1017"));
return false;
} else {
let data = {
ids: this.selectids,
};
this.$Modal.confirm({
title: this.$t("1018"),
content: "",
width: "290px",
closable: true,
okText: this.$t("1004"),
onOk: () => {
axios axios
.request({ .request({
url: "/cnc/BeatAllocation/DeleteMultipleBeats", url: "/config/ProjectLevelSection/GetSectionTree",
data, method: "get",
method: "post", })
}) .then((res) => {
.then((res) => { if (res.data.ret == 1) {
if (res.data.ret === 1) { this.treeContents = res.data.data;
this.$Message.success(this.$t("1058")); this.contentTree(this.treeContents);
this.tosearch(); } else {
this.detailobj = {}; this.$Message.error(this.$t(res.data.msg));
}
});
},
// 树形数据转换
contentTree(arr) {
arr.forEach((ele) => {
ele.title = ele.label;
ele.expand = true;
if (
ele.children.length != 0 &&
ele.children != undefined &&
ele.children != null
) {
this.contentTree(ele.children);
}
});
},
// 获取树id
getList() {
let node = this.$refs.tree.getSelectedNodes();
if (node.length > 0) {
if (node[0].children && node[0].children.length > 0) {
this.$Message.error("请选择具体工位");
} else { } else {
this.$Message.error(this.$t(res.data.msg)); // this.machine = node[0].title;
this.sectionId = node[0].value;
this.getmachine();
} }
}); }
}, },
}); getmachine() {
} axios
}, .request({
edit() { url:
if (this.detailobj === undefined || this.detailobj.id === undefined) { "/config/Machine/GetmachineidBySection?id=" +
this.$Message.error(this.$t("1017")); this.sectionId,
return false; method: "get",
} })
this.sectionname = this.detailobj.stationName; .then((res) => {
this.sectionId = this.detailobj.section_id; if (res.data.ret === 1) {
this.machineId = this.detailobj.machineID; this.machineId = res.data.data.machine_id;
this.editobj.route_number = this.detailobj.route_number; }
this.editobj.process_number = this.detailobj.process_number; });
this.editobj.product_name_text = this.detailobj.product_name_text; },
this.editobj.standard_besat = this.detailobj.standard_besat; closeadd() {
this.editobj.daily_standard_output = this.detailobj.daily_standard_output; this.addmodal = false;
this.editobj.time_num = this.detailobj.time_num; },
this.editobj.route_name = this.detailobj.routeName; adddata() {
this.editobj.updown_besat = this.detailobj.updown_besat; if (this.sectionId === "" || this.sectionId === undefined) {
this.editobj.yieldrate = this.detailobj.yieldrate; this.$Message.error(this.$t(1052));
this.editobj.start_time = this.detailobj.start_time; return false;
this.editobj.end_time = this.detailobj.end_time; }
this.editmodal = true; if (this.machineId === 0) {
}, this.$Message.error(this.$t(100177));
editdata() { return false;
// 验证非空 }
if ( // 验证非空
this.editobj.standard_besat === "" || if (
this.editobj.standard_besat === undefined || this.addobj.program_number === "" ||
this.editobj.standard_besat === 0 this.addobj.program_number === undefined
) { ) {
this.$Message.error(this.$t("800294")); this.$Message.error(this.$t(800291));
return false; return false;
} }
if ( if (
this.editobj.updown_besat === "" || this.addobj.product === "" ||
this.editobj.updown_besat === undefined this.addobj.product === undefined
) { ) {
this.$Message.error(this.$t("500222")); this.$Message.error(this.$t("100064"));
return false; return false;
} }
if ( // if (
this.editobj.daily_standard_output === "" || // this.addobj.route_number == "" ||
this.editobj.daily_standard_output === undefined || // this.addobj.route_number == undefined
this.editobj.daily_standard_output === 0 // ) {
) { // this.$Message.error(this.$t(666620));
this.$Message.error(this.$t("800295")); // return false;
return false; // }
} if (
if ( this.addobj.route_id === "" ||
this.editobj.yieldrate === "" || this.addobj.route_id === undefined || this.addobj.route_id === 0
this.editobj.yieldrate === undefined || ) {
this.editobj.yieldrate === 0 this.$Message.error(this.$t("901088"));
) { return false;
this.$Message.error(this.$t("950156")); }
return false; if (
} this.addobj.standard_besat === "" ||
// if ( this.addobj.standard_besat === undefined ||
// this.editobj.start_time === "" || this.addobj.standard_besat === 0
// this.editobj.start_time === undefined ) {
// ) { this.$Message.error(this.$t("800294"));
// this.$Message.error(this.$t("9000127")); return false;
// return false; }
// }
// if (this.editobj.end_time === "" || this.editobj.end_time === undefined) { if (
// this.$Message.error(this.$t("9000128")); this.addobj.updown_besat === "" ||
// return false; this.addobj.updown_besat === undefined ||
// } this.addobj.updown_besat === 0
if (this.editobj.start_time && this.editobj.end_time && this.editobj.start_time > this.editobj.end_time) { ) {
this.$Message.error(this.$t("100218")); this.$Message.error(this.$t("500222"));
return false; return false;
} }
let data = { if (
sectionid: this.sectionId, this.addobj.daily_standard_output === "" ||
machineid: this.machineId, this.addobj.daily_standard_output === undefined ||
standard_besat: this.editobj.standard_besat, this.addobj.daily_standard_output === 0
daily_standard_output: this.editobj.daily_standard_output, ) {
time_num: this.editobj.time_num, this.$Message.error(this.$t("800295"));
updown_besat: this.editobj.updown_besat, // 上下料节拍 return false;
yieldratio: this.editobj.yieldrate, // 产量系数 }
start_time: this.editobj.start_time, if (
end_time: this.editobj.end_time, this.addobj.yieldrate === "" ||
id: this.detailobj.id, this.addobj.yieldrate === undefined ||
}; this.addobj.yieldrate === 0
axios ) {
.request({ this.$Message.error(this.$t("950156"));
url: "/cnc/BeatAllocation/EditBeatAllocation", return false;
data, }
method: "post", // if (
}) // this.addobj.start_time === "" ||
.then((res) => { // this.addobj.start_time === undefined
if (res.data.ret === 1) { // ) {
this.$Message.success(this.$t("1060")); // this.$Message.error(this.$t("9000127"));
// return false;
// }
// if (this.addobj.end_time === "" || this.addobj.end_time === undefined) {
// this.$Message.error(this.$t("9000128"));
// return false;
// }
if (
this.addobj.start_time &&
this.addobj.end_time &&
this.addobj.start_time > this.addobj.end_time
) {
this.$Message.error(this.$t("100218"));
return false;
}
let data = {
sectionid: this.sectionId,
machineid: this.machineId,
program_number: this.addobj.program_number,
product_name_text: "",
product_name: this.addobj.product,
drawing_number: "",
standard_besat: this.addobj.standard_besat,
daily_standard_output: this.addobj.daily_standard_output,
time_num: this.addobj.time_num,
route_id:this.addobj.route_id,
route_name: this.addobj.route_name,
route_number: this.addobj.route_number,
updown_besat: this.addobj.updown_besat, // 上下料节拍
yieldratio: this.addobj.yieldrate, // 产量系数
start_time: this.addobj.start_time,
end_time: this.addobj.end_time,
};
axios
.request({
url: "/cnc/BeatAllocation/AddBeatAllocation",
data,
method: "post",
})
.then((res) => {
if (res.data.ret === 1) {
this.$Message.success(this.$t("1055"));
this.addmodal = false;
this.tosearch();
} else {
this.$Message.error(this.$t(res.data.msg));
}
});
},
dele() {
if (
this.selectids === undefined ||
this.selectids === "" ||
this.selectids === []
) {
this.$Message.error(this.$t("1017"));
return false;
} else {
let data = {
ids: this.selectids,
};
this.$Modal.confirm({
title: this.$t("1018"),
content: "",
width: "290px",
closable: true,
okText: this.$t("1004"),
onOk: () => {
axios
.request({
url: "/cnc/BeatAllocation/DeleteMultipleBeats",
data,
method: "post",
})
.then((res) => {
if (res.data.ret === 1) {
this.$Message.success(this.$t("1058"));
this.tosearch();
this.detailobj = {};
} else {
this.$Message.error(this.$t(res.data.msg));
}
});
},
});
}
},
edit() {
if (
this.detailobj === undefined ||
this.detailobj.id === undefined
) {
this.$Message.error(this.$t("1017"));
return false;
}
this.sectionname = this.detailobj.stationName;
this.sectionId = this.detailobj.section_id;
this.machineId = this.detailobj.machineID;
this.editobj.route_number = this.detailobj.route_number;
this.editobj.process_number = this.detailobj.process_number;
this.editobj.product_name_text = this.detailobj.product_name_text;
this.editobj.standard_besat = this.detailobj.standard_besat;
this.editobj.daily_standard_output = this.detailobj.daily_standard_output;
this.editobj.time_num = this.detailobj.time_num;
this.editobj.route_name = this.detailobj.routeName;
this.editobj.updown_besat = this.detailobj.updown_besat;
this.editobj.yieldrate = this.detailobj.yieldrate;
this.editobj.start_time = this.detailobj.start_time;
this.editobj.end_time = this.detailobj.end_time;
this.editmodal = true;
},
editdata() {
// 验证非空
if (
this.editobj.standard_besat === "" ||
this.editobj.standard_besat === undefined ||
this.editobj.standard_besat === 0
) {
this.$Message.error(this.$t("800294"));
return false;
}
if (
this.editobj.updown_besat === "" ||
this.editobj.updown_besat === undefined
) {
this.$Message.error(this.$t("500222"));
return false;
}
if (
this.editobj.daily_standard_output === "" ||
this.editobj.daily_standard_output === undefined ||
this.editobj.daily_standard_output === 0
) {
this.$Message.error(this.$t("800295"));
return false;
}
if (
this.editobj.yieldrate === "" ||
this.editobj.yieldrate === undefined ||
this.editobj.yieldrate === 0
) {
this.$Message.error(this.$t("950156"));
return false;
}
// if (
// this.editobj.start_time === "" ||
// this.editobj.start_time === undefined
// ) {
// this.$Message.error(this.$t("9000127"));
// return false;
// }
// if (this.editobj.end_time === "" || this.editobj.end_time === undefined) {
// this.$Message.error(this.$t("9000128"));
// return false;
// }
if (
this.editobj.start_time &&
this.editobj.end_time &&
this.editobj.start_time > this.editobj.end_time
) {
this.$Message.error(this.$t("100218"));
return false;
}
let data = {
sectionid: this.sectionId,
machineid: this.machineId,
standard_besat: this.editobj.standard_besat,
daily_standard_output: this.editobj.daily_standard_output,
time_num: this.editobj.time_num,
updown_besat: this.editobj.updown_besat, // 上下料节拍
yieldratio: this.editobj.yieldrate, // 产量系数
start_time: this.editobj.start_time,
end_time: this.editobj.end_time,
id: this.detailobj.id,
};
axios
.request({
url: "/cnc/BeatAllocation/EditBeatAllocation",
data,
method: "post",
})
.then((res) => {
if (res.data.ret === 1) {
this.$Message.success(this.$t("1060"));
this.editmodal = false;
this.search();
} else {
this.$Message.error(this.$t(res.data.msg));
}
});
},
closeedit() {
this.editmodal = false; this.editmodal = false;
this.search(); },
} else { loadexcel() {
this.$Message.error(this.$t(res.data.msg)); let params = {};
} axios
}); .request({
}, url: "/config/BeatSetDownLoad/GetTemplate",
closeedit() { params,
this.editmodal = false; method: "get",
}, })
loadexcel() { .then((res) => {
let params = {}; if (res.data.ret === 1) {
axios window.location.href =
.request({ axios.publicPath + "" + res.data.data;
url: "/config/BeatSetDownLoad/GetTemplate", } else {
params, this.error(res.data.msg);
method: "get", }
}) });
.then((res) => { },
if (res.data.ret === 1) { Export() {
window.location.href = axios.publicPath + "" + res.data.data; axios
} else { .request({
this.error(res.data.msg); url: "/cnc/Upload/Submit?templateName=BeatAllocation",
} method: "post",
}); })
}, .then((res) => {
Export() { if (res.data.ret === 1) {
axios window.location.href =
.request({ axios.publicPath + "" + res.data.data;
url: "/cnc/Upload/Submit?templateName=BeatAllocation", } else {
method: "post", this.$Message.error(res.data.msg);
}) }
.then((res) => { });
if (res.data.ret === 1) { },
window.location.href = axios.publicPath + "" + res.data.data;
} else {
this.$Message.error(res.data.msg);
}
});
}, },
},
}; };
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.treeSelect { .treeSelect {
span { span {
background: #2d8cf1; background: #2d8cf1;
color: #fff; color: #fff;
margin: 0; margin: 0;
padding: 0 4px; padding: 0 4px;
border-radius: 3px; border-radius: 3px;
cursor: pointer; cursor: pointer;
vertical-align: top; vertical-align: top;
} }
} }
.labelInfo { .labelInfo {
text-align: left !important; text-align: left !important;
} }
</style> </style>
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<div class="divborder newSearchDiv" style="margin:0px;"> <div class="divborder newSearchDiv" style="margin:0px;">
<div class="filter"> <div class="filter">
<label>{{$t('100088')}}</label> <label>{{$t('100088')}}</label>
<!-- <Select v-model="productname" label-in-value filterable clearable remote <!-- <Select v-model="productname " label-in-value filterable clearable remote
:remote-method="remoteMethod" :remote-method="remoteMethod"
:loading="loading1" class="searchSelect" > :loading="loading1" class="searchSelect" >
<Option v-for="item in products" :value="item.id" :key="item.id">{{ item.name }}({{item.code}})</Option> <Option v-for="item in products" :value="item.id" :key="item.id">{{ item.name }}({{item.code}})</Option>
......
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
:key="index" :key="index"
:style="{ :style="{
background: item.bgc, background: item.bgc,
color: item.status != 0 ? fontColor : '', color: item.machineStatus != 0 ? fontColor : '',
}" }"
> >
<p class="flex"> <p class="flex">
...@@ -176,11 +176,11 @@ export default { ...@@ -176,11 +176,11 @@ export default {
let str = ""; let str = "";
str = str =
params.row.status == 1 params.row.status == 1
? "待上料" ? "待执行"
: params.row.status == 2 : params.row.status == 2
? "生产中" ? "执行中"
: params.row.status == 3 : params.row.status == 3
? "待下料" ? "执行完成"
: ""; : "";
return h("div", str); return h("div", str);
}, },
...@@ -362,17 +362,17 @@ export default { ...@@ -362,17 +362,17 @@ export default {
arr.forEach((ele) => { arr.forEach((ele) => {
let bgc = ""; let bgc = "";
if (ele.status == 1) { if (ele.machineStatus == 1) {
bgc = "#ff9900"; bgc = "#ff9900";
} }
if (ele.status == 2) { if (ele.machineStatus == 2) {
bgc = "#19be6b"; bgc = "#19be6b";
} }
if (ele.status == 3) { if (ele.machineStatus == 3) {
bgc = "#2db7f5"; bgc = "#2db7f5";
} }
if (ele.enable == 0) { if (ele.enable == 0) {
bgc = "red"; bgc = "#ed4014";
} }
ele.bgc = bgc; ele.bgc = bgc;
}); });
......
...@@ -98,8 +98,7 @@ ...@@ -98,8 +98,7 @@
<div class="filter"> <div class="filter">
<label>触发时间:</label> <label>触发时间:</label>
<DatePicker <DatePicker
type="datetime" type="datetimerange"
placeholder="Select date"
style="width: 200px" style="width: 200px"
v-model="startTime" v-model="startTime"
@on-change="getTime" @on-change="getTime"
...@@ -108,8 +107,7 @@ ...@@ -108,8 +107,7 @@
<div class="filter"> <div class="filter">
<label>完成时间:</label> <label>完成时间:</label>
<DatePicker <DatePicker
type="datetime" type="datetimerange"
placeholder="Select date"
style="width: 200px" style="width: 200px"
v-model="endTime" v-model="endTime"
@on-change="getTime2" @on-change="getTime2"
...@@ -124,13 +122,13 @@ ...@@ -124,13 +122,13 @@
>{{ $t("1001") }}</Button >{{ $t("1001") }}</Button
> >
<!-- --> <!-- -->
<!-- <Button <Button
type="warning" type="warning"
class="twoWord" class="twoWord"
icon="ios-search" icon="ios-search"
@click="cancel()" @click="cancel()"
>取消</Button >取消</Button
> --> >
<!--只有状态是待执行的可以改成取消--> <!--只有状态是待执行的可以改成取消-->
<Button <Button
type="primary" type="primary"
...@@ -199,11 +197,12 @@ export default { ...@@ -199,11 +197,12 @@ export default {
{ {
title: "任务编号", title: "任务编号",
key: "taskno", key: "taskno",
width: 300, width: 150,
}, },
{ {
title: "产线层级", title: "产线层级",
key: "section", key: "section",
width: 150,
}, },
{ {
title: "触发方", title: "触发方",
...@@ -216,6 +215,7 @@ export default { ...@@ -216,6 +215,7 @@ export default {
{ {
title: "工件编号", title: "工件编号",
key: "sn", key: "sn",
width: 150,
}, },
{ {
title: "工单编号", title: "工单编号",
...@@ -230,7 +230,7 @@ export default { ...@@ -230,7 +230,7 @@ export default {
key: "routeNo", key: "routeNo",
}, },
{ {
title: "工序", title: "工序名称",
key: "route", key: "route",
}, },
{ {
...@@ -248,6 +248,7 @@ export default { ...@@ -248,6 +248,7 @@ export default {
{ {
title: "动作", title: "动作",
key: "action", key: "action",
width: 150,
}, },
{ {
title: "执行类型", title: "执行类型",
...@@ -296,8 +297,8 @@ export default { ...@@ -296,8 +297,8 @@ export default {
sn: "", sn: "",
state: 0, state: 0,
performType: 0, performType: 0,
startTime: "", startTime: [],
endTime: "", endTime: [],
detailobj: {}, detailobj: {},
}; };
}, },
...@@ -316,8 +317,11 @@ export default { ...@@ -316,8 +317,11 @@ export default {
sn: this.sn, sn: this.sn,
status: this.status, status: this.status,
actionType: this.performType, actionType: this.performType,
triggertime: this.startTime, triggerbegin:
complatetime: this.endTime, this.startTime.length > 0 ? this.startTime[0] : "",
triggerend: this.startTime.length > 0 ? this.startTime[1] : "",
complatebegin: this.endTime.length > 0 ? this.endTime[0] : "",
complatend: this.endTime.length > 0 ? this.endTime[1] : "",
page: page, page: page,
pageSize: pagesize, pageSize: pagesize,
}; };
...@@ -337,23 +341,30 @@ export default { ...@@ -337,23 +341,30 @@ export default {
}); });
}, },
cancel() { cancel() {
if (this.detailobj.status != 1) { console.log(this.detailobj);
if (!this.detailobj.id) {
this.$Message.error(this.$t(1043));
return false;
}
if (this.detailobj.send != 0) {
this.$Message.error("该任务清单状态不能取消"); this.$Message.error("该任务清单状态不能取消");
return false; return false;
} }
return; // return;
let data = { // let data = {
section: this.sectionid, // section: this.sectionid,
}; // };
this.request( this.request(
// "/acc/AutomationOperate/CompalateAssemble", "/acc/AutomationState/DeleteTask?id=" + this.detailobj.id,
data, "",
"post" "get"
).then((res) => { ).then((res) => {
if (res.data.ret == 1) { if (res.data.ret == 1) {
this.$Message.success(this.$t(res.data.msg)); this.$Message.success(this.$t(res.data.msg));
this.search(1, 10);
} else { } else {
this.$Message.error(this.$t(res.data.msg)); this.$Message.error(this.$t(res.data.msg));
this.search(1, 10);
} }
}); });
}, },
......
...@@ -10,7 +10,7 @@ using Siger.Middlelayer.AccRepository.Request; ...@@ -10,7 +10,7 @@ using Siger.Middlelayer.AccRepository.Request;
using Siger.Middlelayer.Common; using Siger.Middlelayer.Common;
using Siger.ApiCommon.Filters; using Siger.ApiCommon.Filters;
using Siger.Middlelayer.Common.Extensions; using Siger.Middlelayer.Common.Extensions;
using Siger.Middlelayer.Common.Log; using Siger.Middlelayer.Log;
using Siger.Middlelayer.Common.ModuleEnum; using Siger.Middlelayer.Common.ModuleEnum;
using Siger.Middlelayer.Repository; using Siger.Middlelayer.Repository;
using Siger.Middlelayer.Repository.Repositories.Interface; using Siger.Middlelayer.Repository.Repositories.Interface;
...@@ -21,6 +21,7 @@ using Siger.Middlelayer.Repository.Entities; ...@@ -21,6 +21,7 @@ using Siger.Middlelayer.Repository.Entities;
using NPOI.SS.Formula.Functions; using NPOI.SS.Formula.Functions;
using Siger.Middlelayer.AccRepository.Response; using Siger.Middlelayer.AccRepository.Response;
using Siger.Middlelayer.Common.Helpers; using Siger.Middlelayer.Common.Helpers;
using NPOI.SS.Formula;
namespace Siger.ApiACC.Controllers namespace Siger.ApiACC.Controllers
{ {
...@@ -39,10 +40,11 @@ namespace Siger.ApiACC.Controllers ...@@ -39,10 +40,11 @@ namespace Siger.ApiACC.Controllers
private readonly IProductionBeatSetRepository _productionBeatSet; private readonly IProductionBeatSetRepository _productionBeatSet;
private readonly IAutomationFixtureToolsProductRepository _automationFixtureToolsProduct; private readonly IAutomationFixtureToolsProductRepository _automationFixtureToolsProduct;
private readonly IAutomationFixtureToolsRepository _automationFixtureTools; private readonly IAutomationFixtureToolsRepository _automationFixtureTools;
private readonly IProductRouteRepository _productRoute;
public AutomationController(IUnitOfWork unitOfWork,ISigerProjectLevelSectionRepository sigerProjectLevelSection,IAutomationLineMode automationLineMode,IAutomationMachineStatus automationMachineStatus,ISigerDict sigerDict,IAutomationTaskListRepository automationTaskList, public AutomationController(IUnitOfWork unitOfWork,ISigerProjectLevelSectionRepository sigerProjectLevelSection,IAutomationLineMode automationLineMode,IAutomationMachineStatus automationMachineStatus,ISigerDict sigerDict,IAutomationTaskListRepository automationTaskList,
ISigerProjectMachineAttributionRepository sigerProjectMachineAttribution, IAutomationFixtureMonitor automationFixtureMonitor, IAutomationLocationRepository automationLocation, IProductionBeatSetRepository productionBeatSet, IAutomationFixtureToolsProductRepository automationFixtureToolsProduct, ISigerProjectMachineAttributionRepository sigerProjectMachineAttribution, IAutomationFixtureMonitor automationFixtureMonitor, IAutomationLocationRepository automationLocation, IProductionBeatSetRepository productionBeatSet, IAutomationFixtureToolsProductRepository automationFixtureToolsProduct,
IAutomationFixtureToolsRepository automationFixtureTools) IAutomationFixtureToolsRepository automationFixtureTools, IProductRouteRepository productRoute)
{ {
_unitOfWork = unitOfWork; _unitOfWork = unitOfWork;
_sigerProjectLevelSection = sigerProjectLevelSection; _sigerProjectLevelSection = sigerProjectLevelSection;
...@@ -56,6 +58,7 @@ namespace Siger.ApiACC.Controllers ...@@ -56,6 +58,7 @@ namespace Siger.ApiACC.Controllers
_productionBeatSet = productionBeatSet; _productionBeatSet = productionBeatSet;
_automationFixtureToolsProduct = automationFixtureToolsProduct; _automationFixtureToolsProduct = automationFixtureToolsProduct;
_automationFixtureTools = automationFixtureTools; _automationFixtureTools = automationFixtureTools;
_productRoute = productRoute;
} }
/// <summary> /// <summary>
...@@ -79,7 +82,7 @@ namespace Siger.ApiACC.Controllers ...@@ -79,7 +82,7 @@ namespace Siger.ApiACC.Controllers
machineid=request.machineid, machineid=request.machineid,
projectId=PID, projectId=PID,
updatetime=DateTime.Now, updatetime=DateTime.Now,
enable=request.enable, enable=request.enable==1?1:0,
status=request.status status=request.status
}); });
}else }else
...@@ -98,13 +101,13 @@ namespace Siger.ApiACC.Controllers ...@@ -98,13 +101,13 @@ namespace Siger.ApiACC.Controllers
{ {
if (request.status == (int)Automation.MachineStatus.Waiting || request.status == (int)Automation.MachineStatus.Complated) if (request.status == (int)Automation.MachineStatus.Waiting || request.status == (int)Automation.MachineStatus.Complated)
{ {
var stationDicts = _sigerDict.GetDataByCat(AccDictCost.Automation, PID); var stationDicts = _sigerDict.GetDataByCat(AccDictCost.Automation, PID);
if (!stationDicts.Any()) if (!stationDicts.Any())
{ {
Logger.WriteLineInfo($"AutoProcess 未配置设备类型字典"); Logger.WriteLineInfo($"AutoProcess 未配置设备类型字典");
throw new BadRequestException(AccEnum.AutomationDictNotfound); throw new BadRequestException(AccEnum.AutomationDictNotfound);
} }
//Logger.WriteLineInfo($"设备状态更变{request.status}触发");
if (_automationTaskList.CanTask(PID, machineAttr.station)) if (_automationTaskList.CanTask(PID, machineAttr.station))
{ {
var uploadStation = stationDicts.Where(f => f.dkey == DictKeyValConst.UploadloadStation); var uploadStation = stationDicts.Where(f => f.dkey == DictKeyValConst.UploadloadStation);
...@@ -239,6 +242,7 @@ namespace Siger.ApiACC.Controllers ...@@ -239,6 +242,7 @@ namespace Siger.ApiACC.Controllers
Logger.WriteLineInfo($"AutoProcess 未配置设备类型字典"); Logger.WriteLineInfo($"AutoProcess 未配置设备类型字典");
throw new BadRequestException(AccEnum.AutomationDictNotfound); throw new BadRequestException(AccEnum.AutomationDictNotfound);
} }
//更新Tasklist //更新Tasklist
PlCfeeback(taskObj, request.status, stationDicts); PlCfeeback(taskObj, request.status, stationDicts);
...@@ -253,34 +257,12 @@ namespace Siger.ApiACC.Controllers ...@@ -253,34 +257,12 @@ namespace Siger.ApiACC.Controllers
return new ObjectResult(CommonEnum.Succefull); return new ObjectResult(CommonEnum.Succefull);
} }
//3.Tasklist 任务全部完成 ,创建自动任务 //3.Tasklist 任务全部完成 ,创建自动任务
var section = _sigerProjectLevelSection.Get(f => f.id == taskObj.sectionid);
switch (request.status) if (section != null)
{ {
case (int)TaskResultStatus.Cancel: AutoProcess(section.parentid, stationDicts, taskObj);
case (int)TaskResultStatus.Complated:
{
var section = _sigerProjectLevelSection.Get(f => f.id == taskObj.sectionid);
if (section != null)
{
var updownDic = stationDicts.Where(s => s.dkey == DictKeyValConst.UploadloadStation);
var uploadStations = updownDic.Select(f => f.dval.ToInt()).ToList();
var uploadPostion = uploadStations.Contains(taskObj.sectionid);
if (uploadPostion)
{
Logger.WriteLineInfo($"AutoProcess 上料料工站 无需自动创建任务 ");
break;
}
AutoProcess(section.parentid, stationDicts);
}
break;
}
case (int)TaskResultStatus.Waiting:
case (int)TaskResultStatus.Produce:
default:
{
break;
}
} }
return new ObjectResult(CommonEnum.Succefull); return new ObjectResult(CommonEnum.Succefull);
} }
...@@ -291,6 +273,7 @@ namespace Siger.ApiACC.Controllers ...@@ -291,6 +273,7 @@ namespace Siger.ApiACC.Controllers
taskObj.completetime = DateTime.Now; taskObj.completetime = DateTime.Now;
_automationTaskList.Update(taskObj); _automationTaskList.Update(taskObj);
var monitor = _automationFixtureMonitor.Get(f => f.section == taskObj.sectionid);
//PLC 反馈结束. //PLC 反馈结束.
if (status == (int)TaskResultStatus.Complated) if (status == (int)TaskResultStatus.Complated)
{ {
...@@ -313,19 +296,37 @@ namespace Siger.ApiACC.Controllers ...@@ -313,19 +296,37 @@ namespace Siger.ApiACC.Controllers
location.ordernumber = taskObj.ordercode; location.ordernumber = taskObj.ordercode;
location.productcode = taskObj.productcode; location.productcode = taskObj.productcode;
location.productid = taskObj.productid; location.productid = taskObj.productid;
location.routeid = taskObj.route;
location.sn = taskObj.sn; location.sn = taskObj.sn;
_automationLocation.Update(location); _automationLocation.Update(location);
var monitor = _automationFixtureMonitor.Get(f => f.section == taskObj.sectionid);
if (monitor != null)
{
monitor.section = 0;
_automationFixtureMonitor.Update(monitor);
}
} }
}
if (monitor != null && taskObj.action == TaskAction.Step_SXLW_LK)
{
monitor.section = 0;
} }
//上料上下料设备状态为后台控制,CNC是PLC控制
var machineStatus = _automationMachineStatus.Get(f => f.section == taskObj.sectionid && f.auto==0);
if (machineStatus != null)
{
machineStatus.status = (int)Automation.MachineStatus.Waiting;
_automationMachineStatus.Update(machineStatus);
}
} }
if (monitor != null)
{
monitor.status = status;
monitor.route = taskObj.route;
monitor.fixtureguid = taskObj.fixtureguid;
monitor.fixturename = taskObj.fixturename;
_automationFixtureMonitor.Update(monitor);
}
} }
...@@ -335,7 +336,8 @@ namespace Siger.ApiACC.Controllers ...@@ -335,7 +336,8 @@ namespace Siger.ApiACC.Controllers
/// <param name="line"></param> /// <param name="line"></param>
/// <param name="fixture"></param> /// <param name="fixture"></param>
/// <param name="stationDicts"></param> /// <param name="stationDicts"></param>
void AutoProcess(int line,IEnumerable<SigerTrDict> stationDicts) /// <param name="tasklist"></param>
void AutoProcess(int line,IEnumerable<SigerTrDict> stationDicts,siger_automation_task_list tasklist=null)
{ {
var lineMode = _automationLineMode.Get(f => f.projectId == PID && f.section == line); var lineMode = _automationLineMode.Get(f => f.projectId == PID && f.section == line);
if (lineMode==null) if (lineMode==null)
...@@ -345,11 +347,10 @@ namespace Siger.ApiACC.Controllers ...@@ -345,11 +347,10 @@ namespace Siger.ApiACC.Controllers
} }
if (lineMode.mode==0) if (lineMode.mode==0)
{ {
Logger.WriteLineInfo($"AutoProcess 手动模式"); Logger.WriteLineInfo($"AutoProcess 手动模式 不能创建自动任务");
//手动模式时 退出 //手动模式时 退出
return; return;
} }
/* /*
//自动Task任务 顺序 //自动Task任务 顺序
//1.清洗机下料 //1.清洗机下料
...@@ -366,7 +367,7 @@ namespace Siger.ApiACC.Controllers ...@@ -366,7 +367,7 @@ namespace Siger.ApiACC.Controllers
return; return;
} }
// 获取可用 设备状态列表 排除上料工位 // 获取可用 设备状态列表 排除上料工位
var machineStatusList = _automationMachineStatus.GetList(f => f.projectId == PID && !uploadStations.Contains(f.section) && f.enable == 1); var machineStatusList = _automationMachineStatus.GetList(f => f.projectId == PID && f.auto==1 && !uploadStations.Contains(f.section) && f.enable == 1);
if (!machineStatusList.Any()) if (!machineStatusList.Any())
{ {
Logger.WriteLineInfo($"AutoProcess 无可用状态的设备"); Logger.WriteLineInfo($"AutoProcess 无可用状态的设备");
...@@ -378,59 +379,49 @@ namespace Siger.ApiACC.Controllers ...@@ -378,59 +379,49 @@ namespace Siger.ApiACC.Controllers
{ {
if (cleanMachine.status == (int)Automation.MachineStatus.Complated) if (cleanMachine.status == (int)Automation.MachineStatus.Complated)
{ {
Logger.WriteLineInfo($"AutoProcess 有清洗机完成,创建清洗机Task"); Logger.WriteLineError($"AutoProcess 有清洗机{ cleanMachine.section}完成,创建清洗机Task");
var monitor = _automationFixtureMonitor.Get(f => f.section == cleanMachine.section); if (tasklist == null)
if (monitor != null)
{ {
CreateTask(cleanMachine, TaskActionType.Unload, TaskAction.Step_QXJ_LK, monitor.fixtureguid, monitor.ordernumber, monitor.sn, "无程序",monitor.productId, monitor.productCode, monitor.locationId); Logger.WriteLineError($"AutoProcess Tasklist 为空");
return; //完成当前任务 退出 return;
} }
CreateTask(cleanMachine.section, TaskActionType.Unload, TaskAction.Step_QXJ_LK, tasklist.fixtureguid, tasklist.ordercode, tasklist.sn, "无程序", tasklist.productid, tasklist.productcode, tasklist.locationid, tasklist.route);
return; //完成当前任务 退出
} }
} }
//优先级2 :其他设备待上料 (立库->加工中心) //优先级2 :其他设备待上料 (立库->加工中心)
var freeMachine = machineStatusList.FirstOrDefault(f=>f.status==(int)Automation.MachineStatus.Waiting); var freeMachine = machineStatusList.Where(f=>f.status==(int)Automation.MachineStatus.Waiting);
if (freeMachine != null) if (freeMachine != null)
{ {
Logger.WriteLineInfo($"AutoProcess 普通空闲,创建普通设备上料Task"); Logger.WriteLineError($"AutoProcess 普通空闲,创建普通设备上料Task");
var location = SelectLocation(freeMachine.machineid); var location = SelectLocation(freeMachine.Select(s=>s.machineid).ToList());
if (location != null) if (location != null)
{ {
var monitor = _automationFixtureMonitor.Get(f => f.section == freeMachine.section); // * 更新下一个工序到储位
if (monitor == null) var locationObj = _automationLocation.Get(f => f.id == location.lid);
if (locationObj != null)
{ {
_automationFixtureMonitor.Insert(new siger_automation_fixture_tools_monitor var doneRoute = _productRoute.Get(f => f.id == location.route);
if (doneRoute == null)
return;
var productRoutes = _productRoute.GetList(f => f.projectId == PID && f.productId == location.productId && f.status == (int)RowState.Valid && f.serialNumber > doneRoute.serialNumber);
if (!productRoutes.Any())
{ {
projectId = PID, locationObj.route = string.Empty;
productId=location.productId, }
productCode = location.productCode, else
productName = location.productName, {
fixtureguid = location.fixture, var nextRoute = productRoutes.OrderBy(d => d.serialNumber).FirstOrDefault();
fixturename = location.fixturename,
ordernumber = location.ordernumber, locationObj.routeid = nextRoute != null ? nextRoute.id : 0;
locationId = location.location, locationObj.route = nextRoute != null ? nextRoute.name : "";
section = freeMachine.section, }
sn = location.sn, _automationLocation.Update(locationObj);
createtime = DateTime.Now,
updatetime = DateTime.Now CreateTask(location.section, TaskActionType.Load, TaskAction.Step_LK_JGZX, location.fixture, location.ordernumber, location.sn, location.pn, location.productId, location.productCode, location.location,location.route);
}); return; //完成当前任务 退出
}
else
{
monitor.productId = location.productId;
monitor.productCode = location.productCode;
monitor.productName = location.productName;
monitor.fixtureguid = location.fixture;
monitor.fixturename = location.fixturename;
monitor.ordernumber = location.ordernumber;
monitor.locationId = location.location;
monitor.sn = location.sn;
monitor.updatetime = DateTime.Now;
_automationFixtureMonitor.Update(monitor);
} }
CreateTask(freeMachine, TaskActionType.Load, TaskAction.Step_LK_JGZX, location.fixture, location.ordernumber, location.sn, location.pn,location.productId, location.productCode, location.location);
return; //完成当前任务 退出
} }
} }
//优先级3:其他设备下料 (加工中心 ->清洗机) //优先级3:其他设备下料 (加工中心 ->清洗机)
...@@ -439,15 +430,13 @@ namespace Siger.ApiACC.Controllers ...@@ -439,15 +430,13 @@ namespace Siger.ApiACC.Controllers
var fullMachine = machineStatusList.FirstOrDefault(f => f.status == (int)Automation.MachineStatus.Complated); var fullMachine = machineStatusList.FirstOrDefault(f => f.status == (int)Automation.MachineStatus.Complated);
if (fullMachine != null && cleanMachine.status==(int)Automation.MachineStatus.Waiting) if (fullMachine != null && cleanMachine.status==(int)Automation.MachineStatus.Waiting)
{ {
Logger.WriteLineInfo($"AutoProcess 普通空闲,创建普通设备下料Task "); Logger.WriteLineError($"AutoProcess 清洗机空闲,创建普通设备下料到清洗机Task ");
if (tasklist==null)
var monitor = _automationFixtureMonitor.Get(f => f.section == fullMachine.section);
if (monitor == null)
{ {
Logger.WriteLineInfo($"AutoProcess 找不到CNC监控信息"); Logger.WriteLineError($"AutoProcess Tasklist 为空");
return; return;
} }
CreateTask(fullMachine,TaskActionType.Unload, TaskAction.Step_JGZX_QXJ, monitor.fixtureguid, monitor.ordernumber, monitor.sn,"无程序",monitor.productId, monitor.productCode, monitor.locationId); CreateTask(fullMachine.section,TaskActionType.Unload, TaskAction.Step_JGZX_QXJ, tasklist.fixtureguid,tasklist.ordercode, tasklist.sn,tasklist.programnumber,tasklist.productid,tasklist.productcode,tasklist.locationid,tasklist.route);
return; //完成当前任务 退出 return; //完成当前任务 退出
} }
...@@ -458,7 +447,7 @@ namespace Siger.ApiACC.Controllers ...@@ -458,7 +447,7 @@ namespace Siger.ApiACC.Controllers
/// <summary> /// <summary>
/// 创建自动任务 /// 创建自动任务
/// </summary> /// </summary>
/// <param name="machineStatus"></param> /// <param name="section"></param>
/// <param name="actionType"></param> /// <param name="actionType"></param>
/// <param name="taskAction"></param> /// <param name="taskAction"></param>
/// <param name="guid">工装GUID</param> /// <param name="guid">工装GUID</param>
...@@ -466,14 +455,14 @@ namespace Siger.ApiACC.Controllers ...@@ -466,14 +455,14 @@ namespace Siger.ApiACC.Controllers
/// <param name="sn">工件</param> /// <param name="sn">工件</param>
/// <param name="productCode">产品CODE</param> /// <param name="productCode">产品CODE</param>
/// <param name="locationid">储位ID</param> /// <param name="locationid">储位ID</param>
void CreateTask(siger_automation_machine_status machineStatus,TaskActionType actionType, TaskAction taskAction,string guid,string orderno,string sn,string program,int productId,string productCode,int locationid) void CreateTask(int section,TaskActionType actionType, TaskAction taskAction,string guid,string orderno,string sn,string program,int productId,string productCode,int locationid,int route)
{ {
var taskNo = _automationTaskList.CrateTaskNumber(Automation.TaskTrigerType.Auto); var taskNo = _automationTaskList.CrateTaskNumber(Automation.TaskTrigerType.Auto);
_automationTaskList.Insert(new siger_automation_task_list _automationTaskList.Insert(new siger_automation_task_list
{ {
no= taskNo, no= taskNo,
projectId = PID, projectId = PID,
sectionid = machineStatus.section, sectionid = section,
trigger = TaskTrigerType.Auto, trigger = TaskTrigerType.Auto,
action = taskAction, action = taskAction,
actiontype = ExcueType.None, actiontype = ExcueType.None,
...@@ -491,70 +480,107 @@ namespace Siger.ApiACC.Controllers ...@@ -491,70 +480,107 @@ namespace Siger.ApiACC.Controllers
locationid= locationid, locationid= locationid,
ordercode= orderno, ordercode= orderno,
sn= sn, sn= sn,
remark= EnumHelper.GetEnumDesc(taskAction) remark= EnumHelper.GetEnumDesc(taskAction),
route=route
}); });
var monitor = _automationFixtureMonitor.Get(f => f.section == section);
if (monitor == null)
{
_automationFixtureMonitor.Insert(new siger_automation_fixture_tools_monitor
{
projectId=PID,
section=section,
fixtureguid=guid,
productId=productId,
productCode=productCode,
locationId=locationid,
createtime=DateTime.Now,
ordernumber=orderno,
route=route,
status=1,
sn=sn,
taskno=taskNo,
});
}
else
{
monitor.sn = sn;
monitor.route = route;
monitor.locationId = locationid;
monitor.productCode = productCode;
monitor.productId = productId;
monitor.fixtureguid = guid;
monitor.taskno = taskNo;
_automationFixtureMonitor.Update(monitor);
}
if (_unitOfWork.Commit() > 0) if (_unitOfWork.Commit() > 0)
Logger.WriteLineInfo($"CreateTask 工站 完成"); Logger.WriteLineInfo($"CreateTask sectionId:{section}工站 {EnumHelper.GetEnumDesc(taskAction)} 完成");
else else
Logger.WriteLineInfo($"CreateTask 工站 失败"); Logger.WriteLineInfo($"CreateTask sectionId:{section}工站 {EnumHelper.GetEnumDesc(taskAction)}失败");
} }
/// <summary> /// <summary>
/// 自动匹配储位 储位 ->CNC /// 自动匹配储位 储位 ->CNC
/// </summary> /// </summary>
ResponseAutomationLocationRouteInfo SelectLocation(int machine) ResponseAutomationLocationRouteInfo SelectLocation(List<int> machines)
{ {
// 当前空闲设备能加工的产品 // 当前空闲设备能加工的产品
var beats = _productionBeatSet.GetList(f => f.projectID == PID && f.machineID == machine); var beats = _productionBeatSet.GetList(f => f.projectID == PID && machines.Contains(f.machineID) && f.status==(int)RowState.Valid).ToList();
var productIds = beats.Select(f => f.product_name.ToInt()).Distinct().ToList(); var TempList = new List<ResponseAutoRouteInfo>();
foreach (var b in beats)
// 取产品交期最近的订单
var planOrder = _automationFixtureToolsProduct.GetDeliveryOrder(productIds, PID);
if (!planOrder.Any())
{ {
Logger.WriteLineInfo($"SelectLocation 未找到最近订单号信息"); var autoLocation = _automationLocation.Get(f => f.projectId == b.projectID && !string.IsNullOrEmpty(f.sn) && f.routeid == b.route_number.ToInt() && f.productid == b.product_name.ToInt());
return null; if (autoLocation == null)
continue;
TempList.Add(new ResponseAutoRouteInfo
{
FixtureGuid=autoLocation.fixturetools,
FixtureName=autoLocation.fixturename,
Section=b.section_id,
Machine=b.machineID,
Pn=b.process_number,
ProductId=b.product_name.ToInt(),
ProductName=b.product_name_text,
Location=autoLocation.locationid,
Route=b.route_number.ToInt(),
RouteName=b.route_name,
OrderNo=autoLocation.ordernumber,
Sn=autoLocation.sn,
LId=autoLocation.id
});
} }
var order = planOrder.FirstOrDefault();
//TODO 20210126
var beatset = beats.Where(f => f.product_name == order.productId.ToString());
//var location = _automationLocation.GetList(f => f.projectId == PID && f.ordernumber == order.ordernumber && productIds.Contains(f.productid));
//if (!location.Any())
//{
// Logger.WriteLineInfo($"SelectLocation 未找到最近交期订单号{order.ordernumber} 对应产品 {order.productName}的储位信息");
// return null;
//} var ordernos = TempList.Select(f => f.OrderNo).ToList();
//储位有SN 工件
var location = _automationLocation.GetList(f => f.projectId == PID && productIds.Contains(f.productid));
var hasSnloaction = location.Where(f =>!string.IsNullOrEmpty(f.sn));
if (!hasSnloaction.Any())
return null;
var result = location.FirstOrDefault();
var valiateBeat = beatset.FirstOrDefault(f=>f.route_number.ToInt()>result.routenum); // 取产品交期最近的订单
if (valiateBeat==null) var planOrder = _automationFixtureToolsProduct.GetDeliveryOrder(ordernos, PID);
if (!planOrder.Any())
{ {
Logger.WriteLineInfo($"SelectLocation 未找到产品的工艺顺序"); Logger.WriteLineError($"SelectLocation 未找到最近订单号信息");
return null; return null;
} }
var order = planOrder.FirstOrDefault();
var autoRouteInfo = TempList.Where(f => f.OrderNo == order.ordernumber).OrderBy(d=>d.Sn);
var result = autoRouteInfo.FirstOrDefault();
return new ResponseAutomationLocationRouteInfo return new ResponseAutomationLocationRouteInfo
{ {
fixture = result.fixturetools, section=result.Section,
fixturename = result.fixturename, machine=result.Machine,
ordernumber =result.ordernumber, fixture = result.FixtureGuid,
location=result.locationid, fixturename = result.FixtureName,
productId=result.productid, ordernumber =result.OrderNo,
productCode=result.productcode, location=result.Location,
productName = result.productname, productId=result.ProductId,
sn =result.sn, //productCode=result.productcode,
pn= valiateBeat.process_number, productName = result.ProductName,
route=valiateBeat.route_name sn =result.Sn,
pn= result.Pn,
route=result.Route,
lid=result.LId
}; };
} }
......
...@@ -361,6 +361,9 @@ namespace Siger.ApiACC.Controllers ...@@ -361,6 +361,9 @@ namespace Siger.ApiACC.Controllers
[HttpGet] [HttpGet]
public IActionResult GetLocationList(string productcode, int fillsn=0) public IActionResult GetLocationList(string productcode, int fillsn=0)
{ {
var productFix = _automationFixtureToolsProduct.Get(f => f.productcode == productcode);
var locations = _autoLocationRepository.GetFulllocation(ProjectId, fillsn); var locations = _autoLocationRepository.GetFulllocation(ProjectId, fillsn);
return new ObjectResult(locations); return new ObjectResult(locations);
//if (fillsn == 1) //if (fillsn == 1)
......
...@@ -41,9 +41,11 @@ namespace Siger.ApiACC.Controllers ...@@ -41,9 +41,11 @@ namespace Siger.ApiACC.Controllers
private readonly IAutomationFixtureToolsRepository _automationFixtureTools; private readonly IAutomationFixtureToolsRepository _automationFixtureTools;
private readonly IAutomationLocationRepository _automationLocation; private readonly IAutomationLocationRepository _automationLocation;
private readonly IAutomationLineMode _automationLine; private readonly IAutomationLineMode _automationLine;
private readonly IProductRouteRepository _productRoute;
public AutomationOperateController(IUnitOfWork unitOfWork,ISigerProjectLevelSectionRepository sigerProjectLevelSection , ISigerDict sigerDict,IAutomationMachineStatus automationMachineStatus,ISigerProjectMachineAttributionRepository sigerProjectMachineAttribution,IAutomationTaskListRepository automationTaskList, public AutomationOperateController(IUnitOfWork unitOfWork,ISigerProjectLevelSectionRepository sigerProjectLevelSection , ISigerDict sigerDict,IAutomationMachineStatus automationMachineStatus,ISigerProjectMachineAttributionRepository sigerProjectMachineAttribution,IAutomationTaskListRepository automationTaskList,
IProductPlanDetails planDetails,IProductPlanRepository productPlan,IAutomationFixtureMonitor automationFixtureMonitor ,IAutomationFixtureToolsProductRepository automationFixtureToolsProduct,IAutomationFixtureToolsRepository automationFixtureTools, IAutomationLocationRepository automationLocation, IAutomationLineMode automationLine) IProductPlanDetails planDetails,IProductPlanRepository productPlan,IAutomationFixtureMonitor automationFixtureMonitor ,IAutomationFixtureToolsProductRepository automationFixtureToolsProduct,IAutomationFixtureToolsRepository automationFixtureTools, IAutomationLocationRepository automationLocation,
IAutomationLineMode automationLine, IProductRouteRepository productRoute)
{ {
_unitOfWork = unitOfWork; _unitOfWork = unitOfWork;
_sigerProjectLevelSection = sigerProjectLevelSection; _sigerProjectLevelSection = sigerProjectLevelSection;
...@@ -58,6 +60,7 @@ namespace Siger.ApiACC.Controllers ...@@ -58,6 +60,7 @@ namespace Siger.ApiACC.Controllers
_automationFixtureTools = automationFixtureTools; _automationFixtureTools = automationFixtureTools;
_automationLocation = automationLocation; _automationLocation = automationLocation;
_automationLine = automationLine; _automationLine = automationLine;
_productRoute = productRoute;
} }
/// <summary> /// <summary>
...@@ -154,7 +157,7 @@ namespace Siger.ApiACC.Controllers ...@@ -154,7 +157,7 @@ namespace Siger.ApiACC.Controllers
var state = (int)Automation.TaskResultStatus.Waiting; var state = (int)Automation.TaskResultStatus.Waiting;
if (monitor!=null) if (monitor!=null)
{ {
var taskobj = _automationTaskList.Get(f => f.extend1 == monitor.unixtime.ToStr()); var taskobj = _automationTaskList.Get(f => f.no == monitor.taskno);
state = taskobj != null ? taskobj.status : (int)Automation.TaskResultStatus.Waiting; state = taskobj != null ? taskobj.status : (int)Automation.TaskResultStatus.Waiting;
} }
var result = new ResponsePlanlFixtureInfo var result = new ResponsePlanlFixtureInfo
...@@ -207,11 +210,17 @@ namespace Siger.ApiACC.Controllers ...@@ -207,11 +210,17 @@ namespace Siger.ApiACC.Controllers
{ {
throw new BadRequestException(CommonEnum.Fail); throw new BadRequestException(CommonEnum.Fail);
} }
var fixture = _automationFixtureTools.Get(f => f.guid == taskobj.fixtureguid);
if (fixture==null)
{
throw new BadRequestException(AccEnum.FixtureToolsIsNone);
}
var sendToPLC = new RequestPLC var sendToPLC = new RequestPLC
{ {
ProductCode=taskobj.productcode,
LineID=levelsection.parentid, LineID=levelsection.parentid,
RStation = attr.machine, RStation = attr.machine,
Fixture = taskobj.fixtureguid, Fixture = fixture.code,
RequestForm = taskobj.no, RequestForm = taskobj.no,
RobotStep = (int)taskobj.action, RobotStep = (int)taskobj.action,
StorageNo = taskobj.locationid, StorageNo = taskobj.locationid,
...@@ -317,7 +326,6 @@ namespace Siger.ApiACC.Controllers ...@@ -317,7 +326,6 @@ namespace Siger.ApiACC.Controllers
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);
//上料设备状态与PLC 无关, //上料设备状态与PLC 无关,
//需要手动插入 //需要手动插入
_automationMachineStatus.Insert(new siger_automation_machine_status _automationMachineStatus.Insert(new siger_automation_machine_status
...@@ -325,25 +333,15 @@ namespace Siger.ApiACC.Controllers ...@@ -325,25 +333,15 @@ namespace Siger.ApiACC.Controllers
enable = 1, enable = 1,
section = loading.section, section = loading.section,
machineid = machineAttr.machine, machineid = machineAttr.machine,
auto=0,
projectId = ProjectId, projectId = ProjectId,
status = (int)Automation.MachineStatus.Waiting, status = (int)Automation.MachineStatus.Waiting,
updatetime = DateTime.Now updatetime = DateTime.Now
}); });
} }
else if (machineStatus.auto==1)
{
if (machineStatus.enable == 0)
{
throw new BadRequestException(AccEnum.MachineDisable);
}
if (machineStatus.status != (int)Automation.MachineStatus.Waiting)
{
throw new BadRequestException(AccEnum.MachineBusy);
}
}
if (!_automationTaskList.CanTask(ProjectId,loading.section))
{ {
throw new BadRequestException(AccEnum.TaskProcessing); throw new BadRequestException(AccEnum.MachineDisable);
} }
var plandts = _planDetails.Get(f => f.projectId == ProjectId && f.OrderNumber == loading.code); var plandts = _planDetails.Get(f => f.projectId == ProjectId && f.OrderNumber == loading.code);
...@@ -363,9 +361,20 @@ namespace Siger.ApiACC.Controllers ...@@ -363,9 +361,20 @@ namespace Siger.ApiACC.Controllers
{ {
throw new BadRequestException(AccEnum.FixtureToolsIsNone); throw new BadRequestException(AccEnum.FixtureToolsIsNone);
} }
var exitsUpload = _automationTaskList.Get(f => f.send == 0 && f.locationid == loading.locationid);
if (exitsUpload!=null)
{
throw new BadRequestException(AccEnum.FixtureOrderNulll);
}
var taskNo = _automationTaskList.CrateTaskNumber(Automation.TaskTrigerType.Manual); var taskNo = _automationTaskList.CrateTaskNumber(Automation.TaskTrigerType.Manual);
var sn = _automationTaskList.CreateRandonSn(plan.product_code); var sn = _automationTaskList.CreateRandonSn(plan.product_code);
//上料 指定的第一道工序
var route = _productRoute.GetList(f => f.productId == plan.product_id && f.status==(int)RowState.Valid, "serialNumber",false).FirstOrDefault();
if (route==null)
{
throw new BadRequestException(AccEnum.ProductRouteMissing);
}
var unixtime = UnixTimeHelper.GetNow(); var unixtime = UnixTimeHelper.GetNow();
_automationTaskList.Insert(new siger_automation_task_list _automationTaskList.Insert(new siger_automation_task_list
{ {
...@@ -392,6 +401,7 @@ namespace Siger.ApiACC.Controllers ...@@ -392,6 +401,7 @@ namespace Siger.ApiACC.Controllers
processid=0, processid=0,
programnumber="", programnumber="",
remark ="手动任务-准备上料", remark ="手动任务-准备上料",
route=route.id,
extend1= unixtime.ToString() extend1= unixtime.ToString()
}); });
...@@ -403,7 +413,7 @@ namespace Siger.ApiACC.Controllers ...@@ -403,7 +413,7 @@ namespace Siger.ApiACC.Controllers
_automationFixtureMonitor.Insert(new siger_automation_fixture_tools_monitor _automationFixtureMonitor.Insert(new siger_automation_fixture_tools_monitor
{ {
fixtureguid = fixtureToolsObj.FixtureGuid, fixtureguid = fixtureToolsObj.FixtureGuid,
fixturename = fixtureToolsObj.FixtureName, fixturename = fixtureToolsObj.FixtureCode,
projectId = ProjectId, projectId = ProjectId,
section = loading.section, section = loading.section,
sn = sn, sn = sn,
...@@ -411,11 +421,13 @@ namespace Siger.ApiACC.Controllers ...@@ -411,11 +421,13 @@ namespace Siger.ApiACC.Controllers
updatetime = DateTime.Now, updatetime = DateTime.Now,
status = (int)Automation.MachineStatus.Produce, status = (int)Automation.MachineStatus.Produce,
productId = plan.product_id, productId = plan.product_id,
productCode = plan.product_code, productCode = plan.product_code,
productName = plan.product_name, productName = plan.product_name,
ordernumber = plandts.OrderNumber, ordernumber = plandts.OrderNumber,
locationId = fixtureToolsObj.Location, locationId = fixtureToolsObj.Location,
unixtime = unixtime unixtime = unixtime,
route= route.id,
taskno=taskNo
}); });
} }
else else
...@@ -430,13 +442,15 @@ namespace Siger.ApiACC.Controllers ...@@ -430,13 +442,15 @@ namespace Siger.ApiACC.Controllers
monitor.ordernumber = plandts.OrderNumber; monitor.ordernumber = plandts.OrderNumber;
monitor.locationId = fixtureToolsObj.Location; monitor.locationId = fixtureToolsObj.Location;
monitor.unixtime = unixtime; monitor.unixtime = unixtime;
monitor.route = route.id;
monitor.taskno = taskNo;
_automationFixtureMonitor.Update(monitor); _automationFixtureMonitor.Update(monitor);
} }
if (_unitOfWork.Commit() > 0) if (_unitOfWork.Commit() > 0)
{ {
Logger.WriteLineError($"手动任务创建成功-{Siger.Middlelayer.Common.Helpers.EnumHelper.GetEnumDesc(Automation.TaskAction.Step_LK_SXLW)}"); Logger.WriteLineError($"准备上料任务:{taskNo}创建成功-{EnumHelper.GetEnumDesc(Automation.TaskAction.Step_LK_SXLW)}");
return new ObjectResult(CommonEnum.Succefull); return new ObjectResult(CommonEnum.Succefull);
} }
else else
...@@ -462,19 +476,17 @@ namespace Siger.ApiACC.Controllers ...@@ -462,19 +476,17 @@ namespace Siger.ApiACC.Controllers
{ {
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.MachineOnFree);
//}
//if (machineStatus.status == (int)Automation.MachineStatus.Complated)
//{
// throw new BadRequestException(AccEnum.MachineProCompalate);
//}
if (!_automationTaskList.CanTask(ProjectId, assemble.section))
{ {
throw new BadRequestException(AccEnum.TaskProcessing); throw new BadRequestException(AccEnum.MachineOnFree);
}
if (machineStatus.status == (int)Automation.MachineStatus.Complated)
{
throw new BadRequestException(AccEnum.MachineProCompalate);
} }
machineStatus.status = (int)Automation.MachineStatus.Waiting;
//创建 安装完成动作 //创建 安装完成动作
var monitor = _automationFixtureMonitor.Get(f => f.projectId == ProjectId && f.section == assemble.section); var monitor = _automationFixtureMonitor.Get(f => f.projectId == ProjectId && f.section == assemble.section);
if (monitor==null) if (monitor==null)
...@@ -510,10 +522,12 @@ namespace Siger.ApiACC.Controllers ...@@ -510,10 +522,12 @@ namespace Siger.ApiACC.Controllers
remark = "手动任务-安装完成", remark = "手动任务-安装完成",
}); });
monitor.taskno = taskNo;
_automationFixtureMonitor.Update(monitor);
if (_unitOfWork.Commit() > 0) if (_unitOfWork.Commit() > 0)
{ {
Logger.WriteLineError($"手动任务创建成功-{Siger.Middlelayer.Common.Helpers.EnumHelper.GetEnumDesc(Automation.TaskAction.Step_SXLW_LK)}"); Logger.WriteLineError($"安装完成任务{taskNo}创建成功-{EnumHelper.GetEnumDesc(Automation.TaskAction.Step_SXLW_LK)}");
return new ObjectResult(CommonEnum.Succefull); return new ObjectResult(CommonEnum.Succefull);
} }
else else
...@@ -557,11 +571,12 @@ namespace Siger.ApiACC.Controllers ...@@ -557,11 +571,12 @@ namespace Siger.ApiACC.Controllers
//1. 有检验状态 (立库-》检验工位) //1. 有检验状态 (立库-》检验工位)
//2. 无检验状态 (立库-》上下料工位) //2. 无检验状态 (立库-》上下料工位)
var taskNo = _automationTaskList.CrateTaskNumber(Automation.TaskTrigerType.Manual); var taskNo = _automationTaskList.CrateTaskNumber(Automation.TaskTrigerType.Manual);
var action = lineMode.inspect == 1 ? Automation.TaskAction.Step_LK_CJT : Automation.TaskAction.Step_LK_SXLW;
_automationTaskList.Insert(new siger_automation_task_list _automationTaskList.Insert(new siger_automation_task_list
{ {
no = taskNo, no = taskNo,
action = lineMode.inspect==1?Automation.TaskAction.Step_LK_CJT: Automation.TaskAction.Step_LK_SXLW, action = action,
actiontype = Automation.ExcueType.None, actiontype = Automation.ExcueType.None,
triggertime = DateTime.Now, triggertime = DateTime.Now,
tasktype = Automation.TaskActionType.Load, tasktype = Automation.TaskActionType.Load,
...@@ -581,7 +596,7 @@ namespace Siger.ApiACC.Controllers ...@@ -581,7 +596,7 @@ namespace Siger.ApiACC.Controllers
productcode = location.productcode, productcode = location.productcode,
processid = 0, processid = 0,
programnumber = "", programnumber = "",
remark = "手动任务-准备料", remark = "手动任务-准备料",
extend1= unixtime.ToStr() extend1= unixtime.ToStr()
}); });
...@@ -603,13 +618,13 @@ namespace Siger.ApiACC.Controllers ...@@ -603,13 +618,13 @@ namespace Siger.ApiACC.Controllers
productName = location.productname, productName = location.productname,
ordernumber = location.ordernumber, ordernumber = location.ordernumber,
locationId = location.locationid, locationId = location.locationid,
unixtime= unixtime unixtime= unixtime,
taskno= taskNo
}); });
} }
else else
{ {
monitor.sn = location.sn; monitor.sn = location.sn;
monitor.updatetime = DateTime.Now; monitor.updatetime = DateTime.Now;
monitor.status = (int)Automation.MachineStatus.Produce; monitor.status = (int)Automation.MachineStatus.Produce;
monitor.productId = location.productid; monitor.productId = location.productid;
...@@ -618,11 +633,13 @@ namespace Siger.ApiACC.Controllers ...@@ -618,11 +633,13 @@ namespace Siger.ApiACC.Controllers
monitor.ordernumber = location.ordernumber; monitor.ordernumber = location.ordernumber;
monitor.locationId = location.locationid; monitor.locationId = location.locationid;
monitor.unixtime = unixtime; monitor.unixtime = unixtime;
monitor.taskno = taskNo;
_automationFixtureMonitor.Update(monitor); _automationFixtureMonitor.Update(monitor);
} }
if (_unitOfWork.Commit() > 0) if (_unitOfWork.Commit() > 0)
{ {
Logger.WriteLineError($"准备下料任务{taskNo}创建成功-{EnumHelper.GetEnumDesc(action)}");
return new ObjectResult(CommonEnum.Succefull); return new ObjectResult(CommonEnum.Succefull);
} }
else else
...@@ -660,16 +677,12 @@ namespace Siger.ApiACC.Controllers ...@@ -660,16 +677,12 @@ namespace Siger.ApiACC.Controllers
{ {
throw new BadRequestException(AccEnum.MonitorNotfound); throw new BadRequestException(AccEnum.MonitorNotfound);
} }
//移出 上料位
monitor.section = 0;
var location = _automationLocation.Get(f => f.id == monitor.locationId); var location = _automationLocation.Get(f => f.id == monitor.locationId);
if (location!=null) if (location!=null)
{ {
location.sn = ""; location.sn = "";
_automationLocation.Update(location); _automationLocation.Update(location);
} }
var taskNo = _automationTaskList.CrateTaskNumber(Automation.TaskTrigerType.Manual); var taskNo = _automationTaskList.CrateTaskNumber(Automation.TaskTrigerType.Manual);
_automationTaskList.Insert(new siger_automation_task_list _automationTaskList.Insert(new siger_automation_task_list
{ {
...@@ -697,9 +710,14 @@ namespace Siger.ApiACC.Controllers ...@@ -697,9 +710,14 @@ namespace Siger.ApiACC.Controllers
remark = "手动任务-拆卸完成", remark = "手动任务-拆卸完成",
}); });
//移出 上料位
monitor.section = 0;
monitor.taskno = taskNo;
_automationFixtureMonitor.Update(monitor);
if (_unitOfWork.Commit() > 0) if (_unitOfWork.Commit() > 0)
{ {
Logger.WriteLineError($"手动任务-拆卸完成-{Siger.Middlelayer.Common.Helpers.EnumHelper.GetEnumDesc(Automation.TaskAction.Step_SXLW_LK)}"); Logger.WriteLineError($"拆卸完成任务{taskNo}创建成功-{EnumHelper.GetEnumDesc(Automation.TaskAction.Step_SXLW_LK)}");
return new ObjectResult(CommonEnum.Succefull); return new ObjectResult(CommonEnum.Succefull);
} }
else else
......
...@@ -10,19 +10,23 @@ using Siger.Middlelayer.AccRepository.Response; ...@@ -10,19 +10,23 @@ using Siger.Middlelayer.AccRepository.Response;
using Siger.ApiCommon.Result; using Siger.ApiCommon.Result;
using Siger.Middlelayer.Common; using Siger.Middlelayer.Common;
using Siger.Middlelayer.Share.Enum.ModuleEnum; 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 // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace Siger.ApiACC.Controllers namespace Siger.ApiACC.Controllers
{ {
public class AutomationStateController : BaseController public class AutomationStateController : BaseController
{ {
private readonly IUnitOfWork _unitOfWork;
private readonly ISigerProjectLevelSectionRepository _sigerProjectLevelSection; private readonly ISigerProjectLevelSectionRepository _sigerProjectLevelSection;
private readonly IAutomationMachineStatus _automationMachineStatus; private readonly IAutomationMachineStatus _automationMachineStatus;
private readonly IAutomationTaskListRepository _automationTaskList; private readonly IAutomationTaskListRepository _automationTaskList;
private readonly IAutomationFixtureMonitor _automationFixtureMonitor; 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; _sigerProjectLevelSection = sigerProjectLevelSection;
_automationMachineStatus = automationMachineStatus; _automationMachineStatus = automationMachineStatus;
_automationTaskList = automationTaskList; _automationTaskList = automationTaskList;
...@@ -58,7 +62,7 @@ namespace Siger.ApiACC.Controllers ...@@ -58,7 +62,7 @@ namespace Siger.ApiACC.Controllers
fixtureCode="", fixtureCode="",
fixtureName="", fixtureName="",
lastupdate="", lastupdate="",
status=(int)Automation.MachineStatus.Waiting, machineStatus=d.status,
linemode=d.linemode linemode=d.linemode
}; };
...@@ -71,6 +75,7 @@ namespace Siger.ApiACC.Controllers ...@@ -71,6 +75,7 @@ namespace Siger.ApiACC.Controllers
item.fixtureCode = fixture.fixtureguid; item.fixtureCode = fixture.fixtureguid;
item.fixtureName = fixture.fixturename; item.fixtureName = fixture.fixturename;
item.machineStatus = d.status;
item.status = fixture.status; item.status = fixture.status;
} }
result.Add(item); result.Add(item);
...@@ -80,9 +85,9 @@ namespace Siger.ApiACC.Controllers ...@@ -80,9 +85,9 @@ namespace Siger.ApiACC.Controllers
{ {
sum=new ResponseAutomationMachineStatusTotal { sum=new ResponseAutomationMachineStatusTotal {
waittingTotal =result.Where(f=>f.status==(int)Automation.MachineStatus.Waiting).Count(), waittingTotal =result.Where(f=>f.machineStatus == (int)Automation.MachineStatus.Waiting).Count(),
produceTotal= result.Where(f => f.status == (int)Automation.MachineStatus.Produce).Count(), produceTotal= result.Where(f => f.machineStatus == (int)Automation.MachineStatus.Produce).Count(),
complateTotal= result.Where(f => f.status == (int)Automation.MachineStatus.Complated).Count(), complateTotal= result.Where(f => f.machineStatus == (int)Automation.MachineStatus.Complated).Count(),
disableTotal= result.Where(f => f.enable ==0).Count(), disableTotal= result.Where(f => f.enable ==0).Count(),
}, },
dts=result dts=result
...@@ -90,16 +95,35 @@ namespace Siger.ApiACC.Controllers ...@@ -90,16 +95,35 @@ namespace Siger.ApiACC.Controllers
return new ObjectResult(output); return new ObjectResult(output);
} }
[HttpGet] [HttpGet]
public IActionResult GetTasklist(int section, int tasktype, string productCode, string taskno, string sn, int status, int actionType, string triggertime, string complatetime,int page,int pageSize) public IActionResult GetTasklist(int section, int tasktype, string productCode, string taskno, string sn, int status, int actionType, string triggerbegin,string triggerend, string complatebegin,string complatend,int page,int pageSize)
{ {
var ids = new List<int>(); var ids = new List<int>();
if (section != 0) if (section != 0)
{ {
ids = _sigerProjectLevelSection.GetLevelSectionIds(section, ProjectId).ToList(); ids = _sigerProjectLevelSection.GetLevelSectionIds(section, ProjectId).ToList();
} }
var resulst = _automationTaskList.GetTasklistPagedList(ids, tasktype, productCode, taskno, sn, status, actionType, triggertime, complatetime,ProjectId,page,pageSize); var resulst = _automationTaskList.GetTasklistPagedList(ids, tasktype, productCode, taskno, sn, status, actionType, triggerbegin, triggerend, complatebegin, complatend, ProjectId,page,pageSize);
return new PagedObjectResult(resulst, resulst.Total, page, pageSize); 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 ...@@ -320,16 +320,11 @@ namespace Siger.ApiACC.Controllers
private void CreateTaskList(int section, int productid, string productcode, string sn, int routeid) 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); var taskNo = _automationTaskList.CrateTaskNumber(Automation.TaskTrigerType.Manual);
_automationTaskList.Insert(new siger_automation_task_list _automationTaskList.Insert(new siger_automation_task_list
...@@ -357,6 +352,7 @@ namespace Siger.ApiACC.Controllers ...@@ -357,6 +352,7 @@ namespace Siger.ApiACC.Controllers
programnumber = "", programnumber = "",
remark = "质量检验", remark = "质量检验",
}); });
monitor.taskno = taskNo;
_unitOfWork.Commit(); _unitOfWork.Commit();
} }
......
...@@ -64,8 +64,7 @@ namespace Siger.ApiACC.Controllers ...@@ -64,8 +64,7 @@ namespace Siger.ApiACC.Controllers
[HttpGet] [HttpGet]
public IActionResult GetSn(int sectionid) 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). var monitor = _fixtureMonitor.Get(sectionid);
FirstOrDefault();
return new ObjectResult(monitor?.sn ?? ""); return new ObjectResult(monitor?.sn ?? "");
} }
} }
......
...@@ -50,11 +50,18 @@ namespace Siger.ApiACC.Tasks ...@@ -50,11 +50,18 @@ namespace Siger.ApiACC.Tasks
if (attr == null) if (attr == null)
return; return;
var fixtrue = dbhelper.GetFixture(task.fixtureguid);
if (fixtrue==null)
{
Logger.WriteLineError($"自动工装未找到");
return;
}
var sendToPLC = new RequestPLC var sendToPLC = new RequestPLC
{ {
ProductCode=task.productcode,
LineID= levelsction.parentid, LineID= levelsction.parentid,
RStation = attr.machine, RStation = attr.machine,
Fixture = task.fixtureguid, Fixture = fixtrue.code,
RequestForm = task.no, RequestForm = task.no,
RobotStep = (int)task.action, RobotStep = (int)task.action,
StorageNo = task.locationid, StorageNo = task.locationid,
......
...@@ -70,6 +70,10 @@ namespace Siger.ApiACC.Tasks ...@@ -70,6 +70,10 @@ namespace Siger.ApiACC.Tasks
{ {
return AccDbContext.siger_project_machine_attribution.FirstOrDefault(f => f.station==section && f.status==1); 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() public void Dispose()
{ {
CncDbContext?.Dispose(); CncDbContext?.Dispose();
......
...@@ -23,14 +23,16 @@ namespace Siger.ApiCNC.Controllers ...@@ -23,14 +23,16 @@ namespace Siger.ApiCNC.Controllers
private readonly IProductionBeatSetRepository _beatSetRepository; private readonly IProductionBeatSetRepository _beatSetRepository;
private readonly ISigerProjectMachineRepository _machineRepository; private readonly ISigerProjectMachineRepository _machineRepository;
private readonly ISigerProjectProductRepository _productRepository; private readonly ISigerProjectProductRepository _productRepository;
private readonly IProductRouteRepository _productRoute;
public BeatAllocationController(IUnitOfWork unitOfWork, IProductionBeatSetRepository beatSetRepository, ISigerProjectMachineRepository machineRepository, public BeatAllocationController(IUnitOfWork unitOfWork, IProductionBeatSetRepository beatSetRepository, ISigerProjectMachineRepository machineRepository,
ISigerProjectProductRepository productRepository) ISigerProjectProductRepository productRepository, IProductRouteRepository productRoute)
{ {
_unitOfWork = unitOfWork; _unitOfWork = unitOfWork;
_beatSetRepository = beatSetRepository; _beatSetRepository = beatSetRepository;
_machineRepository = machineRepository; _machineRepository = machineRepository;
_productRepository = productRepository; _productRepository = productRepository;
_productRoute = productRoute;
} }
[HttpGet] [HttpGet]
...@@ -43,6 +45,7 @@ namespace Siger.ApiCNC.Controllers ...@@ -43,6 +45,7 @@ namespace Siger.ApiCNC.Controllers
var validMachines = _machineRepository.GetLevelSectionNames(sectionID, ProjectId); var validMachines = _machineRepository.GetLevelSectionNames(sectionID, ProjectId);
foreach (var time in data.Data) foreach (var time in data.Data)
{ {
var route = _productRoute.Get(f => f.id == time.route_number.ToInt());
var entity = Mapper<ResponseBeatSet, ResponseBeatSet>.Map(time); var entity = Mapper<ResponseBeatSet, ResponseBeatSet>.Map(time);
var section = validMachines.FirstOrDefault(q => q.machine_id == time.machineID); var section = validMachines.FirstOrDefault(q => q.machine_id == time.machineID);
if (section != null) if (section != null)
...@@ -50,6 +53,10 @@ namespace Siger.ApiCNC.Controllers ...@@ -50,6 +53,10 @@ namespace Siger.ApiCNC.Controllers
entity.sectionName = section.machine_name; entity.sectionName = section.machine_name;
entity.stationName = section.lastSecondSectionTitle + "-" + section.lastSectionTitle; entity.stationName = section.lastSecondSectionTitle + "-" + section.lastSectionTitle;
} }
if (route!=null)
{
entity.routeName = route.name;
}
list.Add(entity); list.Add(entity);
} }
return new PagedObjectResult(list, data.Total, page, pagesize); return new PagedObjectResult(list, data.Total, page, pagesize);
...@@ -104,6 +111,11 @@ namespace Siger.ApiCNC.Controllers ...@@ -104,6 +111,11 @@ namespace Siger.ApiCNC.Controllers
{ {
throw new BadRequestException(RequestEnum.ProductNotFound); throw new BadRequestException(RequestEnum.ProductNotFound);
} }
var route = _productRoute.Get(f =>f.id==request.route_id);
if (route==null)
{
throw new BadRequestException(RequestEnum.RouteNotFound);
}
var beatSet = new siger_project_beat_set var beatSet = new siger_project_beat_set
{ {
daily_standard_output = request.daily_standard_output, daily_standard_output = request.daily_standard_output,
...@@ -117,8 +129,8 @@ namespace Siger.ApiCNC.Controllers ...@@ -117,8 +129,8 @@ namespace Siger.ApiCNC.Controllers
standard_besat = request.standard_besat, standard_besat = request.standard_besat,
projectID = ProjectId, projectID = ProjectId,
changemodeltime = request.time_num.ToInt(), changemodeltime = request.time_num.ToInt(),
route_number = request.route_number.ToStr(), route_number = request.route_id.ToStr(),
route_name = request.route_name, route_name = route.name,
updown_besat = request.updown_besat.ToDouble(), updown_besat = request.updown_besat.ToDouble(),
yieldrate = request.yieldratio, yieldrate = request.yieldratio,
start_time = timSet ? start : DateTime.MinValue, start_time = timSet ? start : DateTime.MinValue,
......
...@@ -167,5 +167,7 @@ namespace Siger.Middlelayer.AccRepository ...@@ -167,5 +167,7 @@ namespace Siger.Middlelayer.AccRepository
public DbSet<siger_automation_produce_history> siger_automation_produce_history { get; set; } 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_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 ...@@ -11,7 +11,7 @@ namespace Siger.Middlelayer.AccRepository.Entities
/// </summary> /// </summary>
public string fixtureguid { get; set; } public string fixtureguid { get; set; }
/// <summary> /// <summary>
/// 工装名称 /// 工装编号
/// </summary> /// </summary>
public string fixturename { get; set; } public string fixturename { get; set; }
/// <summary> /// <summary>
...@@ -50,5 +50,9 @@ namespace Siger.Middlelayer.AccRepository.Entities ...@@ -50,5 +50,9 @@ namespace Siger.Middlelayer.AccRepository.Entities
public string productName { get; set; } public string productName { get; set; }
public int locationId { get; set; } public int locationId { get; set; }
public int unixtime { get; set; } public int unixtime { get; set; }
/// <summary>
/// 当前任务
/// </summary>
public string taskno { get; set; }
} }
} }
...@@ -30,5 +30,10 @@ namespace Siger.Middlelayer.AccRepository.Entities ...@@ -30,5 +30,10 @@ namespace Siger.Middlelayer.AccRepository.Entities
/// </summary> /// </summary>
public string program { get; set; } public string program { get; set; }
/// <summary>
/// 1: 自动设备 0:上下料设备
/// </summary>
public int auto { get; set; }
} }
} }
...@@ -103,5 +103,7 @@ namespace Siger.Middlelayer.AccRepository.Entities ...@@ -103,5 +103,7 @@ namespace Siger.Middlelayer.AccRepository.Entities
public string remark { get; set; } public string remark { get; set; }
public string extend1 { get; set; } public string extend1 { get; set; }
public int route { get; set; }
} }
} }
...@@ -67,8 +67,8 @@ namespace Siger.Middlelayer.AccRepository.Entities ...@@ -67,8 +67,8 @@ namespace Siger.Middlelayer.AccRepository.Entities
public int changemodeltime { get; set; } public int changemodeltime { get; set; }
/// <summary> /// <summary>
/// 工序顺序 /// 工序ID Route.Id
/// </summary> /// </summary>
public string route_number { get; set; } = ""; public string route_number { get; set; } = "";
/// <summary> /// <summary>
......
...@@ -103,11 +103,11 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -103,11 +103,11 @@ namespace Siger.Middlelayer.AccRepository.Repositories
/// <param name="productIds"></param> /// <param name="productIds"></param>
/// <param name="projectId"></param> /// <param name="projectId"></param>
/// <returns></returns> /// <returns></returns>
public IEnumerable<ResponseAutomationPlanOrder> GetDeliveryOrder(List<int>productIds,int projectId) public IEnumerable<ResponseAutomationPlanOrder> GetDeliveryOrder(List<string>Ordernums,int projectId)
{ {
var query = from d in _context.siger_project_product_plan_detail var query = from d in _context.siger_project_product_plan_detail
join p in _context.siger_project_product_plan on d.PlanId equals p.id join p in _context.siger_project_product_plan on d.PlanId equals p.id
where d.projectId == projectId && productIds.Contains(p.product_id) && d.status != (int)RowState.Invalid && p.status != (int)RowState.Invalid where d.projectId == projectId && Ordernums.Contains(d.OrderNumber) && d.status != (int)RowState.Invalid && p.status != (int)RowState.Invalid
select new ResponseAutomationPlanOrder select new ResponseAutomationPlanOrder
{ {
productId=p.product_id, productId=p.product_id,
...@@ -136,7 +136,8 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -136,7 +136,8 @@ namespace Siger.Middlelayer.AccRepository.Repositories
ProductName = p.product_name, ProductName = p.product_name,
Url=pd.image, Url=pd.image,
FixtureName=t.name, FixtureName=t.name,
FixtureGuid=t.code, FixtureGuid=t.guid,
FixtureCode=t.code,
ProductCode =q!=null? q.productcode:"", ProductCode =q!=null? q.productcode:"",
Location =l!=null? l.locationid:0, Location =l!=null? l.locationid:0,
}; };
......
...@@ -33,7 +33,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -33,7 +33,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories
join w in _context.siger_wms_storage on l.storageid equals w.id join w in _context.siger_wms_storage on l.storageid equals w.id
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
from u in uu.DefaultIfEmpty() from u in uu.DefaultIfEmpty()
join r in _context.siger_project_beat_set on q.routeid equals r.id into rr join r in _context.siger_project_product_route on q.routeid equals r.id into rr
from r in rr.DefaultIfEmpty() from r in rr.DefaultIfEmpty()
where q.projectId == projectid && q.status == (int)RowState.Valid where q.projectId == projectid && q.status == (int)RowState.Valid
select new ResponseAutomationLocation select new ResponseAutomationLocation
...@@ -56,8 +56,9 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -56,8 +56,9 @@ namespace Siger.Middlelayer.AccRepository.Repositories
status = q.status, status = q.status,
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 = q.sn ?? "", sn = q.sn ?? "",
route = r.route_name ?? "", route = r.name ?? "",
routenumber = r == null ? "" : r.route_number.ToString(), routenumber = r == null ? "" : r.serialNumber.ToString(),
routeid=q.routeid,
cate_guid = c.guid ?? "", cate_guid = c.guid ?? "",
categoryId = c == null ? 0 : c.id categoryId = c == null ? 0 : c.id
}; };
...@@ -238,42 +239,64 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -238,42 +239,64 @@ namespace Siger.Middlelayer.AccRepository.Repositories
public IEnumerable<ResponseAutomationLocationList> GetFulllocation(int projectId,int full) public IEnumerable<ResponseAutomationLocationList> GetFulllocation(int projectId,int full)
{ {
var query = from q in _context.siger_automation_location //获取有SN 的储位
join t in _context.siger_automation_fixture_tools on q.fixturetools equals t.guid if (full==1)
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
{
id = q.id,
typeid = t.id,
fixtureguid = t.guid,
locationid = l.locationid,
location = l.realname,
locationcode = l.serial_number,
wavehouseid = w.id,
wavehouse = w.name,
wavehousecode = w.serial_number,
fixturetoolid = t.id,
code = t.code,
name = t.name,
materialsn = q.sn ?? ""
};
Expression<Func<ResponseAutomationLocationList, bool>> locationidExpression = f => true;
if (full != 0)
{ {
locationidExpression = q => !string.IsNullOrEmpty(q.materialsn); var query = from q in _context.siger_automation_location
join t in _context.siger_automation_fixture_tools on q.fixturetools equals t.guid
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 && !string.IsNullOrEmpty(q.sn)
&& q.status == (int)RowState.Valid&& t.status == (int)RowState.Valid
&& l.status == (int)RowState.Valid && w.status == (int)RowState.Valid
select new ResponseAutomationLocationList
{
id = q.id,
typeid = t.id,
fixtureguid = t.guid,
locationid = l.locationid,
location = l.realname,
locationcode = l.serial_number,
wavehouseid = w.id,
wavehouse = w.name,
wavehousecode = w.serial_number,
fixturetoolid = t.id,
code = t.code,
name = t.name,
materialsn = q.sn
};
Expression<Func<ResponseAutomationLocationList, bool>> locationidExpression = f => true;
return query.Where(locationidExpression);
}else }else
{ {
locationidExpression = q => string.IsNullOrEmpty(q.materialsn); //选择SN为空的储位
var query = from q in _context.siger_automation_location
join t in _context.siger_automation_fixture_tools on q.fixturetools equals t.guid
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 && string.IsNullOrEmpty(q.sn)
&& q.status == (int)RowState.Valid && t.status == (int)RowState.Valid
&& l.status == (int)RowState.Valid&& w.status == (int)RowState.Valid
select new ResponseAutomationLocationList
{
id = q.id,
typeid = t.id,
fixtureguid = t.guid,
locationid = l.locationid,
location = l.realname,
locationcode = l.serial_number,
wavehouseid = w.id,
wavehouse = w.name,
wavehousecode = w.serial_number,
fixturetoolid = t.id,
code = t.code,
name = t.name,
materialsn = q.sn
};
Expression<Func<ResponseAutomationLocationList, bool>> locationidExpression = f => true;
return query.Where(locationidExpression);
} }
return query.Where(locationidExpression);
} }
} }
} }
...@@ -29,7 +29,6 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -29,7 +29,6 @@ namespace Siger.Middlelayer.AccRepository.Repositories
{ {
//已经下发,并且任务完成 //已经下发,并且任务完成
var taskObjs = _context.siger_automation_task_list.Where(f => f.projectId == projectId && f.send==0 ); var taskObjs = _context.siger_automation_task_list.Where(f => f.projectId == projectId && f.send==0 );
if (taskObjs.Any()) if (taskObjs.Any())
{ {
return false; return false;
...@@ -90,10 +89,12 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -90,10 +89,12 @@ 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 var query = from q in _context.siger_automation_task_list
join t in _context.siger_automation_fixture_tools on q.fixtureguid equals t.guid join t in _context.siger_automation_fixture_tools on q.fixtureguid equals t.guid
join r in _context.siger_project_product_route on q.route equals r.id into rtemp
from r in rtemp.DefaultIfEmpty()
join s in _context.siger_project_level_section on q.sectionid equals s.id join s in _context.siger_project_level_section on q.sectionid equals s.id
join lv in _context.siger_project_level_section on s.parentid equals lv.id join lv in _context.siger_project_level_section on s.parentid equals lv.id
where q.projectId == projectid where q.projectId == projectid
...@@ -117,7 +118,8 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -117,7 +118,8 @@ namespace Siger.Middlelayer.AccRepository.Repositories
ordernumber=q.ordercode, ordernumber=q.ordercode,
productCode=q.productcode, productCode=q.productcode,
program=q.programnumber, program=q.programnumber,
route=q.remark, route=r!=null?$"{r.serialNumber}-{r.name}":"",
send=q.send,
tasktype=EnumHelper.GetEnumDesc(q.tasktype), tasktype=EnumHelper.GetEnumDesc(q.tasktype),
status=q.status, status=q.status,
...@@ -153,15 +155,15 @@ namespace Siger.Middlelayer.AccRepository.Repositories ...@@ -153,15 +155,15 @@ namespace Siger.Middlelayer.AccRepository.Repositories
actionTypeExpression = q => q.actionTypeid==actionType; actionTypeExpression = q => q.actionTypeid==actionType;
} }
Expression<Func<ResponseAutomationTasklist, bool>> triggerTimeTypeExpression = f => true; 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; 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) var expression = sectonsExpression.And(taskTypeExpression).And(productCodeExpression).And(tasknoExpression).And(snExpression)
......
...@@ -37,7 +37,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories.Interface ...@@ -37,7 +37,7 @@ namespace Siger.Middlelayer.AccRepository.Repositories.Interface
/// <param name="productIds"></param> /// <param name="productIds"></param>
/// <param name="projectId"></param> /// <param name="projectId"></param>
/// <returns></returns> /// <returns></returns>
IEnumerable<ResponseAutomationPlanOrder> GetDeliveryOrder(List<int> productIds, int projectId); IEnumerable<ResponseAutomationPlanOrder> GetDeliveryOrder(List<string> Ordernums, int projectId);
} }
} }
...@@ -26,6 +26,6 @@ namespace Siger.Middlelayer.AccRepository.Repositories.Interface ...@@ -26,6 +26,6 @@ namespace Siger.Middlelayer.AccRepository.Repositories.Interface
string CreateRandonSn(string productCode); 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 ...@@ -9,7 +9,7 @@ namespace Siger.Middlelayer.AccRepository.Request
{ {
[Required(ErrorMessage = "guidNotNull")] [Required(ErrorMessage = "guidNotNull")]
/// <summary> /// <summary>
/// 任务列表GUID /// 任务列表taskNo
/// </summary> /// </summary>
public string guid { get; set; } public string guid { get; set; }
[Required(ErrorMessage = "status")] [Required(ErrorMessage = "status")]
......
...@@ -6,6 +6,7 @@ namespace Siger.Middlelayer.AccRepository.Request ...@@ -6,6 +6,7 @@ namespace Siger.Middlelayer.AccRepository.Request
{ {
public class RequestPLC public class RequestPLC
{ {
public string ProductCode { get; set; }
/// <summary> /// <summary>
/// 工件唯一识别SN /// 工件唯一识别SN
/// </summary> /// </summary>
......
...@@ -31,6 +31,8 @@ namespace Siger.Middlelayer.AccRepository.Response ...@@ -31,6 +31,8 @@ namespace Siger.Middlelayer.AccRepository.Response
public class ResponseAutomationLocationRouteInfo public class ResponseAutomationLocationRouteInfo
{ {
public int section { get; set; }
public int machine { get; set; }
public string fixture { get; set; } public string fixture { get; set; }
public string fixturename { get; set; } public string fixturename { get; set; }
public string ordernumber { get; set; } public string ordernumber { get; set; }
...@@ -39,8 +41,35 @@ namespace Siger.Middlelayer.AccRepository.Response ...@@ -39,8 +41,35 @@ namespace Siger.Middlelayer.AccRepository.Response
public int productId { get; set; } public int productId { get; set; }
public string productCode { get; set; } public string productCode { get; set; }
public string productName { get; set; } public string productName { get; set; }
public string route { get; set; } public int route { get; set; }
public string pn { get; set; } public string pn { get; set; }
/// <summary>
/// location.id主键
/// </summary>
public int lid { get; set; }
} }
public class ResponseAutoRouteInfo
{
public int Section { get; set; }
public int Machine { get; set; }
public string Pn { get; set; }
public int ProductId { get; set; }
public string ProductName { get; set; }
public int Route { get; set; }
public string RouteName { get; set; }
public string OrderNo { get; set; }
public string FixtureGuid { get; set; }
public string FixtureName { get; set; }
public string Sn { get; set; }
/// <summary>
/// 储位编号
/// </summary>
public int Location { get; set; }
/// <summary>
/// location.id
/// </summary>
public int LId { get; set; }
}
} }
...@@ -31,9 +31,19 @@ namespace Siger.Middlelayer.AccRepository.Response ...@@ -31,9 +31,19 @@ namespace Siger.Middlelayer.AccRepository.Response
/// 工件 /// 工件
/// </summary> /// </summary>
public string sn { get; set; } public string sn { get; set; }
/// <summary>
/// 工序顺序
/// </summary>
public string routenumber { get; set; } public string routenumber { get; set; }
/// <summary>
/// 工序萌宠
/// </summary>
public string route { get; set; } public string route { get; set; }
/// <summary> /// <summary>
/// 工序id
/// </summary>
public int routeid { get; set; }
/// <summary>
/// 物料状态 /// 物料状态
/// </summary> /// </summary>
public int materialstate { get; set; } public int materialstate { get; set; }
......
...@@ -15,6 +15,13 @@ namespace Siger.Middlelayer.AccRepository.Response ...@@ -15,6 +15,13 @@ namespace Siger.Middlelayer.AccRepository.Response
public int location { get; set; } public int location { get; set; }
public string sn { get; set; } public string sn { get; set; }
public int enable { get; set; } public int enable { get; set; }
/// <summary>
/// 设备状态
/// </summary>
public int machineStatus { get; set; }
/// <summary>
/// 任务状态
/// </summary>
public int status { get; set; } public int status { get; set; }
public string lastupdate { get; set; } public string lastupdate { get; set; }
public string linemode { get; set; } public string linemode { get; set; }
......
...@@ -46,5 +46,6 @@ namespace Siger.Middlelayer.AccRepository.Response ...@@ -46,5 +46,6 @@ namespace Siger.Middlelayer.AccRepository.Response
public string triggerTime { get; set; } public string triggerTime { get; set; }
public DateTime? complatevalue { get; set; } public DateTime? complatevalue { get; set; }
public string complatetime { get; set; } public string complatetime { get; set; }
public int send { get; set; }
} }
} }
...@@ -101,6 +101,8 @@ namespace Siger.Middlelayer.CncRepository.Repositories ...@@ -101,6 +101,8 @@ namespace Siger.Middlelayer.CncRepository.Repositories
var sectionIds = new List<int>(); var sectionIds = new List<int>();
var productIds = new List<string>(); var productIds = new List<string>();
var machineIds = new List<int>(); var machineIds = new List<int>();
var validates = new List<BeatSetEntity>();
foreach (var beatSetEntity in beatSetEntities) foreach (var beatSetEntity in beatSetEntities)
{ {
var sectionId = 0; var sectionId = 0;
...@@ -180,14 +182,26 @@ namespace Siger.Middlelayer.CncRepository.Repositories ...@@ -180,14 +182,26 @@ namespace Siger.Middlelayer.CncRepository.Repositories
{ {
errors.Add($"{rowIndex},{(int)RequestEnum.UpDownBesatNotInteger}"); errors.Add($"{rowIndex},{(int)RequestEnum.UpDownBesatNotInteger}");
} }
var route = _context.siger_project_product_route.FirstOrDefault(f =>f.projectId==projectid && f.productId == product.id && f.name == beatSetEntity.RouteName);
if (route == null)
{
errors.Add($"{rowIndex},{(int)RequestEnum.RouteNotFound}");
}
if (errors.Any()) if (errors.Any())
{ {
return new CommonImportResult(0, string.Join(";", errors)); return new CommonImportResult(0, string.Join(";", errors));
} }
beatSetEntity.RouteNumber = route.id.ToString();
validates.Add(beatSetEntity);
} }
var index = 0; var index = 0;
var maxTime = "2199-01-01 00:00:00".ToDateTime(); var maxTime = "2199-01-01 00:00:00".ToDateTime();
foreach (var entity in beatSetEntities) foreach (var entity in validates)
{ {
var beat = new siger_project_beat_set var beat = new siger_project_beat_set
{ {
...@@ -201,12 +215,14 @@ namespace Siger.Middlelayer.CncRepository.Repositories ...@@ -201,12 +215,14 @@ namespace Siger.Middlelayer.CncRepository.Repositories
product_name = productIds[index], product_name = productIds[index],
section_id = sectionIds[index], section_id = sectionIds[index],
standard_besat = entity.CycleTime.ToInt(), standard_besat = entity.CycleTime.ToInt(),
route_name = entity.RouteName, route_name = entity.RouteName,
machineID = machineIds.Count>index?machineIds[index]:0, machineID = machineIds.Count>index?machineIds[index]:0,
changemodeltime = entity.ChangeModelTime.ToInt(), changemodeltime = entity.ChangeModelTime.ToInt(),
updown_besat = entity.UpDownBesat.ToDouble(), updown_besat = entity.UpDownBesat.ToDouble(),
yieldrate = entity.YieldRate.ToInt(), yieldrate = entity.YieldRate.ToInt(),
route_number = entity.RouteNumber, //route_number = entity.RouteNumber,
route_number=entity.RouteNumber,
start_time = string.IsNullOrEmpty(entity.StartTime) ? DateTime.MinValue : entity.StartTime.ToDateTime(), start_time = string.IsNullOrEmpty(entity.StartTime) ? DateTime.MinValue : entity.StartTime.ToDateTime(),
end_time = string.IsNullOrEmpty(entity.EndTime) ? maxTime : entity.EndTime.ToDateTime().AddDays(1).AddSeconds(-1) end_time = string.IsNullOrEmpty(entity.EndTime) ? maxTime : entity.EndTime.ToDateTime().AddDays(1).AddSeconds(-1)
}; };
......
...@@ -13,6 +13,10 @@ namespace Siger.Middlelayer.CncRepository.Request ...@@ -13,6 +13,10 @@ namespace Siger.Middlelayer.CncRepository.Request
public string product_name_text { get; set; } public string product_name_text { get; set; }
/// <summary>
/// productId
/// </summary>
[Required(ErrorMessage = "ProductNameIsEmpty")] [Required(ErrorMessage = "ProductNameIsEmpty")]
public string product_name { get; set; } public string product_name { get; set; }
...@@ -24,6 +28,11 @@ namespace Siger.Middlelayer.CncRepository.Request ...@@ -24,6 +28,11 @@ namespace Siger.Middlelayer.CncRepository.Request
public string time_num { get; set; } public string time_num { get; set; }
/// <summary>
/// 产品工序表ID
/// </summary>
public int route_id { get; set; }
public string route_number { get; set; } public string route_number { get; set; }
public string route_name { get; set; } public string route_name { get; set; }
......
...@@ -375,6 +375,7 @@ CREATE TABLE `siger_automation_machine_status` ( ...@@ -375,6 +375,7 @@ CREATE TABLE `siger_automation_machine_status` (
`machineid` int NOT NULL DEFAULT '0' COMMENT '工位对应设备ID', `machineid` int NOT NULL DEFAULT '0' COMMENT '工位对应设备ID',
`projectid` int NOT NULL DEFAULT '0', `projectid` int NOT NULL DEFAULT '0',
`enable` int NOT NULL DEFAULT '1' COMMENT '设备可用状态 0:不可用 1:可用', `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:生产完成 ', `status` int NOT NULL DEFAULT '1' COMMENT '完工状态 0:取消 1:待生产 2:生产中 3:生产完成 ',
`updatetime` datetime DEFAULT NULL COMMENT '操作时间', `updatetime` datetime DEFAULT NULL COMMENT '操作时间',
`program` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL 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` ( ...@@ -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', `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 '产品名称', `productName` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '产品名称',
`locationId` int(11) NOT NULL DEFAULT 0, `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 '', `status` int(1) NOT NULL DEFAULT 1 COMMENT '',
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; ) 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