gongchunyi
9 天以前 e39bddf535c89c9a7fe5789c01a17f92d4e596e7
src/main/java/com/ruoyi/production/service/impl/ProductWorkOrderServiceImpl.java
@@ -19,7 +19,9 @@
import com.ruoyi.production.pojo.ProductWorkOrder;
import com.ruoyi.production.pojo.ProductWorkOrderFile;
import com.ruoyi.production.service.ProductWorkOrderService;
import com.ruoyi.project.system.domain.SysPost;
import com.ruoyi.project.system.domain.SysUser;
import com.ruoyi.project.system.mapper.SysPostMapper;
import com.ruoyi.project.system.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -50,11 +52,19 @@
    @Autowired
    private SysUserMapper sysUserMapper;
    @Autowired
    private SysPostMapper sysPostMapper;
    @Override
    public IPage<ProductWorkOrderDto> listPage(Page<ProductWorkOrderDto> page, ProductWorkOrderDto productWorkOrder) {
        Long userId = SecurityUtils.getUserId();
        if (!SecurityUtils.isAdmin(userId) && !SecurityUtils.hasRole(Constants.WORKSHOP_DEPUTY_DIRECTOR)) {
            productWorkOrder.setCurrentUserId(userId);
            List<SysPost> posts = sysPostMapper.selectPostsByUserName(SecurityUtils.getUsername());
            boolean isWorkshopDirector = CollectionUtils.isNotEmpty(posts)
                    && posts.stream().anyMatch(post -> Constants.WORKSHOP_DIRECTOR_POST.equals(post.getPostCode()));
            if (!isWorkshopDirector) {
                productWorkOrder.setCurrentUserId(userId);
            }
        }
        return productWorkOrdermapper.pageProductWorkOrder(page, productWorkOrder);
    }