From 94714af765326bc0567a336952b0811667b7be92 Mon Sep 17 00:00:00 2001
From: lyfO_o <764716047@qq.com>
Date: 星期三, 27 十月 2021 16:59:27 +0800
Subject: [PATCH] 货柜预警接口:alarm 字典:alarm_type 01 主电掉电,备电工作 显示:名称+地点+柜号+内容
---
src/main/java/com/nanometer/smartlab/controller/ApplyMngController.java | 196 ++++++++++++++++++++++++++++++++++++-------------
1 files changed, 144 insertions(+), 52 deletions(-)
diff --git a/src/main/java/com/nanometer/smartlab/controller/ApplyMngController.java b/src/main/java/com/nanometer/smartlab/controller/ApplyMngController.java
index 948123a..b7ebec2 100644
--- a/src/main/java/com/nanometer/smartlab/controller/ApplyMngController.java
+++ b/src/main/java/com/nanometer/smartlab/controller/ApplyMngController.java
@@ -5,6 +5,8 @@
import com.nanometer.smartlab.entity.SysReagent;
import com.nanometer.smartlab.entity.SysUser;
import com.nanometer.smartlab.entity.enumtype.ApplyStatus;
+import com.nanometer.smartlab.entity.enumtype.ValidFlag;
+import com.nanometer.smartlab.exception.BusinessException;
import com.nanometer.smartlab.service.*;
import com.nanometer.smartlab.util.Constants;
import com.nanometer.smartlab.util.FacesUtils;
@@ -15,7 +17,9 @@
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.primefaces.context.RequestContext;
+import org.primefaces.event.FileUploadEvent;
import org.primefaces.event.SelectEvent;
+import org.primefaces.event.TabChangeEvent;
import org.primefaces.model.LazyDataModel;
import org.primefaces.model.SortOrder;
import org.springframework.context.annotation.Scope;
@@ -69,22 +73,21 @@
private Timestamp endDeadline;
private Integer status;
private Integer favor;
- private boolean favorFlag;
private List<ApplyStatus> statusSelectList;
+ private String controlProduct;
+
private LazyDataModel<SysReagent> reagentDataModel;
+ private LazyDataModel<SysReagent> reagentFavorDataModel;
private String applyNewReagentName;
private String applyNewCas;
private String applyNewSn;
private SysReagent selectReagent;
+ private int tabValue;
+ private boolean isFlush = false;
- public boolean isFavorFlag() {
- return favorFlag;
- }
- public void setFavorFlag(boolean favorFlag) {
- this.favorFlag = favorFlag;
- }
+
public SysReagent getSelectReagent() {
return selectReagent;
@@ -93,6 +96,7 @@
public void setSelectReagent(SysReagent selectReagent) {
try {
sysUserService.updateUserFavor(selectReagent, getUser());
+ this.isFlush = true;
} catch (Exception e) {
e.printStackTrace();
FacesUtils.warn(e.getMessage());
@@ -238,7 +242,7 @@
if(selectedList!=null&&selectedList.size()>0){
realDataList=selectedList;
}else {
- realDataList=opeApplyService.getOpeApplyList(reagentName, startDeadline, endDeadline, status, getUserId(), null, queryCAS, null, null,null,applyUserName);
+ realDataList=opeApplyService.getOpeApplyList(reagentName, startDeadline,controlProduct, endDeadline, status, getUserId(), null, queryCAS, null, null,null,applyUserName,(byte)1);
}
List<String> headerList = new ArrayList<>();
@@ -298,6 +302,22 @@
}
}
+
+
+ public void uploadApply(FileUploadEvent event){
+ try {
+ opeApplyService.importApply(event, getUser());
+ FacesUtils.info("导入成功");
+ } catch (BusinessException e) {
+ FacesUtils.warn(e.getMessage());
+ } catch (Exception e) {
+ e.printStackTrace();
+ FacesUtils.warn("导入失败,请联系管理员");
+ }
+
+ }
+
+
public HSSFWorkbook exportExcelNew(List<String> headerList, List<OpeApply> dataList) {
HSSFWorkbook hssfWorkbook = new HSSFWorkbook();
@@ -422,6 +442,19 @@
}
}
+ public void onTabChange(TabChangeEvent event) {
+ if ("reagent".equals(event.getTab().getId())) {
+ tabValue = 0;
+ if (isFlush){
+ RequestContext.getCurrentInstance().execute("document.querySelector('.reagentSearch').click()");
+ isFlush = false;
+ }
+ }else if ("applyHistory".equals(event.getTab().getId())){
+ tabValue = 1;
+ }else{
+ tabValue = 2;
+ }
+ }
public void onReagentNewBtnClick() {
this.sysReagent = new SysReagent();
}
@@ -471,10 +504,10 @@
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, status, getUserId(), null, queryCAS,null,applyUserName);
+ int count = opeApplyService.getOpeApplyTotalCount(reagentName, startDeadline,controlProduct, endDeadline, status, getUserId(), null, queryCAS,null,applyUserName,(byte)1);
this.setRowCount(count);
if (count > 0) {
- list = opeApplyService.getOpeApplyList(reagentName, startDeadline, endDeadline, status, getUserId(), null, queryCAS, first, pageSize,null,applyUserName);
+ list = opeApplyService.getOpeApplyList(reagentName, startDeadline,controlProduct, endDeadline, status, getUserId(), null, queryCAS, first, pageSize,null,applyUserName,(byte)1);
for(int i=0;i<list.size();i++){
if(list.get(i).getBeforeApproveUserId()!=null&&!list.get(i).getBeforeApproveUserId().equals("")){
String name=list.get(i).getApproveUserName();
@@ -489,22 +522,23 @@
} 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;
+// 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 opeApplyService.getOpeApply(rowKey);
}
};
}
@@ -519,10 +553,10 @@
public List<SysReagent> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, Object> filters) {
List<SysReagent> list = null;
try {
- int count = sysReagentService.getSysReagentTotalCount2(getUser(),favorFlag ? 1 :null,applyNewReagentName, applyNewCas, applyNewSn,null);
+ int count = sysReagentService.reagentCount(getUser(), applyNewReagentName, applyNewCas, null, applyNewSn);
this.setRowCount(count);
if (count > 0) {
- list = sysReagentService.getSysReagentList2(getUser(),favorFlag ? 1 : null,applyNewReagentName, applyNewCas, applyNewSn,null, first, pageSize);
+ list = sysReagentService.reagentList(getUser(), applyNewReagentName, applyNewCas, null, applyNewSn, first, pageSize,count);
}
} catch (Exception e) {
logger.error(e);
@@ -532,22 +566,61 @@
@Override
public SysReagent getRowData(String rowKey) {
- Iterator<SysReagent> iterator = this.iterator();
- if (iterator != null) {
- SysReagent sr = null;
- while (iterator.hasNext()) {
- sr = iterator.next();
- if (rowKey.equals(sr.getId())) {
- return sr;
- }
- }
- }
- return null;
+// Iterator<SysReagent> iterator = this.iterator();
+// if (iterator != null) {
+// SysReagent sr = null;
+// while (iterator.hasNext()) {
+// sr = iterator.next();
+// if (rowKey.equals(sr.getId())) {
+// return sr;
+// }
+// }
+// }
+ return sysReagentService.getRowData(rowKey);
}
};
}
return reagentDataModel;
+ }
+
+
+ public LazyDataModel<SysReagent> getReagentFavorDataModel() {
+ if (this.reagentFavorDataModel == null) {
+ this.reagentFavorDataModel = new LazyDataModel<SysReagent>() {
+ @Override
+ public List<SysReagent> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, Object> filters) {
+ List<SysReagent> list = null;
+ try {
+ int count = sysReagentService.favorCount(getUser(), null, null, null,null,1);
+ this.setRowCount(count);
+ if (count > 0) {
+ list = sysReagentService.favorList(getUser(),null, null,null, null,1, first, pageSize);
+ }
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ return list;
+ }
+
+ @Override
+ public SysReagent getRowData(String rowKey) {
+// Iterator<SysReagent> iterator = this.iterator();
+// if (iterator != null) {
+// SysReagent sr = null;
+// while (iterator.hasNext()) {
+// sr = iterator.next();
+// if (rowKey.equals(sr.getId())) {
+// return sr;
+// }
+// }
+// }
+ return sysReagentService.getRowData(rowKey);
+ }
+ };
+ }
+
+ return reagentFavorDataModel;
}
public LazyDataModel<OpeApply> getApplyHistoryDataModel() {
@@ -560,12 +633,13 @@
String applyUserId = getUserId();
int count = 0;
if (StringUtils.isNotBlank(applyUserId)) {
- count = opeApplyService.getOpeApplyTotalCount(null, null, null, null, applyUserId, null, null,applyCode,null);
+ count = opeApplyService.getOpeApplyTotalCount(null, null, null,null, null, applyUserId, null, null,applyCode,null,(byte)1);
}
this.setRowCount(count);
if (count > 0) {
- list = opeApplyService.getOpeApplyList(null, null, null, null, applyUserId, null, null, first, pageSize,applyCode,null);
+ list = opeApplyService.getOpeApplyList(null, null,null, null, null, applyUserId, null, null, first, pageSize,applyCode,null,(byte)1);
}
+ selectedList = null;
} catch (Exception e) {
logger.error(e);
}
@@ -574,17 +648,17 @@
@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;
+// 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 opeApplyService.getOpeApply(rowKey);
}
};
}
@@ -672,7 +746,17 @@
//申请一个申购编号
String applyCode = this.sysSequenceService.getApplyCode();
for (OpeApply opeApply : this.applyNewList) {
-
+ if (opeApply.getReagent().getValidFlag() == null
+ ||opeApply.getReagent().getValidFlag().equals(ValidFlag.INVALID)){
+ FacesUtils.warn(opeApply.getReagent().getName()+",该试剂已删除,请选择其他试剂");
+ return;
+ }
+ if (opeApply.getReagent().getType() == 1
+ && (opeApply.getReagent().getSupplierFlag() == null
+ || opeApply.getReagent().getSupplierFlag().equals(ValidFlag.INVALID))){
+ FacesUtils.warn(opeApply.getReagent().getName()+",该试剂供应商已删除,请选择其他试剂");
+ return;
+ }
opeApply.setId(IDUtils.uuid());
opeApply.setApplyCode(applyCode);
opeApply.setApplyUserId(applyUser.getId());
@@ -915,11 +999,19 @@
}
- public Integer getFavor() {
- return favor;
+ public int getTabValue() {
+ return tabValue;
}
- public void setFavor(Integer favor) {
- this.favor = favor;
+ public void setTabValue(int tabValue) {
+ this.tabValue = tabValue;
+ }
+
+ public String getControlProduct() {
+ return controlProduct;
+ }
+
+ public void setControlProduct(String controlProduct) {
+ this.controlProduct = controlProduct;
}
}
--
Gitblit v1.9.2