| | |
| | | package com.nanometer.smartlab.service; |
| | | |
| | | import com.nanometer.smartlab.dao.OpeApplyDao; |
| | | import com.nanometer.smartlab.dao.SysReagentDao; |
| | | 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 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; |
| | |
| | | |
| | | @Resource(name = "opeApplyDao") |
| | | OpeApplyDao opeApplyDao; |
| | | |
| | | @Autowired |
| | | SysProjectDao projectDao; |
| | | |
| | | @Lazy |
| | | @Resource |
| | | OpeOrderService opeOrderService; |
| | |
| | | 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, String controlProduct,Timestamp endDeadline, Integer status, |
| | | String applyUserId, String approveUserId, String queryCas, |
| | | 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>(); |
| | |
| | | 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() |
| | |
| | | |
| | | @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>(); |
| | |
| | | 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() |
| | |
| | | } |
| | | @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)) { |
| | |
| | | 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() |
| | |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public int getOpeApplyTotalCount(String reagentName, Timestamp startDeadline,String controlProduct, Timestamp endDeadline, Integer status, |
| | | String applyUserId, String approveUserId, String queryCas,String applyCode,String applyUserName,Byte isShow) { |
| | | 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)) { |
| | |
| | | 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() |
| | |
| | | } |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public OpeApply getOpeApply(String id) { |
| | | public OpeApply getOpeApply(Long id) { |
| | | try { |
| | | return this.opeApplyDao.getOpeApply(id); |
| | | } catch (DataAccessException e) { |
| | |
| | | @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) { |
| | |
| | | } |
| | | } |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | |
| | | public boolean updateOpeApply(OpeApply opeApply) { |
| | | try { |
| | | int row = this.opeApplyDao.updateOpeApply(opeApply); |
| | |
| | | |
| | | |
| | | @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); |
| | |
| | | } |
| | | |
| | | @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); |
| | |
| | | } |
| | | |
| | | @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); |
| | |
| | | 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()); |
| | |
| | | |
| | | |
| | | @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>(); |
| | |
| | | } |
| | | |
| | | @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); |
| | |
| | | return false; |
| | | } |
| | | |
| | | List<String> ids = new ArrayList<String>(); |
| | | List<Long> ids = new ArrayList<Long>(); |
| | | for (OpeApply opeApply : opeApplyList) { |
| | | ids.add(opeApply.getId()); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public OpeApply selectOpeApplyByPrimaryKey(String id) { |
| | | public OpeApply selectOpeApplyByPrimaryKey(Long id) { |
| | | try { |
| | | OpeApply info = this.opeApplyDao.selectOpeApplyByPrimaryKey(id); |
| | | return info; |
| | |
| | | } |
| | | |
| | | @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); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public int getOpeApplyReserveTotalCountByNameFor(String id,String reagentName, String personName,String productSn,String applyCode,Integer status,Integer isAllApply,boolean isExpired) { |
| | | 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) { |
| | |
| | | } |
| | | } |
| | | @Override |
| | | public List<OpeApplyReserve> getOpeApplyReserveListByNameFor(String id,String reagentName, String personName, Integer first, |
| | | 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>(); |
| | |
| | | } |
| | | } |
| | | @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>(); |
| | |
| | | } |
| | | |
| | | @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); |
| | |
| | | } |
| | | |
| | | @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); |
| | |
| | | } |
| | | |
| | | @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()); |
| | |
| | | } |
| | | |
| | | @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); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public OpeApplyReserve getOpeApplyDetail(String id) { |
| | | public OpeApplyReserve getOpeApplyDetail(Long id) { |
| | | return opeApplyDao.getOpeApplyDetail(id); |
| | | } |
| | | |
| | | @Override |
| | | public void updateOpeApplyInfo(ApplyStatus storage, String consigneeId, Timestamp arrivalTime, String applyId) { |
| | | 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,String consigneeId,Timestamp arrivalTime) { |
| | | public void orderInputWarehouse(List<OpeApplyReserve> opeApplyList,Long consigneeId,Timestamp arrivalTime) { |
| | | for (OpeApplyReserve opeApplyReserve:opeApplyList) { |
| | | //0.1获取该申购单的订单 |
| | | OpeOrder oo = opeOrderService.getOrder(opeApplyReserve.getId()); |
| | | if (oo == null) { |
| | | throw new BusinessException(ExceptionEnumCode.ORDER_ERROR,"订单不存在"); |
| | | } |
| | | //0.2检查条码->得到试剂条码列表 |
| | | List<String> codeList = opeReagentStatusService |
| | | .checkReagentCode(opeApplyReserve.getStartReagentCode2(), opeApplyReserve.getEndReagentCode2(), opeApplyReserve.getArrivalNum()); |
| | | //1.入库 |
| | | if (codeList == null){ |
| | | //无条码入库 不需要增加状态和流向 |
| | | //1.1库存表增加 |
| | | opeWarehouseReserveService.insertOpeWarehouseReserve2(opeApplyReserve, oo,consigneeId); |
| | | }else{ |
| | | //条码入库 |
| | | assert codeList.size() > 0; |
| | | //1.1入库(库存表增加) |
| | | opeWarehouseReserveService.insertOpeWarehouseReserve2(opeApplyReserve, oo,consigneeId); |
| | | //1.2试剂状态表增加,流向增加 |
| | | opeReagentStatusService.orderInputWarehouseReagentStatusAndUseFlow(opeApplyReserve,consigneeId,codeList,oo); |
| | | } |
| | | //2.更改申购单所属订单状态(判断子订单是否全部完成) |
| | | //2.1更改该申购单的状态,收货人和到货时间 |
| | | this.updateOpeApplyInfo(ApplyStatus.STORAGE,consigneeId,arrivalTime, opeApplyReserve.getId()); |
| | | //2.2更改订单状态 |
| | | List<OpeApply> oas = opeOrderService.getOpeApplyListByOrder(oo.getId()); |
| | | assert oas.size() > 0; |
| | | //子订单是否全部入库,是则父单为已入库,否则未完成 |
| | | boolean flag = oas.stream().allMatch(oa -> oa.getStatus() == ApplyStatus.STORAGE); |
| | | oo.setConsigneeUserId(consigneeId); |
| | | oo.setArrivalTime(arrivalTime); |
| | | if (flag){ |
| | | oo.setStatus(ApplyStatus.STORAGE); |
| | | opeOrderService.updateOpeOrderStatus(oo); |
| | | }else{ |
| | | oo.setStatus(ApplyStatus.UNCOMPLETED); |
| | | opeOrderService.updateOpeOrder(oo); |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | /** |
| | |
| | | if (approveUser == null) throw new BusinessException(ExceptionEnumCode.PARAM_NO_EXIST, i+"行:审批人不存在或者审批人姓名存在重复,导入失败"); |
| | | |
| | | OpeApply opeApply = new OpeApply(); |
| | | opeApply.setId(IDUtils.uuid()); |
| | | // opeApply.setId(IDUtils.uuid()); |
| | | opeApply.setValidFlag(ValidFlag.VALID); |
| | | opeApply.setStatus(ApplyStatus.PENDING_APPROVAL); |
| | | opeApply.setApplyCode(sysSequenceService.getApplyCode()); |
| | |
| | | opeApply.setApplyUserId(applyUser.getId()); |
| | | //选择的审批人 |
| | | opeApply.setApproveUserId(approveUser.getId()); |
| | | SysProject project=projectDao.getSysProjectByName(objective); |
| | | //选择的课题组信息 |
| | | opeApply.setObjective(objective); |
| | | opeApply.setProjectId(project!=null?project.getId():null); |
| | | |
| | | adds.add(opeApply); |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public OpeApplyReserve getOpeApplyReserveListByNameForRowData(String rowKey) { |
| | | public OpeApplyReserve getOpeApplyReserveListByNameForRowData(Long rowKey) { |
| | | return opeApplyDao.getOpeApplyReserveListByNameForRowData(rowKey); |
| | | } |
| | | |
| | |
| | | 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); |
| | | } |
| | | |
| | | } |