|
|
@@ -1,7 +1,13 @@
|
|
|
package com.aoyang.tms.controller;
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.aoyang.tms.common.ErrCodeEnum;
|
|
|
+import com.aoyang.tms.controller.param.TmsLineCostAddParam;
|
|
|
import com.aoyang.tms.entity.TmsLineCost;
|
|
|
+import com.aoyang.tms.entity.TmsLineCostOther;
|
|
|
+import com.aoyang.tms.entity.TruckDept;
|
|
|
+import com.aoyang.tms.entity.WorkSpot;
|
|
|
import com.aoyang.tms.service.TmsLineCostService;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
@@ -9,6 +15,10 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
+import java.net.URLDecoder;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
@@ -21,8 +31,8 @@ import com.aoyang.common.param.PageParam;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
|
- * 线路费用表 控制器
|
|
|
- * </p>
|
|
|
+ * 线路费用表 控制器
|
|
|
+ * </p>
|
|
|
*
|
|
|
* @author liujiren
|
|
|
* @since 2022-04-23
|
|
|
@@ -30,31 +40,105 @@ import com.aoyang.common.param.PageParam;
|
|
|
@RestController
|
|
|
@Slf4j
|
|
|
@Api(value = "tms_line_costCRUD接口")
|
|
|
-@RequestMapping("/strategy/tms_line_cost")
|
|
|
+@RequestMapping("/tms/tms_line_cost")
|
|
|
public class TmsLineCostController {
|
|
|
|
|
|
@Resource
|
|
|
private TmsLineCostService tmsLineCostService;
|
|
|
|
|
|
- @ApiOperation(value = "获取tms_line_cost列表",notes="")
|
|
|
- @PostMapping("/list")
|
|
|
- public Result list(@RequestBody PageParam<TmsLineCost> pageParam) {
|
|
|
+ @ApiOperation(value = "获取tms_line_cost分页列表", notes = "")
|
|
|
+ @PostMapping("/page_list")
|
|
|
+ public Result pageList(@RequestBody PageParam<TmsLineCost> pageParam) {
|
|
|
Page<TmsLineCost> page = new Page<>(pageParam.getPage(), pageParam.getSize());
|
|
|
IPage<TmsLineCost> records = tmsLineCostService.page(page, Wrappers.query(pageParam.getParam()));
|
|
|
return new Result<>(records);
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "修改tms_line_cost",notes="根据id修改tms_line_cost")
|
|
|
- @PostMapping("/update")
|
|
|
- public Result update(@RequestBody TmsLineCost tmsLineCost) {
|
|
|
- Boolean flag = tmsLineCostService.updateById(tmsLineCost);
|
|
|
- return new Result<>(flag);
|
|
|
+ @ApiOperation(value = "获取线路费用列表", notes = "必传参数:CycleId,TruckId")
|
|
|
+ @PostMapping("/list")
|
|
|
+ public Result list(@RequestBody TmsLineCost param) {
|
|
|
+ log.info("获取线路费用列表,调用/tms/tms_line_cost/list,参数:{}", JSON.toJSONString(param));
|
|
|
+ if (param == null || param.getCycleId() == null || param.getTruckId() == null) {
|
|
|
+ return new Result<>(ErrCodeEnum.BAD_PARAM.getCode(), ErrCodeEnum.BAD_PARAM.getMessage());
|
|
|
+ }
|
|
|
+ return new Result<>(tmsLineCostService.list(param));
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "添加tms_line_cost",notes="新增一条tms_line_cost")
|
|
|
+ @ApiOperation(value = "根据id获取线路费用详情", notes = "必传参数:Id")
|
|
|
+ @PostMapping("/get_one")
|
|
|
+ public Result getOne(@RequestBody TmsLineCost param) {
|
|
|
+ log.info("根据id获取线路费用详情,调用/tms/tms_line_cost/get_one,参数:{}", JSON.toJSONString(param));
|
|
|
+ if (param == null || param.getId() == null) {
|
|
|
+ return new Result<>(ErrCodeEnum.BAD_PARAM.getCode(), ErrCodeEnum.BAD_PARAM.getMessage());
|
|
|
+ }
|
|
|
+ return new Result<>(tmsLineCostService.getOne(param));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "添加线路费用", notes = "必传参数:LineStart,LineEnd,Kilometre")
|
|
|
@PostMapping("/add")
|
|
|
- public Result add(@RequestBody TmsLineCost tmsLineCost) {
|
|
|
- Boolean flag = tmsLineCostService.save(tmsLineCost);
|
|
|
- return new Result<>(flag);
|
|
|
+ public Result add(@RequestHeader(value = "userId") Long userId,
|
|
|
+ @RequestHeader(value = "userName") String userName,
|
|
|
+ @RequestBody TmsLineCostAddParam param) {
|
|
|
+ log.info("添加线路费用,调用/tms/tms_line_cost/add,参数:{}", JSON.toJSONString(param));
|
|
|
+ if (param == null || param.getLineStart() == null || param.getLineEnd() == null || param.getKilometre() == null) {
|
|
|
+ return new Result<>(ErrCodeEnum.BAD_PARAM.getCode(), ErrCodeEnum.BAD_PARAM.getMessage());
|
|
|
+ }
|
|
|
+ if (param.getList() != null && param.getList().size() > 0) {
|
|
|
+ for (TmsLineCostOther tmsLineCostOther : param.getList()) {
|
|
|
+ if (tmsLineCostOther.getCostName() == null || tmsLineCostOther.getCostName() == null) {
|
|
|
+ return new Result<>(ErrCodeEnum.BAD_PARAM.getCode(), ErrCodeEnum.BAD_PARAM.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String utf8Name = userName;
|
|
|
+ try {
|
|
|
+ utf8Name = URLDecoder.decode(userName, "UTF-8");
|
|
|
+ } catch (UnsupportedEncodingException ignored) {
|
|
|
+ }
|
|
|
+ param.setCreater(userId);
|
|
|
+ param.setCreaterName(utf8Name);
|
|
|
+ param.setCreateDate(LocalDateTime.now());
|
|
|
+
|
|
|
+ return new Result<>(tmsLineCostService.add(param));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "修改线路费用", notes = "必传参数:id,tmsLineCostOther.id")
|
|
|
+ @PostMapping("/update")
|
|
|
+ public Result update(@RequestHeader(value = "userId") Long userId,
|
|
|
+ @RequestHeader(value = "userName") String userName,
|
|
|
+ @RequestBody TmsLineCostAddParam param) {
|
|
|
+ log.info("修改线路费用,调用/tms/tms_line_cost/update,参数:{}", JSON.toJSONString(param));
|
|
|
+ if (param == null || param.getId() == null) {
|
|
|
+ return new Result<>(ErrCodeEnum.BAD_PARAM.getCode(), ErrCodeEnum.BAD_PARAM.getMessage());
|
|
|
+ }
|
|
|
+ if (param.getList() != null && param.getList().size() > 0) {
|
|
|
+ for (TmsLineCostOther tmsLineCostOther : param.getList()) {
|
|
|
+ if (tmsLineCostOther.getId() == null) {
|
|
|
+ return new Result<>(ErrCodeEnum.BAD_PARAM.getCode(), ErrCodeEnum.BAD_PARAM.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String utf8Name = userName;
|
|
|
+ try {
|
|
|
+ utf8Name = URLDecoder.decode(userName, "UTF-8");
|
|
|
+ } catch (UnsupportedEncodingException ignored) {
|
|
|
+ }
|
|
|
+ param.setUpdater(userId);
|
|
|
+ param.setUpdaterName(utf8Name);
|
|
|
+ param.setUpdateDate(LocalDateTime.now());
|
|
|
+
|
|
|
+ return new Result<>(tmsLineCostService.update(param));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "删除线路费用", notes = "必传参数:id")
|
|
|
+ @PostMapping("/delete")
|
|
|
+ public Result delete(@RequestBody TmsLineCostAddParam param) {
|
|
|
+ log.info("删除线路费用,调用/tms/tms_line_cost/delete,参数:{}", JSON.toJSONString(param));
|
|
|
+ if (param == null || param.getId() == null) {
|
|
|
+ return new Result<>(ErrCodeEnum.BAD_PARAM.getCode(), ErrCodeEnum.BAD_PARAM.getMessage());
|
|
|
+ }
|
|
|
+ return new Result<>(tmsLineCostService.delete(param));
|
|
|
}
|
|
|
}
|