From 7da4353b03a540e1de6f3b848a9613f84517db69 Mon Sep 17 00:00:00 2001
From: 李宇 <986321569@qq.com>
Date: Thu, 10 Mar 2022 12:28:16 +0800
Subject: [PATCH] 申购后进入价格确认环节,可修改价格
---
src/main/java/com/nanometer/smartlab/controller/ApplyMngController.java | 188 ++++++++++++++++++++++++++++++++--------------
1 files changed, 129 insertions(+), 59 deletions(-)
diff --git a/src/main/java/com/nanometer/smartlab/controller/ApplyMngController.java b/src/main/java/com/nanometer/smartlab/controller/ApplyMngController.java
index aa4e293..4fcfea1 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;
@@ -70,6 +74,8 @@
private Integer status;
private Integer favor;
private List<ApplyStatus> statusSelectList;
+ private String controlProduct;
+
private LazyDataModel<SysReagent> reagentDataModel;
private LazyDataModel<SysReagent> reagentFavorDataModel;
@@ -77,6 +83,8 @@
private String applyNewCas;
private String applyNewSn;
private SysReagent selectReagent;
+ private int tabValue;
+ private boolean isFlush = false;
@@ -88,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());
@@ -134,7 +143,7 @@
}
public void initApproveUserSelectList() {
- this.approveUserSelectList = this.sysUserService.getHasProjectSysUserList(this.getUserDepartment());
+ this.approveUserSelectList = this.sysUserService.getHasProjectSysUserList(this.getUserDepartment(),this.getUserProject());
if (!CollectionUtils.isEmpty(this.approveUserSelectList)){
if(this.selectedList == null){
this.sysProjectList = sysProjectService.getSysProjectList(this.approveUserSelectList.get(0).getId());
@@ -233,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<>();
@@ -250,6 +259,8 @@
headerList.add("试剂类型");
headerList.add("申购数量");
headerList.add("申购人");
+ headerList.add("申购人课题组");
+ headerList.add("申购人部门");
headerList.add("申购日期");
headerList.add("一级审批者");
headerList.add("二级审批者");
@@ -293,6 +304,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();
@@ -319,16 +346,20 @@
dataRow.createCell(10).setCellValue(dataList.get(i).getReagent().getReagentType()== null ? "": String.valueOf(baseMetaService.getBaseMetaValue(dataList.get(i).getReagent().getReagentType())));
dataRow.createCell(11).setCellValue(String.valueOf(dataList.get(i).getNum()));
dataRow.createCell(12).setCellValue(String.valueOf(dataList.get(i).getApplyUserName()));
- dataRow.createCell(13).setCellValue(String.valueOf(dataList.get(i).getCreateTime()));
+ dataRow.createCell(13).setCellValue(dataList.get(i).getApplyUserProject() == null?"":String.valueOf(dataList.get(i).getApplyUserProject()));
+ dataRow.createCell(14).setCellValue(dataList.get(i).getApplyUserDepartment() == null?"":String.valueOf(dataList.get(i).getApplyUserDepartment()));
+
+
+ dataRow.createCell(15).setCellValue(String.valueOf(dataList.get(i).getCreateTime()));
// SysUser u=sysUserService.getSysUser(dataList.get(i).getApproveUserId());
- dataRow.createCell(14).setCellValue(String.valueOf(dataList.get(i).getFirName()));
+ dataRow.createCell(16).setCellValue(String.valueOf(dataList.get(i).getFirName()));
if(dataList.get(i).getBeforeApproveUserId()!=null && !dataList.get(i).getBeforeApproveUserId().equals("")){
//u=sysUserService.getSysUser(dataList.get(i).getBeforeApproveUserId());
- dataRow.createCell(15).setCellValue(String.valueOf(dataList.get(i).getApproveUserName()));
+ dataRow.createCell(17).setCellValue(String.valueOf(dataList.get(i).getApproveUserName()));
}
//dataRow.createCell(14).setCellValue(String.valueOf(u.getName()));
- dataRow.createCell(16).setCellValue(String.valueOf(dataList.get(i).getStatus().getText()));
- dataRow.createCell(17).setCellValue(dataList.get(i).getMemo()==null ?"":String.valueOf(dataList.get(i).getMemo()));
+ dataRow.createCell(18).setCellValue(String.valueOf(dataList.get(i).getStatus().getText()));
+ dataRow.createCell(19).setCellValue(dataList.get(i).getMemo()==null ?"":String.valueOf(dataList.get(i).getMemo()));
}
return hssfWorkbook;
@@ -417,6 +448,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();
}
@@ -466,10 +510,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();
@@ -484,22 +528,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);
}
};
}
@@ -514,10 +559,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.favorCount(getUser(), applyNewReagentName, applyNewCas, null, applyNewSn, 0);
+ int count = sysReagentService.reagentCount(getUser(), applyNewReagentName, applyNewCas, null, applyNewSn);
this.setRowCount(count);
if (count > 0) {
- list = sysReagentService.favorList(getUser(), applyNewReagentName, applyNewCas, null, applyNewSn, 0, first, pageSize);
+ list = sysReagentService.reagentList(getUser(), applyNewReagentName, applyNewCas, null, applyNewSn, first, pageSize,count);
}
} catch (Exception e) {
logger.error(e);
@@ -527,17 +572,17 @@
@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);
}
};
}
@@ -566,17 +611,17 @@
@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);
}
};
}
@@ -594,12 +639,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);
}
@@ -608,17 +654,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);
}
};
}
@@ -706,11 +752,21 @@
//申请一个申购编号
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());
- opeApply.setStatus(ApplyStatus.PENDING_APPROVAL);
+ opeApply.setStatus(ApplyStatus.Price_CONFIRM);
}
this.opeApplyService.insertOpeApplyList(this.applyNewList);
@@ -949,5 +1005,19 @@
}
+ public int getTabValue() {
+ return tabValue;
+ }
+ 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