kongzy
2024-07-01 47a751cb301d05276ae5d75145d57b2d090fe4e1
src/main/java/com/nanometer/smartlab/controller/RequireMngController.java
@@ -1,7 +1,9 @@
package com.nanometer.smartlab.controller;
import com.nanometer.smartlab.dao.SysProjectDao;
import com.nanometer.smartlab.entity.OpeApply;
import com.nanometer.smartlab.entity.OpeOrder;
import com.nanometer.smartlab.entity.SysProject;
import com.nanometer.smartlab.entity.enumtype.ApplyStatus;
import com.nanometer.smartlab.service.OpeApplyService;
import com.nanometer.smartlab.service.OpeOrderService;
@@ -34,8 +36,11 @@
    private MenuController menuController;
    @Resource
    private OpeOrderService opeOrderService;
    @Resource
    private SysProjectDao sysProjectDao;
    private LazyDataModel<OpeApply> dataModel;
    private LazyDataModel<OpeApply> supplerRequireMngDataModel;
    private OpeOrder opeOrder;
    private List<OpeApply> selectedList;
    private String reagentName;
@@ -50,7 +55,7 @@
            return;
        }
        Set<String> results = new HashSet<>();
        Set<Long> results = new HashSet<>();
        for(OpeApply item : selectedList)
        {
              results.add(item.getReagent().getSupplierId());
@@ -132,7 +137,7 @@
            this.menuController.backToPage();
        } catch (Exception e) {
            logger.error("操作失败。", e);
            FacesUtils.warn("操作失败。");
            FacesUtils.warn("操作失败,message="+e.getMessage());
        }
    }
@@ -143,36 +148,72 @@
                public List<OpeApply> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, Object> filters) {
                    List<OpeApply> list = null;
                    try {
                        int count = opeApplyService.getOpeApplyTotalCount(reagentName, startDeadline, endDeadline, ApplyStatus.APPROVED.getKey(), null, null, null,null,null);
                        int count = opeApplyService.getOpeApplyTotalCount(reagentName, startDeadline,null, endDeadline, ApplyStatus.APPROVED.getKey(), null, null, null,null,null,(byte)1);
                        this.setRowCount(count);
                        if (count > 0) {
                            list = opeApplyService.getOpeApplyList(reagentName, startDeadline, endDeadline, ApplyStatus.APPROVED.getKey(), null, null, null, first, pageSize,null,null);
                            list = opeApplyService.getOpeApplyList(reagentName, startDeadline,null, endDeadline, ApplyStatus.APPROVED.getKey(), null, null, null, first, pageSize,null,null,(byte)1);
                        }
                    } catch (Exception e) {
                        logger.error(e);
                    }
                    selectedList = null;
                    return list;
                }
                @Override
                public OpeApply getRowData(String rowKey) {
                    Iterator<OpeApply> iterator = this.iterator();
                    if (iterator != null) {
                        OpeApply oa = null;
                        while (iterator.hasNext()) {
                            oa = iterator.next();
                            if (rowKey.equals(oa.getId())) {
                                return oa;
                            }
                        }
                    }
                    return null;
//                    if (iterator != null) {
//                        OpeApply oa = null;
//                        while (iterator.hasNext()) {
//                            oa = iterator.next();
//                            if (rowKey.equals(oa.getId())) {
//                                return oa;
//                            }
//                        }
//                    }
                    Long id=Long.valueOf(rowKey);
                    return opeApplyService.getOpeApply(id);
                }
            };
        }
        return dataModel;
    }
    public LazyDataModel<OpeApply> getSupplerRequireMngDataModel() {
        return new LazyDataModel<OpeApply>() {
            @Override
            public List<OpeApply> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, Object> filters) {
                List<OpeApply> list = null;
                try {
                    int count = opeApplyService.getOpeApplySupplerRequireMngTotalCount(getUser(),reagentName, startDeadline, endDeadline, ApplyStatus.APPROVED.getKey(),(byte)1);
                    this.setRowCount(count);
                    if (count > 0) {
                        list = opeApplyService.getOpeApplySupplerRequireMngList(getUser(),reagentName, startDeadline, endDeadline, ApplyStatus.APPROVED.getKey(), first, pageSize,(byte)1);
                    }
                } catch (Exception e) {
                    logger.error(e);
                }
                selectedList = null;
                return list;
            }
            @Override
            public OpeApply getRowData(String rowKey) {
                Long id=Long.valueOf(rowKey);
                return opeApplyService.getOpeApply(id);
            }
        };
    }
    public String getProjectName(Long projectId){
        if(projectId==null){
            return "";
        }
        SysProject project= this.sysProjectDao.getSysProject(projectId);
        return project!=null?project.getProjectName():"";
    }
    public OpeOrder getOpeOrder() {
        return opeOrder;
    }