pd9427
This commit is contained in:
@ -5,7 +5,7 @@
|
||||
# sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
|
||||
from dataclasses import fields
|
||||
from typing import List, Optional, Dict, Any
|
||||
from datetime import datetime
|
||||
from datetime import datetime,timedelta
|
||||
from busisness.models import ArtifactInfoModel, PDRecordModel,FreqRecordModel
|
||||
from busisness.dals import ArtifactDal, PDRecordDal,FreqRecordDal
|
||||
|
||||
@ -52,24 +52,29 @@ class ArtifactBll:
|
||||
if _artifactid is None:
|
||||
return self.dal.insert_artifact(model)
|
||||
else:
|
||||
if not _artifactid and model.ArtifactID:
|
||||
update_dict={
|
||||
'ArtifactID':model.ArtifactID,
|
||||
'ArtifactActionID':model.ArtifactActionID,
|
||||
'ArtifactIDVice1':model.ArtifactIDVice1,
|
||||
'ProduceRingNumber':model.ProduceRingNumber,
|
||||
'SkeletonID':model.SkeletonID,
|
||||
'RingTypeCode':model.RingTypeCode,
|
||||
'SizeSpecification':model.SizeSpecification,
|
||||
'BuriedDepth':model.BuriedDepth,
|
||||
'BlockNumber':model.BlockNumber,
|
||||
'HoleRingMarking':model.HoleRingMarking,
|
||||
'GroutingPipeMarking':model.GroutingPipeMarking,
|
||||
'PolypropyleneFiberMarking':model.PolypropyleneFiberMarking,
|
||||
'BetonVolume':model.BetonVolume,
|
||||
'BetonTaskID':model.BetonTaskID,
|
||||
}
|
||||
return self.dal.update_by_modulecode(model.MouldCode, update_dict)
|
||||
if model.ArtifactID:
|
||||
if not _artifactid:
|
||||
#不存在ArtifactID,更新
|
||||
update_dict={
|
||||
'ArtifactID':model.ArtifactID,
|
||||
'ArtifactActionID':model.ArtifactActionID,
|
||||
'ArtifactIDVice1':model.ArtifactIDVice1,
|
||||
'ProduceRingNumber':model.ProduceRingNumber,
|
||||
'SkeletonID':model.SkeletonID,
|
||||
'RingTypeCode':model.RingTypeCode,
|
||||
'SizeSpecification':model.SizeSpecification,
|
||||
'BuriedDepth':model.BuriedDepth,
|
||||
'BlockNumber':model.BlockNumber,
|
||||
'HoleRingMarking':model.HoleRingMarking,
|
||||
'GroutingPipeMarking':model.GroutingPipeMarking,
|
||||
'PolypropyleneFiberMarking':model.PolypropyleneFiberMarking,
|
||||
'BetonVolume':model.BetonVolume,
|
||||
'BetonTaskID':model.BetonTaskID,
|
||||
}
|
||||
return self.dal.update_by_modulecode(model.MouldCode, update_dict)
|
||||
else:
|
||||
#已经存在了ArtifactID,不处理
|
||||
return 1
|
||||
|
||||
return 1
|
||||
|
||||
@ -113,6 +118,16 @@ class PDRecordBll:
|
||||
"""获取当前浇筑的后三片的派据(有可能其中一项为空,但需要保证第一条有记录)"""
|
||||
return self.dal.get_last_pds(top,mould_code)
|
||||
|
||||
def get_near_pd_scan(self,size:str) -> PDRecordModel:
|
||||
"""获取最近的派单信息"""
|
||||
_target_time = datetime.now() - timedelta(hours=4)
|
||||
where=f"SizeSpecification='{size}' and CreateTime>='{_target_time}'"
|
||||
_pdrecords=self.dal.get_top_pd(1,"ID desc",where)
|
||||
if _pdrecords:
|
||||
return _pdrecords[0]
|
||||
else:
|
||||
return None
|
||||
|
||||
def insert_PD_record(self,model:PDRecordModel) -> bool:
|
||||
"""保存PD官片任务(存在更新,不存在插入)"""
|
||||
if self.dal.exists_artifactid(model.ArtifactActionID):
|
||||
@ -125,9 +140,12 @@ class PDRecordBll:
|
||||
"""完成管片生产"""
|
||||
return self.dal.update_by_modulecode(code, {'Status': status,'EndTime':datetime.now()})
|
||||
|
||||
def start_pd(self, code: str,volumn:float) -> bool:
|
||||
"""开始管片生产"""
|
||||
return self.dal.update_by_modulecode(code, {'Status': 2,'GStatus':1,'OptTime':datetime.now(),'FBetonVolume':volumn})
|
||||
def start_pd(self, status:int,code: str,volumn:float) -> bool:
|
||||
"""开始管片生产,-1不更方量"""
|
||||
if volumn==-1:
|
||||
return self.dal.update_by_modulecode(code, {'Status': status,'GStatus':1,'OptTime':datetime.now()})
|
||||
else:
|
||||
return self.dal.update_by_modulecode(code, {'Status': status,'GStatus':1,'OptTime':datetime.now(),'FBetonVolume':volumn})
|
||||
|
||||
def update_PD_record(self,artifact_action_id: int, update_fields: dict) -> bool:
|
||||
"""更新PD官片任务状态"""
|
||||
@ -137,32 +155,44 @@ class PDRecordBll:
|
||||
"""更新PD官片任务状态"""
|
||||
return self.dal.update_pd_byid(id, update_fields)
|
||||
|
||||
def update_pd_notify(self,id: int, update_fields: dict) -> bool:
|
||||
"""更新PD官片任务状态"""
|
||||
return self.dal.update_pd_notify(id, update_fields)
|
||||
|
||||
def save_PD_record(self,model:PDRecordModel) -> int:
|
||||
|
||||
"""保存PD官片任务(存在ModuleCode更新,不存在插入,存在ArtifactID不处理)"""
|
||||
_artifactid=self.dal.get_artifactid(model.MouldCode)
|
||||
if _artifactid is None:
|
||||
if model.TaskID:
|
||||
model.ScanTime=datetime.now()
|
||||
return self.dal.insert_PD_record(model)
|
||||
else:
|
||||
if not _artifactid and model.ArtifactID:
|
||||
update_dict={
|
||||
'ArtifactID':model.ArtifactID,
|
||||
'ArtifactActionID':model.ArtifactActionID,
|
||||
'TaskID':model.TaskID,
|
||||
'ProjectName':model.ProjectName,
|
||||
'ProduceMixID':model.ProduceMixID,
|
||||
'BetonVolume':model.BetonVolume,
|
||||
'BetonGrade':model.BetonGrade,
|
||||
'BuriedDepth':model.BuriedDepth,
|
||||
'SkeletonID':model.SkeletonID,
|
||||
'RingTypeCode':model.RingTypeCode,
|
||||
'SizeSpecification':model.SizeSpecification,
|
||||
'BlockNumber':model.BlockNumber,
|
||||
'BetonVolume':model.BetonVolume,
|
||||
'GStatus':model.GStatus,
|
||||
'PlannedVolume':model.PlannedVolume
|
||||
}
|
||||
return self.dal.update_by_modulecode(model.MouldCode, update_dict)
|
||||
if model.ArtifactID:
|
||||
if not _artifactid:
|
||||
#不存在ArtifactID,更新PDRecord表
|
||||
update_dict={
|
||||
'ArtifactID':model.ArtifactID,
|
||||
'ArtifactActionID':model.ArtifactActionID,
|
||||
'TaskID':model.TaskID,
|
||||
'ProjectName':model.ProjectName,
|
||||
'ProduceMixID':model.ProduceMixID,
|
||||
'BetonVolume':model.BetonVolume,
|
||||
'BetonGrade':model.BetonGrade,
|
||||
'BuriedDepth':model.BuriedDepth,
|
||||
'SkeletonID':model.SkeletonID,
|
||||
'RingTypeCode':model.RingTypeCode,
|
||||
'SizeSpecification':model.SizeSpecification,
|
||||
'BlockNumber':model.BlockNumber,
|
||||
'BetonVolume':model.BetonVolume,
|
||||
'GStatus':model.GStatus,
|
||||
'PlannedVolume':model.PlannedVolume,
|
||||
'ScanTime':datetime.now(),
|
||||
}
|
||||
return self.dal.update_by_modulecode(model.MouldCode, update_dict)
|
||||
else:
|
||||
#已经存在了ArtifactID,不处理
|
||||
return 1
|
||||
|
||||
return 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user