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

This commit is contained in:
shilixia 2021-12-30 14:17:37 +08:00
commit d3401e3fe9
17 changed files with 374 additions and 138 deletions

View File

@ -2,8 +2,8 @@
ENV = 'development'
# base api
#VUE_APP_BASE_API = 'http://127.0.0.1:8000/api'
VUE_APP_BASE_API = 'http://47.95.0.242:2222/api'
VUE_APP_BASE_API = 'http://127.0.0.1:8000/api'
#VUE_APP_BASE_API = 'http://47.95.0.242:2222/api'
# vue-cli uses the VUE_CLI_BABEL_TRANSPILE_MODULES environment variable,

View File

@ -19,7 +19,7 @@
@expand-change="handlerExpand"
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
>
<el-table-column label="任务编号">
<el-table-column label="任务编号" width="150">
<template slot-scope="scope">{{ scope.row.name }}</template>
</el-table-column>
<el-table-column label="产品名称">

View File

@ -1,6 +1,6 @@
<template>
<div>
<el-row style="position: absolute;z-index: 2000;top: -38px;right: 150px;display: flex">
<el-row class="searchWrap">
<el-date-picker
v-model="timeRange"
type="monthrange"
@ -36,7 +36,7 @@
</el-dropdown>
</div>
</el-row>
<div class="left" style=" width: 400px ;float: left;border-right: 1px solid #f7f7f7">
<div class="left leftTable">
<leftMenu
:list="list"
ref="leftMenu"
@ -376,7 +376,7 @@
this.windowWidth=document.body.clientWidth?document.body.clientWidth:document.documentElement.clientWidth;
}
let currentYear = new Date().getFullYear();
this.timeRange = [currentYear+'-01',currentYear+'-12'];
this.timeRange = [currentYear+'-01',(currentYear+1)+'-12'];
this.list = [...this.proList];
document.addEventListener("scroll", this.handleScroll);
this.list=[...this.list];
@ -385,7 +385,6 @@
this.setStoneLine();
},
computed: {
computedList() {
let arr = [];
this.list.forEach(item => {
@ -1019,6 +1018,11 @@
}
},
watch: {
proList() {
this.list=[...this.proList];
this.handlerCheckList(this.list);
// this.proList = this.proList;
},
currentDaySize(newValue, oldValue) {
this.list.forEach(item => {
item.left = (item.left / oldValue.value) * newValue.value;
@ -1043,7 +1047,7 @@
<style lang="scss" scoped>
.chart {
height: 280px;
height: 300px;
user-select: none;
position: relative;
overflow: hidden;
@ -1375,4 +1379,17 @@
}
}
}
.leftTable{
width: 400px ;
float: left;
height: 300px;
border-right: 1px solid #f7f7f7;
}
.searchWrap{
position: absolute;
z-index: 2000;
top: -38px;
right: 150px;
display: flex
}
</style>

View File

@ -146,7 +146,7 @@
<el-radio v-model="is_testok" :label="testokTrue">检查合格</el-radio>
<el-radio v-model="is_testok" :label="testokFalse">检查不合格</el-radio>
</el-form-item>
<div class="dialog-footer" style="text-align: right">
<div class="dialog-footer" style="text-align: right" v-show="!isDisabled">
<el-button @click="recordCancel"> </el-button>
<el-button type="primary" @click="submitfield('1')">保存</el-button>
<el-button type="warning" @click="submitfield('2')">提交</el-button>
@ -182,6 +182,10 @@
hasPicture:{
type:Boolean,
default:false
},
isDisabled:{
type:Boolean,
default:false
}
},
mounted() {

View File

@ -786,6 +786,7 @@
fieldData(isSubmit){
let that = this;
that.field = []; //检查项目
debugger;
let submit = isSubmit=='1'?false:true;
that.formData.forEach((item) => {
let field_value = 0;
@ -801,12 +802,10 @@
is_hidden: item.is_hidden
});
});
// that.testrecord.form = that.formID;//检查表
that.testrecord.record_data = that.field;//检查项列表
that.testrecord.is_testok = that.is_testok;//检查表检查结果
// that.testrecord.wproduct = that.wproductId;//半成品ID
// that.testrecord.is_submited = true;
that.testrecord.id = that.recordId;
debugger;
if(submit){//提交
this.$emit('recordSubmit',that.testrecord);
}else {//保存

View File

@ -1,11 +1,40 @@
<template>
<div class="dashboard-container">
<el-badge :value="count.total_count" class="item" @click.native="gotoTicketPage">
<el-icon class="el-icon-s-management" style="font-size: 70px;color: #d29898"></el-icon>
</el-badge>
<div></div>
<div class="dashboard-text">name: {{ name }}</div>
<div class="dashboard-text">perms: <span v-for="perm in perms" :key="perm">{{ perm }}</span></div>
<el-card>
<div class="cards">
<div class="cardFirstText">本月2</div>
<div class="cardSecondText">20</div>
<div>合同总数</div>
</div>
<div class="cards">
<div class="cardFirstText">本月20</div>
<div class="cardSecondText">20</div>
<div>生产订单总数</div>
</div>
<div class="cards">
<div class="cardFirstText">在制10</div>
<div class="cardSecondText">20</div>
<div>已排产生产任务</div>
</div>
<div class="cards">
<div class="cardFirstText">本月4</div>
<div class="cardSecondText">2</div>
<div>累计交付产品数</div>
</div>
<div class="cards">
<div class="cardFirstText">本月2</div>
<div class="cardSecondText">2</div>
<div>累计不合格产品数</div>
</div>
</el-card>
<el-card>
<el-badge :value="count.total_count" class="item" @click.native="gotoTicketPage">
<el-icon class="el-icon-s-management" style="font-size: 70px;color: #d29898"></el-icon>
</el-badge>
<div></div>
<div class="dashboard-text">name: {{ name }}</div>
<div class="dashboard-text">perms: <span v-for="perm in perms" :key="perm">{{ perm }}</span></div>
</el-card>
</div>
</template>
@ -37,11 +66,32 @@ export default {
<style lang="scss" scoped>
.dashboard {
&-container {
margin: 30px;
margin: 5px 6px;
}
&-text {
font-size: 30px;
line-height: 46px;
}
}
.cards{
width: 240px;
color: #ffffff;
background: #abccec;
text-align: center;
border-radius: 4px;
padding: 10px;
line-height: 30px;
float: left;
margin: 15px;
.cardFirstText{
text-align: left;
padding-left: 20px;
}
.cardSecondText{
font-size: 30px;
}
}
.cards:hover{
box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
}
</style>

View File

@ -35,6 +35,7 @@
stripe
style="width: 100%"
height="300"
@row-click="tableRowClick"
>
<el-table-column type="index" width="50" />
@ -114,19 +115,11 @@
</div>
</template>
<script>
import {getPlanGantt} from "@/api/srm";
import gantt from "@/components/Gantt/index";
import { getordertoplan } from "@/api/sam";
import {
createProductionplan,
getProductionplanList,
createsubplan,
} from "@/api/pm";
import { getMaterialList } from "@/api/mtm";
import { getProductionplanList} from "@/api/pm";
import checkPermission from "@/utils/permission";
import { genTree } from "@/utils";
import Pagination from "@/components/Pagination"; // secondary package based on el-pagination
const defaulteorderplan = {};
export default {
components: { Pagination, gantt },
data() {
@ -164,17 +157,20 @@ export default {
this.getplanList();
},
//生产计划列表
//列表
getplanList() {
tableRowClick(row){
let that = this;
this.listLoading = true;
getProductionplanList(this.listQuery).then((response) => {
if (response.data) {
this.productionplanList = response.data;
let list = response.data.results;
let arr = [];
list.forEach((item) => {
getPlanGantt({}).then(res=>{
if(res.code===200){
let arr =[],list=[];
let li = res.data.results;
li.forEach((item)=>{
if(item.id===row.id){
list.push(item)
}
});
debugger;
console.log(list);
list.forEach(item => {
if (!item.children || item.children.length < 1) {
let startTime = new Date(item.start_date).getTime();
let endTime = new Date(item.end_date).getTime();
@ -191,8 +187,84 @@ export default {
obj.productNum = item.product_.specification;
obj.isShow = true;
arr.push(obj);
} else if (item.children && item.children.length >= 1) {
let startTime = new Date(item.start_date).getTime();
let endTime = new Date(item.end_date).getTime();
let temp =[];
let parentId = item.id;
let children = item.children;
children.forEach(child => {
let start = new Date(child.start_date).getTime();
let end = new Date(child.end_date).getTime();
let objChild = new Object();
objChild.name = child.number;
objChild.id = child.id;
objChild.top=50;
objChild.parentId=parentId;
objChild.startTime = start;
objChild.endTime = end;
objChild.planTime = [start,end];
objChild.per = child.count;
objChild.per1 = child.count_real;
objChild.type = 1;
objChild.productName = child.product_.name;
objChild.productNum = child.product_.specification;
objChild.isShow= true;
temp.push(objChild);
});
let obj=new Object();
obj.name=item.number;
obj.id=item.id;
obj.top=20;
obj.startTime=startTime;
obj.endTime=endTime;
obj.planTime = [startTime,endTime];
obj.per=item.count;
obj.per1=item.count_real;
obj.type=3;
obj.productName = item.product_.name;
obj.productNum = item.product_.specification;
obj.children = temp;
obj.isShow= true;
arr.push(obj);
}
that.proList = arr;
debugger;
console.log(arr)
});
}else{
that.$message.error(res.msg);
}
})
},
//列表
getplanList() {
let that = this;
this.listLoading = true;
getProductionplanList(this.listQuery).then((response) => {
if (response.data) {
this.productionplanList = response.data;
let list = response.data.results;
let arr = [];
list.forEach((item) => {
// if (!item.children || item.children.length < 1) {
let startTime = new Date(item.start_date).getTime();
let endTime = new Date(item.end_date).getTime();
let obj = new Object();
obj.name = item.number;
obj.id = item.id;
obj.top = 20;
obj.startTime = startTime;
obj.endTime = endTime;
obj.planTime = [startTime, endTime];
obj.per = item.count;
obj.type = 1;
obj.productName = item.product_.name;
obj.productNum = item.product_.specification;
obj.isShow = true;
arr.push(obj);
// }
that.proList = arr;
});
}

View File

@ -377,6 +377,7 @@
:close-on-click-modal="false"
>
<reviewForm
v-if="limitedReview"
:results="fieldList"
:originList="originList"
:formID="recordform"
@ -397,11 +398,13 @@
@close="recordCancel"
>
<customForm
v-if="recordVisible"
:results="fieldList"
:hasPicture="hasPicture"
:formID="recordform"
:wproduct="wproduct"
:recordId="recordId"
:isDisabled="isDisabled"
@recordSubmit="recordSubmit"
@recordSave="recordSave"
@recordCancel="recordCancel"
@ -706,6 +709,7 @@
mutipID: [],
wproduct: null,
isPost: false,
isDisabled: false,
origin_test: null,
hasPicture: false,
outerVisible: false,
@ -1008,6 +1012,7 @@
}
that.fieldList = arr;
that.$nextTick(()=>{
that.isDisabled = false;
that.recordVisible = true;
});
})
@ -1050,7 +1055,45 @@
},
//点击记录里的查看
handleRecordDetail(scope){
let that = this;
that.recordVisible = false;
that.recordId = scope.row.id;
that.recordform = scope.row.form;
that.formName = scope.row.form_.name;
getrffieldList({form: this.recordform, page: 1, page_size: 100}).then((response) => {
if (response.data) {
that.hasPicture = false;
let fieldList = response.data.results;
that.fieldList = [...fieldList];
let arr = fieldList.filter(item => {
return item.field_type === 'draw'
});
if (arr.length > 0) {
that.hasPicture = true;
}
getTestRecordItem(scope.row.id).then((res) => {
let arr = [];
let fieldList = res.data.record_data;
for(let i=0;i<that.fieldList.length;i++){
let obj = that.fieldList[i];
obj.is_testok = null;
for(let j=0;j<fieldList.length;j++){
if(that.fieldList[i].field_key===fieldList[j].field_key){
obj.id = fieldList[j].id;
obj.is_testok = fieldList[j].is_testok;
obj.field_value = fieldList[j].field_value;
}
}
arr.push(obj)
}
that.fieldList = arr;
that.$nextTick(()=>{
that.isDisabled = true;
that.recordVisible = true;
});
})
}
});
},
//半产品复检
handleReview() {
@ -1110,6 +1153,7 @@
that.hasPicture = true;
}
that.$nextTick(()=>{
that.isDisabled = false;
that.recordVisible = true;
});
})

View File

@ -32,12 +32,6 @@
<el-table-column align="center" label="操作" width="220px">
<template slot-scope="scope">
<el-link
v-if="checkPermission(['warehouse_update'])"
@click="handleInspection(scope)"
>检验
</el-link
>
<el-link
v-if="checkPermission(['warehouse_update'])&&scope.row.test===null"
@click="handleInspection(scope)"
@ -181,6 +175,7 @@
@close="recordCancel"
>
<customForm
v-if="innerVisible"
:results="fieldList"
:hasPicture="hasPicture"
:formID="recordform"

View File

@ -10,11 +10,14 @@ class PmService:
"""
ret = {}
subplans = SubProductionPlan.objects.filter(production_plan=plan, is_deleted=False)
qs = subplans.values('process', 'process__name', 'process__number').annotate(count=Sum('main_count'),
count_real=Sum('main_count_real'), count_ok=Sum('main_count_ok'), count_notok=Sum('main_count_notok'))
qs = subplans.values('process', 'process__name', 'process__number').annotate(count=Sum('count'),
count_real=Sum('count_real'), count_ok=Sum('count_ok'), count_notok=Sum('count_notok'))
qs_list = list(qs)
for i in qs_list:
ret[i['process__number']] = {
'process':i['process'],
'process_number':i['process__number'],
'process_name':i['process__name'],
'count':i['count'],
'count_real':i['count_real'],
'count_ok':i['count_ok'],

View File

@ -77,6 +77,7 @@ class TestRecordViewSet(ListModelMixin, UpdateModelMixin, RetrieveModelMixin, De
obj = self.get_object()
if obj.is_submited:
raise exceptions.APIException('该记录已提交不可删除')
WpmServies.add_wproduct_flow_log(obj.wproduct, 'test_delete')
return super().destroy(request, *args, **kwargs)
@action(methods=['post'], detail=True, perms_map={'post':'*'}, serializer_class=TestRecordUpdateSerializer)
@ -89,7 +90,7 @@ class TestRecordViewSet(ListModelMixin, UpdateModelMixin, RetrieveModelMixin, De
with transaction.atomic():
obj.is_submited=True
obj.save()
WpmServies.update_wproduct_by_test(obj, request.user)
WpmServies.update_wproduct_by_test(obj, request.user) # 这里已经做了日志记录和进度计算
return Response()
# def create(self, request, *args, **kwargs):

View File

@ -7,7 +7,7 @@ class SubplanGanttSerializer(serializers.ModelSerializer):
product_ = MaterialSimpleSerializer(source='product', read_only=True)
class Meta:
model = SubProductionPlan
fields = ['id', 'number', 'start_date', 'end_date', 'count', 'count_real', 'count_ok', 'start_date_real', 'end_date_real', 'process_']
fields = ['id', 'number', 'start_date', 'end_date', 'count', 'count_real', 'count_ok', 'start_date_real', 'end_date_real', 'process_', 'product_']
class PlanGanttSerializer(serializers.ModelSerializer):
children = serializers.SerializerMethodField()

View File

@ -0,0 +1,18 @@
# Generated by Django 3.2.9 on 2021-12-30 01:31
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('wpm', '0040_alter_wproductflow_number'),
]
operations = [
migrations.AddField(
model_name='wproductflow',
name='change_str',
field=models.CharField(default='', max_length=1000, verbose_name='变动描述'),
),
]

View File

@ -148,7 +148,9 @@ class WproductFlow(CommonAModel):
on_delete=models.SET_NULL, null=True, blank=True)
ticket = models.ForeignKey('wf.ticket', verbose_name='当前工单',
on_delete=models.SET_NULL, null=True, blank=True)
is_lastlog = models.BooleanField('是否该子计划下的最后一条日志', default=True)
change_str = models.CharField('变动描述', default='', max_length=1000)
class Pick(CommonADModel):

View File

@ -73,10 +73,6 @@ class WpmServies(object):
participant_type=State.PARTICIPANT_TYPE_PERSONAL,
intervene_type=0,
participant=user)
# 更新子计划相关进度
cls.update_subproduction_progress_main(sp=wproduct.subproduction_plan)
else:# 如果不合格
wproduct.act_state = WProduct.WPR_ACT_STATE_NOTOK
# 需要走不合格品审理的工单
@ -95,11 +91,15 @@ class WpmServies(object):
intervene_type=0,
participant=user)
wproduct.update_by = user
wproduct.update_time = timezone.now()
wproduct.test = None
wproduct.save()
# 添加日志
cls.add_wproduct_flow_log(wproduct, 'test_ok' if is_testok else 'test_notok')
# 更新子计划相关进度
cls.update_subproduction_progress_main(sp=wproduct.subproduction_plan)
@classmethod
def update_subproduction_progress_main(cls, sp:SubProductionPlan):
@ -131,3 +131,18 @@ class WpmServies(object):
if count_mtestok >= plan.count:
plan.state = ProductionPlan.PLAN_MTEST_DONE
plan.save()
@classmethod
def add_wproduct_flow_log(cls, instance:WProduct, change_str:str=''):
"""
创建产品变动日志
"""
# update_fields = kwargs['update_fields']
WproductFlow.objects.filter(wproduct=instance, subproduction_plan=instance.subproduction_plan).update(is_lastlog=False)
ins = WproductFlow()
ins.wproduct = instance
for f in WproductFlow._meta.fields:
if f.name not in ['id', 'wproduct', 'is_lastlog']:
setattr(ins, f.name, getattr(instance, f.name, None))
ins.change_str = change_str
ins.save()

View File

@ -34,6 +34,7 @@ def handleTicket(sender, instance, created, **kwargs):
# 工单绑定半成品
wproduct.ticket = instance
wproduct.save()
WpmServies.add_wproduct_flow_log(wproduct, 'ticket_create')
# 检验员
if not ticket_data.get('tester', None):
@ -68,10 +69,7 @@ def handleTicket(sender, instance, created, **kwargs):
wt.save()
wp.ticket = None # 解除当前工单
wp.act_state = WProduct.WPR_ACT_STATE_DOWAIT
wp.save()
# 更新子计划合格进度
WpmServies.update_subproduction_progress_main(sp=sp)
wp.save()
else:
raise exceptions.APIException('返回步骤点错误')
@ -82,18 +80,8 @@ def handleTicket(sender, instance, created, **kwargs):
wp.ticket = None # 解除当前工单
wp.save()
@receiver(post_save, sender=WProduct)
def update_wproduct_log(sender, instance, created, **kwargs):
"""
创建产品变动日志
"""
# update_fields = kwargs['update_fields']
WproductFlow.objects.filter(wproduct=instance, subproduction_plan=instance.subproduction_plan).update(is_lastlog=False)
ins = WproductFlow()
ins.wproduct = instance
for f in WproductFlow._meta.fields:
if f.name not in ['id', 'create_time', 'update_time', 'wproduct', 'is_lastlog']:
setattr(ins, f.name, getattr(instance, f.name, None))
ins.save()
# 添加日志
WpmServies.add_wproduct_flow_log(wp, 'ticket_finish')
# 更新子计划合格进度
WpmServies.update_subproduction_progress_main(sp=wp.subproduction_plan)

View File

@ -81,13 +81,23 @@ class WPlanViewSet(ListModelMixin, GenericViewSet):
wps.update(step=first_step,
act_state=WProduct.WPR_ACT_STATE_TORETEST, is_hidden=False, warehouse=None,
subproduction_plan=sp, update_by=request.user, update_time=timezone.now())
for i in wps:
for m in i['wproducts']:
m.step = first_step
m.act_state = WProduct.WPR_ACT_STATE_TORETEST
m.is_hidden = False
m.warehouse = None
m.subproduction_plan = sp
m.update_by = request.user
m.update_time = timezone.now()
m.save()
WpmServies.add_wproduct_flow_log(instance=m, change_str='pick_half')
pw = PickWproduct()
pw.pick =pick
pw.wproduct = i
pw.number = i.number
pw.material = i.material
pw.subproduction_plan = i.suproduction_plan
pw.wproduct = m
pw.number = m.number
pw.material = m.material
pw.subproduction_plan = m.subproduction_plan
pw.save()
sp.is_picked = True
sp.save()
@ -95,63 +105,63 @@ class WPlanViewSet(ListModelMixin, GenericViewSet):
return Response()
@action(methods=['post'], detail=True, perms_map={'post':'*'}, serializer_class=WplanPutInSerializer)
@transaction.atomic
def putin(self, request, pk=None):
"""
半成品入库
"""
serializer= WplanPutInSerializer(data=request.data)
serializer.is_valid(raise_exception=True)
vdata = serializer.validated_data
subplan = self.get_object()
material = subplan.product
batch = subplan.number
warehouse = vdata['warehouse']
wproducts = WProduct.objects.filter(subproduction_plan=subplan,
act_state=WProduct.WPR_ACT_STATE_OK, material=material, is_deleted=False)
if wproducts.exists():
# 创建入库记录
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)
# 创建入库明细
fifoitem = FIFOItem()
fifoitem.is_tested = True
fifoitem.is_testok = True
fifoitem.warehouse = warehouse
fifoitem.material = material
fifoitem.count = wproducts.count()
fifoitem.batch = batch
fifoitem.fifo = fifo
fifoitem.subproduction_plan = subplan
fifoitem.save()
# 创建入库明细半成品
ips = []
for i in wproducts:
ip = {}
ip['fifoitem'] = fifoitem
ip['wproduct'] = i
ip['number'] = i.number
ip['material'] = material
ips.append(FIFOItemProduct(**ip))
FIFOItemProduct.objects.bulk_create(ips)
# 创建IProduct
ips2 = []
for i in wproducts:
ip = {}
ip['warehouse'] = warehouse
ip['batch'] = batch
ip['wproduct'] = i
ip['number'] = i.number
ip['material'] = material
ips2.append(IProduct(**ip))
IProduct.objects.bulk_create(ips2)
# 更新库存并修改半成品进行状态
update_inm(fifo)
wproducts.update(act_sate=WProduct.WPR_ACT_STATE_INM, warehouse=warehouse, update_by=request.user, update_time=timezone.now())
# @action(methods=['post'], detail=True, perms_map={'post':'*'}, serializer_class=WplanPutInSerializer)
# @transaction.atomic
# def putin(self, request, pk=None):
# """
# 半成品入库
# """
# serializer= WplanPutInSerializer(data=request.data)
# serializer.is_valid(raise_exception=True)
# vdata = serializer.validated_data
# subplan = self.get_object()
# material = subplan.product
# batch = subplan.number
# warehouse = vdata['warehouse']
# wproducts = WProduct.objects.filter(subproduction_plan=subplan,
# act_state=WProduct.WPR_ACT_STATE_OK, material=material, is_deleted=False)
# if wproducts.exists():
# # 创建入库记录
# 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)
# # 创建入库明细
# fifoitem = FIFOItem()
# fifoitem.is_tested = True
# fifoitem.is_testok = True
# fifoitem.warehouse = warehouse
# fifoitem.material = material
# fifoitem.count = wproducts.count()
# fifoitem.batch = batch
# fifoitem.fifo = fifo
# fifoitem.subproduction_plan = subplan
# fifoitem.save()
# # 创建入库明细半成品
# ips = []
# for i in wproducts:
# ip = {}
# ip['fifoitem'] = fifoitem
# ip['wproduct'] = i
# ip['number'] = i.number
# ip['material'] = material
# ips.append(FIFOItemProduct(**ip))
# FIFOItemProduct.objects.bulk_create(ips)
# # 创建IProduct
# ips2 = []
# for i in wproducts:
# ip = {}
# ip['warehouse'] = warehouse
# ip['batch'] = batch
# ip['wproduct'] = i
# ip['number'] = i.number
# ip['material'] = material
# ips2.append(IProduct(**ip))
# IProduct.objects.bulk_create(ips2)
# # 更新库存并修改半成品进行状态
# update_inm(fifo)
# wproducts.update(act_sate=WProduct.WPR_ACT_STATE_INM, warehouse=warehouse, update_by=request.user, update_time=timezone.now())
return Response()
# return Response()
class WMaterialViewSet(CreateUpdateModelAMixin, ListModelMixin, GenericViewSet):
@ -232,10 +242,12 @@ class WProductViewSet(ListModelMixin, GenericViewSet):
elif wproduct.act_state == WProduct.WPR_ACT_STATE_TOCOMBTEST:
savedict['type'] = TestRecord.TEST_COMB
tr = TestRecord.objects.create(**savedict)
# 更新wproduct
wproduct.test = tr
wproduct.update_by = request.user
wproduct.update_time = timezone.now()
wproduct.save()
WpmServies.add_wproduct_flow_log(wproduct, 'test_init')
# 创建检验条目
for i in RecordFormField.objects.filter(form=form, is_deleted=False):
tri = TestRecordItem()
@ -298,6 +310,7 @@ class WProductViewSet(ListModelMixin, GenericViewSet):
i.update_by = request.user
i.update_time = timezone.now()
i.save()
WpmServies.add_wproduct_flow_log(i, 'putins')
return Response()
@action(methods=['post'], detail=True, perms_map={'post':'*'}, serializer_class=WproductPutInSerializer)
@ -345,6 +358,7 @@ class WProductViewSet(ListModelMixin, GenericViewSet):
wproduct.act_state=WProduct.WPR_ACT_STATE_INM
wproduct.warehouse=warehouse
wproduct.save()
WpmServies.add_wproduct_flow_log(wproduct, 'putin')
return Response()
@action(methods=['post'], detail=True, perms_map={'post':'*'}, serializer_class=ScrapSerializer)
@ -370,6 +384,7 @@ class WProductViewSet(ListModelMixin, GenericViewSet):
obj.update_by = request.user
obj.update_time = timezone.now()
obj.save()
WpmServies.add_wproduct_flow_log(obj, 'scrap')
return Response()
# @action(methods=['get'], detail=False, perms_map={'get':'*'})
@ -445,7 +460,11 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd
if instance.is_submited:
raise exceptions.APIException('该操作已提交')
# 恢复半成品可操作
instance.wp_operation.all().update(act_state=WProduct.WPR_ACT_STATE_DOWAIT)
for i in instance.wp_operation.all():
i.act_state = WProduct.WPR_ACT_STATE_DOWAIT
i.update_by = request.user
i.save()
WpmServies.add_wproduct_flow_log(i, 'operation_delete')
self.perform_destroy(instance)
return Response(status=status.HTTP_204_NO_CONTENT)
@ -465,9 +484,13 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd
# 创建操作所用半成品关联记录
if 'wproducts' in vdata:
owps = []
WProduct.objects.filter(pk__in=[x.id for x in vdata['wproducts']]).update(operation=op, act_state=WProduct.WPR_ACT_STATE_DOING)
splans = WpmServies.get_subplans_queryset_from_wproducts(vdata['wproducts'])
for wpd in vdata['wproducts']:
wpd.operation= op
wpd.act_state = WProduct.WPR_ACT_STATE_DOING
wpd.update_by = request.user
wpd.save()
WpmServies.add_wproduct_flow_log(wpd, 'operation_create')
owp = {}
owp['operation'] = op
owp['wproduct'] = wpd
@ -565,6 +588,7 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd
wp.operation = None
wp.update_by = request.user
wp.save()
WpmServies.add_wproduct_flow_log(wp, 'operation_submit')
elif step.type == Step.STEP_TYPE_DIV:
# 更新物料产出情况
for i in OperationMaterial.objects.filter(operation=op, type=SubprodctionMaterial.SUB_MA_TYPE_OUT):
@ -572,9 +596,12 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd
newstep, _ = WpmServies.get_next_step(i.subproduction_plan, step)
wpr = dict(material=i.material, step=newstep,
act_state=WProduct.WPR_ACT_STATE_DOWAIT, remark='',
subproduction_plan=i.subproduction_plan)
subproduction_plan=i.subproduction_plan, create_by=request.user)
for x in range(i.count):
WProduct.objects.create(**wpr)
ins = WProduct.objects.create(**wpr)
# 添加日志
WpmServies.add_wproduct_flow_log(ins, 'operation_submit')
# 更新进度
WpmServies.update_subproduction_progress_main(sp=i.subproduction_plan)
elif step.type == Step.STEP_TYPE_COMB:
oms_w = OperationMaterial.objects.filter(operation=op, type=SubprodctionMaterial.SUB_MA_TYPE_OUT,
@ -595,6 +622,7 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd
WpmServies.update_subproduction_progress_main(sp=oms_w.subproduction_plan)
wproduct.create_by = request.user
wproduct.save()
WpmServies.add_wproduct_flow_log(wproduct, 'operation_submit')
# 隐藏原半成品
wps = WProduct.objects.filter(ow_wproduct__operation = op)
wps.update(is_hidden=True, child=wproduct, update_by=request.user, update_time=timezone.now())