Merge branch 'develop' of https://e.coding.net/ctcdevteam/hberp/hberp into develop

This commit is contained in:
shijing 2022-03-01 13:58:56 +08:00
commit a9fac3f3d0
25 changed files with 414 additions and 142 deletions

View File

@ -65,13 +65,13 @@
</el-table-column>
<el-table-column label="状态" width="120">
<template slot-scope="scope">
<el-tag v-if="scope.row.state===0" type="success">
<el-tag v-if="scope.row.state===10" type="success">
{{ state_[scope.row.state] }}
</el-tag>
<el-tag v-else-if="scope.row.state===1" type="warning">
<el-tag v-else-if="scope.row.state===20" type="warning">
{{ state_[scope.row.state] }}
</el-tag>
<el-tag v-else-if="scope.row.state===2" >
<el-tag v-else-if="scope.row.state===30" >
{{ state_[scope.row.state] }}
</el-tag>
<el-tag v-else type="danger">

View File

@ -84,7 +84,16 @@
<template slot-scope="scope">{{ usetype_[scope.row.way] }}</template>
</el-table-column>
<el-table-column label="校/检状态" width="100">
<template slot-scope="scope">{{ state_[scope.row.state] }}</template>
<template slot-scope="scope">
<el-tag v-if="scope.row.state===10" type="success">
{{ state_[scope.row.state] }}
</el-tag>
<el-tag v-else type="danger">
{{ state_[scope.row.state] }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="保管人">

View File

@ -52,7 +52,16 @@
<template slot-scope="scope">{{ scope.row.equipment_.model }}</template>
</el-table-column>
<el-table-column label="设备状态">
<template slot-scope="scope">{{ state_[scope.row.equipment_.state] }}</template>
<template slot-scope="scope">
<el-tag v-if="scope.row.equipment_.state===10" type="success">
{{ state_[scope.row.equipment_.state] }}
</el-tag>
<el-tag v-else type="danger">
{{ state_[scope.row.equipment_.state] }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="校准检查日期">
<template slot-scope="scope">{{ scope.row.check_date }}</template>

View File

@ -141,7 +141,7 @@
:visible.sync="dialogVisible"
:close-on-click-modal="false"
width="90%"
:title="dialogType === 'edit' ? '编辑出/如库记录' : '新增出/如库记录'"
:title="dialogType === 'edit' ? '编辑入库记录' : '新增入库记录'"
>
<el-form
ref="Form"
@ -220,6 +220,24 @@
<el-input v-model="item.batch" placeholder="批次号"></el-input>
</el-form-item>
</el-col>
<el-col :span="5" style="margin-right: 10px">
<el-form-item
class="expiration_date"
label="有效期"
:prop="'details.' + index + '.expiration_date'"
>
<el-date-picker
v-model="item.expiration_date"
type="date"
placeholder="选择日期"
value-format="yyyy-MM-dd"
style="width:100%"
>
</el-date-picker>
</el-form-item>
</el-col>
<!-- 删除按钮 -->
<el-col :span="1">
<el-tooltip

View File

@ -1,7 +1,11 @@
<template>
<div class="app-container">
<el-card style="margin-top: 2px">
<el-button v-if="this.$route.params.pu_order!=null" type="primary" icon="el-icon-plus" @click="handlecgxCreate"
<el-button
v-if="this.$route.params.pu_order != null"
type="primary"
icon="el-icon-plus"
@click="handlecgxCreate"
>新增采购项入库</el-button
>
<el-table
@ -39,20 +43,29 @@
<el-table-column label="出入库数量">
<template slot-scope="scope">{{ scope.row.count }}</template>
</el-table-column>
<el-table-column label="是否需要复验" v-if="this.$route.params.pu_order!=null">
<el-table-column
label="是否需要复验"
v-if="this.$route.params.pu_order != null"
>
<template slot-scope="scope">
<el-tag v-if="scope.row.need_test == false"></el-tag>
<el-tag v-else></el-tag>
</template>
</el-table-column>
<el-table-column label="复验是否合格" v-if="this.$route.params.pu_order!=null">
<el-table-column
label="复验是否合格"
v-if="this.$route.params.pu_order != null"
>
<template slot-scope="scope">
<el-tag v-if="scope.row.is_testok == false">不合格</el-tag>
<el-tag v-else>合格</el-tag>
</template>
</el-table-column>
<el-table-column label="文件" v-if="this.$route.params.pu_order!=null">
<el-table-column
label="文件"
v-if="this.$route.params.pu_order != null"
>
<template slot-scope="scope" v-if="scope.row.files">
<div v-for="item in scope.row.files_" v-bind:key="item.id">
<el-link :href="item.path" target="_blank" type="primary">{{
@ -61,7 +74,12 @@
</div>
</template>
</el-table-column>
<el-table-column align="center" label="操作" width="220px" v-if="this.$route.params.pu_order!=null">
<el-table-column
align="center"
label="操作"
width="220px"
v-if="this.$route.params.pu_order != null"
>
<template slot-scope="scope">
<el-link
type="primary"
@ -116,8 +134,8 @@
</el-input>
</el-form-item></div
></el-col>
</el-row>
<el-row :gutter="24">
</el-row>
<el-row :gutter="24">
<el-col :span="12"
><div class="grid-content bg-purple">
<el-form-item label="到货时间">
@ -154,6 +172,16 @@
<el-form-item label="批次" :prop="batch">
<el-input v-model="inpur.batch" placeholder="批次号"></el-input>
</el-form-item>
<el-form-item label="有效期" :prop="expiration_date">
<el-date-picker
v-model="inpur.expiration_date"
type="date"
placeholder="选择日期"
value-format="yyyy-MM-dd"
style="width: 100%"
>
</el-date-picker>
</el-form-item>
<el-form-item label="入库数量" :prop="count">
<el-input-number v-model="inpur.count" :min="0"></el-input-number>
</el-form-item>

View File

@ -47,6 +47,9 @@
<el-table-column label="规格型号">
<template slot-scope="scope">{{ scope.row.material_.specification }}</template>
</el-table-column>
<el-table-column label="有效期">
<template slot-scope="scope">{{ scope.row.expiration_date }}</template>
</el-table-column>
<el-table-column label="物料编号">
<template slot-scope="scope">{{

View File

@ -578,7 +578,7 @@
:headers="upHeaders"
:file-list="fileList"
:limit="1"
accept=".doc,.docx,.pdf,.jpg,.png,.tif,.gif,.apng"
accept=".pdf,.jpg,.png,.tif,.gif,.apng"
>
<el-button size="small" type="primary">上传文件</el-button>
</el-upload>

View File

@ -1,16 +1,38 @@
<template>
<div class="app-container">
<el-tabs type="border-card">
<el-tab-pane label="待检半成品">
<el-tabs type="border-card" v-model="activeName" @tab-click="handleClick">
<el-tab-pane label="待检半成品" name="1">
<el-card style="margin-top: 2px">
<el-input
v-model="listQuery.search"
placeholder="半成品名称/编号/子计划编号/工序"
style="width: 300px"
class="filter-item"
@keyup.enter.native="handleFilter1"
/>
<el-button
class="filter-item"
type="primary"
icon="el-icon-search"
@click="handleFilter1"
>搜索
</el-button>
<el-button
class="filter-item"
type="primary"
icon="el-icon-refresh-left"
@click="resetFilter"
>重置
</el-button>
<el-table
v-loading="listLoading"
:data="wproductList.results"
border
fit
stripe
highlight-current-row
max-height="700"
height="100"
highlight-current-row
v-el-height-adaptive-table="{bottomOffset: 50}"
>
<el-table-column type="index" width="50"/>
<el-table-column label="半成品名称">
@ -23,7 +45,8 @@
<template slot-scope="scope">{{ scope.row.material_.specification }}</template>
</el-table-column>
<el-table-column label="检测状态">
<el-table-column label="检测状态"
>
<template slot-scope="scope">
{{ actstate_[scope.row.act_state] }}
</template>
@ -31,7 +54,12 @@
<el-table-column label="子计划编号">
<template slot-scope="scope">{{ scope.row.subproduction_plan_.number }}</template>
</el-table-column>
<el-table-column label="所在子工序">
<el-table-column label="所在子工序" :filters="[{ text: '切割', value: '切割' },{ text: '磨边', value: '磨边' },
{ text: '清洗', value: '清洗' }, { text: '热弯成型', value: '热弯成型' },{ text: '化学钢化', value: '化学钢化' },
{ text: '镀膜', value: '镀膜' }, { text: '断膜', value: '断膜' },{ text: '汇流条制备', value: '汇流条制备' },
{ text: '夹层', value: '夹层' }, { text: '包边', value: '包边' }]"
:filter-method="filterTag"
filter-placement="bottom-end">
<template slot-scope="scope">{{ scope.row.step_.name }}</template>
</el-table-column>
<el-table-column align="center" label="操作" width="220px">
@ -88,16 +116,39 @@
</el-dialog>
</el-card>
</el-tab-pane>
<el-tab-pane label="复检半成品">
<el-tab-pane label="复检半成品" name="2">
<el-card style="margin-top: 2px">
<el-input
v-model="listQuery2.search"
placeholder="半成品名称/编号/子计划编号/工序"
style="width: 300px"
class="filter-item"
@keyup.enter.native="handleFilter2"
/>
<el-button
class="filter-item"
type="primary"
icon="el-icon-search"
@click="handleFilter2"
>搜索
</el-button>
<el-button
class="filter-item"
type="primary"
icon="el-icon-refresh-left"
@click="resetFilter2"
>重置
</el-button>
<el-table
v-loading="listLoading"
:data="wproductList2.results"
border
fit
stripe
highlight-current-row
max-height="600"
height="100"
highlight-current-row
v-el-height-adaptive-table="{bottomOffset: 50}"
>
<el-table-column type="index" width="50"/>
<el-table-column label="半成品名称">
@ -118,7 +169,12 @@
<el-table-column label="子计划编号">
<template slot-scope="scope">{{ scope.row.subproduction_plan_.number }}</template>
</el-table-column>
<el-table-column label="所在子工序">
<el-table-column label="所在子工序"
:filters="[{ text: '切割', value: '切割' },{ text: '磨边', value: '磨边' },
{ text: '清洗', value: '清洗' }, { text: '热弯成型', value: '热弯成型' },{ text: '化学钢化', value: '化学钢化' },
{ text: '镀膜', value: '镀膜' }, { text: '断膜', value: '断膜' },{ text: '汇流条制备', value: '汇流条制备' },
{ text: '夹层', value: '夹层' }, { text: '包边', value: '包边' }]"
:filter-method="filterTag">
<template slot-scope="scope">{{ scope.row.step_.name }}</template>
</el-table-column>
<el-table-column align="center" label="操作" width="220px">
@ -145,20 +201,42 @@
/>
</el-card>
</el-tab-pane>
<el-tab-pane label="已合格半成品">
<el-tab-pane label="已合格半成品" name="3">
<el-card style="margin-top: 2px">
<el-button type="primary" icon="el-icon-plus" @click="handleCreate">
批量入库
</el-button>
<el-input
v-model="listQuery1.search"
placeholder="半成品名称/编号/子计划编号/工序"
style="width: 300px"
class="filter-item"
@keyup.enter.native="handleFilter3"
/>
<el-button
class="filter-item"
type="primary"
icon="el-icon-search"
@click="handleFilter3"
>搜索
</el-button>
<el-button
class="filter-item"
type="primary"
icon="el-icon-refresh-left"
@click="resetFilter3"
>重置
</el-button>
<el-table
v-loading="listLoading"
:data="wproductList1.results"
ref="multipleTable"
border
fit
stripe
highlight-current-row
max-height="600"
height="100"
highlight-current-row
v-el-height-adaptive-table="{bottomOffset: 50}"
>
<el-table-column
@ -184,7 +262,12 @@
<el-table-column label="子计划编号">
<template slot-scope="scope">{{ scope.row.subproduction_plan_.number }}</template>
</el-table-column>
<el-table-column label="所在子工序">
<el-table-column label="所在子工序"
:filters="[{ text: '切割', value: '切割' },{ text: '磨边', value: '磨边' },
{ text: '清洗', value: '清洗' }, { text: '热弯成型', value: '热弯成型' },{ text: '化学钢化', value: '化学钢化' },
{ text: '镀膜', value: '镀膜' }, { text: '断膜', value: '断膜' },{ text: '汇流条制备', value: '汇流条制备' },
{ text: '夹层', value: '夹层' }, { text: '包边', value: '包边' }]"
:filter-method="filterTag">
<template slot-scope="scope">{{ scope.row.step_.name }}</template>
</el-table-column>
@ -212,16 +295,38 @@
/>
</el-card>
</el-tab-pane>
<el-tab-pane label="不合格半成品">
<el-tab-pane label="不合格半成品" name="4">
<el-card style="margin-top: 2px">
<el-input
v-model="listQuery4.search"
placeholder="半成品名称/编号/子计划编号/工序"
style="width: 300px"
class="filter-item"
@keyup.enter.native="handleFilter4"
/>
<el-button
class="filter-item"
type="primary"
icon="el-icon-search"
@click="handleFilter4"
>搜索
</el-button>
<el-button
class="filter-item"
type="primary"
icon="el-icon-refresh-left"
@click="resetFilter4"
>重置
</el-button>
<el-table
v-loading="listLoading"
:data="wproductList4.results"
border
fit
stripe
highlight-current-row
max-height="600"
height="100"
highlight-current-row
v-el-height-adaptive-table="{bottomOffset: 50}"
>
<el-table-column type="index" width="50"/>
<el-table-column label="半成品名称">
@ -239,7 +344,11 @@
<el-table-column label="规格型号">
<template slot-scope="scope">{{ scope.row.material_.specification }}</template>
</el-table-column>
<el-table-column label="所在子工序">
<el-table-column label="所在子工序" :filters="[{ text: '切割', value: '切割' },{ text: '磨边', value: '磨边' },
{ text: '清洗', value: '清洗' }, { text: '热弯成型', value: '热弯成型' },{ text: '化学钢化', value: '化学钢化' },
{ text: '镀膜', value: '镀膜' }, { text: '断膜', value: '断膜' },{ text: '汇流条制备', value: '汇流条制备' },
{ text: '夹层', value: '夹层' }, { text: '包边', value: '包边' }]"
:filter-method="filterTag">
<template slot-scope="scope">{{ scope.row.step_.name }}</template>
</el-table-column>
<el-table-column label="不合格标记">
@ -270,24 +379,25 @@
</el-table-column>
</el-table>
<pagination
v-show="wproductList1.count > 0"
:total="wproductList1.count"
:page.sync="listQuery1.page"
:limit.sync="listQuery1.page_size"
@pagination="getList1"
v-show="wproductList4.count > 0"
:total="wproductList4.count"
:page.sync="listQuery4.page"
:limit.sync="listQuery4.page_size"
@pagination="getList4"
/>
</el-card>
</el-tab-pane>
<el-tab-pane label="夹层半成品">
<el-tab-pane label="夹层半成品" name="5">
<el-card style="margin-top: 2px">
<el-table
v-loading="listLoading"
:data="wproductList3.results"
border
fit
stripe
highlight-current-row
max-height="600"
height="100"
highlight-current-row
v-el-height-adaptive-table="{bottomOffset: 50}"
>
<el-table-column type="index" width="50"/>
@ -310,7 +420,11 @@
<el-table-column label="子计划编号">
<template slot-scope="scope">{{ scope.row.subproduction_plan_.number }}</template>
</el-table-column>
<el-table-column label="所在子工序">
<el-table-column label="所在子工序" :filters="[{ text: '切割', value: '切割' },{ text: '磨边', value: '磨边' },
{ text: '清洗', value: '清洗' }, { text: '热弯成型', value: '热弯成型' },{ text: '化学钢化', value: '化学钢化' },
{ text: '镀膜', value: '镀膜' }, { text: '断膜', value: '断膜' },{ text: '汇流条制备', value: '汇流条制备' },
{ text: '夹层', value: '夹层' }, { text: '包边', value: '包边' }]"
:filter-method="filterTag">
<template slot-scope="scope">{{ scope.row.step_.name }}</template>
</el-table-column>
<el-table-column align="center" label="操作" width="220px">
@ -715,6 +829,7 @@
page: 1,
page_size: 20,
},
activeName: "1",
create_by_: '',
update_time: '',
formLabelWidth: '',
@ -819,15 +934,40 @@
computed: {},
watch: {},
created() {
this.getList();
this.getList2();
this.getList1();
this.getList3();
this.getList4();
this.getList();//待检
this.getList2();//复检
this.getList1();//已合格
this.getList3();//夹层
this.getList4();//不合格
// this.getLists();
},
methods: {
checkPermission,
handleClick(tab) {
this.listLoading = true;
this.listQuery.type = tab.name;
if(tab.name==1)
{
this.getList();
}
else if(tab.name==2)
{
this.getList2();
}
else if(tab.name==3)
{
this.getList1();
}
else if(tab.name==4)
{
this.getList4();
}
else if(tab.name==5)
{
this.getList3();
}
},
//待检半成品列表
getList() {
this.listLoading = true;
@ -838,6 +978,18 @@
}
this.listLoading = false;
});
},
handleFilter1() {
this.listQuery.page = 1;
this.getList();
},
resetFilter1() {
this.listQuery = {
page: 1,
page_size: 20,
};
this.getList();
},
//待检半成品报废
handleScrapbcp(scope) {
@ -850,7 +1002,7 @@
console.log(this.formbcp);
scrap(this.bcpbf, this.formbcp).then((response) => {
if (response.data) {
if (response.code >= 200) {
this.$message.success("该半成品已报废!");
this.dialogFormVisiblebcp = false;
this.getList();
@ -866,6 +1018,18 @@
this.wproductList2 = response.data;
}
});
},
handleFilter2() {
this.listQuery2.page = 1;
this.getList2();
},
resetFilter2() {
this.listQuery2 = {
page: 1,
page_size: 20,
};
this.getList2();
},
//已合格半成品
getList1() {
@ -877,6 +1041,18 @@
}
});
},
handleFilter3() {
this.listQuery1.page = 1;
this.getList1();
},
resetFilter3() {
this.listQuery1 = {
page: 1,
page_size: 20,
};
this.getList1();
},
//不合格半成品
getList4() {
@ -888,6 +1064,18 @@
}
});
},
handleFilter4() {
this.listQuery4.page = 1;
this.getList4();
},
resetFilter4() {
this.listQuery4 = {
page: 1,
page_size: 20,
};
this.getList4();
},
//不合格半成品报废
handleScrap(scope) {
@ -963,6 +1151,10 @@
}
});
},
//筛选
filterTag(value, row) {
return row.step_.name === value;
},
//夹层半成品列表
getList3() {
this.listQuery3.act_state = 26;

View File

@ -18,7 +18,7 @@
style="width: 100%"
height="100"
highlight-current-row
v-el-height-adaptive-table="{bottomOffset: 30}"
v-el-height-adaptive-table="{bottomOffset: 50}"
>
<el-table-column type="index" width="50" />

View File

@ -98,22 +98,26 @@
stripe
highlight-current-row
height="230"
style="width: 100%"
style="width: 100%"
>
<el-table-column type="index" width="50" />
<el-table-column
prop="subproduction_plan_.number"
label="子计划编号"
width="100"
>
</el-table-column>
<el-table-column prop="number" label="玻璃编号">
<el-table-column prop="number" label="玻璃编号" width="100">
</el-table-column>
<el-table-column prop="material_.name" label="玻璃状态">
<el-table-column
prop="material_.name"
label="玻璃状态"
width="170"
>
</el-table-column>
<el-table-column prop="place" label="摆放位置">
</el-table-column>
<el-table-column align="center" label="操作" width="100px">
<template slot-scope="scope">
<el-table-column prop="place" label="摆放位置"> </el-table-column>
<el-table-column align="center" label="操作" width="100px" fixed="right">
<template slot-scope="scope" >
<el-link type="primary" @click="handleupdatewproduct(scope)"
>编辑</el-link
>
@ -812,35 +816,41 @@ export default {
handleClick(tab) {
console.log(tab.name);
var str = tab.label.substr(tab.label.length - 1, 1);
if (str == "x") {
const xhr = new XMLHttpRequest();
// if (str == "x") {
// const xhr = new XMLHttpRequest();
xhr.open("get", tab.name, true);
// xhr.open("get", tab.name, true);
xhr.responseType = "arraybuffer";
// xhr.responseType = "arraybuffer";
xhr.onload = () => {
if (xhr.status == 200) {
mammoth
.convertToHtml({ arrayBuffer: new Uint8Array(xhr.response) })
.then((resultObject) => {
this.$nextTick(() => {
this.wordText = resultObject.value;
});
});
}
};
xhr.send();
var filediv = document.getElementById("file");
filediv.innerHTML =
' <div id="wordView" v-html=' + this.wordText + " />";
} else if (str == "f") {
// xhr.onload = () => {
// if (xhr.status == 200) {
// mammoth
// .convertToHtml({ arrayBuffer: new Uint8Array(xhr.response) })
// .then((resultObject) => {
// this.$nextTick(() => {
// this.wordText = resultObject.value;
// });
// });
// };
// xhr.send();
// var filediv = document.getElementById("file");
// filediv.innerHTML =
// ' <div id="wordView" v-html=' + this.wordText + " />";
// }
if (str == "f") {
this.pdf = tab.name;
var filediv = document.getElementById("file");
filediv.innerHTML =
" <iframe width=1000 height=900 frameborder=0 scrolling=auto src=" +
tab.name +
"></iframe>";
} else if (str == "g") {
var filediv = document.getElementById("file");
filediv.innerHTML =
" <img width=1000 height=900 frameborder=0 scrolling=auto src=" +
tab.name +
"></img>";
}
},
getWordText() {
@ -889,10 +899,9 @@ export default {
//半成品摆放的位置
handleupdatewproduct(scope) {
this.dialogwproductplace = true;
this.wproductplaceID=scope.row.id;
this.wproductplaceID = scope.row.id;
},
submitwproductplace() {
wproductPlace(this.wproductplaceID, this.wproductplace).then((res) => {
if (res.code >= 200) {
this.getpwpList();
@ -1135,12 +1144,33 @@ export default {
//提交本次操作
handlesubmit() {
submitOperation(this.id).then((res) => {
if(this.inputData=="")
{
this.$confirm("没有消耗物料确定提交吗?", "提示", {
confirmButtonText: "确认",
cancelButtonText: "取消",
type: "error",
})
.then(async () => {
await submitOperation(this.id);
this.$router.push({ name: "operation" });
this.$message.success("操作提交成功!");
})
.catch((err) => {
console.error(err);
});
}
else{
submitOperation(this.id).then((res) => {
if (res.code >= 200) {
this.$router.push({ name: "operation" });
this.$message.success("操作提交成功!");
}
});
}
},
},
};

View File

@ -421,6 +421,7 @@
<template slot-scope="scope">
<el-link
v-if="scope.row.material_.type == 2"
type="primary"
@click="handlewproduct(scope)"
>
选择半成品

View File

@ -4,6 +4,7 @@
venv/
__pycache__/
*.pyc
sh/*
media/*
static/*
vuedist/*

View File

@ -4,6 +4,7 @@ from rest_framework.response import Response
from celery import shared_task
import os
import subprocess
from server.settings_pro import DATABASES, BACKUP_DATABASE_PATH
@shared_task
def backup_database():
@ -12,15 +13,18 @@ def backup_database():
"""
import datetime
name = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
command = '''pg_dump "user=postgres password=zcDsj2021 dbname=hberp" >
/home/lighthouse/backup/hberp_{}.sql'''.format(name)
command = 'pg_dump "user={} password={} dbname={}" > {}/hberp_{}.sql'.format(
DATABASES['default']['USER'],
DATABASES['default']['PASSWORD'],
DATABASES['default']['NAME'],
BACKUP_DATABASE_PATH,
name)
completed = subprocess.run(command, shell=True, capture_output=True, text=True)
return completed
@shared_task
def reload_server():
os.chdir('/home/lighthouse/hberp')
command = 'sudo git pull && sudo service supervisor reload'
command = 'bash /home/lighthouse/hberp/hb_server/sh/git.sh'
completed = subprocess.run(command, shell=True, capture_output=True, text=True)
return completed
@ -32,7 +36,7 @@ def reload_server_only():
@shared_task
def backup_media():
command = 'rsync -avu /home/lighthouse/hberp/hb_server/media/ /home/lighthouse/backup/media/'
command = 'bash /home/lighthouse/hberp/hb_server/sh/backup_media.sh'
completed = subprocess.run(command, shell=True, capture_output=True, text=True)
return completed

View File

@ -2,7 +2,7 @@ from django.db import transaction
from django.shortcuts import render
from rest_framework.decorators import permission_classes
from rest_framework.views import APIView
from rest_framework.permissions import IsAdminUser
from rest_framework.permissions import IsAdminUser, AllowAny
from rest_framework.response import Response
from apps.develop.tasks import backup_database, backup_media, reload_server, reload_server_only
from apps.inm.models import FIFO, FIFOItem, Inventory, MaterialBatch
@ -121,8 +121,11 @@ class UpdateFIFONumber(APIView):
i.save()
return Response()
class ReloadServer(APIView):
permission_classes = [IsAdminUser]
authentication_classes = []
permission_classes = []
def post(self, request):
"""
拉取代码并重启服务

View File

@ -98,7 +98,7 @@ class ProductionPlanViewSet(CreateUpdateModelAMixin, ListModelMixin, CreateModel
for index, i in enumerate(subps):
steps = Step.objects.filter(usedstep__subproduction=i, usedstep__subproduction__is_deleted=False,
usedstep__is_deleted=False, is_deleted=False
).values('id', 'number', 'name', 'usedstep__remark', need_test=F('usedstep__need_test'))
).order_by('number').values('id', 'number', 'name', 'usedstep__remark', need_test=F('usedstep__need_test'))
instance = SubProductionPlan.objects.create(production_plan=production_plan, subproduction=i,
start_date=production_plan.start_date, end_date=production_plan.end_date,
workshop=i.process.workshop, process=i.process, create_by=request.user,

View File

@ -200,9 +200,9 @@ class PermissionViewSet(ModelViewSet):
queryset = Permission.objects.all()
serializer_class = PermissionSerializer
pagination_class = None
search_fields = ['name']
ordering_fields = ['sort']
ordering = ['pk']
search_fields = ['name', 'method']
ordering_fields = ['sort', 'id', 'method']
ordering = ['sort']
class OrganizationViewSet(ModelViewSet):

View File

@ -64,6 +64,8 @@ class PickSerializer(serializers.Serializer):
fifo = FIFO.objects.create(type=FIFO.FIFO_TYPE_DO_OUT,
inout_date=timezone.now(), create_by=self.context['request'].user,
number = 'CK' + ranstr(7))
if len(picks)<=0:
raise exceptions.APIException('没有领料项目')
for i in picks:
isLowLevel = False
# 更新出库详情
@ -116,8 +118,9 @@ class PickSerializer(serializers.Serializer):
subproduction_plan=sp)
sp.is_picked=True
sp.state = SubProductionPlan.SUBPLAN_STATE_WORKING #生产中
sp.state_date_real = timezone.now() #实际开工日期
sp.save()
if sp.start_date_real is None:
sp.start_date_real = timezone.now()#实际开工日期
sp.save()
# 创建领料记录
pick = Pick()
pick.subproduction_plan = sp

View File

@ -76,8 +76,9 @@ class WpmService(object):
if wt.step.process == test.step.process:
wproduct.ng_sign = None
ticket = wt.ticket
ticket_data = wt.ticket_data
ticket_data = ticket.ticket_data
ticket_data['retest_result'] = 1
ticket.ticket_data = ticket_data
ticket.update_by = user
ticket.save()
# 创建处理日志

View File

@ -71,6 +71,10 @@ def handleTicket(sender, instance, created, **kwargs):
elif decision in [WProduct.NG_ACCEPT, WProduct.NG_PERMIT]:
wp.act_state = WProduct.WPR_ACT_STATE_OK
# 获取最后一次检验
test= wp.test_wproduct.filter(is_submited=True).order_by('-id').last()
if test.type == TestRecord.TEST_PROCESS_RE or test.is_midtesting:
wp.act_state = WProduct.WPR_ACT_STATE_DOWAIT
wp.ng_sign = decision
wt.save()
wp.ticket = None # 解除当前工单

View File

@ -163,7 +163,7 @@ class WProductViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet):
'to_order').prefetch_related('wp_child')
serializer_class = WProductListSerializer
filterset_class = WProductFilterSet
search_fields = ['number']
search_fields = ['number', 'material__name', 'subproduction_plan__number']
ordering_fields = ['id']
ordering = ['id']
@ -315,7 +315,7 @@ class WProductViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet):
remark = vdata.get('remark', '')
fifo = FIFO.objects.create(type=FIFO.FIFO_TYPE_DO_IN,
is_audited=True, auditor=request.user, inout_date=timezone.now(),
create_by=request.user, remark=remark)
create_by=request.user, remark=remark, number='RK'+ranstr(7))
# 创建入库明细
fifoitem = FIFOItem()
fifoitem.warehouse = warehouse
@ -331,6 +331,8 @@ class WProductViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet):
ip = {}
ip['fifoitem'] = fifoitem
ip['wproduct'] = i
if i.number is None:
raise exceptions.APIException('缺少编号')
ip['number'] = i.number
ip['material'] = material
ips.append(FIFOItemProduct(**ip))
@ -658,8 +660,9 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd
if set(list(sps_omi_l)) != set(list(sps_omo_l)):
raise exceptions.APIException('消耗与产出不一致')
else:
if not omis.exists() and processId !=1: # 不是冷加工
raise exceptions.APIException('请选择消耗物料')
pass
# if omis.exists() and processId !=1: # 不是冷加工
# raise exceptions.APIException('请选择消耗物料')
# 检查自定义表单填写
if OperationRecord.objects.filter(operation=op, is_filled=False).exists():
@ -710,6 +713,9 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd
wp.act_state = WProduct.WPR_ACT_STATE_DOWAIT
if needTest:
wp.act_state = WProduct.WPR_ACT_STATE_TOTEST
if wp.test:# 如果有正在进行的工序中检验
wp.test.is_submited = False
wp.test.save()
wp.operation = None
wp.update_by = request.user

View File

@ -1,4 +0,0 @@
#!/bin/bash
cd /home/lighthouse/hberp/hb_server
source venv/bin/activate
exec celery -A server beat -l info

View File

@ -1,4 +0,0 @@
#!/bin/bash
cd /home/lighthouse/hberp/hb_server
source venv/bin/activate
exec celery -A server worker -l info

View File

@ -1,4 +0,0 @@
#!/bin/bash
cd /home/lighthouse/hberp/hb_server
source venv/bin/activate
exec gunicorn -w 5 -b 0.0.0.0:2223 server.wsgi

View File

@ -24,7 +24,7 @@ from drf_yasg.views import get_schema_view
from rest_framework import routers
from rest_framework.documentation import include_docs_urls
from django.views.generic import TemplateView
from utils.view import GenSignature, UpdateDevelop
from utils.view import GenSignature
import os
router = routers.DefaultRouter()
router.register('', FileViewSet, basename="file")
@ -75,7 +75,6 @@ urlpatterns = [
# 工具
path('api/utils/signature/', GenSignature.as_view()),
path('api/utils/develop/', UpdateDevelop.as_view()),
# 前端页面入口
path('',TemplateView.as_view(template_name="index.html"))

View File

@ -65,30 +65,3 @@ class GenSignature(APIView):
except:
return Response('签名照处理失败,请重新上传',
status=status.HTTP_400_BAD_REQUEST)
import time
class UpdateDevelop(APIView):
"""
更新开发服务器
"""
authentication_classes = ()
permission_classes = ()
def post(self, request, *args, **kwargs):
import os
# 更新后端
os.chdir('/home/lighthouse/hberp')
ret = os.popen('sudo git pull && sudo service supervisor reload')
# 奇怪的处理
# os.chdir('/home/hberp/hb_server/vuedist')
# os.popen('cp index.html indexbak')
# time.sleep(1000)
# os.popen('rm -rf index.html')
# time.sleep(1000)
# os.popen('mv -f indexbak index.html')
# 打包前端
# os.chdir('/home/hberp/hb_client')
# os.system('npm run build:prod')
# os.system('\cp -rf /home/hberp/hb_client/dist/* /home/hberp/hb_server/vuedist')
return Response(ret.read())