|
@@ -3,6 +3,7 @@ package com.aoyang.tms.controller;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.aoyang.tms.common.ErrCodeEnum;
|
|
import com.aoyang.tms.common.ErrCodeEnum;
|
|
|
|
|
+import com.aoyang.tms.service.CommonService;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
@@ -10,6 +11,9 @@ import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.*;
|
|
import io.swagger.annotations.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
|
|
+import java.net.URLDecoder;
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
@@ -38,6 +42,8 @@ public class TruckDeptController {
|
|
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
|
private TruckDeptService truckDeptService;
|
|
private TruckDeptService truckDeptService;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private CommonService commonService;
|
|
|
|
|
|
|
|
@ApiOperation(value = "获取运力部门管理分页列表", notes = "")
|
|
@ApiOperation(value = "获取运力部门管理分页列表", notes = "")
|
|
|
@PostMapping("/page_list")
|
|
@PostMapping("/page_list")
|
|
@@ -49,21 +55,62 @@ public class TruckDeptController {
|
|
|
return new Result<>(truckDeptService.findPage(pageParam));
|
|
return new Result<>(truckDeptService.findPage(pageParam));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @ApiOperation(value = "修改truck_dept", notes = "根据id修改truck_dept")
|
|
|
|
|
|
|
+ @ApiOperation(value = "修改运力部门信息", notes = "根据id修改truck_dept")
|
|
|
@PostMapping("/update")
|
|
@PostMapping("/update")
|
|
|
- public Result update(@RequestBody TruckDept truckDept) {
|
|
|
|
|
- Boolean flag = truckDeptService.updateById(truckDept);
|
|
|
|
|
- return new Result<>(flag);
|
|
|
|
|
|
|
+ public Result update(@RequestHeader(value = "userId") Long userId,
|
|
|
|
|
+ @RequestHeader(value = "userName") String userName,
|
|
|
|
|
+ @RequestBody TruckDept param) {
|
|
|
|
|
+ log.info("修改运力部门信息,调用/tms/truck_dept/update,参数:{}", JSON.toJSONString(param));
|
|
|
|
|
+ if (param == null || param.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<>(truckDeptService.updateById(param));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@ApiOperation(value = "新增运力部门", notes = "新增一条truck_dept")
|
|
@ApiOperation(value = "新增运力部门", notes = "新增一条truck_dept")
|
|
|
@PostMapping("/add")
|
|
@PostMapping("/add")
|
|
|
- public Result add(@RequestBody TruckDept param) {
|
|
|
|
|
|
|
+ public Result add(@RequestHeader(value = "userId") Long userId,
|
|
|
|
|
+ @RequestHeader(value = "userName") String userName,
|
|
|
|
|
+ @RequestBody TruckDept param) {
|
|
|
log.info("新增运力部门,调用/tms/truck_dept/add,参数:{}", JSON.toJSONString(param));
|
|
log.info("新增运力部门,调用/tms/truck_dept/add,参数:{}", JSON.toJSONString(param));
|
|
|
- if (param == null || param.getOrgId() == null || param.getName() == null || param.getOrgName() == null || param.getOrgShortName() == null) {
|
|
|
|
|
|
|
+ if (param == null || param.getOrgId() == null || param.getName() == null || param.getOrgName() == null
|
|
|
|
|
+ || param.getOrgShortName() == 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());
|
|
|
|
|
+ param.setUpdater(userId);
|
|
|
|
|
+ param.setUpdaterName(utf8Name);
|
|
|
|
|
+ param.setUpdateDate(LocalDateTime.now());
|
|
|
|
|
+
|
|
|
|
|
+ return new Result<>(truckDeptService.save(param));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation(value = "删除运力部门", notes = "根据id删除运力部门,参数:id")
|
|
|
|
|
+ @PostMapping("/delete")
|
|
|
|
|
+ public Result delete(@RequestBody TruckDept param) {
|
|
|
|
|
+ log.info("删除运力部门,调用/tms/truck_dept/delete,参数:{}", JSON.toJSONString(param));
|
|
|
|
|
+ if (param == null || param.getId() == null || param.getOrgId() == null) {
|
|
|
return new Result<>(ErrCodeEnum.BAD_PARAM.getCode(), ErrCodeEnum.BAD_PARAM.getMessage());
|
|
return new Result<>(ErrCodeEnum.BAD_PARAM.getCode(), ErrCodeEnum.BAD_PARAM.getMessage());
|
|
|
}
|
|
}
|
|
|
- Boolean flag = truckDeptService.save(param);
|
|
|
|
|
- return new Result<>(flag);
|
|
|
|
|
|
|
+ if (commonService.findOrgTruckNumber(param.getOrgId(), param.getId()) != 0) {
|
|
|
|
|
+ return new Result<>(ErrCodeEnum.DEPARTMENT_EXIST_TRUCK.getCode(), ErrCodeEnum.DEPARTMENT_EXIST_TRUCK.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ return new Result<>(truckDeptService.removeById(param));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|