|
@@ -7,6 +7,8 @@ from utils import *
|
|
|
from utils.sg_auth import *
|
|
|
from models import *
|
|
|
from sqlalchemy import text, exists, and_, or_, not_
|
|
|
+from exceptions import *
|
|
|
+import traceback
|
|
|
|
|
|
router = APIRouter()
|
|
|
|
|
@@ -17,37 +19,73 @@ async def accept(
|
|
|
param: dict = Depends(yst_request_param),
|
|
|
db: Session = Depends(get_db)
|
|
|
):
|
|
|
- bzid = get_req_param(param, 'uuid')
|
|
|
- print(param)
|
|
|
+ try:
|
|
|
+ bzid = get_req_param(param, 'uuid')
|
|
|
+ print(param)
|
|
|
|
|
|
- new_yhpcsb = YstYhpcsbEntity(
|
|
|
- bzid = bzid,
|
|
|
- fzdc = get_req_param(param, 'fzdc'),
|
|
|
- fzr = get_req_param(param, 'fzr'),
|
|
|
- fzrdh = get_req_param(param, 'fzrdh'),
|
|
|
- gm = get_req_param(param, 'gm'),
|
|
|
- gzcs = get_req_param(param, 'gzcs'),
|
|
|
- qzjjss = get_req_param(param, 'qzjjss'),
|
|
|
- swxrs = get_req_param(param, 'swxrs'),
|
|
|
- szdq = get_req_param(param, 'szdq'),
|
|
|
- xxdz = get_req_param(param, 'xxdz'),
|
|
|
- yhdmc = get_req_param(param, 'yhdmc'),
|
|
|
- yhdzt = get_req_param(param, 'yhdzt'),
|
|
|
- ywfzya = get_req_param(param, 'ywfzya'),
|
|
|
- zhlx = get_req_param(param, 'zhlx'),
|
|
|
- create_time = datetime.now()
|
|
|
- )
|
|
|
- db.add(new_yhpcsb)
|
|
|
- db.commit()
|
|
|
+ sfzh = ext_info['cid']
|
|
|
|
|
|
- db.query(YssYstUploadFileEntity).filter(YssYstUploadFileEntity.uuid == bzid).update({"bzid": bzid})
|
|
|
- db.commit()
|
|
|
+ redis_key = "mmyj_yhxx_" + bzid
|
|
|
+ yhxx_info = redis_get_json(redis_key)
|
|
|
+ if yhxx_info is None:
|
|
|
+ raise AppException(code=1, msg="数据异常")
|
|
|
|
|
|
- resp = {
|
|
|
- 'ret': 0,
|
|
|
- 'msg': "您的隐患排查上报已成功提交。"
|
|
|
- }
|
|
|
- return yst_response(resp)
|
|
|
+ db_entity = db.query(YstQyjcxxEntity).filter(YstQyjcxxEntity.bzid == bzid).filter(YstQyjcxxEntity.status == 1).first()
|
|
|
+ if db_entity is not None:
|
|
|
+ result = {
|
|
|
+ 'ret': 0,
|
|
|
+ 'msg': '您的隐患排查上报已成功提交。',
|
|
|
+ 'data': {
|
|
|
+ 'ywid': db_entity.bzid
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return pt_sg_response(result)
|
|
|
+
|
|
|
+ db.query(YstYhpcsbEntity).filter(YstYhpcsbEntity.bzid == bzid).filter(YstYhpcsbEntity.status == 0).delete()
|
|
|
+ db.commit()
|
|
|
+
|
|
|
+ new_yhpcsb = YstYhpcsbEntity(
|
|
|
+ bzid = bzid,
|
|
|
+ sfzh = sfzh,
|
|
|
+ qymc = get_req_param(param, 'qymc'),
|
|
|
+ qydz = get_req_param(param, 'qydz'),
|
|
|
+ qyjb = get_req_param(param, 'qyjb'),
|
|
|
+
|
|
|
+ fzdc = get_req_param(param, 'fzdc'),
|
|
|
+ fzr = get_req_param(param, 'fzr'),
|
|
|
+ fzrdh = get_req_param(param, 'fzrdh'),
|
|
|
+ gm = get_req_param(param, 'gm'),
|
|
|
+ gzcs = get_req_param(param, 'gzcs'),
|
|
|
+ qzjjss = get_req_param(param, 'qzjjss'),
|
|
|
+ swxrs = get_req_param(param, 'swxrs'),
|
|
|
+ szdq = get_req_param(param, 'szdq'),
|
|
|
+ xxdz = get_req_param(param, 'xxdz'),
|
|
|
+ yhdmc = get_req_param(param, 'yhdmc'),
|
|
|
+ yhdzt = get_req_param(param, 'yhdzt'),
|
|
|
+ ywfzya = get_req_param(param, 'ywfzya'),
|
|
|
+ zhlx = get_req_param(param, 'zhlx'),
|
|
|
+ status = 1,
|
|
|
+ create_time = datetime.now()
|
|
|
+ )
|
|
|
+ db.add(new_yhpcsb)
|
|
|
+ db.commit()
|
|
|
+
|
|
|
+ db.query(YssYstUploadFileEntity).filter(YssYstUploadFileEntity.uuid == bzid).update({"bzid": bzid})
|
|
|
+ db.commit()
|
|
|
+
|
|
|
+ resp = {
|
|
|
+ 'ret': 0,
|
|
|
+ 'msg': "您的隐患排查上报已成功提交。"
|
|
|
+ }
|
|
|
+ return yst_response(resp)
|
|
|
+
|
|
|
+ except AppException as e:
|
|
|
+ traceback.print_exc()
|
|
|
+ result = {
|
|
|
+ 'ret': 1,
|
|
|
+ 'msg': "服务异常,本次办理提交失败,您可尝试重新提交。"
|
|
|
+ }
|
|
|
+ return pt_sg_response(result)
|
|
|
|
|
|
|
|
|
@router.post("/query")
|
|
@@ -57,12 +95,14 @@ async def query(
|
|
|
param: dict = Depends(yst_request_param),
|
|
|
db: Session = Depends(get_db)
|
|
|
):
|
|
|
- rows = db.query(YstYhpcsbEntity).all()
|
|
|
+ sfzh = ext_info['cid']
|
|
|
+ rows = db.query(YstYhpcsbEntity).filter(YstYhpcsbEntity.sfzh == sfzh).filter(YstYhpcsbEntity.status == 1).order_by(YstYhpcsbEntity.create_time.desc()).all()
|
|
|
data = [
|
|
|
{
|
|
|
"id": row.id,
|
|
|
"yhdmc": row.yhdmc,
|
|
|
"yhdzt": row.yhdzt,
|
|
|
+ "xxdz": row.xxdz,
|
|
|
"szdq": row.szdq,
|
|
|
"create_time": get_datetime_str(row.create_time)
|
|
|
}
|
|
@@ -82,14 +122,34 @@ async def detail(
|
|
|
param: dict = Depends(yst_request_param),
|
|
|
db: Session = Depends(get_db)
|
|
|
):
|
|
|
- id = get_req_param(param, 'id')
|
|
|
- row = db.query(YstYhpcsbEntity).filter(YstYhpcsbEntity.id == id).first()
|
|
|
- data = get_model_dict(row)
|
|
|
- data["create_time"] = get_datetime_str(row.create_time)
|
|
|
+ try:
|
|
|
+ sfzh = ext_info['cid']
|
|
|
+ id = get_req_param(param, 'id')
|
|
|
+ row = db.query(YstYhpcsbEntity).filter(YstYhpcsbEntity.sfzh == sfzh).filter(YstYhpcsbEntity.id == id).first()
|
|
|
+ bzid = row.bzid
|
|
|
+ data = get_model_dict(row)
|
|
|
+ data["create_time"] = get_datetime_str(row.create_time)
|
|
|
|
|
|
- resp = {
|
|
|
- 'ret': 0,
|
|
|
- 'msg': '',
|
|
|
- 'data': data
|
|
|
- }
|
|
|
- return yst_response(resp)
|
|
|
+ qtFile = []
|
|
|
+ imageUrls = []
|
|
|
+ rows = db.query(YssYstUploadFileEntity).filter(and_(YssYstUploadFileEntity.bzid == bzid, YssYstUploadFileEntity.file_type == 'yyzz')).all()
|
|
|
+ for row in rows:
|
|
|
+ imageUrls.append("/mmh5_yjxm_yst/ebus/yst_mmzhyj/api/yst/file/show?thumb=&file_name={}".format(row.file_name))
|
|
|
+
|
|
|
+ if len(imageUrls) > 0:
|
|
|
+ qtFile.append({'fileName': '隐患点图片', 'imageUrls': imageUrls})
|
|
|
+ resp = {
|
|
|
+ 'ret': 0,
|
|
|
+ 'msg': '',
|
|
|
+ 'data': data,
|
|
|
+ 'qtFile': qtFile
|
|
|
+ }
|
|
|
+ return yst_response(resp)
|
|
|
+
|
|
|
+ except AppException as e:
|
|
|
+ traceback.print_exc()
|
|
|
+ result = {
|
|
|
+ 'ret': 1,
|
|
|
+ 'msg': "服务异常"
|
|
|
+ }
|
|
|
+ return pt_sg_response(result)
|