|  |  |  | 
|---|
|  |  |  | import com.doumee.dao.business.YwStocktakingRecordMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.YwWarehouseMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.model.*; | 
|---|
|  |  |  | import com.doumee.dao.system.join.NoticesJoinMapper; | 
|---|
|  |  |  | import com.doumee.dao.system.model.Notices; | 
|---|
|  |  |  | import com.doumee.service.business.YwStocktakingService; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | 
|---|
|  |  |  | 
|---|
|  |  |  | private YwWarehouseMapper ywWarehouseMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private NoticesJoinMapper noticesJoinMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private RedisTemplate<String, Object> redisTemplate; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | 
|---|
|  |  |  | ywStocktaking.setStatus(Constants.ZERO); | 
|---|
|  |  |  | ywStocktaking.setCode(getNextCode()); | 
|---|
|  |  |  | ywStocktakingMapper.insert(ywStocktaking); | 
|---|
|  |  |  | //添加待办信息 | 
|---|
|  |  |  | Notices notices = new Notices(); | 
|---|
|  |  |  | notices.setCreateDate(new Date()); | 
|---|
|  |  |  | notices.setCreator(ywStocktaking.getCreator()); | 
|---|
|  |  |  | notices.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | notices.setParam1(DateUtil.formatDate(ywStocktaking.getPlanDate(),"yyyy-MM-dd")); | 
|---|
|  |  |  | notices.setTitle("盘点待办"); | 
|---|
|  |  |  | notices.setContent("["+ywStocktaking.getName()+"]将在["+notices.getParam1()+"]进行盘点,请按时执行"); | 
|---|
|  |  |  | notices.setObjId(ywStocktaking.getId()); | 
|---|
|  |  |  | notices.setObjType(Constants.ZERO); | 
|---|
|  |  |  | notices.setType(notices.getObjType()); | 
|---|
|  |  |  | notices.setUserId(ywStocktaking.getUserId()); | 
|---|
|  |  |  | notices.setStatus(Constants.ZERO); | 
|---|
|  |  |  | noticesJoinMapper.insert(notices); | 
|---|
|  |  |  | return ywStocktaking.getId(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | .set(YwStocktaking::getEditDate,DateUtil.getCurrDateTime()) | 
|---|
|  |  |  | .set(YwStocktaking::getEditor,loginUserInfo.getId()) | 
|---|
|  |  |  | .eq(YwStocktaking::getId,id) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | //标记待办删除 | 
|---|
|  |  |  | noticesJoinMapper.update(null,new UpdateWrapper<Notices>().lambda().set(Notices::getIsdeleted,Constants.ONE) | 
|---|
|  |  |  | .eq(Notices::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(Notices::getObjType,Constants.ZERO) | 
|---|
|  |  |  | .eq(Notices::getObjId,id) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"盘点单状态已流转,无法进行该操作"); | 
|---|
|  |  |  | 
|---|
|  |  |  | .set(YwStocktaking::getCancelUserId,loginUserInfo.getId()) | 
|---|
|  |  |  | .set(YwStocktaking::getEditor,loginUserInfo.getId()) | 
|---|
|  |  |  | .set(YwStocktaking::getStatus,Constants.THREE).eq(YwStocktaking::getId,id)); | 
|---|
|  |  |  | //标记待办删除 | 
|---|
|  |  |  | noticesJoinMapper.update(null,new UpdateWrapper<Notices>().lambda().set(Notices::getIsdeleted,Constants.ONE) | 
|---|
|  |  |  | .eq(Notices::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(Notices::getObjType,Constants.ZERO) | 
|---|
|  |  |  | .eq(Notices::getObjId,id) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"盘点单状态已流转,无法进行该操作"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | .set(YwStocktaking::getEditor,loginUserInfo.getId()) | 
|---|
|  |  |  | .set(YwStocktaking::getStatus,Constants.ONE) | 
|---|
|  |  |  | .eq(YwStocktaking::getId,model.getId())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //标记待办已处理 | 
|---|
|  |  |  | noticesJoinMapper.update(null,new UpdateWrapper<Notices>().lambda() | 
|---|
|  |  |  | .set(Notices::getStatus,Constants.ONE) | 
|---|
|  |  |  | .eq(Notices::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(Notices::getObjType,Constants.ZERO) | 
|---|
|  |  |  | .eq(Notices::getObjId,id) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //生成当前仓库下所有的资产信息 | 
|---|
|  |  |  | List<YwStock> stockList = ywStockMapper.selectList(new QueryWrapper<YwStock>().lambda().eq(YwStock::getIsdeleted,Constants.ZERO).eq(YwStock::getWarehouseId,model.getWarehouseId())); | 
|---|
|  |  |  | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(stockList)){ | 
|---|
|  |  |  | 
|---|
|  |  |  | ywStocktaking.setEditDate(new Date()); | 
|---|
|  |  |  | ywStocktaking.setCode(null); | 
|---|
|  |  |  | ywStocktakingMapper.updateById(ywStocktaking); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //标记待办已处理 | 
|---|
|  |  |  | noticesJoinMapper.update(null,new UpdateWrapper<Notices>().lambda() | 
|---|
|  |  |  | .set(Notices::getStatus,Constants.ONE) | 
|---|
|  |  |  | .eq(Notices::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(Notices::getObjType,Constants.ZERO) | 
|---|
|  |  |  | .eq(Notices::getObjId,ywStocktaking.getId()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //添加待办信息 | 
|---|
|  |  |  | Notices notices = new Notices(); | 
|---|
|  |  |  | notices.setCreateDate(new Date()); | 
|---|
|  |  |  | notices.setCreator(ywStocktaking.getCreator()); | 
|---|
|  |  |  | notices.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | notices.setParam1(DateUtil.formatDate(ywStocktaking.getPlanDate(),"yyyy-MM-dd")); | 
|---|
|  |  |  | notices.setTitle("盘点待办"); | 
|---|
|  |  |  | notices.setContent("["+ywStocktaking.getName()+"]将在["+notices.getParam1()+"]进行盘点,请按时执行"); | 
|---|
|  |  |  | notices.setObjId(ywStocktaking.getId()); | 
|---|
|  |  |  | notices.setObjType(Constants.ZERO); | 
|---|
|  |  |  | notices.setType(notices.getObjType()); | 
|---|
|  |  |  | notices.setUserId(ywStocktaking.getUserId()); | 
|---|
|  |  |  | notices.setStatus(Constants.ZERO); | 
|---|
|  |  |  | noticesJoinMapper.insert(notices); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|