提交
This commit is contained in:
parent
965c2a1359
commit
4ff26c4ef7
|
@ -69,4 +69,11 @@ public enum PriceStatus {
|
||||||
public static List<String> canEnable() {
|
public static List<String> canEnable() {
|
||||||
return asList(PASS);
|
return asList(PASS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 允许被报表使用的状态
|
||||||
|
*/
|
||||||
|
public static List<String> canCheckToReport() {
|
||||||
|
return asList(PASS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.ruoyi.web.yh.report.service;
|
package com.ruoyi.web.yh.report.service;
|
||||||
|
|
||||||
|
import com.ruoyi.web.yh.report.domain.ReportVO;
|
||||||
import com.ruoyi.web.yh.report.domain.bo.ReportBO;
|
import com.ruoyi.web.yh.report.domain.bo.ReportBO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,5 +14,10 @@ public interface ReportValidator {
|
||||||
*/
|
*/
|
||||||
void checkPreEdit(ReportBO bo);
|
void checkPreEdit(ReportBO bo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 后校验
|
||||||
|
*/
|
||||||
|
void afterCheck(ReportVO vo);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,30 @@
|
||||||
package com.ruoyi.web.yh.report.service.impl;
|
package com.ruoyi.web.yh.report.service.impl;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.entity.SysDept;
|
||||||
import com.ruoyi.common.utils.ServiceUtil;
|
import com.ruoyi.common.utils.ServiceUtil;
|
||||||
|
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||||
|
import com.ruoyi.system.domain.dto.SysUserQuery;
|
||||||
|
import com.ruoyi.system.domain.vo.SysUserVO;
|
||||||
|
import com.ruoyi.system.service.ISysDeptService;
|
||||||
|
import com.ruoyi.system.service.ISysUserService;
|
||||||
|
import com.ruoyi.web.yh.price.domain.PriceQuery;
|
||||||
|
import com.ruoyi.web.yh.price.domain.PriceVO;
|
||||||
|
import com.ruoyi.web.yh.price.domain.enums.PriceStatus;
|
||||||
|
import com.ruoyi.web.yh.price.service.PriceService;
|
||||||
import com.ruoyi.web.yh.report.domain.ReportVO;
|
import com.ruoyi.web.yh.report.domain.ReportVO;
|
||||||
import com.ruoyi.web.yh.report.domain.bo.ReportBO;
|
import com.ruoyi.web.yh.report.domain.bo.ReportBO;
|
||||||
import com.ruoyi.web.yh.report.domain.enums.ReportStatus;
|
import com.ruoyi.web.yh.report.domain.enums.ReportStatus;
|
||||||
import com.ruoyi.web.yh.report.service.ReportService;
|
import com.ruoyi.web.yh.report.service.ReportService;
|
||||||
import com.ruoyi.web.yh.report.service.ReportValidator;
|
import com.ruoyi.web.yh.report.service.ReportValidator;
|
||||||
|
import com.ruoyi.web.yh.reportProd.domain.bo.ReportProdBO;
|
||||||
|
import com.ruoyi.web.yh.reportUserProd.domain.bo.ReportUserProdBO;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author wjh
|
* @author wjh
|
||||||
* 2024/11/8
|
* 2024/11/8
|
||||||
|
@ -19,6 +35,15 @@ public class ReportValidatorImpl implements ReportValidator {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ReportService reportService;
|
private ReportService reportService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysDeptService deptService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PriceService priceService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysUserService userService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void checkPreEdit(ReportBO bo) {
|
public void checkPreEdit(ReportBO bo) {
|
||||||
ServiceUtil.assertion(bo == null || bo.getReportId() == null, "参数错误");
|
ServiceUtil.assertion(bo == null || bo.getReportId() == null, "参数错误");
|
||||||
|
@ -27,16 +52,76 @@ public class ReportValidatorImpl implements ReportValidator {
|
||||||
ServiceUtil.assertion(old == null || old.getReportId() == null, "待更新的报表不存在");
|
ServiceUtil.assertion(old == null || old.getReportId() == null, "待更新的报表不存在");
|
||||||
ServiceUtil.assertion(!ReportStatus.canEdit().contains(old.getStatus()), "报表当前状态不允许更新,请刷新后重试");
|
ServiceUtil.assertion(!ReportStatus.canEdit().contains(old.getStatus()), "报表当前状态不允许更新,请刷新后重试");
|
||||||
|
|
||||||
// TODO 业务表校验
|
// 校验部门
|
||||||
// TODO 部门是否当前用户可选
|
this.checkDept(bo.getDeptId());
|
||||||
|
|
||||||
// TODO 工序是否当前用户可选
|
// 校验产量
|
||||||
|
this.checkProduct(bo.getProductList());
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterCheck(ReportVO vo) {
|
||||||
|
|
||||||
// TODO 工序是否当前部门的工序
|
// TODO 工序是否当前部门的工序
|
||||||
|
|
||||||
// TODO 员工是否当前用户可选
|
|
||||||
|
|
||||||
// TODO 员工是否当前部门的员工
|
// TODO 员工是否当前部门的员工
|
||||||
|
|
||||||
|
// TODO 订单是否当前部门订单
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkProduct(List<ReportProdBO> productList) {
|
||||||
|
if (CollectionUtils.isEmptyElement(productList)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PriceQuery query = new PriceQuery();
|
||||||
|
query.setPriceIds(CollectionUtils.map(productList, ReportProdBO::getPriceId));
|
||||||
|
query.setNeedScope(true);
|
||||||
|
List<PriceVO> priceList = priceService.selectPriceList(query);
|
||||||
|
|
||||||
|
for (ReportProdBO prod : productList) {
|
||||||
|
if (prod == null || prod.getPriceId() == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 校验工序
|
||||||
|
PriceVO price = priceList.stream().filter(item -> Objects.equals(item.getPriceId(), prod.getPriceId())).findFirst().orElse(null);
|
||||||
|
ServiceUtil.assertion(price == null, "工序%s不存在", prod.getPriceName());
|
||||||
|
ServiceUtil.assertion(!PriceStatus.canCheckToReport().contains(price.getStatus()), "工序%s当前状态不允许被使用", price.getName());
|
||||||
|
ServiceUtil.assertion(price.getDisabled() == null || price.getDisabled(), "工序%s已被禁用,无法使用", price.getName());
|
||||||
|
|
||||||
|
// 校验产量和工序的数值是否一致
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 员工是否当前用户可选
|
||||||
|
List<ReportUserProdBO> userProdList = productList.stream().map(ReportProdBO::getUserProdList).flatMap(List::stream).collect(Collectors.toList());
|
||||||
|
SysUserQuery userQuery = new SysUserQuery();
|
||||||
|
userQuery.setUserIds(CollectionUtils.map(userProdList, ReportUserProdBO::getUserId));
|
||||||
|
userQuery.setNeedScope(true);
|
||||||
|
List<SysUserVO> userList = userService.selectUserList(userQuery);
|
||||||
|
for (ReportUserProdBO userProd : userProdList) {
|
||||||
|
if (userProd == null || userProd.getUserId() == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 校验员工
|
||||||
|
SysUserVO user = userList.stream().filter(item -> Objects.equals(item.getUserId(), userProd.getUserId())).findFirst().orElse(null);
|
||||||
|
ServiceUtil.assertion(user == null, "员工不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO 订单是否当前用户可选
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkDept(Long deptId) {
|
||||||
|
if (deptId == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 部门是否当前用户可选
|
||||||
|
SysDept dept = deptService.selectDeptById(deptId, true);
|
||||||
|
ServiceUtil.assertion(dept == null, "部门不存在");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user