| | |
| | | package com.nanometer.smartlab.controller; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.nanometer.smartlab.dao.OpeReagentStatusDao; |
| | | import com.nanometer.smartlab.entity.OpeReagentStatus; |
| | | import com.nanometer.smartlab.entity.SysUser; |
| | | import com.nanometer.smartlab.entity.dto.ApplyListDto; |
| | | import com.nanometer.smartlab.entity.enumtype.OperateStatus; |
| | | import com.nanometer.smartlab.exception.BusinessException; |
| | | import com.nanometer.smartlab.service.SysUserService; |
| | | import com.nanometer.smartlab.util.FacesUtils; |
| | | import com.nanometer.smartlab.util.Utils; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.apache.log4j.Logger; |
| | | import org.primefaces.context.RequestContext; |
| | | import org.primefaces.model.LazyDataModel; |
| | | import org.primefaces.model.SortOrder; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.annotation.Scope; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Controller; |
| | | |
| | | import com.nanometer.smartlab.entity.OpeUseFlow; |
| | |
| | | |
| | | private LazyDataModel<OpeUseFlow> dataModel; |
| | | |
| | | private String reagentId; |
| | | private Long reagentId; |
| | | |
| | | private String reagentCode; |
| | | private String houseName; |
| | |
| | | private Date startDate; |
| | | |
| | | private Date endDate; |
| | | |
| | | private Hashtable printTable; |
| | | |
| | | private String containerCode; |
| | | |
| | | private Integer operatestate; |
| | | |
| | | public String getHouseName() { |
| | | return houseName; |
| | |
| | | this.houseName = houseName; |
| | | } |
| | | |
| | | @Value("${institute.name}") |
| | | String instituteName; |
| | | |
| | | @Resource |
| | | private OpeUseFlowService opeUseFlowService; |
| | | |
| | | @Resource |
| | | private SysReagentService sysReagentService; |
| | | |
| | | @Resource |
| | | private SysUserService sysUserService; |
| | | @Resource |
| | | private OpeReagentStatusDao opeReagentStatusDao; |
| | | private List<SysReagent> reagentSelectList; |
| | | |
| | | private OpeUseFlow selectedOne; |
| | | |
| | | public List<SysReagent> getReagentSelectList() { |
| | | if (this.reagentSelectList == null) { |
| | |
| | | Map<String, Object> filters) { |
| | | List<OpeUseFlow> list = null; |
| | | try { |
| | | int count = opeUseFlowService.getOpeUseFlowTotalCountByName(houseName,reagentId, reagentCode, null, getUserId(),startDate,endDate); |
| | | int count = opeUseFlowService.getOpeUseFlowTotalCountByName(houseName,reagentId, reagentCode, containerCode,null, getUserId(),startDate,endDate,operatestate); |
| | | this.setRowCount(count); |
| | | if (count > 0) { |
| | | list = opeUseFlowService.getOpeUseFlowListByName(houseName,reagentId, reagentCode, null, getUserId(),startDate,endDate, first, pageSize); |
| | | list = opeUseFlowService.getOpeUseFlowListByName(houseName,reagentId, reagentCode, containerCode,null, getUserId(),startDate,endDate, first, pageSize,operatestate); |
| | | } |
| | | selectedOne = null; |
| | | } catch (Exception e) { |
| | | logger.error(e); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public OpeUseFlow getRowData(String rowKey) { |
| | | Iterator<OpeUseFlow> iterator = this.iterator(); |
| | | OpeUseFlow temp = null; |
| | | if(iterator!= null) |
| | | { |
| | | while(iterator.hasNext()) |
| | | { |
| | | temp=iterator.next(); |
| | | if(rowKey.equals(temp.getId())) |
| | | { |
| | | return temp; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return temp; |
| | | // Iterator<OpeUseFlow> iterator = this.iterator(); |
| | | // OpeUseFlow temp = null; |
| | | // if(iterator!= null) |
| | | // { |
| | | // while(iterator.hasNext()) |
| | | // { |
| | | // temp=iterator.next(); |
| | | // if(rowKey.equals(temp.getId())) |
| | | // { |
| | | // return temp; |
| | | // } |
| | | // } |
| | | // } |
| | | return opeUseFlowService.selectById(rowKey); |
| | | } |
| | | }; |
| | | } |
| | |
| | | return dataModel; |
| | | } |
| | | |
| | | public String getReagentId() { |
| | | public void export2Excel() { |
| | | |
| | | List<Map> list = opeUseFlowService.selectAll(houseName,reagentId, reagentCode, containerCode,getUserId(),startDate,endDate); |
| | | try{ |
| | | boolean isexport = opeUseFlowService.export2Excel(list); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | FacesUtils.warn("导出失败"); |
| | | } |
| | | } |
| | | |
| | | public Long getReagentId() { |
| | | return reagentId; |
| | | } |
| | | |
| | | public void setReagentId(String reagentId) { |
| | | public void setReagentId(Long reagentId) { |
| | | this.reagentId = reagentId; |
| | | } |
| | | |
| | |
| | | this.reagentCode = reagentCode; |
| | | } |
| | | |
| | | /** |
| | | * 生成领用单 |
| | | */ |
| | | public void generateRecipients(OpeUseFlow ouf) { |
| | | String receiptNumber = ouf.getReceiptNumber(); |
| | | String code = ouf.getReagentCode(); |
| | | //id:个数 |
| | | Map<Long, Integer> printInfo = opeUseFlowService.getRegentInfoFromReceiptNumber(receiptNumber); |
| | | //无法得到当时的领用单的领用人,试剂状态表没有存入,userId会随时变化 |
| | | printTable = null; |
| | | Integer sum = 0; |
| | | printTable = new Hashtable(); |
| | | List<ApplyListDto> applyList = new ArrayList<>(); |
| | | //获取当时操作状态为领取的人员 |
| | | Map<String,Long> info= opeUseFlowService.getApplyUserByReagentCode(code); |
| | | SysUser applyPersonInfo = sysUserService.getUser(info.get("user_id")); |
| | | printTable.put("head", instituteName); |
| | | printTable.put("title", "领用单"); |
| | | printTable.put("applyPerson", applyPersonInfo.getName()); |
| | | printTable.put("department", applyPersonInfo.getDepartment()); |
| | | String time = new SimpleDateFormat("yyyy-MM-dd").format(info.get("create_time")); |
| | | printTable.put("date", time); |
| | | if (StringUtils.isNotBlank(applyPersonInfo.getPhone())){ |
| | | printTable.put("phone", applyPersonInfo.getPhone()); |
| | | } |
| | | if (applyPersonInfo.getProjectId()!=null){ |
| | | printTable.put("project", applyPersonInfo.getProjectId()); |
| | | } |
| | | |
| | | printTable.put("receiptNumber", receiptNumber); |
| | | for (Map.Entry<Long, Integer> map : printInfo.entrySet()) { |
| | | ApplyListDto lis = new ApplyListDto(); |
| | | Map reagentDetail = sysReagentService.getReagentDetail(map.getKey()); |
| | | lis.setNum(map.getValue().toString()); //数量 |
| | | 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 += map.getValue(); |
| | | } |
| | | applyList.add(new ApplyListDto("合计", "", "", "", "", String.valueOf(sum), "")); |
| | | printTable.put("applyList", applyList); |
| | | |
| | | } |
| | | public Date getStartDate() { |
| | | if (null == startDate){ |
| | | Date now = new Date(); |
| | |
| | | }else { |
| | | return startDate; |
| | | } |
| | | } |
| | | |
| | | //报废试剂 |
| | | public void scrapReagent(){ |
| | | if (this.selectedOne == null) { |
| | | FacesUtils.warn("请选择"); |
| | | return; |
| | | } |
| | | try { |
| | | String reagentCode = this.selectedOne.getReagentCode(); |
| | | if (StringUtils.isBlank(reagentCode)) { |
| | | FacesUtils.warn("试剂条码为空"); |
| | | return; |
| | | } |
| | | OpeReagentStatus opeReagentStatusByCode = this.opeReagentStatusDao.getOpeReagentStatusByReagentCode(reagentCode); |
| | | if (opeReagentStatusByCode==null) { |
| | | FacesUtils.warn("试剂条码不存在"); |
| | | return; |
| | | } |
| | | Long reagentId = opeReagentStatusByCode.getReagentId(); |
| | | opeUseFlowService.scrapReagent(reagentId, reagentCode, getUserId()); |
| | | FacesUtils.warn("操作成功"); |
| | | } catch (BusinessException e) { |
| | | FacesUtils.warn(e.getMessage()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | FacesUtils.warn("操作失败"); |
| | | } |
| | | |
| | | } |
| | | |
| | | public List<Map<String,Object>>getOperatestateList(){ |
| | | return OperateStatus.getOperateStatusList(); |
| | | } |
| | | |
| | | public void setStartDate(Date startDate) { |
| | |
| | | public void setEndDate(Date endDate) { |
| | | this.endDate = endDate; |
| | | } |
| | | |
| | | |
| | | public Hashtable getPrintTable() { |
| | | return printTable; |
| | | } |
| | | |
| | | public void setPrintTable(Hashtable printTable) { |
| | | this.printTable = printTable; |
| | | } |
| | | |
| | | public String getContainerCode() { |
| | | return containerCode; |
| | | } |
| | | |
| | | public void setContainerCode(String containerCode) { |
| | | this.containerCode = containerCode; |
| | | } |
| | | |
| | | public OpeUseFlow getSelectedOne() { |
| | | return selectedOne; |
| | | } |
| | | |
| | | public void setSelectedOne(OpeUseFlow selectedOne) { |
| | | this.selectedOne = selectedOne; |
| | | } |
| | | |
| | | public void setOperatestate(Integer operatestate) { |
| | | this.operatestate = operatestate; |
| | | } |
| | | |
| | | public Integer getOperatestate(){ |
| | | return operatestate; |
| | | } |
| | | } |