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
|
||||
|
||||
|
||||
@ -233,8 +233,8 @@ class PDRecordDal(BaseDal):
|
||||
# 确保top为正整数
|
||||
if not isinstance(top, int) or top <= 0:
|
||||
raise ValueError("top参数必须是正整数")
|
||||
# _target_time = datetime.now() - timedelta(hours=4)
|
||||
_target_time ='2026-02-06 00:00:00'
|
||||
_target_time = datetime.now() - timedelta(hours=4)
|
||||
# _target_time ='2026-03-31 00:00:00'
|
||||
# 查询当前浇筑模具编号的前一条记录
|
||||
sql = f"""SELECT * FROM PDRecord WHERE CreateTime>? and ID>(
|
||||
select ID FROM PDRecord WHERE MouldCode=? and CreateTime>?
|
||||
@ -330,12 +330,23 @@ class PDRecordDal(BaseDal):
|
||||
print(f"更新PD管片任务失败: {e}")
|
||||
return False
|
||||
|
||||
def update_pd_notify(self, id: int, update_data: dict) -> bool:
|
||||
"""更新PD官片任务记录"""
|
||||
try:
|
||||
# 构建WHERE条件
|
||||
where_condition = f"ID={id} and Status<>5"
|
||||
# 使用update方法更新数据
|
||||
affected_rows = self.db_dao.update("PDRecord", update_data, where_condition)
|
||||
return affected_rows > 0
|
||||
except Exception as e:
|
||||
raise
|
||||
|
||||
def update_by_modulecode(self, module_code: str, update_data: dict) -> bool:
|
||||
"""更新构件派单记录"""
|
||||
try:
|
||||
# 构建WHERE条件
|
||||
_target_time = datetime.now() - timedelta(hours=4)
|
||||
_target_time ='2026-02-06 00:00:00'
|
||||
# _target_time ='2026-02-06 00:00:00'
|
||||
where_condition = f"MouldCode='{module_code}' and CreateTime>='{_target_time}'"
|
||||
# 使用update方法更新数据
|
||||
affected_rows = self.db_dao.update("PDRecord", update_data, where_condition)
|
||||
|
||||
@ -254,8 +254,12 @@ class PDRecordModel:
|
||||
ProjectName: str=""
|
||||
#生产配合比编号
|
||||
ProduceMixID: str=""
|
||||
#派单方量
|
||||
#设计方量
|
||||
BetonVolume: float=0.0
|
||||
#计划派单方量
|
||||
BetonVolume2: float=0.0
|
||||
#修改后的方量
|
||||
BetonVolumeUpd: float=0.0
|
||||
#实际派单方量
|
||||
FBetonVolume: float=0.0
|
||||
#实际派单方量
|
||||
@ -288,6 +292,11 @@ class PDRecordModel:
|
||||
EndTime: str=""
|
||||
#派单时间(下发)
|
||||
OptTime: str=""
|
||||
#扫描时间
|
||||
ScanTime: str=""
|
||||
#ErpID
|
||||
ErpID: str=""
|
||||
|
||||
|
||||
|
||||
@dataclass
|
||||
@ -348,4 +357,4 @@ class LEDInfo:
|
||||
# 白班拆模强度文本描述
|
||||
DayStrengthValue: str
|
||||
# 夜班拆模强度文本描述
|
||||
NihtStrengthValue: str
|
||||
NihtStrengthValue: str
|
||||
|
||||
Reference in New Issue
Block a user