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/service/OpeApplyServiceImpl.java | 444 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 398 insertions(+), 46 deletions(-) diff --git a/src/main/java/com/nanometer/smartlab/service/OpeApplyServiceImpl.java b/src/main/java/com/nanometer/smartlab/service/OpeApplyServiceImpl.java index 1f61365..ded8ae7 100644 --- a/src/main/java/com/nanometer/smartlab/service/OpeApplyServiceImpl.java +++ b/src/main/java/com/nanometer/smartlab/service/OpeApplyServiceImpl.java @@ -1,11 +1,10 @@ package com.nanometer.smartlab.service; -import com.nanometer.smartlab.dao.OpeApplyDao; -import com.nanometer.smartlab.entity.OpeApply; -import com.nanometer.smartlab.entity.OpeApplyReserve; -import com.nanometer.smartlab.entity.SysUser; +import com.nanometer.smartlab.dao.*; +import com.nanometer.smartlab.entity.*; import com.nanometer.smartlab.entity.enumtype.ApplyStatus; import com.nanometer.smartlab.entity.enumtype.SeeFlag; +import com.nanometer.smartlab.entity.enumtype.ValidFlag; import com.nanometer.smartlab.exception.AlarmCode; import com.nanometer.smartlab.exception.AlarmException; import com.nanometer.smartlab.exception.BusinessException; @@ -14,6 +13,18 @@ import com.nanometer.smartlab.util.MessageUtil; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.primefaces.event.FileUploadEvent; +import org.primefaces.model.UploadedFile; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Lazy; import org.springframework.dao.DataAccessException; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.dao.DuplicateKeyException; @@ -23,12 +34,14 @@ import org.springframework.util.CollectionUtils; import javax.annotation.Resource; +import java.io.IOException; +import java.io.InputStream; import java.math.BigDecimal; import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.text.DecimalFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; /** * Created by johnny on 17/12/12. @@ -41,13 +54,39 @@ @Resource(name = "opeApplyDao") OpeApplyDao opeApplyDao; + @Autowired + SysProjectDao projectDao; + + @Lazy + @Resource + OpeOrderService opeOrderService; + @Lazy + @Resource + OpeReagentStatusService opeReagentStatusService; + @Lazy + @Resource + OpeWarehouseReserveService opeWarehouseReserveService; + @Lazy + @Resource + SysReagentService sysReagentService; + @Resource + SysSequenceService sysSequenceService; @Resource private SysUserService sysUserService; + @Resource + private BaseMetaService baseMetaService; + @Resource + private OpeOrderDao opeOrderDao; + @Resource + private OpeReagentCodeDao opeReagentCodeDao; + + @Value("${activeEnv}") + private String activeEnv; @Transactional(propagation = Propagation.REQUIRED) - public List<OpeApply> getOpeApplyList(String reagentName, Timestamp startDeadline, Timestamp endDeadline, Integer status, - String applyUserId, String approveUserId, String queryCas, - Integer first, Integer pageSize,String applyCode,String applyUserName) { + public List<OpeApply> getOpeApplyList(String reagentName, Timestamp startDeadline, String controlProduct,Timestamp endDeadline, Integer status, + Long applyUserId, Long approveUserId, String queryCas, + Integer first, Integer pageSize,String applyCode,String applyUserName,Byte isShow) { try { Map<String, Object> params = new HashMap<String, Object>(); if (StringUtils.isNotBlank(reagentName)) { @@ -56,11 +95,14 @@ params.put("startDeadline", startDeadline); params.put("endDeadline", endDeadline); params.put("status", status); + params.put("isShow", isShow); + params.put("controlProduct", controlProduct); - if (StringUtils.isNotBlank(applyUserId)) { + if (applyUserId!=null) { SysUser sysUser = sysUserService.getSysUser(applyUserId); // 不是管理员时,加入applyUserId - if (sysUser.getSeeFlag().getKey() != SeeFlag.MANAGE.getKey()) { + if (sysUser.getSeeFlag().getKey() != SeeFlag.MANAGE.getKey() + && sysUser.getSeeFlag().getKey() != SeeFlag.LEADING.getKey()) { params.put("applyUserId", applyUserId); } @@ -86,7 +128,7 @@ @Transactional(propagation = Propagation.REQUIRED) public List<OpeApply> getOpeApplyListForApproval(String applyUserName,String approvaUserName,String reagentName, Timestamp startDeadline, Timestamp endDeadline, Integer status, - String applyUserId, String approveUserId, String queryCas, + Long applyUserId, Long approveUserId, String queryCas, Integer first, Integer pageSize,String applyCode,String searchApproval) { try { Map<String, Object> params = new HashMap<String, Object>(); @@ -98,10 +140,11 @@ params.put("status", status); params.put("searchApproval",searchApproval); - if (StringUtils.isNotBlank(approveUserId)) { + if (approveUserId!=null) { SysUser sysUser = sysUserService.getSysUser(approveUserId); // 不是管理员时,加入applyUserId - if (sysUser.getSeeFlag().getKey() != SeeFlag.MANAGE.getKey()) { + if (sysUser.getSeeFlag().getKey() != SeeFlag.MANAGE.getKey() + && sysUser.getSeeFlag().getKey() != SeeFlag.LEADING.getKey()) { params.put("approveUserId", approveUserId); } } @@ -127,7 +170,7 @@ } @Transactional(propagation = Propagation.REQUIRED) public int getOpeApplyTotalCountForApproval(String applyUserName,String approvaUserName,String reagentName, Timestamp startDeadline, Timestamp endDeadline, Integer status, - String applyUserId, String approveUserId, String queryCas,String applyCode,String searchApproval) { + Long applyUserId, Long approveUserId, String queryCas,String applyCode,String searchApproval) { try { Map<String, Object> params = new HashMap<String, Object>(); if (StringUtils.isNotBlank(reagentName)) { @@ -137,10 +180,11 @@ params.put("endDeadline", endDeadline); params.put("status", status); params.put("searchApproval",searchApproval); - if (StringUtils.isNotBlank(approveUserId)) { + if (approveUserId!=null) { SysUser sysUser = sysUserService.getSysUser(approveUserId); // 不是管理员时,加入applyUserId - if (sysUser.getSeeFlag().getKey() != SeeFlag.MANAGE.getKey()) { + if (sysUser.getSeeFlag().getKey() != SeeFlag.MANAGE.getKey() + && sysUser.getSeeFlag().getKey() != SeeFlag.LEADING.getKey()) { params.put("approveUserId", approveUserId); } } @@ -164,8 +208,8 @@ } @Transactional(propagation = Propagation.REQUIRED) - public int getOpeApplyTotalCount(String reagentName, Timestamp startDeadline, Timestamp endDeadline, Integer status, - String applyUserId, String approveUserId, String queryCas,String applyCode,String applyUserName) { + public int getOpeApplyTotalCount(String reagentName, Timestamp startDeadline,String controlProduct, Timestamp endDeadline, Integer status, + Long applyUserId, Long approveUserId, String queryCas,String applyCode,String applyUserName,Byte isShow) { try { Map<String, Object> params = new HashMap<String, Object>(); if (StringUtils.isNotBlank(reagentName)) { @@ -174,11 +218,14 @@ params.put("startDeadline", startDeadline); params.put("endDeadline", endDeadline); params.put("status", status); + params.put("isShow", isShow); + params.put("controlProduct", controlProduct); - if (StringUtils.isNotBlank(applyUserId)) { + if (applyUserId!=null) { SysUser sysUser = sysUserService.getSysUser(applyUserId); // 不是管理员时,加入applyUserId - if (sysUser.getSeeFlag().getKey() != SeeFlag.MANAGE.getKey()) { + if (sysUser.getSeeFlag().getKey() != SeeFlag.MANAGE.getKey() + && sysUser.getSeeFlag().getKey() != SeeFlag.LEADING.getKey()) { params.put("applyUserId", applyUserId); } @@ -201,7 +248,7 @@ } @Transactional(propagation = Propagation.REQUIRED) - public OpeApply getOpeApply(String id) { + public OpeApply getOpeApply(Long id) { try { return this.opeApplyDao.getOpeApply(id); } catch (DataAccessException e) { @@ -213,7 +260,7 @@ @Transactional(propagation = Propagation.REQUIRED) public OpeApply insertOpeApply(OpeApply opeApply) { try { - opeApply.setId(IDUtils.uuid()); + // opeApply.setId(IDUtils.uuid()); this.opeApplyDao.insertOpeApply(opeApply); return opeApply; } catch (DuplicateKeyException ex) { @@ -245,7 +292,7 @@ } } - @Transactional(propagation = Propagation.REQUIRED) + public boolean updateOpeApply(OpeApply opeApply) { try { int row = this.opeApplyDao.updateOpeApply(opeApply); @@ -268,7 +315,7 @@ @Transactional(propagation = Propagation.REQUIRED) - public boolean updateFirst(String id) { + public boolean updateFirst(Long id) { try { Map<String, Object> params = new HashMap<String, Object>(); params.put("id",id); @@ -291,7 +338,7 @@ } @Transactional(propagation = Propagation.REQUIRED) - public boolean updateFirst2(String id) { + public boolean updateFirst2(Long id) { try { Map<String, Object> params = new HashMap<String, Object>(); params.put("id",id); @@ -335,7 +382,7 @@ } @Override - public boolean updateSelectedOpeApplyStatus(String memo, List<String> applyIds, String adminUserId, List<String> adminApplyIds,List<String> firstUserIds) { + public boolean updateSelectedOpeApplyStatus(String memo, List<Long> applyIds, Long adminUserId, List<Long> adminApplyIds,List<Long> firstUserIds) { boolean apply = false, adminApply = false; if (!CollectionUtils.isEmpty(applyIds)) { apply = this.updateOpeApplyStatus(ApplyStatus.APPROVED, memo, applyIds); @@ -346,8 +393,7 @@ return apply || adminApply; } - @Transactional(propagation = Propagation.REQUIRED) - public boolean updateOpeApplyStatus(ApplyStatus status, String memo, List<String> applyIds) { + public boolean updateOpeApplyStatus(ApplyStatus status, String memo, List<Long> applyIds) { try { Map<String, Object> params = new HashMap<String, Object>(); params.put("status", status.getKey()); @@ -375,7 +421,7 @@ @Transactional(propagation = Propagation.REQUIRED) - public boolean updateOpeApplyAdminStatus2(String memo, List<String> applyIds, String adminUserId,List<String> firstUserIds) { + public boolean updateOpeApplyAdminStatus2(String memo, List<Long> applyIds, Long adminUserId,List<Long> firstUserIds) { try { for(int i=0;i<applyIds.size();i++){ Map<String, Object> params = new HashMap<String, Object>(); @@ -404,7 +450,7 @@ } @Transactional(propagation = Propagation.REQUIRED) - public boolean updateOpeApplyAdminStatus(String memo, List<String> applyIds, String adminUserId,List<String> firstUserIds) { + public boolean updateOpeApplyAdminStatus(String memo, List<Long> applyIds, Long adminUserId,List<Long> firstUserIds) { try { Map<String, Object> params = new HashMap<String, Object>(); params.put("userId", adminUserId); @@ -437,7 +483,7 @@ return false; } - List<String> ids = new ArrayList<String>(); + List<Long> ids = new ArrayList<Long>(); for (OpeApply opeApply : opeApplyList) { ids.add(opeApply.getId()); } @@ -487,7 +533,7 @@ } @Override - public OpeApply selectOpeApplyByPrimaryKey(String id) { + public OpeApply selectOpeApplyByPrimaryKey(Long id) { try { OpeApply info = this.opeApplyDao.selectOpeApplyByPrimaryKey(id); return info; @@ -504,7 +550,7 @@ } @Override - public int getOpeApplyReserveTotalCountByName(String id,String reagentName, String personName) { + public int getOpeApplyReserveTotalCountByName(Long id,String reagentName, String personName) { try { Map<String, Object> params = new HashMap<String, Object>(); params.put("reagentName", reagentName); @@ -519,12 +565,20 @@ } @Override - public int getOpeApplyReserveTotalCountByNameFor(String id,String reagentName, String personName) { + public int getOpeApplyReserveTotalCountByNameFor(Long userId,String reagentName, String personName,String productSn,String applyCode,Integer status,Integer isAllApply,boolean isExpired) { try { Map<String, Object> params = new HashMap<String, Object>(); params.put("reagentName", reagentName); params.put("personName", personName); - params.put("userId",id); + params.put("userId",userId); + params.put("productSn",productSn); + params.put("applyCode",applyCode); + if (isExpired) { + params.put("status",ApplyStatus.EXPIRED.getKey()); + }else{ + params.put("status", status); + } + params.put("isAllApply",isAllApply); return this.opeApplyDao.getOpeApplyReserveTotalCountFor(params); } catch (DataAccessException e) { logger.error(e.getMessage(), e); @@ -533,8 +587,8 @@ } } @Override - public List<OpeApplyReserve> getOpeApplyReserveListByNameFor(String id,String reagentName, String personName, Integer first, - Integer pageSize) { + public List<OpeApplyReserve> getOpeApplyReserveListByNameFor(Long id,String reagentName, String personName, Integer first, + Integer pageSize,String productSn,String applyCode,Integer status,Integer isAllApply,boolean isExpired) { try { Map<String, Object> params = new HashMap<String, Object>(); params.put("reagentName", reagentName); @@ -542,6 +596,14 @@ params.put("userId",id); params.put("first", first); params.put("pageSize", pageSize); + params.put("productSn",productSn); + params.put("applyCode",applyCode); + if (isExpired) { + params.put("status",ApplyStatus.EXPIRED.getKey()); + }else{ + params.put("status", status); + } + params.put("isAllApply",isAllApply); return this.opeApplyDao.getOpeApplyReserveListFor(params); } catch (DataAccessException e) { logger.error(e.getMessage(), e); @@ -550,7 +612,7 @@ } } @Override - public List<OpeApplyReserve> getOpeApplyReserveListByName(String id,String reagentName, String personName, Integer first, + public List<OpeApplyReserve> getOpeApplyReserveListByName(Long id,String reagentName, String personName, Integer first, Integer pageSize) { try { Map<String, Object> params = new HashMap<String, Object>(); @@ -568,7 +630,7 @@ } @Transactional(propagation = Propagation.REQUIRED) - public boolean updaetOpeApplyPrice(BigDecimal applyPrice, String id){ + public boolean updaetOpeApplyPrice(BigDecimal applyPrice, Long id){ try{ Map<String, Object> params = new HashMap<String, Object>(); params.put("applyPrice", applyPrice); @@ -586,7 +648,7 @@ } @Transactional(propagation = Propagation.REQUIRED) - public boolean updaetOpeApplyStockFlag(int stockFlag, String id){ + public boolean updaetOpeApplyStockFlag(int stockFlag, Long id){ try{ Map<String, Object> params = new HashMap<String, Object>(); params.put("stockFlag", stockFlag); @@ -604,7 +666,7 @@ } @Transactional(propagation = Propagation.REQUIRED) - public boolean cancelApply(ApplyStatus status,String id){ + public boolean cancelApply(ApplyStatus status,Long id){ try{ Map<String, Object> params = new HashMap<String, Object>(); params.put("status", status.getKey()); @@ -622,15 +684,305 @@ } @Transactional(propagation = Propagation.REQUIRED) - public List<OpeApply>selectByReId(String id){ + public List<OpeApply>selectByReId(Long id){ return this.opeApplyDao.selectByReId(id); } @Transactional(propagation = Propagation.REQUIRED) - public void updateByReId(String newReId,String oldReId){ + public void updateByReId(Long newReId,Long oldReId){ Map<String, Object> params=new HashMap(); params.put("newReId",newReId); params.put("oldReId",oldReId); this.opeApplyDao.updateByReId(params); } + + @Override + public OpeApplyReserve getOpeApplyDetail(Long id) { + return opeApplyDao.getOpeApplyDetail(id); + } + + @Override + public void updateOpeApplyInfo(ApplyStatus storage, Long consigneeId, Timestamp arrivalTime, Long applyId,Integer arrivalNum) { + Map<String,Object> params = new HashMap(); + params.put("status", storage); + params.put("consigneeId", consigneeId); + params.put("arrivalTime", arrivalTime); + params.put("applyId", applyId); + if(arrivalNum!=null){ + params.put("arrivalNum",arrivalNum); + } + opeApplyDao.updateOpeApplyInfo(params); + } + + @Override + @Transactional + public void orderInputWarehouse(List<OpeApplyReserve> opeApplyList,Long consigneeId,Timestamp arrivalTime) { + for (OpeApplyReserve opeApplyReserve:opeApplyList) { + int existArrivalNum=this.opeApplyDao.getArrivalNumById(opeApplyReserve.getId()); + Integer applyNum = opeApplyReserve.getNum(); + Integer arrivalNum = opeApplyReserve.getArrivalNum(); + + if(arrivalNum<=existArrivalNum||arrivalNum>applyNum){ + throw new BusinessException(ExceptionEnumCode.ORDER_ERROR,"到货数量不正确"); + } + + ApplyStatus flag = ApplyStatus.STORAGE; + if(applyNum > arrivalNum) + { + flag = ApplyStatus.UNCOMPLETED; + } + //0.1获取该申购单的订单 + OpeOrder opeOrder = opeOrderService.getOrder(opeApplyReserve.getId()); + if (opeOrder == null) { + throw new BusinessException(ExceptionEnumCode.ORDER_ERROR,"订单不存在"); + } + + this.updateOpeApplyInfo(flag,consigneeId,arrivalTime, opeApplyReserve.getId(),arrivalNum); + + + OpeApply opeApply=new OpeApply(); + BeanUtils.copyProperties(opeApplyReserve,opeApply); + OpeReagentCode opeReagentCode=this.opeReagentCodeDao.getReagentCode(opeOrder.getId(),opeApply.getId()); + if(opeReagentCode==null){ + throw new BusinessException(ExceptionEnumCode.SYS_ERR, "申购编号:" + opeApply.getApplyCode() + "的试剂条形码未自动生成"); + } + + List<OpeReagentStatus> opeReagentStatusList=opeOrderService.generateReagentStatus(opeApply,opeReagentCode,opeOrder.getConsigneeUserId(),arrivalNum); + opeOrderService.generateOpeUseFlow(opeReagentStatusList); + opeOrderService.updateWareHouse(opeApply,arrivalNum-existArrivalNum); + this.opeReagentCodeDao.updateStatus(opeOrder.getId(),opeApply.getId(),1); + + + List<OpeApply> oas = opeOrderService.getOpeApplyListByOrder(opeOrder.getId()); + assert oas.size() > 0; + //子订单是否全部入库,是则父单为已入库,否则未完成 + boolean orderflag = oas.stream().allMatch(oa -> oa.getStatus() == ApplyStatus.STORAGE); + opeOrder.setConsigneeUserId(consigneeId); + opeOrder.setArrivalTime(arrivalTime); + if (orderflag){ + opeOrder.setStatus(ApplyStatus.STORAGE); + opeOrderService.updateOpeOrderStatus(opeOrder); + }else{ + opeOrder.setStatus(ApplyStatus.UNCOMPLETED); + opeOrderService.updateOpeOrder(opeOrder); + } + } + } + /** + * 补贴条码更新订单的领用数量 + */ + @Override + public void btUpdateApplyAndOrder(List<OpeApply> opeList) { + + } + + @Override + @Transactional + public void importApply(FileUploadEvent event,SysUser user) throws IOException { + + + UploadedFile file = event.getFile(); + InputStream is = file.getInputstream(); + boolean isExcel2003 = true; + if (file.getFileName().matches("^.+\\.(?i)(xlsx)$")) { + isExcel2003 = false; + } + Workbook wb = null; + if (isExcel2003) { + wb = new HSSFWorkbook(is); + } else { + wb = new XSSFWorkbook(is); + } + Sheet sheet = wb.getSheetAt(0); + int totalRows = sheet.getPhysicalNumberOfRows(); + ArrayList<OpeApply> adds = new ArrayList<>(); + Row row = null; + int totalCells = 0; + for (int i = 1; i < totalRows; i++) { + List<String> valuesList = new ArrayList<String>(); + row = sheet.getRow(i); + + totalCells = row.getLastCellNum(); + //第10列是课题,其他都不能为空 + for (int index = 0; index < totalCells; index++) { + String cellInfo = ""; + if (row.getCell(index) != null) { + if (row.getCell(index).getCellType() == CellType.BLANK && index != 9) { + throw new BusinessException(ExceptionEnumCode.PARAM_NULL, "第" + ++i + "行:除了课题组都不能为空"); + } + if (row.getCell(index).getCellType() == CellType.NUMERIC) { + DecimalFormat df = new DecimalFormat("#######"); //格式化number String字符 + cellInfo = df.format(row.getCell(index).getNumericCellValue()); + }else{ + cellInfo = row.getCell(index).getStringCellValue(); + } + } + valuesList.add(cellInfo); + } + + Map<String,Object> detail = new HashMap<>(); + detail.put("product_sn", valuesList.get(0)); + detail.put("name", valuesList.get(1)); + detail.put("reagent_format", valuesList.get(2)); + detail.put("packing", valuesList.get(3)); + detail.put("cas", valuesList.get(4)); + detail.put("product_home", valuesList.get(5)); + detail.put("reagent_type", valuesList.get(6)); + SysReagent sysReagent = sysReagentService.getReagentByDetail(detail); + if (sysReagent == null) throw new BusinessException(ExceptionEnumCode.PARAM_NO_EXIST, i+"行:试剂不存在或者有多条,导入失败"); + + //申购数量 + Integer num = new Double(valuesList.get(7)).intValue(); + if (num < 1) throw new BusinessException(ExceptionEnumCode.PARAM_NO_EXIST, i+"行:试剂申购数量不合法,导入失败"); + + //申购人姓名 + String applyUserName = valuesList.get(8); + SysUser applyUser = sysUserService.getUserByName(applyUserName); + if (applyUser == null) throw new BusinessException(ExceptionEnumCode.PARAM_NO_EXIST, i+"行:申购人不存在或者申购人姓名存在重复,导入失败"); + //课题组名称 + String objective = valuesList.get(9); + + String format = "yyyy-MM-dd"; + SimpleDateFormat dateFormat = new SimpleDateFormat(format); + Date applyDate = null; + int cellnum = 10; + CellType type = row.getCell(cellnum).getCellType(); + Object value = row.getCell(cellnum); + if (null == value || StringUtils.isBlank(value.toString())) { + throw new BusinessException(ExceptionEnumCode.PARAM_NO_EXIST, i+"行,申购日期不能为空"); + } else { + if (type.equals(CellType.NUMERIC)) { + try { + applyDate = row.getCell(cellnum).getDateCellValue(); + } catch (Exception e) { + e.printStackTrace(); + throw new BusinessException(ExceptionEnumCode.PARAM_NO_EXIST, i+"行,申购日期解析错误,请检查是否有无效字符"); + } + } else if (type.equals(CellType.STRING)) { + String cellInfo = row.getCell(10).getStringCellValue(); + try { + applyDate = dateFormat.parse(cellInfo); + } catch (ParseException e) { + e.printStackTrace(); + throw new BusinessException(ExceptionEnumCode.PARAM_NO_EXIST, i+"行:申购日期不合法,应如2016-10-09,导入失败"); + } + } else { + throw new BusinessException(ExceptionEnumCode.PARAM_NO_EXIST, i+"行:申购日期解析错误,请检查是否有无效字符"); + } + } + + //选择的审批人姓名 + String approveUserName = valuesList.get(11); + //根据姓名获取用户信息的id + SysUser approveUser = sysUserService.getUserByName(approveUserName); + if (approveUser == null) throw new BusinessException(ExceptionEnumCode.PARAM_NO_EXIST, i+"行:审批人不存在或者审批人姓名存在重复,导入失败"); + + OpeApply opeApply = new OpeApply(); + // opeApply.setId(IDUtils.uuid()); + opeApply.setValidFlag(ValidFlag.VALID); + opeApply.setStatus(ApplyStatus.PENDING_APPROVAL); + opeApply.setApplyCode(sysSequenceService.getApplyCode()); + //设置试剂id + opeApply.setReagent(sysReagent); + assert applyDate != null; + Timestamp applyTime = new Timestamp(applyDate.getTime()); + opeApply.setCreateTime(applyTime); + opeApply.setUpdateTime(applyTime); + //价格 + opeApply.setApplyPrice(sysReagent.getPrice()); + //申购数量 + opeApply.setNum(num); + //申购人 + opeApply.setApplyUserId(applyUser.getId()); + //选择的审批人 + opeApply.setApproveUserId(approveUser.getId()); + SysProject project=projectDao.getSysProjectByName(objective); + //选择的课题组信息 + opeApply.setProjectId(project!=null?project.getId():null); + + adds.add(opeApply); + + } + + if (adds.size() > 0) { + opeApplyDao.insertList(adds); + } + + } + + @Override + public OpeApplyReserve getOpeApplyReserveListByNameForRowData(Long rowKey) { + return opeApplyDao.getOpeApplyReserveListByNameForRowData(rowKey); + } + + @Override + public int getOpeApplySupplerRequireMngTotalCount(SysUser user,String reagentName, Timestamp startDeadline, Timestamp endDeadline, int status, byte isShow) { + Map<String, Object> params = new HashMap<>(); + params.put("reagentName",reagentName ); + params.put("startDeadline", startDeadline); + params.put("endDeadline", endDeadline); + params.put("status", status); + params.put("isShow", isShow); + //看到供应商是自己的单位的数据 + String company = baseMetaService.getBaseMetaValue(user.getCompany()); + if (user.getSeeFlag().getKey() != SeeFlag.MANAGE.getKey() + && user.getSeeFlag().getKey() != SeeFlag.LEADING.getKey()) { + params.put("company", company); + } + return this.opeApplyDao.getOpeApplySupplerRequireMngTotalCount(params); + } + + @Override + public List<OpeApply> getOpeApplySupplerRequireMngList(SysUser user,String reagentName, Timestamp startDeadline, Timestamp endDeadline, int status, int first, int pageSize, byte isShow) { + Map<String, Object> params = new HashMap<>(); + params.put("reagentName", reagentName); + params.put("startDeadline", startDeadline); + params.put("endDeadline", endDeadline); + params.put("status", status); + params.put("isShow", isShow); + //看到供应商是自己的单位的数据 + String company = baseMetaService.getBaseMetaValue(user.getCompany()); + if (user.getSeeFlag().getKey() != SeeFlag.MANAGE.getKey() + && user.getSeeFlag().getKey() != SeeFlag.LEADING.getKey()) { + params.put("company", company); + } + + return this.opeApplyDao.getOpeApplySupplerRequireMngList(params); + } + + @Override + public int updateOpeApplyStatusById(Integer status, Long applyId) { + return this.opeApplyDao.updateOpeApplyStatusById(applyId,status); + } + + @Override + public List<OpeApply> getOpeApplyByOrderId(Long orderId) { + return this.opeApplyDao.getOpeApplyByOrderId(orderId); + } + + @Override + public SysReagent getReagentByApplyId(Long applyId) { + return this.opeApplyDao.getReagentByApplyId(applyId); + } + + @Override + public int getOpeApplyCountWithOrder(String applyCode, String orderCode, String orderName) { + Map<String, Object> params = new HashMap<>(); + params.put("applyCode", applyCode); + params.put("orderCode", orderCode); + params.put("orderName", orderName); + return this.opeApplyDao.getOpeApplyCountWithOrder(params); + } + + @Override + public List<OpeApply> getOpeApplyListWithOrder(String applyCode, String orderCode, String orderName, int first, int pageSize) { + Map<String, Object> params = new HashMap<>(); + params.put("applyCode", applyCode); + params.put("orderCode", orderCode); + params.put("orderName", orderName); + params.put("first", first); + params.put("pageSize", pageSize); + return this.opeApplyDao.getOpeApplyListWithOrder(params); + } + } -- Gitblit v1.9.2