Commit 11765b2796074d42571d9a8b7ba2643dc76ffdf4
1 parent
5dfcf12b
人机材时间修改
Showing
4 changed files
with
43 additions
and
5 deletions
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/mechanicalcost/vo/MechanicalCostSaveReqVO.java
| 1 | 1 | package com.zteits.urbanops.module.garden.controller.admin.mechanicalcost.vo; |
| 2 | 2 | |
| 3 | 3 | import cn.idev.excel.annotation.ExcelProperty; |
| 4 | +import com.fasterxml.jackson.annotation.JsonFormat; | |
| 4 | 5 | import com.zteits.urbanops.module.garden.controller.admin.costfee.vo.TeamBizdomainRelVo; |
| 5 | 6 | import io.swagger.v3.oas.annotations.media.Schema; |
| 6 | 7 | import jakarta.validation.constraints.NotEmpty; |
| 7 | 8 | import jakarta.validation.constraints.NotNull; |
| 8 | 9 | import lombok.Data; |
| 10 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 9 | 11 | |
| 10 | 12 | import java.math.BigDecimal; |
| 11 | 13 | import java.time.LocalDate; |
| ... | ... | @@ -52,20 +54,24 @@ public class MechanicalCostSaveReqVO { |
| 52 | 54 | |
| 53 | 55 | @Schema(description = "开始使用时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 54 | 56 | @NotNull(message = "开始使用时间不能为空") |
| 57 | + @JsonFormat(pattern = "yyyy-MM-dd", shape = JsonFormat.Shape.STRING) | |
| 58 | + @DateTimeFormat(pattern = "yyyy-MM-dd") | |
| 55 | 59 | private LocalDate startUseTime; |
| 56 | 60 | |
| 57 | 61 | @Schema(description = "使用年限") |
| 58 | 62 | private Long serviceLife; |
| 59 | 63 | |
| 60 | 64 | @Schema(description = "结束使用时间") |
| 65 | + @JsonFormat(pattern = "yyyy-MM-dd", shape = JsonFormat.Shape.STRING) | |
| 66 | + @DateTimeFormat(pattern = "yyyy-MM-dd") | |
| 61 | 67 | private LocalDate endUseTime; |
| 62 | 68 | |
| 63 | 69 | @Schema(description = "归属公司", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") |
| 64 | - @NotEmpty(message = "归属公司不能为空") | |
| 70 | + //@NotEmpty(message = "归属公司不能为空") | |
| 65 | 71 | private String companyName; |
| 66 | 72 | |
| 67 | 73 | @Schema(description = "归属公司ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "5463") |
| 68 | - @NotEmpty(message = "归属公司ID不能为空") | |
| 74 | + //@NotEmpty(message = "归属公司ID不能为空") | |
| 69 | 75 | private String companyId; |
| 70 | 76 | |
| 71 | 77 | @Schema(description = "部门id", example = "13645") | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/rentalmechanicalcost/vo/RentalMechanicalCostRespVO.java
| ... | ... | @@ -2,6 +2,7 @@ package com.zteits.urbanops.module.garden.controller.admin.rentalmechanicalcost. |
| 2 | 2 | |
| 3 | 3 | import cn.idev.excel.annotation.ExcelIgnoreUnannotated; |
| 4 | 4 | import cn.idev.excel.annotation.ExcelProperty; |
| 5 | +import com.fasterxml.jackson.annotation.JsonFormat; | |
| 5 | 6 | import com.fhs.core.trans.anno.Trans; |
| 6 | 7 | import com.fhs.core.trans.constant.TransType; |
| 7 | 8 | import com.zteits.urbanops.module.garden.controller.admin.costfee.vo.TeamBizdomainRelVo; |
| ... | ... | @@ -55,6 +56,8 @@ public class RentalMechanicalCostRespVO { |
| 55 | 56 | |
| 56 | 57 | @Schema(description = "开始使用时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 57 | 58 | @ExcelProperty("开始使用时间") |
| 59 | + @JsonFormat(pattern = "yyyy-MM-dd", shape = JsonFormat.Shape.STRING) | |
| 60 | + @DateTimeFormat(pattern = "yyyy-MM-dd") | |
| 58 | 61 | private LocalDate startUseTime; |
| 59 | 62 | |
| 60 | 63 | @Schema(description = "使用时长(天)") |
| ... | ... | @@ -63,14 +66,16 @@ public class RentalMechanicalCostRespVO { |
| 63 | 66 | |
| 64 | 67 | @Schema(description = "结束使用时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 65 | 68 | @ExcelProperty("结束使用时间") |
| 69 | + @JsonFormat(pattern = "yyyy-MM-dd", shape = JsonFormat.Shape.STRING) | |
| 70 | + @DateTimeFormat(pattern = "yyyy-MM-dd") | |
| 66 | 71 | private LocalDate endUseTime; |
| 67 | 72 | |
| 68 | 73 | @Schema(description = "归属公司", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") |
| 69 | - @ExcelProperty("归属公司") | |
| 74 | + //@ExcelProperty("归属公司") | |
| 70 | 75 | private String companyName; |
| 71 | 76 | |
| 72 | 77 | @Schema(description = "归属公司ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25530") |
| 73 | - @ExcelProperty("归属公司ID") | |
| 78 | + //@ExcelProperty("归属公司ID") | |
| 74 | 79 | private String companyId; |
| 75 | 80 | |
| 76 | 81 | @Schema(description = "道路ID数组(多选)") | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/mechanicalcost/MechanicalCostServiceImpl.java
| ... | ... | @@ -8,6 +8,8 @@ import com.zteits.urbanops.module.garden.controller.admin.costfee.vo.TeamBizdoma |
| 8 | 8 | import com.zteits.urbanops.module.garden.dal.dataobject.mechanicalcost.MechanicalCostDO; |
| 9 | 9 | import com.zteits.urbanops.module.garden.dal.mysql.mechanicalcost.MechanicalCostMapper; |
| 10 | 10 | import com.zteits.urbanops.module.garden.service.mechanicaldepreciation.MechanicalDepreciationService; |
| 11 | +import com.zteits.urbanops.module.system.api.dept.DeptApi; | |
| 12 | +import com.zteits.urbanops.module.system.api.dept.dto.DeptRespDTO; | |
| 11 | 13 | import jakarta.annotation.Resource; |
| 12 | 14 | import org.apache.commons.collections4.CollectionUtils; |
| 13 | 15 | import org.springframework.stereotype.Service; |
| ... | ... | @@ -17,7 +19,10 @@ import org.springframework.validation.annotation.Validated; |
| 17 | 19 | import java.util.List; |
| 18 | 20 | import java.util.stream.Collectors; |
| 19 | 21 | |
| 22 | +import static com.zteits.urbanops.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST; | |
| 20 | 23 | import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 24 | +import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception0; | |
| 25 | +import static com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils.getCompanyId; | |
| 21 | 26 | import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.MECHANICAL_COST_NOT_EXISTS; |
| 22 | 27 | |
| 23 | 28 | |
| ... | ... | @@ -35,8 +40,15 @@ public class MechanicalCostServiceImpl implements MechanicalCostService { |
| 35 | 40 | @Resource |
| 36 | 41 | private MechanicalDepreciationService mechanicalDepreciationService; |
| 37 | 42 | |
| 43 | + @Resource | |
| 44 | + private DeptApi deptApi; | |
| 45 | + | |
| 38 | 46 | @Override |
| 39 | 47 | public Long createMechanicalCost(MechanicalCostSaveReqVO createReqVO) { |
| 48 | + DeptRespDTO deptRespDTO = deptApi.getDept(getCompanyId()); | |
| 49 | + if(null == deptRespDTO){ | |
| 50 | + throw exception0(BAD_REQUEST.getCode(), "无效参数-登录人所属单位为空"); | |
| 51 | + } | |
| 40 | 52 | // 插入 |
| 41 | 53 | MechanicalCostDO mechanicalCost = BeanUtils.toBean(createReqVO, MechanicalCostDO.class); |
| 42 | 54 | |
| ... | ... | @@ -44,7 +56,8 @@ public class MechanicalCostServiceImpl implements MechanicalCostService { |
| 44 | 56 | .map(TeamBizdomainRelVo::getTeamId) |
| 45 | 57 | .collect(Collectors.toList()); |
| 46 | 58 | mechanicalCost.setDeptId(deptIds); |
| 47 | - | |
| 59 | + mechanicalCost.setCompanyId(String.valueOf(deptRespDTO.getId())); | |
| 60 | + mechanicalCost.setCompanyName(deptRespDTO.getName()); | |
| 48 | 61 | mechanicalCostMapper.insert(mechanicalCost); |
| 49 | 62 | // 返回 |
| 50 | 63 | return mechanicalCost.getId(); | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/rentalmechanicalcost/RentalMechanicalCostServiceImpl.java
| ... | ... | @@ -7,6 +7,8 @@ import com.zteits.urbanops.module.garden.controller.admin.rentalmechanicalcost.v |
| 7 | 7 | import com.zteits.urbanops.module.garden.controller.admin.rentalmechanicalcost.vo.RentalMechanicalCostSaveReqVO; |
| 8 | 8 | import com.zteits.urbanops.module.garden.dal.dataobject.rentalmechanicalcost.RentalMechanicalCostDO; |
| 9 | 9 | import com.zteits.urbanops.module.garden.dal.mysql.rentalmechanicalcost.RentalMechanicalCostMapper; |
| 10 | +import com.zteits.urbanops.module.system.api.dept.DeptApi; | |
| 11 | +import com.zteits.urbanops.module.system.api.dept.dto.DeptRespDTO; | |
| 10 | 12 | import jakarta.annotation.Resource; |
| 11 | 13 | import org.springframework.stereotype.Service; |
| 12 | 14 | import org.springframework.validation.annotation.Validated; |
| ... | ... | @@ -14,7 +16,10 @@ import org.springframework.validation.annotation.Validated; |
| 14 | 16 | import java.util.List; |
| 15 | 17 | import java.util.stream.Collectors; |
| 16 | 18 | |
| 19 | +import static com.zteits.urbanops.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST; | |
| 17 | 20 | import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 21 | +import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception0; | |
| 22 | +import static com.zteits.urbanops.framework.security.core.util.SecurityFrameworkUtils.getCompanyId; | |
| 18 | 23 | import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.RENTAL_MECHANICAL_COST_NOT_EXISTS; |
| 19 | 24 | |
| 20 | 25 | /** |
| ... | ... | @@ -29,14 +34,23 @@ public class RentalMechanicalCostServiceImpl implements RentalMechanicalCostServ |
| 29 | 34 | @Resource |
| 30 | 35 | private RentalMechanicalCostMapper rentalMechanicalCostMapper; |
| 31 | 36 | |
| 37 | + @Resource | |
| 38 | + private DeptApi deptApi; | |
| 39 | + | |
| 32 | 40 | @Override |
| 33 | 41 | public Long createRentalMechanicalCost(RentalMechanicalCostSaveReqVO createReqVO) { |
| 42 | + DeptRespDTO deptRespDTO = deptApi.getDept(getCompanyId()); | |
| 43 | + if(null == deptRespDTO){ | |
| 44 | + throw exception0(BAD_REQUEST.getCode(), "无效参数-登录人所属单位为空"); | |
| 45 | + } | |
| 34 | 46 | // 插入 |
| 35 | 47 | RentalMechanicalCostDO rentalMechanicalCost = BeanUtils.toBean(createReqVO, RentalMechanicalCostDO.class); |
| 36 | 48 | List<Long> deptIds = createReqVO.getTeamIds().stream() |
| 37 | 49 | .map(TeamBizdomainRelVo::getTeamId) |
| 38 | 50 | .collect(Collectors.toList()); |
| 39 | 51 | rentalMechanicalCost.setDeptId(deptIds); |
| 52 | + rentalMechanicalCost.setCompanyId(String.valueOf(deptRespDTO.getId())); | |
| 53 | + rentalMechanicalCost.setCompanyName(deptRespDTO.getName()); | |
| 40 | 54 | rentalMechanicalCostMapper.insert(rentalMechanicalCost); |
| 41 | 55 | // 返回 |
| 42 | 56 | return rentalMechanicalCost.getId(); | ... | ... |