|
@@ -1990,7 +1990,7 @@ class listtb(View):
|
|
|
"QY":"容器","YSSL":"套装颜色数","YMXH":"研磨品类型",
|
|
|
"QTY":"订单数量","GZSL":"灌装支数量","EST_DD":"业务交期",
|
|
|
"PD_DEP":"生产部门","REM":"备注","PMC_DD":"PMC回复交期","WH_REM":"大货备注",
|
|
|
- "operation":"操作","ITM":"项次"},
|
|
|
+ "operation":"操作","ITM":"项次","WH":"订单库位","BAT_QTY":"现存量","QTY_FIN":"已完工量","W_QTY_FIN":"未完工量"},
|
|
|
]
|
|
|
if ifmerge=='1':
|
|
|
# 排序规则
|
|
@@ -2023,12 +2023,12 @@ class listtb(View):
|
|
|
return http.JsonResponse(context)
|
|
|
total_count = result[0]["total"] #总记录数
|
|
|
total_page = math.ceil(result[0]["total"]/page_size) #计算总页数,总记录数除以每页记录数
|
|
|
- print(total_page)
|
|
|
+ # print(total_page)
|
|
|
sql = """SELECT TOP {0}
|
|
|
ORDER0 AS ORDER0 ,ISNULL(OS_DD,'') AS OS_DD,
|
|
|
ISNULL(CUS_SNM,'') AS CUS_SNM,OS_NO AS OS_NO,PRD_NO AS PRD_NO,ISNULL(DZRL,'') AS DZRL,'' AS RQ,ISNULL(YSSL,'') AS YSSL,'' AS YMXH,
|
|
|
ISNULL(QTY,0) AS QTY,ISNULL(GZSL,0) AS GZSL,left(Convert(varchar(100), EST_DD, 23), 11) AS EST_DD,PD_DEP AS PD_DEP,ISNULL(REM,'') AS REM,PMC_DD AS PMC_DD,WH_REM AS WH_REM,
|
|
|
- ITM AS ITM,SPC_NO,CUS_NO,PMC_REM
|
|
|
+ ITM AS ITM,SPC_NO,CUS_NO,PMC_REM,WH
|
|
|
FROM View_aa WHERE {1} AND OS_NO+PRD_NO+Convert(varchar(100), ITM, 23) NOT IN(SELECT TOP {2} OS_NO+PRD_NO+Convert(varchar(100), ITM, 23) FROM View_aa WHERE {3} {4}) {5}""".\
|
|
|
format(page_size,conditional,page_size*page,conditional,sort,sort)
|
|
|
# 这里是合并处理
|
|
@@ -2051,12 +2051,12 @@ class listtb(View):
|
|
|
# conditional 条件
|
|
|
# gurup_by 分组
|
|
|
# sort 排序
|
|
|
- gurup_by = ' GROUP BY OS_NO,PRD_NO,OS_DD,PMC_DD,ORDER0,CUS_SNM,DZRL,RQ,PD_DEP,REM '
|
|
|
+ gurup_by = ' GROUP BY OS_NO,PRD_NO,OS_DD,PMC_DD,ORDER0,CUS_SNM,DZRL,RQ,PD_DEP,REM,WH '
|
|
|
conditional = ' left(Convert(varchar(100), OS_DD, 23), 11) >=' + "'" + st_time + "'" + ' AND ' + 'left(Convert(varchar(100), OS_DD, 23), 11) <=' + "'" + sh_time + "'" + cus_no + cls_id + PMC_REM + \
|
|
|
business_time + prd_no + sc_dep + os_type + capacity
|
|
|
sql_count = ("""SELECT COUNT(OS_NO) AS total FROM (SELECT OS_NO FROM View_aa WHERE {0} {1}) A""".format(conditional,gurup_by))
|
|
|
# sql_count = ("""SELECT COUNT(OS_NO) AS total FROM View_aa WHERE {0} {1}""".format(conditional,gurup_by))
|
|
|
- print(sql_count)
|
|
|
+ # print(sql_count)
|
|
|
result = executeQuery(sql_count)
|
|
|
if len(result) == 0 or result[0]["total"]==0:
|
|
|
context = {
|
|
@@ -2068,16 +2068,16 @@ class listtb(View):
|
|
|
}
|
|
|
return http.JsonResponse(context)
|
|
|
total_count = result[0]["total"] # 总记录数
|
|
|
- print(total_count)
|
|
|
+ # print(total_count)
|
|
|
total_page = math.ceil(result[0]["total"] / page_size) # 计算总页数,总记录数除以每页记录数
|
|
|
- print(total_page)
|
|
|
+ # print(total_page)
|
|
|
sql = """SELECT TOP {0} ORDER0 AS ORDER0 ,ISNULL(OS_DD,'') AS OS_DD,
|
|
|
ISNULL(CUS_SNM,'') AS CUS_SNM,OS_NO AS OS_NO,PRD_NO AS PRD_NO,ISNULL(DZRL,'') AS DZRL,'' AS RQ,SUM(ISNULL(YSSL,0)) AS YSSL,'' AS YMXH,
|
|
|
SUM(ISNULL(QTY,0)) AS QTY,SUM(ISNULL(GZSL,0)) AS GZSL,
|
|
|
stuff((SELECT ';' + replace(CONVERT(CHAR(19), left(Convert(varchar(100), B.EST_DD, 23), 11), 120),' ','') FROM View_aa B WHERE A.OS_NO=B.OS_NO AND B.PRD_NO=A.PRD_NO FOR xml path('')),1,1,'')AS EST_DD
|
|
|
,PD_DEP AS PD_DEP,ISNULL(REM,'') AS REM,PMC_DD AS PMC_DD,
|
|
|
stuff((SELECT ';' + CAST(B.WH_REM AS VARCHAR(500)) FROM View_aa B WHERE A.OS_NO=B.OS_NO AND B.PRD_NO=A.PRD_NO FOR xml path('')),1,1,'')AS WH_REM,
|
|
|
-stuff((SELECT ';' + CAST(B.ITM AS VARCHAR(500)) FROM View_aa B WHERE A.OS_NO=B.OS_NO AND B.PRD_NO=A.PRD_NO FOR xml path('')),1,1,'')AS ITM
|
|
|
+stuff((SELECT ';' + CAST(B.ITM AS VARCHAR(500)) FROM View_aa B WHERE A.OS_NO=B.OS_NO AND B.PRD_NO=A.PRD_NO FOR xml path('')),1,1,'')AS ITM,'','','',WH
|
|
|
FROM View_aa A WHERE {1} AND OS_NO+PRD_NO NOT IN(SELECT TOP {2} OS_NO+PRD_NO FROM View_aa WHERE {3} {4} {5}){6} {7}""".\
|
|
|
format(page_size,conditional,page_size*page,conditional,gurup_by,sort,gurup_by,sort)
|
|
|
# print(sql)
|
|
@@ -2088,10 +2088,30 @@ stuff((SELECT ';' + CAST(B.ITM AS VARCHAR(500)) FROM View_aa B WHERE A.OS_NO=B.O
|
|
|
for i in no_data:
|
|
|
# print(1111)
|
|
|
# OS_NO.append(i[5])
|
|
|
+ # 增量已完工未完工,现存量
|
|
|
+ sql_qty = """SELECT ISNULL(SUM(A.BAT_QTY),0) AS BAT_QTY,ISNULL(CAST(SUM(ISNULL(B.QTY_FIN,0)) AS FLOAT),0) AS QTY_FIN FROM
|
|
|
+ (SELECT CAST(SUM(ISNULL(QTY_IN,0)-ISNULL(QTY_OUT,0)) AS FLOAT) AS BAT_QTY,PRD_NO,WH FROM BAT_REC1 GROUP BY PRD_NO,WH)A
|
|
|
+ left join MF_MO B ON A.PRD_NO=B.MRP_NO
|
|
|
+ WHERE A.PRD_NO='{0}' AND B.SO_NO='{1}' AND A.WH='{2}'""".format(i[4],i[3],i[20])
|
|
|
+ # print(sql_qty)
|
|
|
+ try:
|
|
|
+ result = executeQuery(sql_qty)[0]
|
|
|
+ except Exception:
|
|
|
+ return http.HttpResponseForbidden("查询库存异常")
|
|
|
+ # print(result)
|
|
|
+ # 定义现存量BAT_QTY,"QTY_FIN":"已完工量","W_QTY_FIN":"未完工量"
|
|
|
+ BAT_QTY=0
|
|
|
+ QTY_FIN=0
|
|
|
+ W_QTY_FIN=0
|
|
|
+ if len(result)>0:
|
|
|
+ BAT_QTY=result["BAT_QTY"]
|
|
|
+ QTY_FIN=result["QTY_FIN"]
|
|
|
+ W_QTY_FIN=float(i[9])-result["QTY_FIN"]
|
|
|
data.append({"ORDER0": i[0], "OS_DD": str(i[1])[:10] , "CUS_SNM": i[2], "OS_NO": str(i[3]),
|
|
|
"PRD_NO": i[4], "DZRL": i[5], "QY": i[6], "YSSL": i[7],
|
|
|
"YMXH": i[8], "QTY": float(i[9]),"GZSL": float(i[10]),"EST_DD": str(i[11]),
|
|
|
- "PD_DEP": i[12],"REM":i[13],"PMC_DD": str(i[14]),"WH_REM": i[15],"operation": "保存","ITM":i[16]})
|
|
|
+ "PD_DEP": i[12],"REM":i[13],"PMC_DD": str(i[14]),"WH_REM": i[15],"operation": "保存",
|
|
|
+ "ITM":i[16],"WH":i[20],"BAT_QTY":BAT_QTY,"QTY_FIN":QTY_FIN,"W_QTY_FIN":W_QTY_FIN})
|
|
|
|
|
|
# print(data)啊
|
|
|
# print(sql)
|
|
@@ -2317,6 +2337,7 @@ class DepMacfDepData(View):
|
|
|
dep = request.GET["dep"].split('->')[0] #部门编码->这里需要进行切割,因为传过来的是编码+名称(’编码->名称‘)
|
|
|
except Exception:
|
|
|
dep = request.GET["dep"]
|
|
|
+ dep_ie = dep #这里是用于
|
|
|
try:
|
|
|
selected = executeQuery(f"SELECT selected FROM DSCSETTING WHERE DEP='{dep}'")[0]["selected"]
|
|
|
except Exception:
|
|
@@ -2326,10 +2347,12 @@ class DepMacfDepData(View):
|
|
|
else:
|
|
|
dep = "AND b.UP=" + "'" + dep + "' " +"AND b.selected='T'"
|
|
|
sql = ("""SELECT b.dep,b.dep_name as dep_name,cast(sum(isnull(a.QTY_FIN,0)) as decimal(14,2)) as ok_qty,cast(sum(ISNULL(a.QTY,0)-isnull(a.QTY_FIN,0)) as decimal(14,2)) as un_qty,
|
|
|
- cast(max(B.s_capacity) as float) as s_capacity ,cast(max(B.s_d_staffing) as float) as s_d_staffing ,0 as e_capacity ,0 as tolf_days ,0 as epl_personnel ,0 as p_d_f_e_configurations,
|
|
|
+ cast(max(B.s_capacity) as float) as s_capacity ,cast(max(C.total_manpower) as float) as s_d_staffing ,0 as e_capacity ,0 as tolf_days ,0 as epl_personnel ,0 as p_d_f_e_configurations,
|
|
|
'' as a_strength ,0 as e_a_workers ,0 as work_sum,0 as zj_274_24 ,0 as a_274_24 ,0 as new_personnel ,'' as rem ,0 as need_hours, 0 as a_25 ,
|
|
|
0 as e_d_workers ,0 as p_gap
|
|
|
- from mf_mo a left join DSCSETTING b on a.dep=b.dep where isnull(a.CLOSE_ID,'')!='T' {0} group by b.dep,b.dep_name""".format(dep))
|
|
|
+ from mf_mo a left join DSCSETTING b on a.dep=b.dep
|
|
|
+ left join MF_IEFILE c on a.dep=c.dep and iefile_no in(select max(iefile_no) from MF_IEFILE where dep='{0}')
|
|
|
+ where isnull(a.CLOSE_ID,'')!='T' {1} group by b.dep,b.dep_name""".format(dep_ie,dep))
|
|
|
print(sql)
|
|
|
try:
|
|
|
result = executeQuery(sql)
|
|
@@ -2765,7 +2788,6 @@ class IeFileMaintaintm(View):
|
|
|
# ie工艺号文件维护接口
|
|
|
class IeFileMaintain(View):
|
|
|
def get(self,request):
|
|
|
- print(request.GET)
|
|
|
# 校验参数合法性
|
|
|
sqlinjection = sqlinjections().ifsql(request.GET)
|
|
|
if sqlinjection:
|
|
@@ -2810,7 +2832,7 @@ class IeFileMaintain(View):
|
|
|
(3600/A.point)/A.total_manpower AS rjcn,8*(3600/A.point) AS bxscn,A.postil_up/((3600/A.point)/A.total_manpower) AS djcb,
|
|
|
A.total_manpower*8 AS bzzys,'T' AS qiting,'' AS qitingexplain,''AS choice FROM MF_IEFILE A,TF_IEFILE_BOM B,TF_MM0 C
|
|
|
WHERE A.IEFILE_NO = B.IEFILE_NO AND B.BOM_NO=C.ID_NO {0}""".format(parameter)
|
|
|
- print(sql)
|
|
|
+ # print(sql)
|
|
|
try:
|
|
|
result = executeQuery(sql)
|
|
|
except Exception:
|
|
@@ -2827,7 +2849,7 @@ class IeFileMaintain(View):
|
|
|
"rem":i["rem"],"iefile_no":i["iefile_no"],"sys_date":i["sys_date"].strftime('%Y-%m-%d'),"user_no":i["user_no"],"bzsj":float(i["bzsj"]),"scxphl":float('%.2f' %i["scxphl"]),"scxbphl":float('%.2f' %i["scxbphl"]),
|
|
|
"ssgs": float(i["ssgs"]),"scjp": float(i["scjp"]),"xscn": float(i["xscn"]),"rjcn": float(i["rjcn"]),"bxscn": float(i["bxscn"]),"djcb": float(i["djcb"]),"bzzys": float(i["bzzys"]),
|
|
|
"qiting":i["qiting"],"qitingexplain":i["qitingexplain"],"choice":i["choice"]})
|
|
|
- print(data)
|
|
|
+ # print(data)
|
|
|
content = {
|
|
|
"data":data,
|
|
|
"mssage": "ie文件查询成功",
|
|
@@ -2838,6 +2860,7 @@ class IeFileMaintain(View):
|
|
|
def post(self,request):
|
|
|
req_data = json.loads(request.body.decode())["data"]
|
|
|
# print(req_data)
|
|
|
+ sid = transaction.savepoint() # 开启事物
|
|
|
with connection.cursor() as cursor:
|
|
|
for i in req_data["selected_data"]:
|
|
|
print(i)
|
|
@@ -2847,6 +2870,7 @@ class IeFileMaintain(View):
|
|
|
cursor.execute(sql, [])
|
|
|
except Exception:
|
|
|
return http.HttpResponseForbidden("异常操作,修改失败")
|
|
|
+ transaction.savepoint_commit(sid) # 提交事物
|
|
|
content = {
|
|
|
"mssage": "设置启用状态成功",
|
|
|
"code": 200
|
|
@@ -2873,10 +2897,22 @@ class IeFileMaintain(View):
|
|
|
bxscn = req_data.get("bxscn") #8小时产能(套)
|
|
|
djcb = req_data.get("djcb") #单件成本(套)
|
|
|
bzzys = req_data.get("bzzys") #标准总用时(小时)
|
|
|
- mo_no=req_data.get("mm_no")
|
|
|
+ mm_no=req_data.get("mm_no")
|
|
|
+ data_timeqi_mo=req_data.get("data_timeqi_mo")
|
|
|
+ data_timezhi_mo=req_data.get("data_timezhi_mo")
|
|
|
+ if not all([data_timeqi_mo,data_timezhi_mo]):
|
|
|
+ return http.HttpResponseForbidden("请选择时间")
|
|
|
+ # 校验日期格式
|
|
|
+ try:
|
|
|
+ datetime.datetime.strptime(data_timeqi_mo, '%Y-%m-%d')
|
|
|
+ datetime.datetime.strptime(data_timezhi_mo, '%Y-%m-%d')
|
|
|
+ except Exception:
|
|
|
+ return http.HttpResponseForbidden('日期格式输入不正确')
|
|
|
+ data_time = " AND left(Convert(varchar(100), MM_DD, 23), 11)>=" + "'" + data_timeqi_mo + "'" + " AND left(Convert(varchar(100), MM_DD, 23), 11)<=" + "'" + data_timezhi_mo + "'"
|
|
|
# 判断是否有数据
|
|
|
if len(selected_data)<=0:
|
|
|
return http.HttpResponseForbidden("没有选择数据")
|
|
|
+ sid = transaction.savepoint() # 开启事物
|
|
|
with connection.cursor() as cursor:
|
|
|
for i in selected_data:
|
|
|
# 1、利用单号查询阶梯单价
|
|
@@ -2886,14 +2922,18 @@ class IeFileMaintain(View):
|
|
|
except Exception:
|
|
|
return http.HttpResponseForbidden("阶梯单价查询异常")
|
|
|
#1、1查询缴库单信息
|
|
|
- if len(mo_no)<=0:
|
|
|
- sql2 = """SELECT MM_NO,ID_NO,PRD_NO,CAST(QTY AS FLOAT ) AS QTY,ITM FROM TF_MM0 WHERE MM_ID='MM' AND ID_NO='{0}'""".format(i["bom_no"])
|
|
|
+ if len(mm_no)<=0:
|
|
|
+ sql2 = """SELECT MM_NO,ID_NO,PRD_NO,CAST(QTY AS FLOAT ) AS QTY,ITM FROM TF_MM0 WHERE MM_ID='MM' AND ID_NO='{0}' {1}""".format(i["bom_no"],data_time)
|
|
|
+ print(sql2)
|
|
|
else:
|
|
|
- sql2 = """SELECT MM_NO,ID_NO,PRD_NO,CAST(QTY AS FLOAT ) AS QTY,ITM FROM TF_MM0 WHERE MM_ID='MM' AND ID_NO='{0}' AND MM_NO='{1}'""".format(i["bom_no"],mo_no)
|
|
|
+ sql2 = """SELECT MM_NO,ID_NO,PRD_NO,CAST(QTY AS FLOAT ) AS QTY,ITM FROM TF_MM0 WHERE MM_ID='MM' AND ID_NO='{0}' AND MM_NO='{1}' {2}""".format(i["bom_no"],mm_no,data_time)
|
|
|
+ print(sql2)
|
|
|
try:
|
|
|
result_mm_no = executeQuery(sql2)
|
|
|
+ if len(result_mm_no)<=0:
|
|
|
+ return http.HttpResponseForbidden("指定更新缴库单号时间范围内无缴库单")
|
|
|
except Exception:
|
|
|
- return http.HttpResponseForbidden("查询缴库单异常")
|
|
|
+ return http.HttpResponseForbidden("指定更新缴库单号时间范围内无缴库单")
|
|
|
# 如果查询得到缴库单的时候遍历
|
|
|
if len(result_mm_no)>0:
|
|
|
# 这里可以拿到每个缴库单的数量
|
|
@@ -2904,7 +2944,7 @@ class IeFileMaintain(View):
|
|
|
DJCB_T_MB='{16}',BZZYS_H_MB='{17}' WHERE MM_NO='{18}' AND ITM='{19}'"""\
|
|
|
.format(i["hr_up"],i["file_serial"],i["workshop_name"],i["dep_name"],i["total_manpower"],i["point"],i["job_time"],i["postil_up"],i["bzsj"],
|
|
|
i["scxphl"],i["scxbphl"],i["ssgs"],i["scjp"],i["xscn"],i["rjcn"],i["bxscn"],i["djcb"],i["bzzys"],result_mm_no_qty["MM_NO"],result_mm_no_qty["ITM"])
|
|
|
- print(sql)
|
|
|
+ # print(sql)
|
|
|
cursor.execute(sql, [])
|
|
|
# 有设置阶梯单价的时候
|
|
|
if len(result_up)>0:
|
|
@@ -2918,12 +2958,17 @@ class IeFileMaintain(View):
|
|
|
break
|
|
|
except Exception:
|
|
|
return http.HttpResponseForbidden("更新数据异常1")
|
|
|
+ #没有设置阶梯单价的时候设置计件单价为文件标注单价
|
|
|
else:
|
|
|
+ # 查询批注单价
|
|
|
try:
|
|
|
- sql3 = """UPDATE TF_MM0_z SET JJDJ_MB={0} WHERE MM_NO='{1}' AND ITM='{2}'""".format(result_row["UP"], result_mm_no_qty["MM_NO"], i["postil_up"])
|
|
|
- # print(sql3)
|
|
|
+ sql4 = """SELECT CAST(postil_up AS FLOAT) AS postil_up FROM MF_IEFILE WHERE IEFILE_NO='{0}'""".format(i["iefile_no"])
|
|
|
+ postil_up = executeQuery(sql4)[0]["postil_up"]
|
|
|
+ except Exception:
|
|
|
+ return http.HttpResponseForbidden("查询批注单价异常")
|
|
|
+ try:
|
|
|
+ sql3 = """UPDATE TF_MM0_z SET JJDJ_MB={0} WHERE MM_NO='{1}' AND ITM='{2}'""".format(postil_up, result_mm_no_qty["MM_NO"], result_mm_no_qty["ITM"])
|
|
|
cursor.execute(sql3, [])
|
|
|
- break
|
|
|
except Exception:
|
|
|
return http.HttpResponseForbidden("更新数据异常2")
|
|
|
# if len(result_up)>0:
|
|
@@ -2932,8 +2977,7 @@ class IeFileMaintain(View):
|
|
|
# print(2222222222222)
|
|
|
# else:
|
|
|
# print("直接更新批注单价")
|
|
|
-
|
|
|
- print(req_data)
|
|
|
+ transaction.savepoint_commit(sid) # 提交事物
|
|
|
content = {
|
|
|
"mssage": "修改成功",
|
|
|
"code": 200
|
|
@@ -2942,6 +2986,7 @@ class IeFileMaintain(View):
|
|
|
def delete(self,request):
|
|
|
req_data = json.loads(request.body.decode())
|
|
|
# print(req_data)
|
|
|
+ sid = transaction.savepoint() # 开启事物
|
|
|
with connection.cursor() as cursor:
|
|
|
for i in req_data["selected_data"]:
|
|
|
print(i)
|
|
@@ -2951,15 +2996,198 @@ class IeFileMaintain(View):
|
|
|
cursor.execute(sql, [])
|
|
|
except Exception:
|
|
|
return http.HttpResponseForbidden("异常操作,修改失败")
|
|
|
+ transaction.savepoint_commit(sid) # 提交事物
|
|
|
content = {
|
|
|
"mssage": "删除成功",
|
|
|
"code": 200
|
|
|
}
|
|
|
return http.JsonResponse(content)
|
|
|
-#ie文件号明细表
|
|
|
-class IeFileMaintainDetail(View):
|
|
|
+#ie文件号明细表渲染
|
|
|
+class IeFileMaintainDetailtm(View):
|
|
|
def get(self,request):
|
|
|
return render(request, 'iefilemaintaindetail.html')
|
|
|
+#数据接口
|
|
|
+class IeFileMaintainDetail(View):
|
|
|
+ def get(self, request):
|
|
|
+ erp_dep = request.GET['erp_dep']
|
|
|
+ iefileno = request.GET['iefileno']
|
|
|
+ data_timeqi = request.GET['data_timeqi']
|
|
|
+ data_timezhi = request.GET['data_timezhi']
|
|
|
+ cls_id = request.GET['cls_id']
|
|
|
+ if not all([data_timeqi,data_timezhi,cls_id]):
|
|
|
+ return http.HttpResponseForbidden("请选择时间,以及其他相关参数")
|
|
|
+ # 校验日期格式
|
|
|
+ try:
|
|
|
+ datetime.datetime.strptime(data_timeqi, '%Y-%m-%d')
|
|
|
+ datetime.datetime.strptime(data_timezhi, '%Y-%m-%d')
|
|
|
+ except Exception:
|
|
|
+ return http.HttpResponseForbidden('日期格式输入不正确')
|
|
|
+ if erp_dep :
|
|
|
+ erp_dep = " AND C.DEP="+"'"+erp_dep+"'"
|
|
|
+ else:
|
|
|
+ erp_dep=''
|
|
|
+ if iefileno :
|
|
|
+ iefileno = " AND A.IEFILE_NO="+"'"+iefileno+"'"
|
|
|
+ else:
|
|
|
+ iefileno=''
|
|
|
+ if cls_id=='1':
|
|
|
+ cls_id=''
|
|
|
+ elif cls_id=='2':
|
|
|
+ cls_id=" AND ISNULL(A3.CLOSE_ID,'')='T'"
|
|
|
+ else:
|
|
|
+ cls_id = " AND ISNULL(A3.CLOSE_ID,'')<>'T'"
|
|
|
+ data_time=" AND left(Convert(varchar(100), c.MM_DD, 23), 11)>=" + "'" + data_timeqi + "'" + " AND left(Convert(varchar(100), c.MM_DD, 23), 11)<=" + "'" + data_timezhi + "'"
|
|
|
+ parameter = data_time+ erp_dep + iefileno
|
|
|
+ sql = """select isnull(e.gdmc_mb,'') as gdmc_mb,d.prd_no,isnull(d.PRD_NAME,'') as prd_name,isnull(d.SO_NO,'') as so_no,d.mm_no
|
|
|
+,isnull(e.ZYXT_MB,'') as zyxt_mb,ISNULL(f.name,'') AS dep_name,g.name as t_wh,isnull(cast(d.qty as float),0) as t_qty
|
|
|
+,cast(isnull(e.JJDJ_MB,0) as float) as jjdj_mb,CAST(isnull(e.JJDJ_MB,0)*isnull(d.qty,0) AS FLOAT) as jj_up
|
|
|
+,CAST(isnull(a1.mo_bc_qty,0) AS FLOAT) AS mo_bc_qty
|
|
|
+,CAST(isnull(a2.mo_ym_qty,0) AS FLOAT) AS mo_ym_qty
|
|
|
+,CAST((isnull(a3.QTY_FIN,0)-a3.qty)/a3.qty AS FLOAT) AS cj_qty
|
|
|
+,cast(isnull(E.PJSJ_S_MB,0) as float) AS pjsj_s_mb,CAST(isnull(A.job_time,0) AS FLOAT) AS job_time,A.file_serial
|
|
|
+,'' as sjgs,'' as kqjs,'' as wdyy,'' as gscs,'' as bzjkjs,'' as bzjkgs
|
|
|
+,cast(isnull(E.xxcn_t_mb,0) as float) as xxcn_t_mb,cast(isnull(E.rjcn_t_mb,0) as float) as rjcn_t_mb
|
|
|
+,case when isnull(a3.CLOSE_ID,'')='T' then 'T'else 'F' end as mo_cli_id,a3.mo_no,cast(a3.qty as float) as mo_qty
|
|
|
+,cast(isnull(a3.QTY_FIN_UNSH,0) as float) as ws__mo_qty,cast(isnull(a3.QTY_FIN,0) as float) as sh_mo_qty
|
|
|
+,cast(a.total_manpower as float) as total_manpower,a.iefile_no,d.itm,d.id_no
|
|
|
+from MF_IEFILE A
|
|
|
+, TF_IEFILE_BOM b
|
|
|
+, MF_MM0 c
|
|
|
+, TF_MM0 d
|
|
|
+--包材齐套率
|
|
|
+LEFT JOIN
|
|
|
+(select ROUND(sum(a.QTY/(a.QTY_RSV+isnull(a.QTY_LOST,0))),2) as mo_bc_qty,mo_no from TF_MO a,prdt b,INDX C where a.prd_no=b.prd_no
|
|
|
+AND C.IDX_NO=B.IDX1 AND C.IDX_UP='C'
|
|
|
+GROUP BY A.MO_NO) A1 ON a1.mo_no=d.mo_no
|
|
|
+--研磨品齐套率
|
|
|
+LEFT JOIN
|
|
|
+(select ROUND(sum(a.QTY/(a.QTY_RSV+isnull(a.QTY_LOST,0))),2) as mo_ym_qty,mo_no from TF_MO a,prdt b,INDX C where a.prd_no=b.prd_no
|
|
|
+AND C.IDX_NO=B.IDX1 AND C.IDX_UP='A'
|
|
|
+GROUP BY A.MO_NO) A2 ON a2.mo_no=d.mo_no
|
|
|
+--超交率
|
|
|
+LEFT JOIN MF_MO A3 ON A3.MO_NO=D.MO_NO
|
|
|
+, TF_MM0_z e
|
|
|
+, DEPT F
|
|
|
+, MY_wh G
|
|
|
+where A.CLS_ID='T' AND a.iefile_no=b.iefile_no and b.bom_no=d.id_no and c.MM_NO=d.MM_NO and d.MM_NO=e.MM_NO and d.itm=e.itm and
|
|
|
+ c.dep=f.dep and d.wh=g.wh {0} {1}""".format(parameter,cls_id)
|
|
|
+ print(sql)
|
|
|
+ try:
|
|
|
+ result = executeQuery(sql)
|
|
|
+ if len(result)<=0:
|
|
|
+ return http.HttpResponseForbidden('没有查询到数据')
|
|
|
+ except Exception:
|
|
|
+ return http.HttpResponseForbidden('没有查询到数据')
|
|
|
+ data=[{"gdmc_mb":"工序类型","prd_no":"产品","prd_name":"产品名称","so_no":"计划受订","mm_no":"缴库单号","zyxt_mb":"生产线","dep_name":"缴库班组",
|
|
|
+ "t_wh":"仓库","t_qty":"缴库数量","jjdj_mb":"计件单价","jj_up":"计件金额","mo_bc_qty":"包材齐套率","mo_ym_qty":"研磨品齐套率","cj_qty":"超缴率",
|
|
|
+ "pjsj_s_mb":"瓶颈节拍(S)","job_time":"参考工时","file_serial":"工艺文件","sjgs":"实际工时","kqjs":"考勤机时","wdyy":"未达成原因分析/责任部门",
|
|
|
+ "gscs":"改善措施/其他说明项","bzjkjs":"标准缴库机时","bzjkgs":"标准缴库工时","xxcn_t_mb":"IE小时产能","rjcn_t_mb":"IE人均小时产能","mo_cli_id":"结案状态",
|
|
|
+ "mo_no":"制令单号","mo_qty":"需生产量","ws__mo_qty":"缴库未审","sh_mo_qty":"缴库已审","dep_qty_sum":"车间达成数量合计","total_manpower":"车间效率标准","s_ie":"IE单价"}]
|
|
|
+ if len(result)>10000:
|
|
|
+ return http.HttpResponseForbidden("查询记录数过大请重新缩小查询范围")
|
|
|
+ if len(result) != 0:
|
|
|
+ for i in result:
|
|
|
+ # 查询车间达成数量合计
|
|
|
+ i["dep_qty_sum"]=''
|
|
|
+ if len(i["zyxt_mb"])>0:
|
|
|
+ sql2 ="""select isnull(cast(sum(c.qty) as float),0) dep_qty_sum from TF_MM0 c,TF_MM0_z b where c.mm_no=b.mm_no and c.itm=b.itm and b.zyxt_mb
|
|
|
+ in(select dep_name from DSCSETTING where up=(SELECT up FROM DSCSETTING where dep_name='{0}' and selected='T') ) {1}""".format(i["zyxt_mb"],data_time)
|
|
|
+ # print(sql2)
|
|
|
+ try:
|
|
|
+ dep_qty_sum = executeQuery(sql2)[0]["dep_qty_sum"]
|
|
|
+ # print(dep_qty_sum)
|
|
|
+ except Exception:
|
|
|
+ dep_qty_sum=''
|
|
|
+ i["dep_qty_sum"]=dep_qty_sum
|
|
|
+ # 处理IE单价
|
|
|
+ # 1、利用单号查询阶梯单价
|
|
|
+ sql3 = """SELECT IEFILE_NO,CAST(QTY AS FLOAT) AS QTY,CAST(UP AS FLOAT) AS UP FROM TF_IEFILE_UP WHERE IEFILE_NO ='{0}' ORDER BY QTY ASC""".format(i["iefile_no"])
|
|
|
+ try:
|
|
|
+ result_up = executeQuery(sql3)
|
|
|
+ except Exception:
|
|
|
+ return http.HttpResponseForbidden("阶梯单价查询异常")
|
|
|
+ # 1、1查询缴库单信息
|
|
|
+ sql4 = """SELECT MM_NO,ID_NO,PRD_NO,CAST(QTY AS FLOAT ) AS QTY,ITM FROM TF_MM0 WHERE MM_ID='MM' AND ID_NO='{0}' AND MM_NO='{1}' AND ITM='{2}'""".format(
|
|
|
+ i["id_no"], i["mm_no"],i["itm"])
|
|
|
+ try:
|
|
|
+ result_mm_no = executeQuery(sql4)[0]
|
|
|
+ except Exception:
|
|
|
+ return http.HttpResponseForbidden("查询缴库单异常")
|
|
|
+ # 遍历阶梯单价并判断是否得到合法的ie单价
|
|
|
+ s_ie=''
|
|
|
+ for result_qty in result_up:
|
|
|
+ if result_mm_no["QTY"]<=result_qty["QTY"]:
|
|
|
+ s_ie = result_qty["UP"]
|
|
|
+ break
|
|
|
+ data.append({"gdmc_mb":i["gdmc_mb"],"prd_no":i["prd_no"],"prd_name":i["prd_name"],"so_no":i["so_no"],"mm_no":i["mm_no"],"zyxt_mb":i["zyxt_mb"],"dep_name":i["dep_name"],
|
|
|
+ "t_wh":i["t_wh"],"t_qty":i["t_qty"],"jjdj_mb":i["jjdj_mb"],"jj_up":i["jj_up"],"mo_bc_qty":i["mo_bc_qty"],"mo_ym_qty":i["mo_ym_qty"],"cj_qty":i["cj_qty"],
|
|
|
+ "pjsj_s_mb": i["pjsj_s_mb"],"job_time":i["job_time"],"file_serial":i["file_serial"],"sjgs":i["sjgs"],"kqjs":i["kqjs"],"wdyy":i["wdyy"],"gscs":i["gscs"],
|
|
|
+ "bzjkjs": i["bzjkjs"],"bzjkgs":i["bzjkgs"],"xxcn_t_mb":i["xxcn_t_mb"],"rjcn_t_mb":i["rjcn_t_mb"],"mo_cli_id":i["mo_cli_id"],"mo_no":i["mo_no"],"mo_qty":i["mo_qty"],
|
|
|
+ "ws__mo_qty": i["ws__mo_qty"],"sh_mo_qty":i["sh_mo_qty"],"dep_qty_sum":i["dep_qty_sum"],"total_manpower":i["total_manpower"],"s_ie":s_ie})
|
|
|
+ content = {
|
|
|
+ "data": data,
|
|
|
+ "mssage": "查询明细成功",
|
|
|
+ "code": 200
|
|
|
+ }
|
|
|
+ return http.JsonResponse(content)
|
|
|
+#ie文件号统计表渲染
|
|
|
+class IeFileMaintaInfotm(View):
|
|
|
+ def get(self, request):
|
|
|
+ return render(request, 'iefilemaintaininfo.html')
|
|
|
+
|
|
|
+# ie文件号统计表数据接口
|
|
|
+class IeFileMaintaInfo(View):
|
|
|
+ def get(self, request):
|
|
|
+ erp_dep = request.GET['erp_dep']
|
|
|
+ iefileno = request.GET['iefileno']
|
|
|
+ data_timeqi = request.GET['data_timeqi']
|
|
|
+ data_timezhi = request.GET['data_timezhi']
|
|
|
+ cls_id = request.GET['cls_id']
|
|
|
+ if not all([data_timeqi, data_timezhi, cls_id]):
|
|
|
+ return http.HttpResponseForbidden("请选择时间,以及其他相关参数")
|
|
|
+ # 校验日期格式
|
|
|
+ try:
|
|
|
+ datetime.datetime.strptime(data_timeqi, '%Y-%m-%d')
|
|
|
+ datetime.datetime.strptime(data_timezhi, '%Y-%m-%d')
|
|
|
+ except Exception:
|
|
|
+ return http.HttpResponseForbidden('日期格式输入不正确')
|
|
|
+ if erp_dep:
|
|
|
+ erp_dep = " AND A.DEP=" + "'" + erp_dep + "'"
|
|
|
+ else:
|
|
|
+ erp_dep = ''
|
|
|
+ if iefileno:
|
|
|
+ iefileno = " AND C.IEFILE_NO=" + "'" + iefileno + "'"
|
|
|
+ else:
|
|
|
+ iefileno = ''
|
|
|
+ if cls_id == '1':
|
|
|
+ cls_id = ''
|
|
|
+ elif cls_id == '2':
|
|
|
+ cls_id = " AND ISNULL(B.CLOSE_ID,'')='T'"
|
|
|
+ else:
|
|
|
+ cls_id = " AND ISNULL(B.CLOSE_ID,'')<>'T'"
|
|
|
+ data_time = " AND left(Convert(varchar(100), A.MM_DD, 23), 11)>=" + "'" + data_timeqi + "'" + " AND left(Convert(varchar(100), A.MM_DD, 23), 11)<=" + "'" + data_timezhi + "'"
|
|
|
+ parameter = data_time + erp_dep + iefileno +cls_id
|
|
|
+ sql = """SELECT B.dep,C.dep_name,CAST(SUM(B.qty_fin) AS FLOAT) AS qty_fin,CAST(sum(C.total_manpower) AS FLOAT) AS tjbz,CAST(SUM(B.qty) AS FLOAT) AS qty,CAST(ROUND(SUM(B.QTY_FIN)/SUM(C.total_manpower),2) AS FLOAT) as xl
|
|
|
+ FROM TF_MM0 A
|
|
|
+, MF_MO B,MF_IEFILE C
|
|
|
+WHERE A.MO_NO=B.MO_NO AND A.DEP=B.DEP AND A.DEP=C.DEP AND C.CLS_ID='T' {0} GROUP BY B.DEP,C.dep_name """.format(parameter)
|
|
|
+ print(sql)
|
|
|
+ try:
|
|
|
+ result = executeQuery(sql)
|
|
|
+ if len(result)<=0:
|
|
|
+ return http.HttpResponseForbidden('没有查询到数据')
|
|
|
+ except Exception:
|
|
|
+ return http.HttpResponseForbidden('没有查询到数据')
|
|
|
+ data=[{"dep":"车间编码","dep_name":"车间名称","tjbz":"统计标准","qty_fin":"统计数量","xl":"效率"}]
|
|
|
+ for i in result:
|
|
|
+ data.append({"dep":i["dep"],"dep_name":i["dep_name"],"tjbz":i["tjbz"],"qty_fin":i["qty_fin"],"xl":i["xl"]})
|
|
|
+ print(data)
|
|
|
+ content = {
|
|
|
+ "data": data,
|
|
|
+ "mssage": "查询明细成功",
|
|
|
+ "code": 200
|
|
|
+ }
|
|
|
+ return http.JsonResponse(content)
|
|
|
# 测试
|
|
|
class text(View):
|
|
|
def get(self, request):
|