|
|
|
@ -3,9 +3,12 @@ package cn.iocoder.yudao.module.mes.controller.admin.baogongrecord;
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
|
|
|
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
|
|
|
import cn.iocoder.yudao.module.mes.controller.admin.itemrequisition.vo.ItemRequisitionRespVO;
|
|
|
|
import cn.iocoder.yudao.module.mes.controller.admin.itemrequisition.vo.ItemRequisitionRespVO;
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.mes.controller.admin.plan.vo.PlanRespVO;
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.mes.controller.admin.plan.vo.PlanSaveReqVO;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.itemrequisition.ItemRequisitionDO;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.itemrequisition.ItemRequisitionDO;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.organization.OrganizationDO;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.organization.OrganizationDO;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.plan.PlanDO;
|
|
|
|
import cn.iocoder.yudao.module.mes.dal.dataobject.plan.PlanDO;
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.mes.service.plan.PlanService;
|
|
|
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
|
|
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
|
|
|
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
|
|
|
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
@ -19,6 +22,8 @@ import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
import javax.validation.constraints.*;
|
|
|
|
import javax.validation.constraints.*;
|
|
|
|
import javax.validation.*;
|
|
|
|
import javax.validation.*;
|
|
|
|
import javax.servlet.http.*;
|
|
|
|
import javax.servlet.http.*;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
|
|
|
|
@ -47,6 +52,9 @@ public class BaogongRecordController {
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private BaogongRecordService baogongRecordService;
|
|
|
|
private BaogongRecordService baogongRecordService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private PlanService planService;
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private AdminUserApi adminUserApi;
|
|
|
|
private AdminUserApi adminUserApi;
|
|
|
|
|
|
|
|
|
|
|
|
@ -54,6 +62,27 @@ public class BaogongRecordController {
|
|
|
|
@Operation(summary = "创建报工")
|
|
|
|
@Operation(summary = "创建报工")
|
|
|
|
@PreAuthorize("@ss.hasPermission('mes:baogong-record:create')")
|
|
|
|
@PreAuthorize("@ss.hasPermission('mes:baogong-record:create')")
|
|
|
|
public CommonResult<Long> createBaogongRecord(@Valid @RequestBody BaogongRecordSaveReqVO createReqVO) {
|
|
|
|
public CommonResult<Long> createBaogongRecord(@Valid @RequestBody BaogongRecordSaveReqVO createReqVO) {
|
|
|
|
|
|
|
|
PlanDO plan = planService.getPlan(createReqVO.getPlanId());
|
|
|
|
|
|
|
|
if (plan.getWangongNumber() == null) {
|
|
|
|
|
|
|
|
plan.setWangongNumber(0L);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (plan.getPassNumber() == null) {
|
|
|
|
|
|
|
|
plan.setPassNumber(0L);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (plan.getNoPassNumber() == null) {
|
|
|
|
|
|
|
|
plan.setNoPassNumber(0L);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
plan.setWangongNumber(plan.getWangongNumber() + createReqVO.getNum() + createReqVO.getNoPassNum());
|
|
|
|
|
|
|
|
plan.setPassNumber(plan.getPassNumber() + createReqVO.getNum());
|
|
|
|
|
|
|
|
plan.setNoPassNumber(plan.getNoPassNumber() + createReqVO.getNoPassNum());
|
|
|
|
|
|
|
|
if (plan.getWangongNumber() <= 0) {
|
|
|
|
|
|
|
|
plan.setPassRate(BigDecimal.ZERO);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
BigDecimal rate = new BigDecimal(plan.getPassNumber())
|
|
|
|
|
|
|
|
.divide(new BigDecimal(plan.getWangongNumber()), 4, RoundingMode.HALF_UP);
|
|
|
|
|
|
|
|
plan.setPassRate(rate.multiply(new BigDecimal("100")));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
planService.updatePlan(BeanUtils.toBean(plan, PlanSaveReqVO.class));
|
|
|
|
return success(baogongRecordService.createBaogongRecord(createReqVO));
|
|
|
|
return success(baogongRecordService.createBaogongRecord(createReqVO));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|