package com.nanometer.smartlab.controller;
|
|
import java.util.Iterator;
|
import java.util.List;
|
import java.util.Map;
|
|
import javax.annotation.Resource;
|
|
import org.apache.commons.lang.StringUtils;
|
import org.apache.log4j.Logger;
|
import org.primefaces.model.LazyDataModel;
|
import org.primefaces.model.SortOrder;
|
import org.springframework.context.annotation.Scope;
|
import org.springframework.stereotype.Controller;
|
|
import com.nanometer.smartlab.entity.OpeOrder;
|
import com.nanometer.smartlab.entity.OpeReagentStatus;
|
import com.nanometer.smartlab.entity.SysLaboratory;
|
import com.nanometer.smartlab.entity.SysLaboratoryContainer;
|
import com.nanometer.smartlab.entity.SysReagent;
|
import com.nanometer.smartlab.entity.enumtype.ApplyStatus;
|
import com.nanometer.smartlab.entity.enumtype.ArrivalStatus;
|
import com.nanometer.smartlab.service.OpeReagentStatusService;
|
import com.nanometer.smartlab.service.SysLaboratoryContainerService;
|
import com.nanometer.smartlab.service.SysReagentService;
|
import com.nanometer.smartlab.util.Constants;
|
import com.nanometer.smartlab.util.FacesUtils;
|
|
/**
|
* Created by cmower on 17/11/20.
|
*/
|
@Controller
|
@Scope("session")
|
public class LaboratoryStockMngController extends BaseController {
|
|
private static final long serialVersionUID = 101543880938627455L;
|
|
private static Logger logger = Logger.getLogger(LaboratoryStockMngController.class);
|
|
@Resource
|
private OpeReagentStatusService opeReagentStatusService;
|
@Resource
|
private SysReagentService sysReagentService;
|
@Resource
|
private SysLaboratoryContainerService sysLaboratoryContainerService;
|
@Resource
|
private MenuController menuController;
|
|
private LazyDataModel<OpeReagentStatus> reagentStatusDataModel;
|
/**
|
* 使用记录用
|
*/
|
private LazyDataModel<OpeReagentStatus> reagentStoreDataModel;
|
|
private String reagentId;
|
private List<SysReagent> reagentSelectList;
|
private List<OpeReagentStatus> selectedStoreList;
|
|
private List<SysLaboratoryContainer> laboratoryContainers;
|
|
private String reagentCode;
|
private String labName;
|
|
/**
|
* 数据模型
|
*/
|
private String laboratoryId;
|
private String laboratoryContainerId;
|
|
/**
|
* SpringMenu中初始化
|
*/
|
public void initPage() {
|
this.initReagentSelectList();
|
}
|
|
public void initStorePage() {
|
}
|
|
private void initReagentSelectList() {
|
//this.setReagentSelectList(this.sysReagentService.getSysReagentList(null, null, null, null, null));
|
}
|
|
private int action;
|
|
@SuppressWarnings("serial")
|
public LazyDataModel<OpeReagentStatus> getReagentStatusDataModel() {
|
if (this.reagentStatusDataModel == null) {
|
this.reagentStatusDataModel = new LazyDataModel<OpeReagentStatus>() {
|
@Override
|
public List<OpeReagentStatus> load(int first, int pageSize, String sortField, SortOrder sortOrder,
|
Map<String, Object> filters) {
|
List<OpeReagentStatus> list = null;
|
System.out.println(reagentId);
|
try {
|
int count = opeReagentStatusService.getOpeReagentStatusTotalCountForLab(reagentId, null,
|
ArrivalStatus.LABORATORY.getKey(), reagentCode, getUserId(),labName);
|
this.setRowCount(count);
|
if (count > 0) {
|
list = opeReagentStatusService.getOpeReagentStatusListForLab(reagentId, null,
|
ArrivalStatus.LABORATORY.getKey(), reagentCode, getUserId(),labName, first, pageSize);
|
}
|
} catch (Exception e) {
|
logger.error(e);
|
}
|
return list;
|
}
|
|
@Override
|
public OpeReagentStatus getRowData(String rowKey) {
|
// Iterator<OpeReagentStatus> iterator = this.iterator();
|
// if (iterator != null) {
|
// OpeReagentStatus su = null;
|
// while (iterator.hasNext()) {
|
// su = iterator.next();
|
// if (rowKey.equals(su.getId())) {
|
// return su;
|
// }
|
// }
|
// }
|
return null;
|
}
|
};
|
}
|
return reagentStatusDataModel;
|
}
|
|
@SuppressWarnings("serial")
|
public LazyDataModel<OpeReagentStatus> getReagentStoreDataModel() {
|
if (this.reagentStoreDataModel == null) {
|
this.reagentStoreDataModel = new LazyDataModel<OpeReagentStatus>() {
|
@Override
|
public List<OpeReagentStatus> load(int first, int pageSize, String sortField, SortOrder sortOrder,
|
Map<String, Object> filters) {
|
List<OpeReagentStatus> list = null;
|
try {
|
int count = opeReagentStatusService.getOpeReagentStatusTotalCount(null, null,
|
ArrivalStatus.PERSONAL.getKey(), null, getUserId());
|
this.setRowCount(count);
|
if (count > 0) {
|
list = opeReagentStatusService.getOpeReagentStatusList(null, null,
|
ArrivalStatus.PERSONAL.getKey(), null, getUserId(), first, pageSize);
|
}
|
} catch (Exception e) {
|
logger.error(e);
|
}
|
selectedStoreList = null;
|
return list;
|
}
|
|
@Override
|
public OpeReagentStatus getRowData(String rowKey) {
|
// Iterator<OpeReagentStatus> iterator = this.iterator();
|
// if (iterator != null) {
|
// OpeReagentStatus su = null;
|
// while (iterator.hasNext()) {
|
// su = iterator.next();
|
// if (rowKey.equals(su.getId())) {
|
// return su;
|
// }
|
// }
|
// }
|
return opeReagentStatusService.getOpeReagentStatus(rowKey);
|
}
|
};
|
}
|
return reagentStoreDataModel;
|
}
|
|
|
public void exportLabStock() {
|
try {
|
List<Map> list = opeReagentStatusService.selectExportList(reagentId, null,
|
ArrivalStatus.LABORATORY.getKey(), reagentCode, getUserId(),labName);
|
opeReagentStatusService.exportLabStock2Excel(list);
|
FacesUtils.info("导出成功");
|
}catch (Exception e){
|
e.printStackTrace();
|
FacesUtils.warn("导出失败");
|
}
|
}
|
|
public int getAction() {
|
return action;
|
}
|
|
public List<SysReagent> getReagentSelectList() {
|
if (this.reagentSelectList == null) {
|
this.initReagentSelectList();
|
}
|
return reagentSelectList;
|
}
|
|
public void setReagentSelectList(List<SysReagent> reagentSelectList) {
|
this.reagentSelectList = reagentSelectList;
|
}
|
|
public String getReagentId() {
|
return reagentId;
|
}
|
|
public void setReagentId(String reagentId) {
|
this.reagentId = reagentId;
|
}
|
|
public String getReagentCode() {
|
return reagentCode;
|
}
|
|
public void setReagentCode(String reagentCode) {
|
this.reagentCode = reagentCode;
|
}
|
|
public String getLaboratoryId() {
|
return laboratoryId;
|
}
|
|
public void setLaboratoryId(String laboratoryId) {
|
this.laboratoryId = laboratoryId;
|
}
|
|
public String getLaboratoryContainerId() {
|
return laboratoryContainerId;
|
}
|
|
public void setLaboratoryContainerId(String laboratoryContainerId) {
|
this.laboratoryContainerId = laboratoryContainerId;
|
}
|
|
public void onCancelBtnClick() {
|
this.menuController.backToPage();
|
}
|
|
// 现在试剂柜多了操作状态字段,
|
// 实验室临时存放的操作状态无法判断
|
// 是试剂柜入库,还是错误入库
|
// 暂定是试剂柜入库
|
public void onSaveBtnClick() {
|
if (StringUtils.isBlank(laboratoryId)) {
|
FacesUtils.warn("请选择实验室。");
|
return;
|
}
|
if (StringUtils.isBlank(laboratoryContainerId)) {
|
FacesUtils.warn("请选择临时存储库。");
|
return;
|
}
|
if (this.selectedStoreList == null || this.selectedStoreList.size() == 0) {
|
FacesUtils.warn("请选择试剂。");
|
return;
|
}
|
|
for (OpeReagentStatus opeReagentStatus : selectedStoreList) {
|
if (opeReagentStatus.getStatus().getKey() != ArrivalStatus.PERSONAL.getKey()) {
|
FacesUtils.warn("只能存放个人领用中的试剂。");
|
return;
|
}
|
}
|
|
this.opeReagentStatusService.store(selectedStoreList, laboratoryId, laboratoryContainerId);
|
|
FacesUtils.info("存放成功。");
|
}
|
|
public List<OpeReagentStatus> getSelectedStoreList() {
|
return selectedStoreList;
|
}
|
|
public void setSelectedStoreList(List<OpeReagentStatus> selectedStoreList) {
|
this.selectedStoreList = selectedStoreList;
|
}
|
|
public void onStoreBtnClick() {
|
this.menuController.goToPage(Constants.PAGE_LABARATORY_STORE, Constants.PAGE_LABARATORY_STOCK_MNG);
|
}
|
|
public void onLaboratoryChange() {
|
laboratoryContainers = sysLaboratoryContainerService.getSysLaboratoryContainerList(laboratoryId);
|
}
|
|
public List<SysLaboratoryContainer> getLaboratoryContainers() {
|
return laboratoryContainers;
|
}
|
|
public void setLaboratoryContainers(List<SysLaboratoryContainer> laboratoryContainers) {
|
this.laboratoryContainers = laboratoryContainers;
|
}
|
|
public String getLabName() {
|
return labName;
|
}
|
|
public void setLabName(String labName) {
|
this.labName = labName;
|
}
|
}
|