瀏覽代碼

其他费用相关代码

chengang 4 年之前
父節點
當前提交
25d69a6ad3

+ 1 - 1
src/main/java/com/aoyang/tms/controller/TmsGasFeeController.java

@@ -93,7 +93,7 @@ public class TmsGasFeeController {
         return new Result<>(tmsGasFeeService.save(param));
     }
 
-    @ApiOperation(value = "修改燃气费用", notes = "必传参数:id,tmsLineCostOther.id")
+    @ApiOperation(value = "修改燃气费用", notes = "必传参数:id")
     @PostMapping("/update")
     public Result update(@RequestHeader(value = "userId") Long userId,
                          @RequestHeader(value = "userName") String userName,

+ 83 - 16
src/main/java/com/aoyang/tms/controller/TmsOtherFeeController.java

@@ -1,6 +1,9 @@
 package com.aoyang.tms.controller;
 
 
+import com.alibaba.fastjson.JSON;
+import com.aoyang.tms.common.ErrCodeEnum;
+import com.aoyang.tms.entity.TmsGasFee;
 import com.aoyang.tms.entity.TmsOtherFee;
 import com.aoyang.tms.service.TmsOtherFeeService;
 import org.springframework.web.bind.annotation.*;
@@ -9,7 +12,10 @@ import org.springframework.web.bind.annotation.RestController;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.*;
 import lombok.extern.slf4j.Slf4j;
-import java.util.*;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.time.LocalDateTime;
 import javax.annotation.Resource;
 
 import com.aoyang.common.result.Result;
@@ -21,10 +27,10 @@ import com.aoyang.common.param.PageParam;
 
 /**
  * <p>
-    * 其他费用表 控制器
-    * </p>
+ * 其他费用表 控制器
+ * </p>
  *
- * @author liujiren
+ * @author chengang
  * @since 2022-04-23
  */
 @RestController
@@ -36,25 +42,86 @@ public class TmsOtherFeeController {
     @Resource
     private TmsOtherFeeService tmsOtherFeeService;
 
-    @ApiOperation(value = "获取tms_other_fee列表",notes="")
-    @PostMapping("/list")
-    public Result list(@RequestBody PageParam<TmsOtherFee> pageParam) {
+    @ApiOperation(value = "获取tms_other_fee分页列表", notes = "")
+    @PostMapping("/page_list")
+    public Result pageList(@RequestBody PageParam<TmsOtherFee> pageParam) {
         Page<TmsOtherFee> page = new Page<>(pageParam.getPage(), pageParam.getSize());
         IPage<TmsOtherFee> records = tmsOtherFeeService.page(page, Wrappers.query(pageParam.getParam()));
         return new Result<>(records);
     }
 
-    @ApiOperation(value = "修改tms_other_fee",notes="根据id修改tms_other_fee")
-    @PostMapping("/update")
-    public Result update(@RequestBody TmsOtherFee tmsOtherFee) {
-        Boolean flag = tmsOtherFeeService.updateById(tmsOtherFee);
-        return new Result<>(flag);
+    @ApiOperation(value = "获取其他费用列表(供行车费用列表展示用)", notes = "必传参数:CycleId,TruckId")
+    @PostMapping("/list")
+    public Result list(@RequestBody TmsOtherFee param) {
+        log.info("获取其他费用列表(供行车费用列表展示用),调用/tms/tms_other_fee/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<>(tmsOtherFeeService.list(param));
     }
 
-    @ApiOperation(value = "添加tms_other_fee",notes="新增一条tms_other_fee")
+    @ApiOperation(value = "根据id获取其他费用详情", notes = "必传参数:Id")
+    @PostMapping("/get_one")
+    public Result getOne(@RequestBody TmsOtherFee param) {
+        log.info("根据id获取其他费用详情,调用/tms/tms_other_fee/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<>(tmsOtherFeeService.getById(param));
+    }
+
+    @ApiOperation(value = "添加其他费用", notes = "必传参数:CycleId,TruckId")
     @PostMapping("/add")
-    public Result add(@RequestBody TmsOtherFee tmsOtherFee) {
-        Boolean flag = tmsOtherFeeService.save(tmsOtherFee);
-        return new Result<>(flag);
+    public Result add(@RequestHeader(value = "userId") Long userId,
+                      @RequestHeader(value = "userName") String userName,
+                      @RequestBody TmsOtherFee param) {
+        log.info("添加其他费用,调用/tms/tms_other_fee/add,参数:{}", JSON.toJSONString(param));
+        if (param == null || param.getCycleId() == null || param.getTruckId() == 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<>(tmsOtherFeeService.save(param));
     }
+
+    @ApiOperation(value = "修改其他费用", notes = "必传参数:id")
+    @PostMapping("/update")
+    public Result update(@RequestHeader(value = "userId") Long userId,
+                         @RequestHeader(value = "userName") String userName,
+                         @RequestBody TmsOtherFee param) {
+        log.info("修改其他费用,调用/tms/tms_other_fee/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<>(tmsOtherFeeService.updateById(param));
+    }
+
+    @ApiOperation(value = "删除其他费用", notes = "必传参数:id")
+    @PostMapping("/delete")
+    public Result delete(@RequestBody TmsOtherFee param) {
+        log.info("删除其他费用,调用/tms/tms_other_fee/delete,参数:{}", JSON.toJSONString(param));
+        if (param == null || param.getId() == null) {
+            return new Result<>(ErrCodeEnum.BAD_PARAM.getCode(), ErrCodeEnum.BAD_PARAM.getMessage());
+        }
+        return new Result<>(tmsOtherFeeService.removeById(param));
+    }
+
 }

+ 18 - 0
src/main/java/com/aoyang/tms/controller/vo/TmsOtherFeeListVO.java

@@ -0,0 +1,18 @@
+package com.aoyang.tms.controller.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class TmsOtherFeeListVO {
+
+    @ApiModelProperty(value = "其他费用id")
+    @JsonFormat(shape = JsonFormat.Shape.STRING)
+    private Long otherFeeId;
+
+    @ApiModelProperty(value = "其他费用总数")
+    private BigDecimal otherFeeSum;
+}

+ 1 - 1
src/main/java/com/aoyang/tms/entity/TmsGasFee.java

@@ -19,7 +19,7 @@ import lombok.experimental.Accessors;
     * 燃气费用表
     * </p>
  *
- * @author liujiren
+ * @author chengang
  * @since 2022-04-23
  */
 @Data

+ 5 - 1
src/main/java/com/aoyang/tms/entity/TmsOtherFee.java

@@ -19,7 +19,7 @@ import lombok.experimental.Accessors;
     * 其他费用表
     * </p>
  *
- * @author liujiren
+ * @author chengang
  * @since 2022-04-23
  */
 @Data
@@ -82,6 +82,10 @@ public class TmsOtherFee implements Serializable {
     @TableField("repair_fee")
     private BigDecimal repairFee;
 
+    @ApiModelProperty(value = "安全费用")
+    @TableField("save_fee")
+    private BigDecimal saveFee;
+
     @ApiModelProperty(value = "创建人id")
     @TableField("creater")
     @JsonFormat(shape = JsonFormat.Shape.STRING)

+ 23 - 1
src/main/java/com/aoyang/tms/service/TmsOtherFeeService.java

@@ -1,16 +1,38 @@
 package com.aoyang.tms.service;
 
+import com.aoyang.tms.controller.vo.TmsOtherFeeListVO;
 import com.aoyang.tms.entity.TmsOtherFee;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.math.BigDecimal;
+import java.util.List;
+
 /**
  * <p>
  * 其他费用表 服务类
  * </p>
  *
- * @author liujiren
+ * @author chengang
  * @since 2022-04-23
  */
 public interface TmsOtherFeeService extends IService<TmsOtherFee> {
 
+    /**
+     * @return
+     * @Author chengang
+     * @Description 获取其他费用列表(供行车费用列表展示用)
+     * @Date 2022/4/23
+     * @Param
+     **/
+    List<TmsOtherFeeListVO> list(TmsOtherFee param);
+
+    /**
+     * @return
+     * @Author chengang
+     * @Description 获取其他费用总数
+     * @Date 2022/4/23
+     * @Param
+     **/
+    BigDecimal feeSum(TmsOtherFee param);
+
 }

+ 56 - 0
src/main/java/com/aoyang/tms/service/impl/TmsOtherFeeServiceImpl.java

@@ -1,12 +1,18 @@
 package com.aoyang.tms.service.impl;
 
 
+import com.aoyang.tms.controller.vo.TmsOtherFeeListVO;
 import com.aoyang.tms.entity.TmsOtherFee;
 import com.aoyang.tms.mapper.TmsOtherFeeMapper;
 import com.aoyang.tms.service.TmsOtherFeeService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * <p>
  * 其他费用表 服务实现类
@@ -18,4 +24,54 @@ import org.springframework.stereotype.Service;
 @Service
 public class TmsOtherFeeServiceImpl extends ServiceImpl<TmsOtherFeeMapper, TmsOtherFee> implements TmsOtherFeeService {
 
+    @Override
+    public List<TmsOtherFeeListVO> list(TmsOtherFee param) {
+        QueryWrapper<TmsOtherFee> queryWrapper = new QueryWrapper<>();
+        if (param.getCycleId() != null) {
+            queryWrapper.eq("cycle_id", param.getCycleId());
+        }
+        if (param.getTruckId() != null) {
+            queryWrapper.eq("truck_id", param.getTruckId());
+        }
+        List<TmsOtherFee> list = list(queryWrapper.orderByAsc("create_date"));
+        List<TmsOtherFeeListVO> listVOS = new ArrayList<>();
+        for (TmsOtherFee tmsOtherFee : list) {
+            TmsOtherFeeListVO tmsOtherFeeListVO = new TmsOtherFeeListVO();
+            tmsOtherFeeListVO.setOtherFeeId(tmsOtherFee.getId());
+            tmsOtherFeeListVO.setOtherFeeSum(feeSum(tmsOtherFee));
+            listVOS.add(tmsOtherFeeListVO);
+        }
+
+        return listVOS;
+    }
+
+    @Override
+    public BigDecimal feeSum(TmsOtherFee param) {
+        BigDecimal feeSum = BigDecimal.ZERO;
+        if (param.getButterFee() != null) {
+            feeSum = feeSum.add(param.getButterFee());
+        }
+        if (param.getMaintenanceFee() != null) {
+            feeSum = feeSum.add(param.getMaintenanceFee());
+        }
+        if (param.getRepairFee() != null) {
+            feeSum = feeSum.add(param.getRepairFee());
+        }
+        if (param.getSaveFee() != null) {
+            feeSum = feeSum.add(param.getSaveFee());
+        }
+        if (param.getTireFee() != null) {
+            feeSum = feeSum.add(param.getTireFee());
+        }
+        if (param.getCarReviewFee() != null) {
+            feeSum = feeSum.add(param.getCarReviewFee());
+        }
+        if (param.getOilChangeFee() != null) {
+            feeSum = feeSum.add(param.getOilChangeFee());
+        }
+        if (param.getWeighingPassingOtherFee() != null) {
+            feeSum = feeSum.add(param.getWeighingPassingOtherFee());
+        }
+        return feeSum;
+    }
 }

+ 3 - 1
src/main/resources/mapper/TmsOtherFeeMapper.xml

@@ -16,6 +16,8 @@
         <result column="oil_change_fee" property="oilChangeFee" />
         <result column="car_review_fee" property="carReviewFee" />
         <result column="repair_fee" property="repairFee" />
+        <result column="save_fee" property="saveFee" />
+
         <result column="creater" property="creater" />
         <result column="creater_name" property="createrName" />
         <result column="create_date" property="createDate" />
@@ -26,7 +28,7 @@
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id, cycle_id, truck_id, car_number, trailer_number, maintenance_fee, butter_fee, tire_fee, weighing_passing_other_fee, oil_change_fee, car_review_fee, repair_fee, creater, creater_name, create_date, updater, updater_name, update_date
+        id, cycle_id, truck_id, car_number, trailer_number, maintenance_fee, butter_fee, tire_fee, weighing_passing_other_fee, oil_change_fee, car_review_fee, repair_fee, save_fee, creater, creater_name, create_date, updater, updater_name, update_date
     </sql>
 
 </mapper>