From 47a751cb301d05276ae5d75145d57b2d090fe4e1 Mon Sep 17 00:00:00 2001
From: kongzy <kongzy>
Date: 星期一, 01 七月 2024 10:58:35 +0800
Subject: [PATCH] change

---
 src/main/java/com/nanometer/smartlab/controller/WarehouseStockMngController.java |  652 +++++++++++++++++++++++++++++++----------------------------
 1 files changed, 344 insertions(+), 308 deletions(-)

diff --git a/src/main/java/com/nanometer/smartlab/controller/WarehouseStockMngController.java b/src/main/java/com/nanometer/smartlab/controller/WarehouseStockMngController.java
index 2962b20..a16737d 100644
--- a/src/main/java/com/nanometer/smartlab/controller/WarehouseStockMngController.java
+++ b/src/main/java/com/nanometer/smartlab/controller/WarehouseStockMngController.java
@@ -1,9 +1,6 @@
 package com.nanometer.smartlab.controller;
 
-import com.nanometer.smartlab.dao.BaseMetaDao;
-import com.nanometer.smartlab.dao.OpeApplyDao;
-import com.nanometer.smartlab.dao.OpeReagentStatusDao;
-import com.nanometer.smartlab.dao.OpeWarehouseReserveDao;
+import com.nanometer.smartlab.dao.*;
 import com.nanometer.smartlab.entity.*;
 import com.nanometer.smartlab.entity.dto.ApplyListDto;
 import com.nanometer.smartlab.entity.enumtype.*;
@@ -22,6 +19,7 @@
 import org.primefaces.model.LazyDataModel;
 import org.primefaces.model.SortOrder;
 import org.primefaces.model.StreamedContent;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.PropertySource;
 import org.springframework.context.annotation.Scope;
@@ -58,6 +56,8 @@
 
     @Resource
     private OpeApplyService opeApplyService;
+	@Resource
+	private SysProjectDao sysProjectDao;
 
 	@Resource
 	private OpeWarehouseReserveService opeWarehouseReserveService;
@@ -99,7 +99,7 @@
 	OpeApplyDao opeApplyDao;
 
     @Resource
-	OpeLaboratoryReserveService opeLaboratoryReserveService;
+	OpeLaboratoryReserveDao opeLaboratoryReserveDao;
 	/**
 	 * 数据源
 	 */
@@ -126,7 +126,7 @@
 	/**
 	 *打开条形码对话框用
 	 */
-	private Map<String,Map<String,OpeWarehouseReserve>> warehouseReserveUseTmp=new HashMap<>();
+	private Map<Long,Map<Long,OpeWarehouseReserve>> warehouseReserveUseTmp=new HashMap<>();
 	/**
 	 * 打开条形码对话框用
 	 */
@@ -146,17 +146,17 @@
 		this.reagentStatusSelectListForPerson = reagentStatusSelectListForPerson;
 	}
 
-	private String reagentId;
-	private String reagentLogId;
+	private String reagentName;
+	private Long reagentLogId;
 
 	private String userName;
 	private Integer tabValue = 0;
 
 	private List<SysReagent> reagentSelectList;
 	private List<String> showCodes;
-	private String userId;
-	private String projectNum;
-	private String userLogId;
+	private Long userId;
+	private Long projectId;
+	private Long userLogId;
 	private String reagentCode;
 	private Integer useNum;
 	private String startReagentCode;
@@ -173,7 +173,11 @@
 	@Value("${institute.name}")
 	String instituteName;
 
+	private boolean isExpired;
+
 	private Hashtable printTable;
