|
|
@ -6,9 +6,18 @@ import com.github.pagehelper.PageInfo; |
|
|
|
import com.hai.common.exception.ErrorCode; |
|
|
|
import com.hai.common.exception.ErrorCode; |
|
|
|
import com.hai.common.exception.ErrorHelp; |
|
|
|
import com.hai.common.exception.ErrorHelp; |
|
|
|
import com.hai.common.exception.SysCode; |
|
|
|
import com.hai.common.exception.SysCode; |
|
|
|
|
|
|
|
import com.hai.common.security.UserCenter; |
|
|
|
import com.hai.common.utils.ResponseMsgUtil; |
|
|
|
import com.hai.common.utils.ResponseMsgUtil; |
|
|
|
|
|
|
|
import com.hai.entity.HighGasOilPriceTask; |
|
|
|
|
|
|
|
import com.hai.entity.HighMerchantStore; |
|
|
|
|
|
|
|
import com.hai.entity.SecDictionary; |
|
|
|
|
|
|
|
import com.hai.entity.SecRegion; |
|
|
|
|
|
|
|
import com.hai.enum_type.GasTaskPriceTypeEnum; |
|
|
|
import com.hai.model.ResponseData; |
|
|
|
import com.hai.model.ResponseData; |
|
|
|
|
|
|
|
import com.hai.model.UserInfoModel; |
|
|
|
|
|
|
|
import com.hai.service.CommonService; |
|
|
|
import com.hai.service.HighGasOilPriceTaskService; |
|
|
|
import com.hai.service.HighGasOilPriceTaskService; |
|
|
|
|
|
|
|
import com.hai.service.HighMerchantStoreService; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.Logger; |
|
|
@ -18,6 +27,7 @@ import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
@Controller |
|
|
|
@Controller |
|
|
@ -30,18 +40,94 @@ public class HighGasOilPriceTaskController { |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private HighGasOilPriceTaskService gasOilPriceTaskService; |
|
|
|
private HighGasOilPriceTaskService gasOilPriceTaskService; |
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/addTask",method = RequestMethod.POST) |
|
|
|
@Resource |
|
|
|
|
|
|
|
private HighMerchantStoreService merchantStoreService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private CommonService commonService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private UserCenter userCenter; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/batchAddTask",method = RequestMethod.POST) |
|
|
|
@ResponseBody |
|
|
|
@ResponseBody |
|
|
|
@ApiOperation(value = "增加任务") |
|
|
|
@ApiOperation(value = "批量增加任务") |
|
|
|
public ResponseData addTask(@RequestBody JSONObject body) { |
|
|
|
public ResponseData batchAddTask(@RequestBody List<HighGasOilPriceTask> taskList) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
if (body.getLong("regionId") == null |
|
|
|
UserInfoModel userInfoModel = userCenter.getSessionModel(UserInfoModel.class); |
|
|
|
|| body.getInteger("oilNo") == null |
|
|
|
if (userInfoModel == null) { |
|
|
|
|| body.getBigDecimal("price") == null |
|
|
|
log.error("HighGasDiscountOilPriceController -> updateOilPriceOfficial() error!",""); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (taskList == null || taskList.size() == 0) { |
|
|
|
|
|
|
|
log.error("HighGasDiscountOilPriceController -> updateOilPriceOfficial() error!",""); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (HighGasOilPriceTask task : taskList) { |
|
|
|
|
|
|
|
if (task.getPriceType() == null |
|
|
|
|
|
|
|
|| task.getPrice() == null |
|
|
|
|
|
|
|
|| task.getOilNo() == null |
|
|
|
|
|
|
|
|| task.getExecutionType() == null |
|
|
|
) { |
|
|
|
) { |
|
|
|
log.error("HighGasDiscountOilPriceController -> updateOilPriceOfficial() error!",""); |
|
|
|
log.error("HighGasDiscountOilPriceController -> updateOilPriceOfficial() error!",""); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 执行方式 1. 立刻执行 2. 定时执行
|
|
|
|
|
|
|
|
if (task.getExecutionType().equals(2) && task.getStartTime() == null) { |
|
|
|
|
|
|
|
log.error("HighGasDiscountOilPriceController -> updateOilPriceOfficial() error!",""); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未配置执行时间"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 价格类型 1. 国标价 2. 油站价 3. 优惠幅度
|
|
|
|
|
|
|
|
if (task.getPriceType().equals(GasTaskPriceTypeEnum.type1.getStatus())) { |
|
|
|
|
|
|
|
if (task.getRegionId() == null) { |
|
|
|
|
|
|
|
log.error("HighGasDiscountOilPriceController -> updateOilPriceOfficial() error!",""); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未配置区域"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 加油站
|
|
|
|
|
|
|
|
SecRegion region = commonService.getRegionsById(task.getRegionId()); |
|
|
|
|
|
|
|
if (region == null) { |
|
|
|
|
|
|
|
log.error("HighGasDiscountOilPriceController -> updateOilPriceOfficial() error!",""); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到区域"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
task.setRegionId(region.getRegionId()); |
|
|
|
|
|
|
|
task.setRegionName(region.getRegionName()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 价格类型 1. 国标价 2. 油站价 3. 优惠幅度
|
|
|
|
|
|
|
|
if (task.getPriceType().equals(GasTaskPriceTypeEnum.type2.getStatus()) |
|
|
|
|
|
|
|
|| task.getPriceType().equals(GasTaskPriceTypeEnum.type3.getStatus())) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (task.getMerStoreId() == null) { |
|
|
|
|
|
|
|
log.error("HighGasDiscountOilPriceController -> updateOilPriceOfficial() error!",""); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未配置加油站"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 加油站
|
|
|
|
|
|
|
|
HighMerchantStore store = merchantStoreService.getDetailById(task.getMerStoreId()); |
|
|
|
|
|
|
|
if (store == null) { |
|
|
|
|
|
|
|
log.error("HighGasDiscountOilPriceController -> updateOilPriceOfficial() error!",""); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到加油站"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
task.setMerStoreId(store.getId()); |
|
|
|
|
|
|
|
task.setMerStoreName(store.getStoreName()); |
|
|
|
|
|
|
|
task.setMerStoreAddress(store.getAddress()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查询油品
|
|
|
|
|
|
|
|
SecDictionary oil = commonService.mappingSysCode("GAS_OIL_TYPE", task.getOilNo().toString()); |
|
|
|
|
|
|
|
if (oil == null) { |
|
|
|
|
|
|
|
log.error("HighGasDiscountOilPriceController -> updateOilPriceOfficial() error!",""); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
task.setOilType(Integer.parseInt(oil.getExt1())); |
|
|
|
|
|
|
|
task.setOilTypeName(oil.getExt2()); |
|
|
|
|
|
|
|
task.setOilNoName(oil.getCodeName()); |
|
|
|
|
|
|
|
task.setOpUserId(userInfoModel.getSecUser().getId()); |
|
|
|
|
|
|
|
task.setOpUserName(userInfoModel.getSecUser().getUserName()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gasOilPriceTaskService.batchAddTask(taskList); |
|
|
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success("操作成功"); |
|
|
|
return ResponseMsgUtil.success("操作成功"); |
|
|
|
|
|
|
|
|
|
|
@ -103,6 +189,12 @@ public class HighGasOilPriceTaskController { |
|
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
|
param.put("regionId", regionId); |
|
|
|
param.put("regionId", regionId); |
|
|
|
param.put("regionName", regionName); |
|
|
|
param.put("regionName", regionName); |
|
|
|
|
|
|
|
param.put("merStoreId", status); |
|
|
|
|
|
|
|
param.put("merStoreName", status); |
|
|
|
|
|
|
|
param.put("oilType", status); |
|
|
|
|
|
|
|
param.put("oilNo", status); |
|
|
|
|
|
|
|
param.put("priceType", status); |
|
|
|
|
|
|
|
param.put("executionType", status); |
|
|
|
param.put("status", status); |
|
|
|
param.put("status", status); |
|
|
|
|
|
|
|
|
|
|
|
PageHelper.startPage(pageNum,pageSize); |
|
|
|
PageHelper.startPage(pageNum,pageSize); |
|
|
|