|
|
@@ -28,6 +28,7 @@ import lombok.AllArgsConstructor;
|
|
|
import org.springblade.client.entity.Message;
|
|
|
import org.springblade.client.feign.IMessageClient;
|
|
|
import org.springblade.client.feign.ISerialClient;
|
|
|
+import org.springblade.client.feign.IWechatClient;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.BeanUtil;
|
|
|
@@ -61,6 +62,7 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.MathContext;
|
|
|
import java.math.RoundingMode;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
|
@@ -98,6 +100,8 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
//消息
|
|
|
private final IMessageClient messageClient;
|
|
|
|
|
|
+ private final IWechatClient wechatClient;
|
|
|
+
|
|
|
/**
|
|
|
* 获取收发货订单详情
|
|
|
*
|
|
|
@@ -282,6 +286,7 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
gdShip.setTaskId(rwShip.getId());
|
|
|
gdShip.setSendTotalNum(new BigDecimal("0.00"));
|
|
|
baseMapper.insert(gdShip);
|
|
|
+ StringBuilder goodsNames = new StringBuilder();
|
|
|
|
|
|
//根据销售id获得销售明细数据
|
|
|
List<PjOrderItems> list = orderItemsService.list(new QueryWrapper<PjOrderItems>()
|
|
|
@@ -291,7 +296,8 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
.eq("tenant_id", AuthUtil.getTenantId()));
|
|
|
if (ObjectUtil.isNotEmpty(list)) {
|
|
|
List<PjShipItems> shipItemsList = new ArrayList<>();
|
|
|
- list.forEach(e -> {
|
|
|
+ for (PjOrderItems e : list) {
|
|
|
+ goodsNames.append(e.getGoodsName()).append(",");
|
|
|
//根据销售明细创建出库工单明细
|
|
|
PjShipItems shipItems = new PjShipItems();
|
|
|
BeanUtil.copyProperties(e, shipItems);
|
|
|
@@ -307,7 +313,8 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
shipItemsList.add(shipItems);
|
|
|
}
|
|
|
|
|
|
- });
|
|
|
+ }
|
|
|
+ ;
|
|
|
shipItemsService.saveBatch(shipItemsList);
|
|
|
gdShip.setNumberRows(list.size());
|
|
|
}
|
|
|
@@ -374,6 +381,37 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //给角色为财务的人发送消息
|
|
|
+ R<String> clientDeptIds = sysClient.getRoleIds(AuthUtil.getTenantId(), "客服");
|
|
|
+ StringBuilder openIds = new StringBuilder();
|
|
|
+ if (clientDeptIds.isSuccess() && StringUtils.isNotBlank(clientDeptIds.getData())) {
|
|
|
+ R<List<User>> userList = userClient.listUserByRoleId(Long.valueOf(clientDeptIds.getData()), AuthUtil.getTenantId(), rwShip.getSalesCompanyId());
|
|
|
+ if (userList.isSuccess() && CollectionUtils.isNotEmpty(userList.getData())) {
|
|
|
+ for (User datum : userList.getData()) {
|
|
|
+ if (ObjectUtils.isNotNull(datum.getOaOpenId())) {
|
|
|
+ openIds.append(datum.getOaOpenId()).append(",");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(rwShip.getStockClerkId())) {
|
|
|
+ R<User> resUser = userClient.userInfoById(rwShip.getStockClerkId());
|
|
|
+ if (resUser.isSuccess() && ObjectUtils.isNotNull(resUser.getData())) {
|
|
|
+ if (ObjectUtils.isNotNull(resUser.getData().getOaOpenId())) {
|
|
|
+ openIds.append(resUser.getData().getOaOpenId()).append(",");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
|
|
|
+ String date1 = format.format(new Date());
|
|
|
+
|
|
|
+ System.out.println("=========发送人openIds=========" + openIds);
|
|
|
+ if (ObjectUtils.isNotNull(openIds)) {
|
|
|
+ String rest = wechatClient.sendMessage(openIds.substring(0, openIds.length() - 1), "订单出库通知", "订单出库通知", date1, rwShip.getCustomerName(), gdShip.getBillno(),
|
|
|
+ "", "", goodsNames.toString(), new BigDecimal("0.00"), "1", AuthUtil.getTenantId());
|
|
|
+ System.out.println("=========发送返回值=========" + rest);
|
|
|
+ }
|
|
|
}
|
|
|
return R.success("操作成功");
|
|
|
}
|
|
|
@@ -417,6 +455,8 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
if (ObjectUtils.isNull(ship.getStorageId())) {
|
|
|
throw new RuntimeException("请先选择仓库");
|
|
|
}
|
|
|
+ ship.setGoodsTotalNum(ship.getShipItemsList().stream().map(PjShipItems::getGoodsNum).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ ship.setSendTotalNum(ship.getShipItemsList().stream().map(PjShipItems::getSendNum).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
if (ship.getId() == null) {
|
|
|
// 获取系统编号
|
|
|
R billNo = serialClient.getBillNo(OrderTypeEnum.FHGD.getType(), OrderTypeEnum.FHGD.getType(), OrderTypeEnum.FHGD.getType());
|
|
|
@@ -1376,8 +1416,8 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
return baseMapper.stockDataDetails(pjShipStockDetails);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public R shipments(PjShip pjShip) {
|
|
|
+ @Override
|
|
|
+ public R shipments(PjShip pjShip) {
|
|
|
int i = baseMapper.updateById(pjShip);
|
|
|
if (i > 0) {
|
|
|
return R.success("ok");
|
|
|
@@ -1386,7 +1426,7 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
+ /**
|
|
|
* 生成工单历史记录
|
|
|
*/
|
|
|
public void saveHistory(Long pid, String status) {
|