+	@Autowired
+	private AccountInAndOutService accountInAndOutService;
 
 	public Hashtable getPrintTable() {
 		return printTable;
@@ -213,11 +217,13 @@
 
 	private List<SysUser> userSelectList;
 	private List<SysUser> applyUserSelectList;
-	private String supplierId;
+	private Long supplierId;
 	private List<SysSupplier> supplierSelectList;
 	//private boolean flag = false;
 	//领用单号
 	private String receiptNumber;
+	//备注
+	private String note;
 	// 试剂库
     private LazyDataModel<SysReagent> reagentDataModel;
 	// 直接入库试剂List
@@ -238,14 +244,14 @@
     private List<SysWarehouse> warehouseList;
     private List<SysWarehouseContainer> warehouseContainerList;
     private List<BaseMeta> warehouseContainerPlaceList;
-    private Map<String, String> warehouseNameMap;
-    private Map<String, SysWarehouseContainer> warehouseContainerMap;
-    private Map<String, List<SysWarehouseContainer>> warehouseIdContainerMap;
+    private Map<Long, String> warehouseNameMap;
+    private Map<Long, SysWarehouseContainer> warehouseContainerMap;
+    private Map<Long, List<SysWarehouseContainer>> warehouseIdContainerMap;
 
-    private String laboratoryId;
-    private String oriLaboratoryId;
+    private Long laboratoryId;
+    private Long oriLaboratoryId;
     private List<SysLaboratory> laboratory;
-    private String laboratoryContainerId;
+    private Long laboratoryContainerId;
     private List<SysLaboratoryContainer> laboratoryContainers;
 
 	/**
@@ -274,7 +280,7 @@
 	//到货时间
 	private Timestamp arrivalTime;
 	//收货人
-	private String consigneeId;
+	private Long consigneeId;
 	//OpeApply
 	private List<OpeApplyReserve> opeApplyList;
 	/**
@@ -306,7 +312,14 @@
 		this.initUserSelectList();
 	}
 
-
+	/**
+	 * 获取已领用数量
+	 * @param applyCode
+	 * @return
+	 */
+	public Integer getUsedCount(String applyCode){
+		return this.opeReagentStatusDao.getReagentStatusCountByApplyCode(applyCode);
+	}
 
 
 
@@ -316,15 +329,15 @@
 		this.initUserSelectList();
 
         this.warehouseList = this.sysWarehouseService.getSysWarehouseList(null, null, null, null);
-        this.warehouseNameMap = new HashMap<String, String>();
+        this.warehouseNameMap = new HashMap<Long, String>();
         if (this.warehouseList != null && this.warehouseList.size() > 0) {
             for (SysWarehouse house : this.warehouseList) {
                 this.warehouseNameMap.put(house.getId(), house.getName());
             }
         }
 
-        this.warehouseContainerMap = new HashMap<String, SysWarehouseContainer>();
-        this.warehouseIdContainerMap = new HashMap<String, List<SysWarehouseContainer>>();
+        this.warehouseContainerMap = new HashMap<Long, SysWarehouseContainer>();
+        this.warehouseIdContainerMap = new HashMap<Long, List<SysWarehouseContainer>>();
         List<SysWarehouseContainer> warehouseContainerList = this.sysWarehouseContainerService.getSysWarehouseContainerList(null, null, null, null, null);
         if (warehouseContainerList != null && warehouseContainerList.size() > 0) {
             for (SysWarehouseContainer container : warehouseContainerList) {
@@ -344,14 +357,14 @@
 	public void initInputWarehouse() {
 		logger.info("WarehouseStockMngController initInputWarehouse start");
 		this.warehouseList = this.sysWarehouseService.getSysWarehouseList(null, null, null, null);
-		this.warehouseNameMap = new HashMap<String, String>();
+		this.warehouseNameMap = new HashMap<Long, String>();
 		if (this.warehouseList != null && this.warehouseList.size() > 0) {
 			for (SysWarehouse house : this.warehouseList) {
 				this.warehouseNameMap.put(house.getId(), house.getName());
 			}
 		}
-		this.warehouseContainerMap = new HashMap<String, SysWarehouseContainer>();
-		this.warehouseIdContainerMap = new HashMap<String, List<SysWarehouseContainer>>();
+		this.warehouseContainerMap = new HashMap<Long, SysWarehouseContainer>();
+		this.warehouseIdContainerMap = new HashMap<Long, List<SysWarehouseContainer>>();
 		List<SysWarehouseContainer> warehouseContainerList = this.sysWarehouseContainerService.getSysWarehouseContainerList(null, null, null, null, null);
 		if (warehouseContainerList != null && warehouseContainerList.size() > 0) {
 			for (SysWarehouseContainer container : warehouseContainerList) {
@@ -391,11 +404,11 @@
 	private void initReagentStatusSelectList() {
 		logger.info("WarehouseStockMngController initReagentStatusSelectList start");
 		if (selectedOpeWarehouseReserve != null) {
-			String reagentId = selectedOpeWarehouseReserve.getReagentId();
+			Long reagentId = selectedOpeWarehouseReserve.getReagentId();
 			String articleNumber = selectedOpeWarehouseReserve.getArticleNumber();
 
-			this.setReagentStatusSelectList(opeReagentStatusService.getOpeReagentStatusList(reagentId, articleNumber,
-					ArrivalStatus.WAREHOUSE.getKey(), reagentCode, null, null, null));
+			this.setReagentStatusSelectList(opeReagentStatusService.getOpeReagentStatusList22(reagentId, articleNumber,
+					ArrivalStatus.WAREHOUSE.getKey(), reagentCode, null, null,null, null));
 
 //			System.out.print("this.getReagentStatusSelectList().size(): " + this.reagentStatusSelectList.size());
 //			System.out.print("this.getReagentStatusSelectList().get(0): " + this.reagentStatusSelectList.get(0).getReagentCode());
@@ -408,13 +421,10 @@
 	private void initReagentStatusSelectListForPerson() {
 		logger.info("WarehouseStockMngController initReagentStatusSelectListForPerson start");
 		if (selectedOpeApplyReserve != null) {
-			String reagentId = selectedOpeApplyReserve.getReagent().getId();
+			Long reagentId = selectedOpeApplyReserve.getReagent().getId();
 			String articleNumber = selectedOpeApplyReserve.getArticleNumber();
-			System.out.println(reagentId);
-			System.out.println(articleNumber);
-			System.out.println(reagentCode);
-			this.setReagentStatusSelectListForPerson(opeReagentStatusService.getOpeReagentStatusList(reagentId, articleNumber,
-					ArrivalStatus.WAREHOUSE.getKey(), reagentCode, null, null, null));
+			this.setReagentStatusSelectListForPerson(opeReagentStatusService.getOpeReagentStatusList22(reagentId, articleNumber,
+					ArrivalStatus.WAREHOUSE.getKey(), reagentCode, null, selectedOpeApplyReserve.getApplyCode(),null, null));
 
 		}
 	}
@@ -424,7 +434,8 @@
 		System.out.println(getUser().getSeeFlag().getKey());
 		//SysUser u=sysUserService.getSysUser(getUserId());
 		//System.out.println(u);
-		if (getUser().getSeeFlag().getKey() != SeeFlag.MANAGE.getKey()) {
+		if (getUser().getSeeFlag().getKey() != SeeFlag.MANAGE.getKey()
+				&& getUser().getSeeFlag().getKey() != SeeFlag.LEADING.getKey()) {
 			editFlag=0;
 		}else{
 			editFlag=1;
@@ -495,7 +506,7 @@
 		}
 		//1.判断非状态为确认的申购单不能入库
 		for (OpeApplyReserve opeApplyReserve : this.selectedListForPerson) {
-			if (opeApplyReserve.getStatus() != ApplyStatus.SUPPLIER_CONFIRM) {
+			if (opeApplyReserve.getStatus() != ApplyStatus.SUPPLIER_CONFIRM && opeApplyReserve.getStatus() != ApplyStatus.UNCOMPLETED) {
 				FacesUtils.warn("非已确认的数据不能入库。");
 				return;
 			}
@@ -655,9 +666,9 @@
 
 
 		//相同的试剂不能再多选
-		Set<String> checkTable = new HashSet<>();
+		Set<Long> checkTable = new HashSet<>();
 		for (OpeApplyReserve oar : selectedTmpOrderList) {
-			String reagentId = oar.getReagent().getId();
+			Long reagentId = oar.getReagent().getId();
 			if (!checkTable.contains(reagentId)) {
 				checkTable.add(reagentId);
 			}else{
@@ -667,8 +678,12 @@
 		}
 		checkTable = null;
 		//
-		this.userId = selectedTmpOrderList.get(0).getApplyUser();
-
+		this.userId = selectedTmpOrderList.get(0).getApplyUserId();
+		SysUser sysUser = sysUserService.getSysUser(this.userId);
+		if (sysUser == null){
+			FacesUtils.info("申领人不存在");
+			return;
+		}
 		this.menuController.goToPage(Constants.PAGE_WAREHOUSE_REAGENT_USE_NEW_PERSON, Constants.PAGE_WAREHOUSE_STOCK_MNG);
 	}
 
@@ -741,8 +756,8 @@
 		}
 		if (warehouseReserveUseTmp.get(selectedOpeApplyReserve.getReagent().getId()) == null) {
 			//初始化库中领用和大小,
-			reagentCodeSelectedList = selectedOpeApplyReserve.getReagentCode();
-			useNum = selectedOpeApplyReserve.getReagentCode() == null?0: selectedOpeApplyReserve.getReagentCode().size();
+			reagentCodeSelectedList = selectedOpeApplyReserve.getReagentCodes();
+			useNum = selectedOpeApplyReserve.getReagentCodes() == null?0: selectedOpeApplyReserve.getReagentCodes().size();
 			this.endReagentCodeForPerson = null;
 			this.startReagentCodeForPerson = null;
 		}
@@ -752,7 +767,7 @@
 	/**
 	* 变换库存
 	*/
-	public void selectChangeReserve(String  id) {
+	public void selectChangeReserve(Long  id) {
 		if (warehouseReserveList.size() > 0) {
 			warehouseReserveList.forEach(owr -> {
 				if (owr.getWarehouseId().equals(id)){
@@ -790,7 +805,7 @@
 		owr.setReagentId(opeWarehouseReserve.getReagentId());
 		owr.setUseNum(useNum);
 		if (warehouseReserveUseTmp.get(owr.getReagentId()) == null) {
-			Map<String, OpeWarehouseReserve> tmp = new HashMap<>();
+			Map<Long, OpeWarehouseReserve> tmp = new HashMap<>();
 			tmp.put(owr.getWarehouseId(), owr);
 			warehouseReserveUseTmp.put(owr.getReagentId(), tmp);
 		}else{
@@ -799,7 +814,7 @@
 		//变换条码
 		btCodeChange();
 	}
-	
+
 	/**
 	* 取消一个仓库领取
 	*/
@@ -819,13 +834,13 @@
 		List<OpeWarehouseReserve> list = new ArrayList<>();
 
 
-		Map<String, OpeWarehouseReserve> dataMap = warehouseReserveUseTmp.
+		Map<Long, OpeWarehouseReserve> dataMap = warehouseReserveUseTmp.
 				get(opeWarehouseReserve.getReagentId());
 		if (dataMap ==null) {
 			return list;
 		}
-		Set<Map.Entry<String, OpeWarehouseReserve>> entries = dataMap.entrySet();
-		for (Map.Entry<String, OpeWarehouseReserve> e : entries) {
+		Set<Map.Entry<Long, OpeWarehouseReserve>> entries = dataMap.entrySet();
+		for (Map.Entry<Long, OpeWarehouseReserve> e : entries) {
 			list.add(e.getValue());
 		}
 		return list;
@@ -918,7 +933,7 @@
 					opeApplyReserve.setSelectNum(useNum);
 					if(this.reagentCodeSelectedList != null)
 					{
-						opeApplyReserve.setReagentCode(this.reagentCodeSelectedList);
+						opeApplyReserve.setReagentCodes(this.reagentCodeSelectedList);
 					}
 					opeApplyReserve.setFlag(1);
 					//删除前面部分的补贴条码领用显示
@@ -965,7 +980,7 @@
 					opeApplyReserve.setSelectNum(distance);
 					opeApplyReserve.setStartReagentCode2(this.startReagentCodeForPerson);
 					opeApplyReserve.setEndReagentCode2(this.endReagentCodeForPerson);
-					opeApplyReserve.setReagentCode(codeList);
+					opeApplyReserve.setReagentCodes(codeList);
 					opeApplyReserve.setCacheUpdateList(getDataTmp());
 					opeApplyReserve.setFlag(0);
 					reagentCodeSelectedList = null;
@@ -1074,6 +1089,7 @@
 		this.selectedInputStorageTmpOrderList = null;
 		this.endReagentCodeForPerson = null;
 		this.startReagentCodeForPerson = null;
+		this.laboratoryId = null;
 		this.useNum = null;
 		this.menuController.backToPage();
 	}
@@ -1122,15 +1138,16 @@
 			checkReserve(list2);
 			//1.2判断提交的条码是否重复(只有补贴条码需要判断)
 			checkReagentCode(list2);
+			String receiptNum = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date());
 			//库中领取
 			if(list.size()>0&&list!=null){
 				//扣库存 对象中的reagentCode存的是id
 
 				for(OpeApplyReserve app:list){
-					List<String> reagentCode=app.getReagentCode();
-					if(reagentCode!=null && reagentCode.size()>0){
-						for(String opeReagentStatusId:reagentCode){
-							OpeReagentStatus opeReagentStatus=this.opeReagentStatusService.getOpeReagentStatus(opeReagentStatusId);
+					List<String> reagentCodes=app.getReagentCodes();
+					if(reagentCodes!=null && reagentCodes.size()>0){
+						for(String reagentCode:reagentCodes){
+							OpeReagentStatus opeReagentStatus=this.opeReagentStatusService.getOpeReagentStatusByCode(reagentCode);
 							if (!this.opeReagentStatusService.isAllowWarehouseUse(opeReagentStatus)) {
 								FacesUtils.warn("只能申领在仓库的试剂。");
 								return;
@@ -1139,7 +1156,7 @@
 					}
 				}
 
-				this.opeWarehouseReserveService.claimForPerson(list, userId,projectNum,laboratoryId,laboratoryContainerId);
+				this.opeWarehouseReserveService.claimForPerson(list, userId,projectId,laboratoryId,laboratoryContainerId,receiptNum);
 			}
 
 			//补贴条码
@@ -1153,7 +1170,7 @@
 					opeApply.setReagent(list2.get(i).getReagent());
 					opeApply.setStartReagentCode(list2.get(i).getStartReagentCode2());
 					opeApply.setEndReagentCode(list2.get(i).getEndReagentCode2());
-					opeApply.setReagentCodeList(list2.get(i).getReagentCode());
+					opeApply.setReagentCodeList(list2.get(i).getReagentCodes());
 					opeApply.setId(list2.get(i).getId());
 					opeList.add(opeApply);
 					OpeLaboratoryReserve lr=new OpeLaboratoryReserve();
@@ -1163,7 +1180,7 @@
 					lr.setReserve(list2.get(i).getSelectNum());
 					lr.setUserId(userId);
 					lr.setValidFlag(ValidFlag.VALID);
-					this.opeLaboratoryReserveService.insert(lr);
+					this.opeLaboratoryReserveDao.insertOpeLaboratoryReserve(lr);
 				}
 				this.opeWarehouseReserveService.reagentDStore3(opeList,userId);
 
@@ -1185,7 +1202,7 @@
 				if (oar.getStatus() == ApplyStatus.SUPPLIER_CONFIRM) {
 					//领用完 就改成已经入库
 					if (oar.getNum() == oar.getUsed() + oar.getSelectNum()) {
-						opeApplyService.updateOpeApplyInfo(ApplyStatus.STORAGE,null,null, oar.getId());
+						opeApplyService.updateOpeApplyInfo(ApplyStatus.STORAGE,null,null, oar.getId(),null);
 						//2.2更改订单状态
 						OpeOrder oo = opeOrderService.getOrder(oar.getId());
 						List<OpeApply> oas = opeOrderService.getOpeApplyListByOrder(oo.getId());
@@ -1210,16 +1227,27 @@
 			printTable = new Hashtable();
 			int sum = 0;
 			List<ApplyListDto> applyList = new ArrayList<>();
-			Map applyPersonInfo = sysUserService.getUser(userId);
+			SysUser applyPersonInfo = sysUserService.getUser(userId);
+			if (applyPersonInfo == null) {
+				FacesUtils.warn("申领人不存在或者申领人部门被删除。");
+				return;
+			}
 			printTable.put("head", instituteName);
 			printTable.put("title", "领用单");
-			printTable.put("applyPerson", applyPersonInfo.get("name"));
-			printTable.put("department", applyPersonInfo.get("meta_value"));
+			printTable.put("applyPerson", applyPersonInfo.getName());
+			printTable.put("department", applyPersonInfo.getDepartmentName());
 			printTable.put("date", Utils.now("yyyy-MM-dd"));
-			printTable.put("phone", applyPersonInfo.get("phone"));
-			String receiptNum = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date());
+
 			printTable.put("receiptNumber", receiptNum);
-			printTable.put("project", applyPersonInfo.get("project"));
+			if (StringUtils.isNotBlank(applyPersonInfo.getPhone())){
+				printTable.put("phone", applyPersonInfo.getPhone());
+			}
+			if (applyPersonInfo.getProjectId()!=null){
+				SysProject sysProject=this.sysProjectDao.getSysProject(applyPersonInfo.getProjectId());
+				if(sysProject!=null){
+					printTable.put("project", sysProject.getProjectName());
+				}
+			}
 			SysLaboratory lab = sysLaboratoryService.getSysLaboratory(laboratoryId);
 			printTable.put("lab", lab.getName());
 			this.receiptNumber = receiptNum;
@@ -1259,7 +1287,7 @@
 	 */
 	public void associatedFlowReceiptNumber() {
 		try {
-			opeUseFlowService.updateReceiptNumberByCode(selectedTmpOrderList, receiptNumber);
+			opeUseFlowService.updateReceiptNumberByCode(selectedTmpOrderList, receiptNumber, note);
 			//弹出打印窗口
 			RequestContext.getCurrentInstance().execute("document.getElementById('indirectPrint').click()");
 		} catch (Exception e) {
@@ -1275,7 +1303,7 @@
 
 	public void associatedFlowReceiptNumber2() {
 		try {
-			opeUseFlowService.updateReceiptNumberByCode2(selectedTmpList, receiptNumber);
+			opeUseFlowService.updateReceiptNumberByCode2(selectedTmpList, receiptNumber,note);
 			//弹出打印窗口
 			RequestContext.getCurrentInstance().execute("document.getElementById('indirectPrint').click()");
 		} catch (Exception e) {
@@ -1287,7 +1315,7 @@
 
 	public void closeDialog() {
 		try {
-			opeUseFlowService.updateReceiptNumberByCode(selectedTmpOrderList, receiptNumber);
+			opeUseFlowService.updateReceiptNumberByCode(selectedTmpOrderList, receiptNumber,note);
 			onCancelBtnClick();
 		} catch (Exception e) {
 			logger.info(e.getMessage());
@@ -1297,7 +1325,7 @@
 
 	public void closeDialog2() {
 		try {
-			opeUseFlowService.updateReceiptNumberByCode2(selectedTmpList, receiptNumber);
+			opeUseFlowService.updateReceiptNumberByCode2(selectedTmpList, receiptNumber,note);
 			onCancelBtnClick();
 		} catch (Exception e) {
 			logger.info(e.getMessage());
@@ -1331,7 +1359,7 @@
 		for (OpeApplyReserve oar : list) {
 			List<String> codeList = opeReagentStatusService
 					.checkReagentCode(oar.getStartReagentCode2(), oar.getEndReagentCode2(), oar.getSelectNum());
-			oar.setReagentCode(codeList);
+			oar.setReagentCodes(codeList);
 			if (codeList != null && codeList.size() > 0) {
 				for (String code:codeList) {
 					if (!checkSet.contains(code)) {
@@ -1472,6 +1500,8 @@
 		}
 
 	}
+
+
 	public  void  onSaveBtnClick() {
 		try {
 			if (this.selectedTmpList == null || this.selectedTmpList.size() == 0) {
@@ -1487,15 +1517,26 @@
 			printTable = null;
 			printTable = new Hashtable();
 			List<ApplyListDto> applyList = new ArrayList<>();
-			Map applyPersonInfo = sysUserService.getUser(userId);
+			SysUser applyPersonInfo = sysUserService.getUser(userId);
+			if (applyPersonInfo == null) {
+				FacesUtils.warn("申领人不存在或者申领人部门被删除。");
+				return;
+			}
 			printTable.put("head", instituteName);
 			printTable.put("title", "领用单");
-			printTable.put("applyPerson", applyPersonInfo.get("name"));
-			printTable.put("department", applyPersonInfo.get("meta_value"));
+			printTable.put("applyPerson", applyPersonInfo.getName());
+			printTable.put("department", applyPersonInfo.getDepartmentName());
 			printTable.put("date", Utils.now("yyyy-MM-dd"));
-			printTable.put("phone", applyPersonInfo.get("phone"));
-			printTable.put("project", applyPersonInfo.get("project"));
-			SysLaboratory lab = sysLaboratoryService.getSysLaboratory(laboratoryId);
+			if (StringUtils.isNotBlank(applyPersonInfo.getPhone())){
+				printTable.put("phone", applyPersonInfo.getPhone());
+			}
+			if (applyPersonInfo.getProjectId()!=null){
+				SysProject sysProject=this.sysProjectDao.getSysProject(applyPersonInfo.getProjectId());
+				if(sysProject!=null){
+					printTable.put("project", sysProject.getProjectName());
+				}
+			}
+			SysLaboratory lab = sysLaboratoryService.getSysLaboratorySimpleInfo(laboratoryId);
 			String receiptNum = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date());
 			printTable.put("receiptNumber", receiptNum);
 			printTable.put("lab", lab.getName());
@@ -1504,43 +1545,17 @@
 			//int size = 0;
 			int sum = 0;
 			List<OpeWarehouseReserve> list=new ArrayList<>();
-			List<OpeWarehouseReserve> list2=new ArrayList<>();
 			for (OpeWarehouseReserve selectWarehouseReserve : this.selectedTmpList) {
-				if(selectWarehouseReserve.getFlag()==1){
-					list.add(selectWarehouseReserve);
-				}else{
-					list2.add(selectWarehouseReserve);
-				}
+				list.add(selectWarehouseReserve);
 			}
+
 			if(list.size()>0&&list!=null){
 				for (OpeWarehouseReserve selectWarehouseReserve : list) {
-					List<String> reagentCodes = selectWarehouseReserve.getReagentCodes();
-					if (reagentCodes != null && reagentCodes.size() > 0)
-						for (String opeReagentStatusId : reagentCodes) {
-							OpeReagentStatus opeReagentStatus = this.opeReagentStatusService
-									.getOpeReagentStatus(opeReagentStatusId);
-							if (!this.opeReagentStatusService.isAllowWarehouseUse(opeReagentStatus)) {
-								FacesUtils.warn("只能申领在仓库的试剂。");
-								return;
-							}else {
-								opeReagentStatus.setHouseId(laboratoryId);
-								opeReagentStatus.setContainerId(laboratoryContainerId);
-								this.opeReagentStatusDao.updateOpeReagentStatusDao(opeReagentStatus);//更新试剂状态表
-								OpeLaboratoryReserve lr=new OpeLaboratoryReserve();
-								lr.setReagentId(selectWarehouseReserve.getReagentId());
-								lr.setHouseId(laboratoryId);
-								lr.setContainerId(laboratoryContainerId);
-								lr.setReserve(selectWarehouseReserve.getSelectNum());
-								lr.setUserId(userId);
-								lr.setValidFlag(ValidFlag.VALID);
-								this.opeLaboratoryReserveService.insert(lr);
-							}
-							//else {
-							//size++;
-							//}
-						}
-					ApplyListDto lis = new ApplyListDto();
 					Map reagentDetail = sysReagentService.getReagentDetail(selectWarehouseReserve.getReagentId());
+					if (reagentDetail == null) {
+						throw new Exception("试剂有误,请联系管理员");
+					}
+					ApplyListDto lis = new ApplyListDto();
 					lis.setNum(String.valueOf(selectWarehouseReserve.getSelectNum())); //数量
 					lis.setMainMetering(String.format("%s%s", reagentDetail.get("main_metering"), reagentDetail.get("unit")));
 					lis.setControlProducts((String) reagentDetail.get("controlProducts"));
@@ -1552,90 +1567,10 @@
 					sum += selectWarehouseReserve.getSelectNum();
 				}
 
-				//if (size == 0) {
-				//FacesUtils.warn("未选择一个条形码。");
-				//return;
-				//}
-				this.opeWarehouseReserveService.claim(list, userId,projectNum);
+				this.opeWarehouseReserveService.claim(list, userId,projectId,laboratoryId,laboratoryContainerId,receiptNum);
 			}
 
-			if(list2.size()>0&&list2!=null){
-				List<OpeApply> opeList=new ArrayList<>();
-				//this.opeApplyService.getOpeApplyList(null,null,null,null,null)
-				for(int i=0;i<list2.size();i++){
-					OpeApply opeApply=new OpeApply();
-					opeApply.setArticleNumber(list2.get(i).getArticleNumber());
-					opeApply.setHouseId(laboratoryId);
-					opeApply.setContainerId(laboratoryContainerId);
-					opeApply.setReagent(this.sysReagentService.getSysReagent(list2.get(i).getReagentId()));
-					opeApply.setStartReagentCode(list2.get(i).getStartReagentCode2());
-					opeApply.setEndReagentCode(list2.get(i).getEndReagentCode2());
-					opeApply.setReagentCodeList(list2.get(i).getReagentCodes());
-					opeList.add(opeApply);
-					OpeLaboratoryReserve lr=new OpeLaboratoryReserve();
-					lr.setReagentId(list2.get(i).getReagentId());
-					lr.setHouseId(laboratoryId);
-					lr.setContainerId(laboratoryContainerId);
-					lr.setReserve(list2.get(i).getSelectNum());
-					lr.setUserId(userId);
-					lr.setValidFlag(ValidFlag.VALID);
-					this.opeLaboratoryReserveService.insert(lr);
-					//opeList.add(this.opeApplyService.getOpeApply(list2.get(i).getId()));
-					ApplyListDto lis = new ApplyListDto();
-					Map reagentDetail = sysReagentService.getReagentDetail(list2.get(i).getReagentId());
 
-					lis.setNum(String.valueOf(list2.get(i).getSelectNum())); //数量
-					lis.setMainMetering(String.format("%s%s", reagentDetail.get("main_metering"), reagentDetail.get("unit")));
-					lis.setControlProducts((String) reagentDetail.get("controlProducts"));
-					lis.setProductName((String) reagentDetail.get("name"));
-					lis.setReagentFormat((String) reagentDetail.get("reagentFormat"));
-					lis.setProductCode((String)reagentDetail.get("productCode"));
-					lis.setMemo((String)reagentDetail.get("memo"));
-					applyList.add(lis);
-
-					sum += list2.get(i).getSelectNum();
-				}
-				this.opeWarehouseReserveService.reagentDStore4(opeList,userId);
-				for(int i=0;i<list2.size();i++){
-
-					List<String> reagentCodes = opeReagentStatusService
-							.generateReagentCode(list2.get(i).getStartReagentCode2(), list2.get(i).getEndReagentCode2());
-					Integer selectNum = list2.get(i).getSelectNum();
-					for (int j = 0;j<selectNum;j++){
-						// 试剂使用情况入库insert
-						OpeUseFlow opeUseFlow = new OpeUseFlow();
-						opeUseFlow.setReagentCode(reagentCodes.get(0));
-						opeUseFlow.setStatus(ArrivalStatus.WAREHOUSE);
-						//仓库信息
-						List<OpeWarehouseReserve> warehouseReserveInfo = opeWarehouseReserveService
-								.selectWarehouseByRidAndArticleNumberAndWarehouse(list2.get(i).getReagent().getId()
-										, list2.get(i).getArticleNumber()
-										, list2.get(i).getWarehouseId());
-						opeUseFlow.setHouseId(list2.get(i).getWarehouseId());
-						opeUseFlow.setContainerId(warehouseReserveInfo.get(0).getContainerId());
-						opeUseFlow.setCreateTime(warehouseReserveInfo.get(0).getUpdateTime());
-						opeUseFlow.setUserId(warehouseReserveInfo.get(0).getUserId());
-						opeUseFlow.setRemainder(list2.get(i).getReagent().getMainMetering()!=null?list2.get(i).getReagent().getMainMetering():new BigDecimal(0));
-						opeUseFlow.setStoreType(StoreType.DIRECTSTORE);
-
-						Map<String, String> metaMap = new HashMap<>();
-						metaMap.put("groupId", "operate_status");
-						metaMap.put("metaKey", String.valueOf(OperateStatus.WAREHOUSEIN.getKey()));
-						List<BaseMeta> baseMetaList = baseMetaDao.getBaseMetaList(metaMap);
-						opeUseFlow.setOperateState(baseMetaList.get(0).getId());
-						this.opeUseFlowService.insertOpeUseFlow(opeUseFlow);
-						reagentCodes.remove(0);
-					}
-
-					list2.get(i).setReserve(list2.get(i).getReserve()-list2.get(i).getSelectNum());
-					opeWarehouseReserveDao.updateOpeWarehouseReserve2(list2.get(i));
-				}
-
-
-				//opeWarehouseReserve.setReserve(opeWarehouseReserve.getReserve()-opeWarehouseReserve.getSelectNum());
-				//opeWarehouseReserveDao.updateOpeWarehouseReserve(opeWarehouseReserve);
-				//this.opeWarehouseReserveService.claim(list2, userId,projectNum);
-			}
 
 			//领用票最后一行
 			applyList.add(new ApplyListDto("合计", "", "", "", "", String.valueOf(sum), ""));
@@ -1644,6 +1579,10 @@
 			FacesUtils.info("申领成功。");
 			RequestContext.getCurrentInstance().execute("PF('printDialog').show()");
 //            this.menuController.goToPage(Constants.PAGE_WAREHOUSE_STOCK_MNG, Constants.PAGE_WAREHOUSE_REAGENT_USE_NEW);
+		} catch (BusinessException e) {
+			logger.error(e.getMessage(), e);
+			FacesUtils.warn(e.getMessage());
+
 		} catch (Exception e) {
 			logger.error(e.getMessage(), e);
 			FacesUtils.warn("操作失败。");
@@ -1659,6 +1598,10 @@
                 if (StringUtils.isBlank(opeApplyReserve.getArticleNumber())) {
                     throw new BusinessException(ExceptionEnumCode.PARAM_EXIST, opeApplyReserve.getReagent().getName() + ":批号不能为空");
                 }
+                SysReagent sysReagent = sysReagentService.getSysReagent(opeApplyReserve.getReagent().getId());
+				if (sysReagent == null){
+					throw new BusinessException(ExceptionEnumCode.PARAM_EXIST, opeApplyReserve.getReagent().getName() + ":被删除");
+				}
             }
 
 			//用来检验提交表单得试剂条码是否重复
@@ -1713,31 +1656,34 @@
 						Map<String, Object> filters) {
 					List<OpeWarehouseReserve> list = null;
 					try {
-						int count = opeWarehouseReserveService.getOpeWarehouseReserveTotalCountByName(reagentId, supplierId,productSn,warehouseName);
+						int count = opeWarehouseReserveService.getOpeWarehouseReserveTotalCountByName(reagentName, supplierId,productSn,warehouseName);
 						this.setRowCount(count);
 						if (count > 0) {
-							list = opeWarehouseReserveService.getOpeWarehouseReserveListByName(reagentId, supplierId, first,
+							list = opeWarehouseReserveService.getOpeWarehouseReserveListByName(reagentName, supplierId, first,
 									pageSize,productSn,warehouseName);
 						}
 					} catch (Exception e) {
 						logger.error(e);
 					}
+					selectedList = null;
+					selectedTmpList=null;
 					return list;
 				}
 
 				@Override
 				public OpeWarehouseReserve getRowData(String rowKey) {
-					Iterator<OpeWarehouseReserve> iterator = this.iterator();
-					if (iterator != null) {
-						OpeWarehouseReserve su = null;
-						while (iterator.hasNext()) {
-							su = iterator.next();
-							if (rowKey.equals(su.getId())) {
-								return su;
-							}
-						}
-					}
-					return null;
+//					Iterator<OpeWarehouseReserve> iterator = this.iterator();
+//					if (iterator != null) {
+//						OpeWarehouseReserve su = null;
+//						while (iterator.hasNext()) {
+//							su = iterator.next();
+//							if (rowKey.equals(su.getId())) {
+//								return su;
+//							}
+//						}
+//					}
+					Long id=Long.valueOf(rowKey);
+					return opeWarehouseReserveService.getRowData(id);
 				}
 			};
 		}
@@ -1754,8 +1700,8 @@
 						Map<String, Object> filters) {
 					List<OpeApplyReserve> list = null;
 					SysUser loginUser = getUser();
-					String id="";
-					if(loginUser.getSeeFlag()==SeeFlag.MANAGE){
+					Long id=null;
+					if(loginUser.getSeeFlag()==SeeFlag.MANAGE||loginUser.getSeeFlag() ==SeeFlag.LEADING){
 
 					}else {
 						//userName=loginUser.getName();
@@ -1763,31 +1709,34 @@
 					}
 
 					try {
-						int count = opeApplyService.getOpeApplyReserveTotalCountByNameFor(id, reagentId, userName, productSn, applyCode, status, isAllApply);
+						int count = opeApplyService.getOpeApplyReserveTotalCountByNameFor(id, null, userName, productSn, applyCode, status, isAllApply,isExpired);
 						this.setRowCount(count);
 						if (count > 0) {
-							list = opeApplyService.getOpeApplyReserveListByNameFor(id, reagentId, userName, first,
-									pageSize, productSn, applyCode, status, isAllApply);
+							list = opeApplyService.getOpeApplyReserveListByNameFor(id, null, userName, first,
+									pageSize, productSn, applyCode, status, isAllApply,isExpired);
 						}
 					} catch (Exception e) {
 						logger.error(e);
 					}
+					selectedListForPerson = null;
+					selectedTmpOrderList=null;
 					return list;
 				}
 
 				@Override
 				public OpeApplyReserve getRowData(String rowKey) {
-					Iterator<OpeApplyReserve> iterator = this.iterator();
-					if (iterator != null) {
-						OpeApplyReserve su = null;
-						while (iterator.hasNext()) {
-							su = iterator.next();
-							if (rowKey.equals(su.getId())) {
-								return su;
-							}
-						}
-					}
-					return null;
+//					Iterator<OpeApplyReserve> iterator = this.iterator();
+//					if (iterator != null) {
+//						OpeApplyReserve su = null;
+//						while (iterator.hasNext()) {
+//							su = iterator.next();
+//							if (rowKey.equals(su.getId())) {
+//								return su;
+//							}
+//						}
+//					}
+					Long id=Long.valueOf(rowKey);
+					return opeApplyService.getOpeApplyReserveListByNameForRowData(id);
 				}
 			};
 		}
@@ -1861,8 +1810,8 @@
 			List<OpeApplyReserve> realDataList = new ArrayList<>();
 			//map=null;
 			SysUser loginUser = getUser();
-			String id="";
-			if(loginUser.getSeeFlag()==SeeFlag.MANAGE){
+			Long id=null;
+			if(loginUser.getSeeFlag()==SeeFlag.MANAGE||loginUser.getSeeFlag() == SeeFlag.LEADING){
 
 			}else {
 				//userName=loginUser.getName();
@@ -1871,8 +1820,8 @@
 			if(selectedListForPerson!=null&&selectedListForPerson.size()>0){
 				realDataList=selectedListForPerson;
 			}else {
-				realDataList = opeApplyService.getOpeApplyReserveListByNameFor(id,reagentId, userName, null,
-						null,productSn,applyCode,status,isAllApply);
+				realDataList = opeApplyService.getOpeApplyReserveListByNameFor(id,null, userName, null,
+						null,productSn,applyCode,status,isAllApply,isExpired);
 			}
 			List<String> headerList = new ArrayList<>();
 			headerList.add("申购编号");
@@ -1946,16 +1895,16 @@
 			dataRow.createCell(2).setCellValue(dataList.get(i).getReagent().getName()== null ? "": String.valueOf(dataList.get(i).getReagent().getName()));
 			dataRow.createCell(3).setCellValue(dataList.get(i).getReagent().getControlProducts()== null ? "": String.valueOf(dataList.get(i).getReagent().getControlProducts()));
 			dataRow.createCell(4).setCellValue(dataList.get(i).getReagent().getReagentFormat()== null ? "": String.valueOf(dataList.get(i).getReagent().getReagentFormat()));
-			dataRow.createCell(5).setCellValue(dataList.get(i).getReagent().getMainMetering()== null ? "": String.valueOf(dataList.get(i).getReagent().getMainMetering()));
+			dataRow.createCell(5).setCellValue(dataList.get(i).getReagent().getMainMetering()== null ? "": String.valueOf(dataList.get(i).getReagent().getMainMetering())+dataList.get(i).getReagent().getReagentUnit());
 			dataRow.createCell(6).setCellValue(dataList.get(i).getReagent().getPrice()== null ? "": String.valueOf(dataList.get(i).getReagent().getPrice()));
 			dataRow.createCell(7).setCellValue(dataList.get(i).getReagent().getCas()== null ? "": String.valueOf(dataList.get(i).getReagent().getCas()));
 			dataRow.createCell(8).setCellValue(dataList.get(i).getReagent().getReagentCharacter()== null ? "": String.valueOf(dataList.get(i).getReagent().getReagentCharacter()));
-			dataRow.createCell(9).setCellValue(dataList.get(i).getReagent().getProductHomeName()== null ? "":  String.valueOf(dataList.get(i).getReagent().getProductHomeName()));
+			dataRow.createCell(9).setCellValue(dataList.get(i).getReagent().getProductHome()== null ? "":  String.valueOf(dataList.get(i).getReagent().getProductHome()));
 			dataRow.createCell(10).setCellValue(dataList.get(i).getNum()== null ? "": String.valueOf(dataList.get(i).getNum()));
 			dataRow.createCell(11).setCellValue(dataList.get(i).getUsed()== null ? "": String.valueOf(dataList.get(i).getUsed()));
 			dataRow.createCell(12).setCellValue(dataList.get(i).getApplyUserId()== null ? "": String.valueOf(dataList.get(i).getApplyUserId()));
 			dataRow.createCell(13).setCellValue(dataList.get(i).getStatus()== null ? "": String.valueOf(dataList.get(i).getStatus().getText()));
-			dataRow.createCell(14).setCellValue(dataList.get(i).getProject()== null ? "": String.valueOf(dataList.get(i).getProject()));
+			dataRow.createCell(14).setCellValue(dataList.get(i).getProjectName()== null ? "": String.valueOf(dataList.get(i).getProjectName()));
 			dataRow.createCell(15).setCellValue(dataList.get(i).getProjectManage()== null ? "": String.valueOf(dataList.get(i).getProjectManage()));
 			dataRow.createCell(16).setCellValue(dataList.get(i).getArrivalTime()== null ? "": String.valueOf(dataList.get(i).getArrivalTime()));
 		}
@@ -1988,7 +1937,7 @@
 			if(selectedList!=null&&selectedList.size()>0){
 				realDataList=selectedList;
 			}else {
-				realDataList = opeWarehouseReserveService.getOpeWarehouseReserveListByName(reagentId, supplierId, null,
+				realDataList = opeWarehouseReserveService.getOpeWarehouseReserveListByName(reagentName, supplierId, null,
 						null,productSn,warehouseName);
 			}
 				List<String> headerList = new ArrayList<>();
@@ -2042,6 +1991,15 @@
 		}
 	}
 
+
+	public void onExportOutAndIn(){
+		FacesContext currentInstance = FacesContext.getCurrentInstance();
+		currentInstance.responseComplete();
+		ExternalContext etx = currentInstance.getExternalContext();
+		HttpServletResponse resp = (HttpServletResponse) etx.getResponse();
+		accountInAndOutService.exportExcel(resp);
+	}
+
 	public  HSSFWorkbook exportExcelNew(List<String> headerList, List<OpeWarehouseReserve> dataList) {
 		HSSFWorkbook hssfWorkbook = new HSSFWorkbook();
 		Integer total = null;
@@ -2055,10 +2013,10 @@
 			dataRow.createCell(0).setCellValue(dataList.get(i).getReagent().getName()== null ? "": String.valueOf(dataList.get(i).getReagent().getName()));
 			dataRow.createCell(1).setCellValue(dataList.get(i).getReagent().getProductSn()== null ? "": String.valueOf(dataList.get(i).getReagent().getProductSn()));
 			dataRow.createCell(2).setCellValue(dataList.get(i).getReagent().getCas()== null ? "": String.valueOf(dataList.get(i).getReagent().getCas()));
-			dataRow.createCell(3).setCellValue(dataList.get(i).getReagent().getProductHomeName()== null ? "":  String.valueOf(dataList.get(i).getReagent().getProductHomeName()));
+			dataRow.createCell(3).setCellValue(dataList.get(i).getReagent().getProductHome()== null ? "":  String.valueOf(dataList.get(i).getReagent().getProductHome()));
 			dataRow.createCell(4).setCellValue(dataList.get(i).getReagent().getSupplierName()== null ? "": String.valueOf(dataList.get(i).getReagent().getSupplierName()));
-			dataRow.createCell(5).setCellValue(dataList.get(i).getReagent().getReagentFormat()== null ? "": String.valueOf(baseMetaService.getBaseMetaValue(dataList.get(i).getReagent().getReagentFormat())));
-			dataRow.createCell(6).setCellValue(dataList.get(i).getReagent().getMainMetering()== null ? "": String.valueOf(dataList.get(i).getReagent().getMainMetering())+baseMetaService.getBaseMetaValue(dataList.get(i).getReagent().getReagentUnit()));
+			dataRow.createCell(5).setCellValue(dataList.get(i).getReagent().getReagentFormat()== null ? "": String.valueOf(dataList.get(i).getReagent().getReagentFormat()));
+			dataRow.createCell(6).setCellValue(dataList.get(i).getReagent().getMainMetering()== null ? "": String.valueOf(dataList.get(i).getReagent().getMainMetering())+dataList.get(i).getReagent().getReagentUnit());
 			dataRow.createCell(7).setCellValue(dataList.get(i).getReagent().getPrice()== null ? "": String.valueOf(dataList.get(i).getReagent().getPrice()));
 			dataRow.createCell(8).setCellValue(dataList.get(i).getArticleNumber()== null ? "": String.valueOf(dataList.get(i).getArticleNumber()));
 			dataRow.createCell(9).setCellValue(dataList.get(i).getReserve()== null ? "": String.valueOf(dataList.get(i).getReserve()));
@@ -2113,7 +2071,7 @@
             return;
         }
 
-        List<String> selectedIds = new ArrayList<String>();
+        List<Long> selectedIds = new ArrayList<Long>();
 
         for (OpeApply oa : this.reagentDStoreSelectedList) {
         	selectedIds.add(oa.getReagent().getId());
@@ -2181,7 +2139,7 @@
     public void onSaveBtnClickNew() {
 
         if (this.reagentDStore.getReagent() == null
-                || StringUtils.isBlank(this.reagentDStore.getReagent().getId())) {
+                || this.reagentDStore.getReagent().getId()==null) {
             FacesUtils.warn("请选择入库试剂。");
     		RequestContext.getCurrentInstance().execute("PF('reagentDStoreDialog').hide()");
             return;
@@ -2208,17 +2166,17 @@
         }*/
 
         // 检查仓库名
-        if (StringUtils.isBlank(this.reagentDStore.getHouseId())) {
+        if (this.reagentDStore.getHouseId()==null) {
             FacesUtils.warn("仓库名不能为空。");
             return;
         }
         // 检查货柜名
-        if (StringUtils.isBlank(this.reagentDStore.getContainerId())) {
+        if (this.reagentDStore.getContainerId()==null) {
             FacesUtils.warn("货柜名不能为空。");
             return;
         }
         // 检查货柜位置
-        if (StringUtils.isBlank(this.reagentDStore.getPlaceId())) {
+        if (this.reagentDStore.getPlace()==null) {
             FacesUtils.warn("货柜位置不能为空。");
             return;
         }
@@ -2245,7 +2203,7 @@
                                 && apply.getEndReagentCode().equals(this.reagentDStore.getEndReagentCode())).count() > 0) {
                     FacesUtils.warn("该试剂已被增加!");
                 }else {
-                    this.reagentDStore.setId(IDUtils.uuid());
+                 //   this.reagentDStore.setId(IDUtils.uuid());
                     this.reagentDStoreList.add(this.reagentDStore);
                     FacesUtils.info("增加成功。");
                 }
@@ -2261,7 +2219,7 @@
                                 && apply.getEndReagentCode().equals(this.reagentDStore.getEndReagentCode())).count() > 0) {
                     FacesUtils.warn("该试剂已被增加!");
                 }else {
-                    this.reagentDStore.setId(IDUtils.uuid());
+                  //  this.reagentDStore.setId(IDUtils.uuid());
                     this.reagentDStoreList.add(this.reagentDStore);
                     FacesUtils.info("增加成功。");
                 }
@@ -2278,36 +2236,42 @@
         this.reagentDStore.setReagent((SysReagent)event.getObject());
 
     	this.reagentDStoreEditFlag = Constants.ACTION_ADD;
+		onWarehouseSelectChange(null);
     	RequestContext.getCurrentInstance().execute("PF('reagentDStoreDialog').show()");
     }
 
-    public void onWarehouseSelectChange(String warehouseId) {
+    public void onWarehouseSelectChange(Long warehouseId) {
         this.warehouseContainerList = null;
         this.warehouseContainerPlaceList = null;
         this.changeWarehouseContainerList(warehouseId);
         this.changeWarehouseContainerPlaceList(null);
     }
 
-    private void changeWarehouseContainerList(String warehouseId) {
-        if (StringUtils.isBlank(warehouseId)) {
+	public void onWarehouseContainerSelectChange(Long warehouseContainerId) {
+		this.warehouseContainerPlaceList = null;
+		this.changeWarehouseContainerPlaceList(warehouseContainerId);
+	}
+
+    private void changeWarehouseContainerList(Long warehouseId) {
+        if (warehouseId==null) {
             if (this.warehouseList != null && this.warehouseList.size() > 0) {
                 warehouseId = this.warehouseList.get(0).getId();
             }
         }
 
-        if (StringUtils.isNotBlank(warehouseId)) {
+        if (warehouseId!=null) {
             this.warehouseContainerList = warehouseIdContainerMap.get(warehouseId);
         }
     }
 
-    private void changeWarehouseContainerPlaceList(String warehouseContainerId) {
-        if (StringUtils.isBlank(warehouseContainerId)) {
+    private void changeWarehouseContainerPlaceList(Long warehouseContainerId) {
+        if (warehouseContainerId==null) {
             if (this.warehouseContainerList != null && this.warehouseContainerList.size() > 0) {
                 warehouseContainerId = this.warehouseContainerList.get(0).getId();
             }
         }
 
-        if (StringUtils.isNotBlank(warehouseContainerId)) {
+        if (warehouseContainerId!=null) {
             SysWarehouseContainer container = this.warehouseContainerMap.get(warehouseContainerId);
             BaseMeta baseMeta = null;
             if (container != null
@@ -2317,26 +2281,36 @@
         }
     }
 
-    public String formatWarehouseName(String id) {
-        if (StringUtils.isNotBlank(id)
-                && this.warehouseNameMap != null) {
-            return warehouseNameMap.get(id);
-        }
-
-        return "";
+    public String formatWarehouseName(Long id) {
+		if(id==null){
+			return "";
+		}
+		String name=warehouseNameMap.get(id);
+		if(StringUtils.isBlank(name)){
+			SysWarehouse warehouse=this.sysWarehouseService.getSysWarehouse(id);
+			if(warehouse!=null){
+				warehouseNameMap.put(warehouse.getId(),warehouse.getName());
+				name=warehouse.getName();
+			}
+		}
+		return name;
     }
-    public String formatWarehouseContainerName(String id) {
-        if (StringUtils.isNotBlank(id)
-                && this.warehouseContainerMap != null) {
-            if (this.warehouseContainerMap.get(id) != null) {
-                return this.warehouseContainerMap.get(id).getContainerCode();
-            }
-        }
-
-        return "";
+    public String formatWarehouseContainerName(Long id) {
+		if(id==null){
+			return "";
+		}
+		String containerCode=this.warehouseContainerMap.get(id).getContainerCode();
+		if(StringUtils.isBlank(containerCode)){
+			SysWarehouseContainer sysWarehouseContainer = this.sysWarehouseContainerService.getSysWarehouseContainer(id);
+			if(sysWarehouseContainer!=null){
+				this.warehouseContainerMap.put(sysWarehouseContainer.getId(),sysWarehouseContainer);
+				containerCode=sysWarehouseContainer.getContainerCode();
+			}
+		}
+		return containerCode;
     }
-    public String formatWarehouseContainerPlaceName(String id) {
-        if (StringUtils.isNotBlank(id)) {
+    public String formatWarehouseContainerPlaceName(Long id) {
+        if (id!=null) {
             return this.baseMetaService.getBaseMetaValue(id);
         }
 
@@ -2358,12 +2332,12 @@
 		this.reagentSelectList = reagentSelectList;
 	}
 
-	public String getReagentId() {
-		return reagentId;
+	public String getReagentName() {
+		return reagentName;
 	}
 
-	public void setReagentId(String reagentId) {
-		this.reagentId = reagentId;
+	public void setReagentName(String reagentName) {
+		this.reagentName = reagentName;
 	}
 
 	public List<SysUser> getUserSelectList() {
@@ -2373,7 +2347,7 @@
 		return userSelectList;
 	}
 
-	public SysUser getSelectedUserById(String userId) {
+	public SysUser getSelectedUserById(Long userId) {
 		return userSelectList.stream().filter(u->u.getId().equals(userId)).findFirst().get();
 	}
 
@@ -2388,28 +2362,28 @@
 		this.userSelectList = userSelectList;
 	}
 
-	public String getUserId() {
+	public Long getUserId() {
 		return userId;
 	}
 
-	public void setUserId(String userId) {
+	public void setUserId(Long userId) {
 		this.userId = userId;
 	}
 
 
-	public String getProjectNum() {
-		return projectNum;
+	public Long getProjectId() {
+		return projectId;
 	}
 
-	public void setProjectNum(String projectNum) {
-		this.projectNum = projectNum;
+	public void setProjectId(Long projectId) {
+		this.projectId = projectId;
 	}
 
-	public String getSupplierId() {
+	public Long getSupplierId() {
 		return supplierId;
 	}
 
-	public void setSupplierId(String supplierId) {
+	public void setSupplierId(Long supplierId) {
 		this.supplierId = supplierId;
 	}
 
@@ -2457,19 +2431,19 @@
 		this.reagentCodeSelectedList = reagentCodeSelectedList;
 	}
 
-	public String getReagentLogId() {
+	public Long getReagentLogId() {
 		return reagentLogId;
 	}
 
-	public void setReagentLogId(String reagentLogId) {
+	public void setReagentLogId(Long reagentLogId) {
 		this.reagentLogId = reagentLogId;
 	}
 
-	public String getUserLogId() {
+	public Long getUserLogId() {
 		return userLogId;
 	}
 
-	public void setUserLogId(String userLogId) {
+	public void setUserLogId(Long userLogId) {
 		this.userLogId = userLogId;
 	}
 
@@ -2498,7 +2472,6 @@
     }
 
 	public void handleEvent2(){
-		System.out.println("===============================");
 			if(useNum!=null && useNum>0){
 				if(startReagentCode!=null && !startReagentCode.equals("")){
 				if (startReagentCode.matches(".*\\D+.*")) {
@@ -2534,6 +2507,10 @@
 			}else {
 				FacesUtils.info("请输入领用数量");
 			}
+	}
+
+	public void clearStartAndEndCode(){
+		endReagentCode = "";
 	}
 
 	public void handleEventForPerson(){
@@ -2628,17 +2605,18 @@
 
                 @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;
+//                            }
+//                        }
+//                    }
+					Long id=Long.valueOf(rowKey);
+                    return sysReagentService.getSysReagentListNewRowData(id);
                 }
             };
         }
@@ -2715,27 +2693,30 @@
 		this.useNum = useNum;
 	}
 
-	public String getOriLaboratoryId() {
+	public Long getOriLaboratoryId() {
 		return oriLaboratoryId;
 	}
 
-	public void setOriLaboratoryId(String oriLaboratoryId) {
+	public void setOriLaboratoryId(Long oriLaboratoryId) {
 		this.oriLaboratoryId = oriLaboratoryId;
 	}
 
 	public void resetLaboratory(){
 		laboratory = null;
+		laboratoryId = null;
 		laboratoryContainers = null;
 		//getLaboratory();
 		//getLaboratoryContainers();
 	}
 
+//	public void setContainerId(){
+//	}
 	public void resetLaboratoryContainers() {
 		laboratoryContainers = null;
 		//getLaboratoryContainers();
 	}
 	public List<SysLaboratory> getLaboratory() {
-		if(userId != null && userId.trim().length() > 0)
+ 		if(userId != null)
 		{
 
 			//Todo 修改申领人的实验室显示信息
@@ -2743,15 +2724,15 @@
 			if(this.laboratory != null && this.laboratory.size() > 0)
 			{
 				//flag =true;
-				//if(laboratoryId != null && laboratoryId.trim().length() > 0)
-				//{
-				//	this.oriLaboratoryId = this.laboratoryId;
-				//}else
-				//{
-				//	this.oriLaboratoryId = this.laboratory.get(0).getId();
-				//}
+				if(laboratoryId != null)
+				{
+					this.oriLaboratoryId = this.laboratoryId;
+				}else
+				{
+					this.laboratoryId = this.laboratory.get(0).getId();
+				}
 
-				this.laboratoryId = this.laboratory.get(0).getId();
+//				this.laboratoryId = this.laboratory.get(0).getId();
 				this.laboratoryContainers = this.sysLaboratoryContainerService.getSysLaboratoryContainerList(laboratoryId);
 			}else {
 				this.oriLaboratoryId = null;
@@ -2771,7 +2752,7 @@
 	}
 
 	public List<SysLaboratoryContainer> getLaboratoryContainers() {
-		if(laboratoryId != null && laboratoryId.trim().length() > 0)
+ 		if(laboratoryId != null)
 		{
 			this.laboratoryContainers = this.sysLaboratoryContainerService.getSysLaboratoryContainerList(laboratoryId);
 		}
@@ -2782,20 +2763,20 @@
 		this.laboratoryContainers = laboratoryContainers;
 	}
 
-	public String getLaboratoryId() {
+	public Long getLaboratoryId() {
 		return laboratoryId;
 	}
 
-	public void setLaboratoryId(String laboratoryId) {
+	public void setLaboratoryId(Long laboratoryId) {
 		this.laboratoryId = laboratoryId;
 	}
 
-	public String getLaboratoryContainerId() {
+	public Long getLaboratoryContainerId() {
 
 		return laboratoryContainerId;
 	}
 
-	public void setLaboratoryContainerId(String laboratoryContainerId) {
+	public void setLaboratoryContainerId(Long laboratoryContainerId) {
 		this.laboratoryContainerId = laboratoryContainerId;
 	}
 
@@ -2910,11 +2891,11 @@
 		this.arrivalTime = arrivalTime;
 	}
 
-	public String getConsigneeId() {
+	public Long getConsigneeId() {
 		return consigneeId;
 	}
 
-	public void setConsigneeId(String consigneeId) {
+	public void setConsigneeId(Long consigneeId) {
 		this.consigneeId = consigneeId;
 	}
 
@@ -3073,4 +3054,59 @@
 	public void setIsAllApply(Integer isAllApply) {
 		this.isAllApply = isAllApply;
 	}
+
+	public boolean getIsExpired() {
+		return isExpired;
+	}
+
+	public void setIsExpired(boolean isExpired) {
+		this.isExpired = isExpired;
+	}
+
+	//过期处理
+	public void expireOrder() {
+		//1.判断当前订单是否是已入库的状态
+		if (this.selectedListForPerson.size() < 1) {
+			FacesUtils.warn("请选择数据。");
+			return;
+		}
+		ArrayList<Long> ids = new ArrayList<>();
+		for (OpeApplyReserve oa : this.selectedListForPerson) {
+			ids.add(oa.getId());
+			if (oa.getStatus() != ApplyStatus.SUPPLIER_CONFIRM) {
+				FacesUtils.warn("只能让已确认状态的单子过期。");
+				return;
+			}
+		}
+
+		opeApplyService.updateOpeApplyStatus(ApplyStatus.EXPIRED, null, ids);
+		FacesUtils.warn("操作成功。");
+
+
+	}
+
+	public void recoverOrder(){
+		if (this.selectedListForPerson.size() < 1) {
+			FacesUtils.warn("请选择数据。");
+			return;
+		}
+		ArrayList<Long> ids = new ArrayList<>();
+		for (OpeApplyReserve oa : this.selectedListForPerson) {
+			ids.add(oa.getId());
+			if (oa.getStatus() != ApplyStatus.EXPIRED) {
+				FacesUtils.warn("只能让过期单子恢复确认。");
+				return;
+			}
+		}
+		opeApplyService.updateOpeApplyStatus(ApplyStatus.SUPPLIER_CONFIRM, null, ids);
+		FacesUtils.warn("操作成功。");
+	}
+
+    public String getNote() {
+        return note;
+    }
+
+    public void setNote(String note) {
+        this.note = note;
+    }
 }

--
Gitblit v1.9.2