Lius
2024-01-26 09e22d89710364548fa896917506a372795a7bd3
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcPassRateServiceImpl.java
@@ -10,10 +10,10 @@
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.mdc.entity.MdcEquipment;
import org.jeecg.modules.mdc.entity.MdcPassRate;
import org.jeecg.modules.mdc.entity.MdcStandardProcessDuration;
import org.jeecg.modules.mdc.mapper.MdcPassRateMapper;
import org.jeecg.modules.mdc.service.IMdcEquipmentService;
import org.jeecg.modules.mdc.service.IMdcPassRateService;
import org.jeecg.modules.mdc.util.DateUtils;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
@@ -24,6 +24,8 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -99,7 +101,7 @@
                if (passRate.getUnqualifiedQuantity() == null || passRate.getUnqualifiedQuantity() == 0) {
                    passRate.setPassRate(new BigDecimal("1"));
                } else {
                    passRate.setPassRate(new BigDecimal(passRate.getUnqualifiedQuantity()).divide(new BigDecimal(passRate.getProcessQuantity())).setScale(2, BigDecimal.ROUND_HALF_UP));
                    passRate.setPassRate(new BigDecimal("1").subtract(new BigDecimal(passRate.getUnqualifiedQuantity()).divide(new BigDecimal(passRate.getProcessQuantity()), 4, BigDecimal.ROUND_HALF_UP)));
                }
            }
            boolean b = super.save(passRate);
@@ -124,7 +126,7 @@
            if (mdcPassRate.getUnqualifiedQuantity() == null || mdcPassRate.getUnqualifiedQuantity() == 0) {
                mdcPassRate.setPassRate(new BigDecimal("1"));
            } else {
                mdcPassRate.setPassRate(new BigDecimal(mdcPassRate.getUnqualifiedQuantity()).divide(new BigDecimal(mdcPassRate.getProcessQuantity())).setScale(2, BigDecimal.ROUND_HALF_UP));
                mdcPassRate.setPassRate(new BigDecimal("1").subtract(new BigDecimal(mdcPassRate.getUnqualifiedQuantity()).divide(new BigDecimal(mdcPassRate.getProcessQuantity()), 4, BigDecimal.ROUND_HALF_UP)));
            }
        }
        return super.updateById(mdcPassRate);
@@ -188,9 +190,27 @@
        //获取当前登录用户
        //update-begin---author:wangshuai ---date:20211227  for:[JTC-116]导出人写死了------------
        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("合格率列表数据", "导出人:" + user.getRealname(), "导出信息"));
        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("合格率列表数据", "导出人:" + user.getRealname(), "合格率"));
        //update-end---author:wangshuai ---date:20211227  for:[JTC-116]导出人写死了------------
        mv.addObject(NormalExcelConstants.DATA_LIST, mdcPassRates);
        return mv;
    }
    @Override
    public BigDecimal findProcessQuantity(String equipmentId, String validDate) {
        String startTime = DateUtils.format(DateUtils.toDate(validDate + "-01 00:00:00", DateUtils.STR_DATE_TIME_SMALL), DateUtils.STR_DATE_TIME_SMALL);
        LocalDate localDate = LocalDate.of(Integer.parseInt(validDate.split("-")[0]), Integer.parseInt(validDate.split("-")[1]), Integer.parseInt("01")).plusMonths(1);
        String endTime = DateUtils.format(DateUtils.toDate(localDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + " 00:00:00", DateUtils.STR_DATE_TIME_SMALL), DateUtils.STR_DATE_TIME_SMALL);
        Integer result = this.baseMapper.findProcessQuantity(equipmentId, startTime, endTime);
        return result == null ? new BigDecimal("0") : new BigDecimal(result);
    }
    @Override
    public BigDecimal findUnqualifiedQuantity(String equipmentId, String validDate) {
        String startTime = DateUtils.format(DateUtils.toDate(validDate + "-01 00:00:00", DateUtils.STR_DATE_TIME_SMALL), DateUtils.STR_DATE_TIME_SMALL);
        LocalDate localDate = LocalDate.of(Integer.parseInt(validDate.split("-")[0]), Integer.parseInt(validDate.split("-")[1]), Integer.parseInt("01")).plusMonths(1);
        String endTime = DateUtils.format(DateUtils.toDate(localDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + " 00:00:00", DateUtils.STR_DATE_TIME_SMALL), DateUtils.STR_DATE_TIME_SMALL);
        Integer result = this.baseMapper.findUnqualifiedQuantity(equipmentId, startTime, endTime);
        return result == null ? new BigDecimal("0") : new BigDecimal(result);
    }
}