|
@@ -1,49 +1,90 @@
|
|
|
package com.fjhx.applet.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.applet.mapper.MaterialReceiveMapper;
|
|
|
import com.fjhx.applet.service.MaterialReceiveService;
|
|
|
import com.fjhx.base.BaseEntity;
|
|
|
import com.fjhx.utils.Assert;
|
|
|
+import com.fjhx.utils.WxAppletUtil;
|
|
|
+import org.springblade.system.user.feign.IUserClient;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.StringJoiner;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class MaterialReceiveServiceImpl extends ServiceImpl<MaterialReceiveMapper, BaseEntity> implements MaterialReceiveService {
|
|
|
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IUserClient userClient;
|
|
|
+
|
|
|
@Override
|
|
|
public synchronized void submit() {
|
|
|
|
|
|
List<Map<String, Object>> list = baseMapper.selectWaterDetail();
|
|
|
|
|
|
-
|
|
|
Map<Integer, List<Map<String, Object>>> stockChangeType =
|
|
|
list.stream().collect(Collectors.groupingBy(item -> (Integer) item.get("stockChangeType")));
|
|
|
|
|
|
- StringJoiner outJoiner = new StringJoiner(",", "(", ")");
|
|
|
- // 出库处理
|
|
|
- List<Map<String, Object>> outList = stockChangeType.get(20);
|
|
|
+ // 补出库处理
|
|
|
+ List<Map<String, Object>> outList = stockChangeType.get(29);
|
|
|
if (outList != null) {
|
|
|
+ StringJoiner outJoiner = new StringJoiner(",", "(", ")");
|
|
|
+ HashSet<String> waterIdSet = new HashSet<>();
|
|
|
+
|
|
|
for (Map<String, Object> map : outList) {
|
|
|
- // TODO 发起审批流
|
|
|
outJoiner.add(map.get("id").toString());
|
|
|
+ waterIdSet.add(map.get("waterId").toString() + "," + map.get("userId").toString());
|
|
|
}
|
|
|
+
|
|
|
+ // TODO 发起审批流
|
|
|
+ if (waterIdSet.size() > 0) {
|
|
|
+ String uuid = UUID.randomUUID().toString();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 物料接收待审批
|
|
|
baseMapper.updateReceive(outJoiner.toString(), 1);
|
|
|
}
|
|
|
|
|
|
- // 补出库处理
|
|
|
- StringJoiner repairJoiner = new StringJoiner(",", "(", ")");
|
|
|
- List<Map<String, Object>> repairList = stockChangeType.get(23);
|
|
|
+ // 出库处理
|
|
|
+ List<Map<String, Object>> repairList = stockChangeType.get(30);
|
|
|
if (repairList != null) {
|
|
|
+ StringJoiner repairJoiner = new StringJoiner(",", "(", ")");
|
|
|
+ HashSet<String> accountSet = new HashSet<>();
|
|
|
for (Map<String, Object> map : repairList) {
|
|
|
- // TODO 发送消息
|
|
|
repairJoiner.add(map.get("id").toString());
|
|
|
+ accountSet.add(map.get("account").toString());
|
|
|
}
|
|
|
+
|
|
|
+ // 物料接收待确认
|
|
|
baseMapper.updateReceive(repairJoiner.toString(), 2);
|
|
|
+
|
|
|
+ // 获取openId
|
|
|
+ Map<String, String> accountMap = userClient.getOpenidByAccount(new ArrayList<>(accountSet));
|
|
|
+ for (String account : accountSet) {
|
|
|
+ String openId = accountMap.get(account);
|
|
|
+ // 发送消息
|
|
|
+ if (ObjectUtil.isNotEmpty(openId)) {
|
|
|
+ Integer num = baseMapper.countNum(account);
|
|
|
+ WxAppletUtil.UniformSendEntity uniformSendEntity = new WxAppletUtil.UniformSendEntity();
|
|
|
+ uniformSendEntity.setTouser(openId);
|
|
|
+ uniformSendEntity.setTemplate_id("Tt0C6SOrtd2QXIdLqrm0CNdarUE4LG_lNJblUnkqTPM");
|
|
|
+ uniformSendEntity.setPage("pages/user/login");
|
|
|
+ uniformSendEntity.addData("thing1", "智能仓储");
|
|
|
+ uniformSendEntity.addData("thing2", "您有" + num + "条待接收物料");
|
|
|
+ uniformSendEntity.addData("time3", DateUtil.format(new Date(), "yyyy年MM月dd日 HH:mm"));
|
|
|
+ WxAppletUtil.sendMessage(uniformSendEntity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|