From 44a8924439d364f0090cc03d42f964829a61304c Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Thu, 6 Jun 2024 16:57:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/BsGasClassGroupController.java | 8 +- .../BsGasClassGroupTaskController.java | 94 ++++++++++++++++--- .../dao/BsGasClassGroupTaskMapperExt.java | 4 +- .../impl/BsGasClassGroupTaskServiceImpl.java | 4 +- 4 files changed, 90 insertions(+), 20 deletions(-) diff --git a/bweb/src/main/java/com/bweb/controller/BsGasClassGroupController.java b/bweb/src/main/java/com/bweb/controller/BsGasClassGroupController.java index df0c3d8..e8c2fe2 100644 --- a/bweb/src/main/java/com/bweb/controller/BsGasClassGroupController.java +++ b/bweb/src/main/java/com/bweb/controller/BsGasClassGroupController.java @@ -64,8 +64,8 @@ public class BsGasClassGroupController { try { SecUserSessionObject userInfoModel = userCenter.getSessionModel(SecUserSessionObject.class); if (userInfoModel == null - || userInfoModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type2.getCode())) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR); + || !userInfoModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type2.getCode())) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.ROLE_NOT_PERMISSIONS); } if (body == null || StringUtils.isBlank(body.getString("name")) @@ -163,7 +163,7 @@ public class BsGasClassGroupController { Map param = new HashMap<>(); if (userInfoModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type2.getCode())) { - param.put("merchantStoreId", userInfoModel.getAccount().getObjectId()); + param.put("merId", userInfoModel.getAccount().getObjectId()); } else if (userInfoModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type3.getCode())) { // 查询油站工作人员 @@ -171,7 +171,7 @@ public class BsGasClassGroupController { if (gasStaff == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } - param.put("merchantStoreId", gasStaff.getMerId()); + param.put("merId", gasStaff.getMerId()); } param.put("name", name); param.put("principalName", principalName); diff --git a/bweb/src/main/java/com/bweb/controller/BsGasClassGroupTaskController.java b/bweb/src/main/java/com/bweb/controller/BsGasClassGroupTaskController.java index 6454c3e..49c6621 100644 --- a/bweb/src/main/java/com/bweb/controller/BsGasClassGroupTaskController.java +++ b/bweb/src/main/java/com/bweb/controller/BsGasClassGroupTaskController.java @@ -62,11 +62,31 @@ public class BsGasClassGroupTaskController { @ApiOperation(value = "开启班组任务") public ResponseData startGroupTask(@RequestBody JSONObject body) { try { - if (body == null || body.getLong("gasId") == null || body.getLong("gasClassGroupId") == null) { + SecUserSessionObject userInfoModel = userCenter.getSessionModel(SecUserSessionObject.class); + if (userInfoModel == null || + (!userInfoModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type2.getCode()) + && !userInfoModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type3.getCode()))) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.ROLE_NOT_PERMISSIONS); + } + + if (body == null || body.getLong("gasClassGroupId") == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } - gasClassGroupTaskService.startGroupTask(body.getLong("gasId"), body.getLong("gasClassGroupId")); + Long gasId = null; + if (userInfoModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type2.getCode())) { + gasId = userInfoModel.getAccount().getObjectId(); + + } else if (userInfoModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type3.getCode())) { + // 查询油站工作人员 + BsGasStaff gasStaff = gasStaffService.getStaffDetailById(userInfoModel.getAccount().getObjectId()); + if (gasStaff == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + gasId = gasStaff.getMerId(); + } + + gasClassGroupTaskService.startGroupTask(gasId, body.getLong("gasClassGroupId")); return ResponseMsgUtil.success("操作成功"); @@ -79,13 +99,28 @@ public class BsGasClassGroupTaskController { @RequestMapping(value = "/endGroupTask", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "结束班组任务") - public ResponseData endGroupTask(@RequestBody JSONObject body) { + public ResponseData endGroupTask() { try { - if (body == null || body.getLong("gasId") == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + SecUserSessionObject userInfoModel = userCenter.getSessionModel(SecUserSessionObject.class); + if (userInfoModel == null || + (!userInfoModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type2.getCode()) + && !userInfoModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type3.getCode()))) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.ROLE_NOT_PERMISSIONS); } + Long gasId = null; + if (userInfoModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type2.getCode())) { + gasId = userInfoModel.getAccount().getObjectId(); - gasClassGroupTaskService.endGroupTask(body.getLong("gasId")); + } else if (userInfoModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type3.getCode())) { + // 查询油站工作人员 + BsGasStaff gasStaff = gasStaffService.getStaffDetailById(userInfoModel.getAccount().getObjectId()); + if (gasStaff == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + gasId = gasStaff.getMerId(); + } + + gasClassGroupTaskService.endGroupTask(gasId); return ResponseMsgUtil.success("操作成功"); @@ -100,11 +135,30 @@ public class BsGasClassGroupTaskController { @ApiOperation(value = "交换班组任务") public ResponseData swapGroupTask(@RequestBody JSONObject body) { try { - if (body == null || body.getLong("gasId") == null || body.getLong("gasClassGroupId") == null) { + if (body == null || body.getLong("gasClassGroupId") == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } - gasClassGroupTaskService.swapGroupTask(body.getLong("gasId"), body.getLong("gasClassGroupId")); + SecUserSessionObject userInfoModel = userCenter.getSessionModel(SecUserSessionObject.class); + if (userInfoModel == null || + (!userInfoModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type2.getCode()) + && !userInfoModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type3.getCode()))) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.ROLE_NOT_PERMISSIONS); + } + Long gasId = null; + if (userInfoModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type2.getCode())) { + gasId = userInfoModel.getAccount().getObjectId(); + + } else if (userInfoModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type3.getCode())) { + // 查询油站工作人员 + BsGasStaff gasStaff = gasStaffService.getStaffDetailById(userInfoModel.getAccount().getObjectId()); + if (gasStaff == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + gasId = gasStaff.getMerId(); + } + + gasClassGroupTaskService.swapGroupTask(gasId, body.getLong("gasClassGroupId")); return ResponseMsgUtil.success("操作成功"); @@ -117,15 +171,31 @@ public class BsGasClassGroupTaskController { @RequestMapping(value = "/getCurrentClassGroupTask", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询当前班次") - public ResponseData getCurrentClassGroupTask(@RequestParam(name = "gasId", required = true) Long gasId) { + public ResponseData getCurrentClassGroupTask(@RequestParam(name = "gasId", required = false) Long gasId) { try { + SecUserSessionObject userInfoModel = userCenter.getSessionModel(SecUserSessionObject.class); + if (userInfoModel == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.ROLE_NOT_PERMISSIONS); + } + Map param = new HashMap<>(); + if (userInfoModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type2.getCode())) { + gasId = userInfoModel.getAccount().getObjectId(); + + } else if (userInfoModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type3.getCode())) { + // 查询油站工作人员 + BsGasStaff gasStaff = gasStaffService.getStaffDetailById(userInfoModel.getAccount().getObjectId()); + if (gasStaff == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + gasId = gasStaff.getMerId(); + } + GasClassGroupTaskDataCount dataCount; - Map param = new HashMap<>(); - param.put("merchantStoreId", gasId); + param.put("merId", gasId); param.put("status", GasClassGroupTaskStatus.status1.getStatus()); List list = gasClassGroupTaskService.getGroupTaskList(param); - if (list.size() > 0) { + if (!list.isEmpty()) { dataCount = gasClassGroupTaskService.countGroupTaskData(gasId, list.get(0).getClassNum(), list.get(0).getId(), diff --git a/service/src/main/java/com/hfkj/dao/BsGasClassGroupTaskMapperExt.java b/service/src/main/java/com/hfkj/dao/BsGasClassGroupTaskMapperExt.java index 0b5b52e..cedfc56 100644 --- a/service/src/main/java/com/hfkj/dao/BsGasClassGroupTaskMapperExt.java +++ b/service/src/main/java/com/hfkj/dao/BsGasClassGroupTaskMapperExt.java @@ -49,11 +49,11 @@ public interface BsGasClassGroupTaskMapperExt { " from bs_gas_order a" + " where a.gas_class_group_task_id = #{gasClassGroupTaskId} and a.status in (4)" + " GROUP BY a.gas_oil_no) b on b.gas_oil_no = a.oil_no" + - " WHERE a.merchant_store_id = #{gasId} and 0 ]]> " + + " WHERE a.mer_id = #{gasId} and 0 ]]> " + "") List> countOilData(@Param("gasId") Long gasId, @Param("gasClassGroupTaskId") Long gasClassGroupTaskId); - @Select("select count(1) from bs_gas_class_group_task where merchant_store_id = #{gasId} and `status` <> 0") + @Select("select count(1) from bs_gas_class_group_task where mer_id = #{gasId} and `status` <> 0") int getLatestClassNum(@Param("gasId") Long gasId); } diff --git a/service/src/main/java/com/hfkj/service/gas/impl/BsGasClassGroupTaskServiceImpl.java b/service/src/main/java/com/hfkj/service/gas/impl/BsGasClassGroupTaskServiceImpl.java index e2eca93..fbf7867 100644 --- a/service/src/main/java/com/hfkj/service/gas/impl/BsGasClassGroupTaskServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/gas/impl/BsGasClassGroupTaskServiceImpl.java @@ -55,7 +55,7 @@ public class BsGasClassGroupTaskServiceImpl implements BsGasClassGroupTaskServic // 查询进行中的任务 Map param = new HashMap<>(); - param.put("merchantStoreId", merchant.getId()); + param.put("merId", merchant.getId()); param.put("status", GasClassGroupTaskStatus.status1.getStatus()); List list = getGroupTaskList(param); if (!list.isEmpty()) { @@ -82,7 +82,7 @@ public class BsGasClassGroupTaskServiceImpl implements BsGasClassGroupTaskServic public void endGroupTask(Long gasId) { // 查询进行中的任务 Map param = new HashMap<>(); - param.put("merchantStoreId", gasId); + param.put("merId", gasId); param.put("status", GasClassGroupTaskStatus.status1.getStatus()); List list = getGroupTaskList(param); if (!list.isEmpty()) {