|
|
@@ -1,5 +1,6 @@
|
|
|
package com.sckw.product.service;
|
|
|
|
|
|
+import com.alibaba.fastjson2.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
@@ -13,10 +14,7 @@ import com.sckw.core.model.page.PageResult;
|
|
|
import com.sckw.core.model.vo.TableBottom;
|
|
|
import com.sckw.core.model.vo.TableStatisticRes;
|
|
|
import com.sckw.core.model.vo.TableTop;
|
|
|
-import com.sckw.core.utils.BeanUtils;
|
|
|
-import com.sckw.core.utils.CollectionUtils;
|
|
|
-import com.sckw.core.utils.NumberUtils;
|
|
|
-import com.sckw.core.utils.StringUtils;
|
|
|
+import com.sckw.core.utils.*;
|
|
|
import com.sckw.core.web.constant.HttpStatus;
|
|
|
import com.sckw.core.web.context.LoginUserHolder;
|
|
|
import com.sckw.excel.utils.DateUtil;
|
|
|
@@ -31,6 +29,9 @@ import com.sckw.product.model.vo.req.*;
|
|
|
import com.sckw.product.model.vo.res.*;
|
|
|
import com.sckw.redis.constant.RedisConstant;
|
|
|
import com.sckw.redis.utils.RedissonUtils;
|
|
|
+import com.sckw.stream.enums.MessageEnum;
|
|
|
+import com.sckw.stream.model.SckwMessage;
|
|
|
+import com.sckw.stream.model.UserInfo;
|
|
|
import com.sckw.system.api.RemoteSystemService;
|
|
|
import com.sckw.system.api.RemoteUserService;
|
|
|
import com.sckw.system.api.model.dto.res.EntCacheResDto;
|
|
|
@@ -40,6 +41,8 @@ import com.sckw.system.api.model.dto.res.UserCacheResDto;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.cloud.stream.function.StreamBridge;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
@@ -73,6 +76,10 @@ public class KwpGoodsService {
|
|
|
private final KwpGoodsAttributeService kwpGoodsAttributeService;
|
|
|
private final KwpGoodsImageService kwpGoodsImageService;
|
|
|
private final KwpGoodsPriceRangeService kwpGoodsPriceRangeService;
|
|
|
+ private final StreamBridge streamBridge;
|
|
|
+
|
|
|
+ @Value("${goods.url.list}")
|
|
|
+ private String goodsListUrl;
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -650,6 +657,7 @@ public class KwpGoodsService {
|
|
|
* @Param id:
|
|
|
* @return: void
|
|
|
*/
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void batchPutOnShelves(Long id) {
|
|
|
LambdaQueryWrapper<KwpGoods> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.eq(KwpGoods::getId, id).eq(KwpGoods::getEntId, LoginUserHolder.getEntId()).eq(KwpGoods::getDelFlag, Global.NO).last("LIMIT 1");
|
|
|
@@ -674,6 +682,34 @@ public class KwpGoodsService {
|
|
|
LambdaUpdateWrapper<KwpGoods> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
updateWrapper.set(KwpGoods::getStatus, GoodsStatusEnum.PUT_ON_SHELVES.getCode()).set(KwpGoods::getAddedTime, new Date()).eq(KwpGoods::getId, id);
|
|
|
kwpGoodsMapper.update(null, updateWrapper);
|
|
|
+ sendMsg(MessageEnum.PRODUCT_ON_SHELVES, goods);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc: 发送消息提醒
|
|
|
+ * @author: yzc
|
|
|
+ * @date: 2023-09-05 11:53
|
|
|
+ * @Param msgEnum:
|
|
|
+ * @Param goods:
|
|
|
+ * @return: void
|
|
|
+ */
|
|
|
+ private void sendMsg(MessageEnum msgEnum, KwpGoods goods) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("productName", goods.getName());
|
|
|
+ //给创建人发消息
|
|
|
+ List<UserInfo> userInfos = new ArrayList<>();
|
|
|
+ UserInfo createUser = new UserInfo();
|
|
|
+ createUser.setUserId(goods.getCreateBy()).setEntId(goods.getEntId());
|
|
|
+ userInfos.add(createUser);
|
|
|
+ SckwMessage msg = new SckwMessage();
|
|
|
+ msg.setRequestId(UUIDUtils.get32UUID())
|
|
|
+ .setMessageEnum(msgEnum)
|
|
|
+ .setParams(map)
|
|
|
+ .setMsgUrl(goodsListUrl)
|
|
|
+ .setUserInfos(userInfos)
|
|
|
+ .setCreateBy(LoginUserHolder.getUserId());
|
|
|
+ log.info(msgEnum.getTitle() + "消息:{}", JSON.toJSONString(msg));
|
|
|
+ streamBridge.send("sckw-message", JSON.toJSONString(msg));
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -684,6 +720,7 @@ public class KwpGoodsService {
|
|
|
* @Param ids:
|
|
|
* @return: void
|
|
|
*/
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void batchTakeOffShelves(List<Long> ids) {
|
|
|
LambdaQueryWrapper<KwpGoods> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.in(KwpGoods::getId, ids).eq(KwpGoods::getStatus, GoodsStatusEnum.PUT_ON_SHELVES.getCode()).eq(KwpGoods::getEntId, LoginUserHolder.getEntId()).eq(KwpGoods::getDelFlag, Global.NO);
|
|
|
@@ -694,6 +731,9 @@ public class KwpGoodsService {
|
|
|
LambdaUpdateWrapper<KwpGoods> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
updateWrapper.set(KwpGoods::getStatus, GoodsStatusEnum.TAKE_OFF_SHELVES.getCode()).set(KwpGoods::getShelfTime, new Date()).in(KwpGoods::getId, ids);
|
|
|
kwpGoodsMapper.update(null, updateWrapper);
|
|
|
+ list.forEach(e -> {
|
|
|
+ sendMsg(MessageEnum.PRODUCT_REMOVED_SHELVES, e);
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|