package com.bweb.controller; import com.alibaba.fastjson.JSONObject; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.utils.ResponseMsgUtil; import com.hai.model.ResponseData; import com.hai.service.HighGasOilPriceTaskService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.HashMap; import java.util.Map; @Controller @RequestMapping(value = "/gasOilPriceTask") @Api(value = "油品价格配置") public class HighGasOilPriceTaskController { private static Logger log = LoggerFactory.getLogger(HighGasOilPriceTaskController.class); @Resource private HighGasOilPriceTaskService gasOilPriceTaskService; @RequestMapping(value="/addTask",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "增加任务") public ResponseData addTask(@RequestBody JSONObject body) { try { if (body.getLong("regionId") == null || body.getInteger("oilNo") == null || body.getBigDecimal("price") == null ) { log.error("HighGasDiscountOilPriceController -> updateOilPriceOfficial() error!",""); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } return ResponseMsgUtil.success("操作成功"); } catch (Exception e) { log.error("HighGasOilPriceTaskController -> addTask() error!",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/delTask",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "删除任务") public ResponseData delTask(@RequestBody JSONObject body) { try { if (body.getLong("taskId") == null) { log.error("HighGasOilPriceTaskController -> delTask() error!",""); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } gasOilPriceTaskService.delTask(body.getLong("taskId")); return ResponseMsgUtil.success("操作成功"); } catch (Exception e) { log.error("HighGasOilPriceTaskController -> delTask() error!",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/getTaskDetail",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询任务详情") public ResponseData getTaskDetail(@RequestParam(name = "taskId", required = true) Long taskId) { try { return ResponseMsgUtil.success(gasOilPriceTaskService.getDetailById(taskId)); } catch (Exception e) { log.error("HighGasOilPriceTaskController -> getTaskDetail() error!",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/getTaskList",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询任务列表") public ResponseData getTaskList(@RequestParam(name = "regionId", required = false) Integer regionId, @RequestParam(name = "regionName", required = false) String regionName, @RequestParam(name = "merStoreId", required = false) Integer merStoreId, @RequestParam(name = "merStoreName", required = false) String merStoreName, @RequestParam(name = "oilType", required = false) Integer oilType, @RequestParam(name = "oilNo", required = false) Integer oilNo, @RequestParam(name = "priceType", required = false) Integer priceType, @RequestParam(name = "executionType", required = false) Integer executionType, @RequestParam(name = "status", required = false) Integer status, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize) { try { Map param = new HashMap<>(); param.put("regionId", regionId); param.put("regionName", regionName); param.put("status", status); PageHelper.startPage(pageNum,pageSize); return ResponseMsgUtil.success(new PageInfo<>(gasOilPriceTaskService.getTaskList(param))); } catch (Exception e) { log.error("HighGasOilPriceTaskController -> getTaskList() error!",e); return ResponseMsgUtil.exception(e); } } }