用车计算,合并
This commit is contained in:
parent
658264daad
commit
66da2e471a
@ -27,6 +27,11 @@
|
|||||||
<artifactId>hutool-crypto</artifactId>
|
<artifactId>hutool-crypto</artifactId>
|
||||||
<version>${hutool.version}</version>
|
<version>${hutool.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.json</groupId>
|
||||||
|
<artifactId>json</artifactId>
|
||||||
|
<version>20180813</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -21,5 +21,6 @@ public interface TmsIogisticsPriceMapper extends BaseMapper<TmsIogisticsPrice> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<TmsIogisticsPrice> getIogisticsPrice(@Param("pickUpHub") String pickUpHub,
|
List<TmsIogisticsPrice> getIogisticsPrice(@Param("pickUpHub") String pickUpHub,
|
||||||
@Param("deliveryAddress") String deliveryAddress);
|
@Param("deliveryAddress") String deliveryAddress,
|
||||||
|
@Param("shipType") String shipType);
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
and a.car_long = b.car_long
|
and a.car_long = b.car_long
|
||||||
where a.start_city = #{pickUpHub}
|
where a.start_city = #{pickUpHub}
|
||||||
and a.target_city = #{deliveryAddress}
|
and a.target_city = #{deliveryAddress}
|
||||||
|
and a.ship_type = #{shipType}
|
||||||
and a.failure_time >= TRUNC(SYSDATE)
|
and a.failure_time >= TRUNC(SYSDATE)
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
@ -4,10 +4,8 @@ import java.io.Serializable;
|
|||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
@ -71,4 +69,6 @@ public class VehiclePallet implements Serializable {
|
|||||||
/**更新人*/
|
/**更新人*/
|
||||||
@ApiModelProperty(value = "更新人")
|
@ApiModelProperty(value = "更新人")
|
||||||
private java.lang.String updateBy;
|
private java.lang.String updateBy;
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String supplierCode;
|
||||||
}
|
}
|
||||||
|
@ -15,4 +15,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||||||
public interface VehiclePalletMapper extends BaseMapper<VehiclePallet> {
|
public interface VehiclePalletMapper extends BaseMapper<VehiclePallet> {
|
||||||
|
|
||||||
List<String> getCarType();
|
List<String> getCarType();
|
||||||
|
|
||||||
|
List<VehiclePallet> getCarInfo(@Param("shipType") String shipType,
|
||||||
|
@Param("pickUpHub") String pickUpHub,
|
||||||
|
@Param("deliveryAddress") String deliveryAddress);
|
||||||
}
|
}
|
||||||
|
@ -6,4 +6,13 @@
|
|||||||
select car_type from tms_vehicle_pallet
|
select car_type from tms_vehicle_pallet
|
||||||
group by car_type
|
group by car_type
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getCarInfo" resultType="org.jeecg.modules.tms.basicdata.vehiclepallet.entity.VehiclePallet">
|
||||||
|
select b.*,a.supplier_code from tms_iogistics_price a inner JOIN tms_vehicle_pallet b
|
||||||
|
on a.CAR_TYPE = b.CAR_TYPE AND a.CAR_LONG = b.CAR_LONG
|
||||||
|
WHERE a.CAR_TYPE = #{shipType}
|
||||||
|
AND a.START_CITY = #{pickUpHub}
|
||||||
|
AND a.TARGET_CITY = #{deliveryAddress}
|
||||||
|
ORDER BY b.MAX_PALLETS DESC
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
@ -33,6 +33,7 @@ import org.jeecgframework.poi.excel.entity.ImportParams;
|
|||||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||||
import org.jeecg.common.system.base.controller.JeecgController;
|
import org.jeecg.common.system.base.controller.JeecgController;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||||
@ -201,25 +202,25 @@ public class VehicleInOutController extends JeecgController<VehicleInOut, IVehic
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping(value = "/take")
|
@PostMapping(value = "/take")
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Result<String> take(@RequestBody VehicleInOut vehicleInOut) {
|
public Result<String> take(@RequestBody VehicleInOut vehicleInOut) {
|
||||||
LambdaQueryWrapper<VehicleInOut> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<VehicleInOut> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
lambdaQueryWrapper.eq(VehicleInOut::getVehicleDemandCountId, vehicleInOut.getId());
|
lambdaQueryWrapper.eq(VehicleInOut::getVehicleDemandCountId, vehicleInOut.getId());
|
||||||
List<VehicleInOut> list = vehicleInOutService.list(lambdaQueryWrapper);
|
lambdaQueryWrapper.ne(VehicleInOut::getCurrentStatus, TmsConstants.currentStatus_1);
|
||||||
if (list != null && list.size() > 0) {
|
VehicleInOut vi = vehicleInOutService.getOne(lambdaQueryWrapper);
|
||||||
if ("1".equals(vehicleInOut.getEfType())) {
|
if (vi != null) {
|
||||||
return Result.error("已经进行过提货了!");
|
return Result.error("已经操作过了!");
|
||||||
} else {
|
|
||||||
return Result.error("已经进行过送货了!");
|
|
||||||
}
|
}
|
||||||
}
|
LambdaQueryWrapper<VehicleInOut> lam = new LambdaQueryWrapper<>();
|
||||||
vehicleInOut.setId(null)
|
lam.eq(VehicleInOut::getVehicleDemandCountId, vehicleInOut.getId());
|
||||||
.setCreateTime(null)
|
vehicleInOutService.remove(lam);
|
||||||
.setCreateBy(null)
|
vehicleInOut.setVehicleDemandCountId(vehicleInOut.getId())
|
||||||
.setCurrentStatus(TmsConstants.currentStatus_1)
|
.setCurrentStatus(TmsConstants.currentStatus_1)
|
||||||
.setPo(vehicleInOut.getPo())
|
.setId(null)
|
||||||
.setVehicleDemandCountId(vehicleInOut.getId());
|
.setCreateTime(null)
|
||||||
|
.setCreateBy(null);
|
||||||
vehicleInOutService.save(vehicleInOut);
|
vehicleInOutService.save(vehicleInOut);
|
||||||
return Result.OK("提货成功!");
|
return Result.OK("操作成功!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,5 +14,5 @@ public class TmsConstants {
|
|||||||
|
|
||||||
public static String shipType_0 = "0";
|
public static String shipType_0 = "0";
|
||||||
public static String shipType_1 = "1";
|
public static String shipType_1 = "1";
|
||||||
public static String shipType_2 = "2";
|
public static String shipType_2 = "快递";
|
||||||
}
|
}
|
||||||
|
@ -78,6 +78,10 @@ public class DeliveryDemandServiceImpl extends ServiceImpl<DeliveryDemandMapper,
|
|||||||
(merged1.getTotalPallets() == null ? 0 : merged1.getTotalPallets()) +
|
(merged1.getTotalPallets() == null ? 0 : merged1.getTotalPallets()) +
|
||||||
(merged2.getTotalPallets() == null ? 0 : merged2.getTotalPallets())
|
(merged2.getTotalPallets() == null ? 0 : merged2.getTotalPallets())
|
||||||
);
|
);
|
||||||
|
merged1.setPreTotalPallets(
|
||||||
|
(merged1.getPreTotalPallets() == null ? 0 : merged1.getPreTotalPallets()) +
|
||||||
|
(merged2.getPreTotalPallets() == null ? 0 : merged2.getPreTotalPallets())
|
||||||
|
);
|
||||||
merged1.setTotalShips(
|
merged1.setTotalShips(
|
||||||
/*(merged1.getTotalShips() == null ? 0 : merged1.getTotalShips()) +
|
/*(merged1.getTotalShips() == null ? 0 : merged1.getTotalShips()) +
|
||||||
(merged2.getTotalShips() == null ? 0 : merged2.getTotalShips())*/
|
(merged2.getTotalShips() == null ? 0 : merged2.getTotalShips())*/
|
||||||
@ -141,6 +145,10 @@ public class DeliveryDemandServiceImpl extends ServiceImpl<DeliveryDemandMapper,
|
|||||||
(merged1.getTotalPallets() == null ? 0 : merged1.getTotalPallets()) +
|
(merged1.getTotalPallets() == null ? 0 : merged1.getTotalPallets()) +
|
||||||
(merged2.getTotalPallets() == null ? 0 : merged2.getTotalPallets())
|
(merged2.getTotalPallets() == null ? 0 : merged2.getTotalPallets())
|
||||||
);
|
);
|
||||||
|
merged1.setPreTotalPallets(
|
||||||
|
(merged1.getPreTotalPallets() == null ? 0 : merged1.getPreTotalPallets()) +
|
||||||
|
(merged2.getPreTotalPallets() == null ? 0 : merged2.getPreTotalPallets())
|
||||||
|
);
|
||||||
merged1.setTotalShips(
|
merged1.setTotalShips(
|
||||||
/*(merged1.getTotalShips() == null ? 0 : merged1.getTotalShips()) +
|
/*(merged1.getTotalShips() == null ? 0 : merged1.getTotalShips()) +
|
||||||
(merged2.getTotalShips() == null ? 0 : merged2.getTotalShips())*/
|
(merged2.getTotalShips() == null ? 0 : merged2.getTotalShips())*/
|
||||||
|
@ -46,9 +46,10 @@ public class VehicleDemandServiceImpl extends ServiceImpl<VehicleDemandMapper, V
|
|||||||
private final IVehicleDemandCountService vehicleDemandCountService;
|
private final IVehicleDemandCountService vehicleDemandCountService;
|
||||||
private final TmsIogisticsPriceMapper iogisticsPriceMapper;
|
private final TmsIogisticsPriceMapper iogisticsPriceMapper;
|
||||||
private final DeliveryDemandMapper deliveryDemandMapper;
|
private final DeliveryDemandMapper deliveryDemandMapper;
|
||||||
|
private final VehicleDemandMapper vehicleDemandMapper;
|
||||||
|
|
||||||
/*//用车计算方法,根据价格选择车(tms_iogistics_price表)
|
//用车计算方法,根据价格选择车(tms_iogistics_price表)
|
||||||
@Override
|
/*@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Result<?> carCount(VehicleDemand vehicleDemand) {
|
public Result<?> carCount(VehicleDemand vehicleDemand) {
|
||||||
// 1.判断是否进行过用车计算
|
// 1.判断是否进行过用车计算
|
||||||
@ -62,7 +63,8 @@ public class VehicleDemandServiceImpl extends ServiceImpl<VehicleDemandMapper, V
|
|||||||
// 2.查询物流价格信息(从起始城市到目标城市各种车型的价格)
|
// 2.查询物流价格信息(从起始城市到目标城市各种车型的价格)
|
||||||
List<TmsIogisticsPrice> iogisticsPriceList = iogisticsPriceMapper.getIogisticsPrice(
|
List<TmsIogisticsPrice> iogisticsPriceList = iogisticsPriceMapper.getIogisticsPrice(
|
||||||
vehicleDemand.getPickUpHub(),
|
vehicleDemand.getPickUpHub(),
|
||||||
vehicleDemand.getDeliveryAddress());
|
vehicleDemand.getDeliveryAddress(),
|
||||||
|
vehicleDemand.getShipType());
|
||||||
if (iogisticsPriceList == null || iogisticsPriceList.size() <= 0) {
|
if (iogisticsPriceList == null || iogisticsPriceList.size() <= 0) {
|
||||||
return Result.error("没有符合的物流价格基础信息,请维护!");
|
return Result.error("没有符合的物流价格基础信息,请维护!");
|
||||||
}
|
}
|
||||||
@ -72,15 +74,18 @@ public class VehicleDemandServiceImpl extends ServiceImpl<VehicleDemandMapper, V
|
|||||||
// Integer: 该种车型与车长选择的数量
|
// Integer: 该种车型与车长选择的数量
|
||||||
Solution solution = findCheapestSolution(iogisticsPriceList, vehicleDemand.getTotalPallets());
|
Solution solution = findCheapestSolution(iogisticsPriceList, vehicleDemand.getTotalPallets());
|
||||||
// 打印,方便查看,开发时可以打开
|
// 打印,方便查看,开发时可以打开
|
||||||
*//*for (Map.Entry<String, Integer> entry : solution.getVehicleCounts().entrySet()) {
|
for (Map.Entry<String, Integer> entry : solution.getVehicleCounts().entrySet()) {
|
||||||
System.out.println(entry.getKey() + " 车: " + entry.getValue() + " 辆");
|
System.out.println(entry.getKey() + " 车: " + entry.getValue() + " 辆");
|
||||||
}*//*
|
}
|
||||||
// 4.转化集合
|
// 4.转化集合
|
||||||
List<VehicleDemandCount> vehicleDemandCounts = convertToVehicleDemandCountList(solution.getVehicleCounts(), vehicleDemand);
|
List<VehicleDemandCount> vehicleDemandCounts = convertToVehicleDemandCountList(solution.getVehicleCounts(), vehicleDemand);
|
||||||
// 5.新增
|
// 5.新增
|
||||||
vehicleDemandCountService.saveBatch(vehicleDemandCounts);
|
vehicleDemandCountService.saveBatch(vehicleDemandCounts);
|
||||||
// 6.更新发货需求当前状态
|
// 6.更新发货需求当前状态
|
||||||
deliveryDemandMapper.updateByVdNo(vehicleDemand.getVdNo(), TmsConstants.currentStatus_2);
|
deliveryDemandMapper.updateByVdNo(vehicleDemand.getVdNo(), TmsConstants.currentStatus_2);
|
||||||
|
// 7.更新用车需求当前状态
|
||||||
|
vehicleDemand.setCurrentStatus(TmsConstants.currentStatus_2);
|
||||||
|
vehicleDemandMapper.updateById(vehicleDemand);
|
||||||
log.info("用车需求计算,用车需求编号:{},方案:{},费用:{}",vehicleDemand.getVdNo(),
|
log.info("用车需求计算,用车需求编号:{},方案:{},费用:{}",vehicleDemand.getVdNo(),
|
||||||
solution.getVehicleCounts(),solution.getTotalCost());
|
solution.getVehicleCounts(),solution.getTotalCost());
|
||||||
return Result.OK("用车计算成功!");
|
return Result.OK("用车计算成功!");
|
||||||
@ -188,7 +193,8 @@ public class VehicleDemandServiceImpl extends ServiceImpl<VehicleDemandMapper, V
|
|||||||
.setCarType(vehiclePallet.getCarType())
|
.setCarType(vehiclePallet.getCarType())
|
||||||
.setSystemCarType(vehiclePallet.getCarType())
|
.setSystemCarType(vehiclePallet.getCarType())
|
||||||
.setCarLong(vehiclePallet.getCarLong())
|
.setCarLong(vehiclePallet.getCarLong())
|
||||||
.setSystemCarLong(vehiclePallet.getCarLong());
|
.setSystemCarLong(vehiclePallet.getCarLong())
|
||||||
|
.setSupplierCode(vehiclePallet.getSupplierCode());
|
||||||
vehicleDemandCounts.add(vehicleDemandCount);
|
vehicleDemandCounts.add(vehicleDemandCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,9 +212,15 @@ public class VehicleDemandServiceImpl extends ServiceImpl<VehicleDemandMapper, V
|
|||||||
return Result.error("已经进行过用车计算了!");
|
return Result.error("已经进行过用车计算了!");
|
||||||
}
|
}
|
||||||
// 2.查询车型可装托数(倒序)
|
// 2.查询车型可装托数(倒序)
|
||||||
LambdaQueryWrapper<VehiclePallet> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
/*LambdaQueryWrapper<VehiclePallet> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
lambdaQueryWrapper.orderByDesc(VehiclePallet::getMaxPallets);
|
lambdaQueryWrapper.orderByDesc(VehiclePallet::getMaxPallets);
|
||||||
List<VehiclePallet> vehiclePallets = vehiclePalletMapper.selectList(lambdaQueryWrapper);
|
lambdaQueryWrapper.eq(VehiclePallet::getCarType, vehicleDemand.getShipType());
|
||||||
|
List<VehiclePallet> vehiclePallets = vehiclePalletMapper.selectList(lambdaQueryWrapper);*/
|
||||||
|
List<VehiclePallet> vehiclePallets = vehiclePalletMapper.getCarInfo(vehicleDemand.getShipType(),
|
||||||
|
vehicleDemand.getPickUpHub(), vehicleDemand.getDeliveryAddress());
|
||||||
|
if (vehiclePallets == null || vehiclePallets.size() == 0) {
|
||||||
|
return Result.error("没有符合的物流价格基础信息,请维护!");
|
||||||
|
}
|
||||||
// 3.进行车辆选择
|
// 3.进行车辆选择
|
||||||
// 3.1.获取需要装车总托数
|
// 3.1.获取需要装车总托数
|
||||||
Integer totalPallets = vehicleDemand.getTotalPallets();
|
Integer totalPallets = vehicleDemand.getTotalPallets();
|
||||||
@ -235,7 +247,9 @@ public class VehicleDemandServiceImpl extends ServiceImpl<VehicleDemandMapper, V
|
|||||||
vehicleDemandCountService.saveBatch(vehicleDemandCounts);
|
vehicleDemandCountService.saveBatch(vehicleDemandCounts);
|
||||||
// 更新发货需求当前状态
|
// 更新发货需求当前状态
|
||||||
deliveryDemandMapper.updateByVdNo(vehicleDemand.getVdNo(), TmsConstants.currentStatus_2);
|
deliveryDemandMapper.updateByVdNo(vehicleDemand.getVdNo(), TmsConstants.currentStatus_2);
|
||||||
System.out.println(ids);
|
// 更新用车需求当前状态
|
||||||
|
vehicleDemand.setCurrentStatus(TmsConstants.currentStatus_2);
|
||||||
|
vehicleDemandMapper.updateById(vehicleDemand);
|
||||||
return Result.OK("用车计算成功!");
|
return Result.OK("用车计算成功!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,94 @@
|
|||||||
|
package org.jeecg.modules.tms.utils;
|
||||||
|
|
||||||
|
import okhttp3.*;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class DingTalkUtils {
|
||||||
|
|
||||||
|
private static final String APP_KEY = "dingdz6no5d2igfucd8h"; //AppKey
|
||||||
|
private static final String APP_SECRET = "YB0ieklneXHEUZ0dyRxu36w9AKSbjqVpS7z6iPE1_3YzTvS3yeQ-jieeP4Al0sIW";
|
||||||
|
private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
|
||||||
|
|
||||||
|
public static String getAccessToken() throws IOException {
|
||||||
|
OkHttpClient client = new OkHttpClient();
|
||||||
|
String url = "https://oapi.dingtalk.com/gettoken?appkey=" + APP_KEY + "&appsecret=" + APP_SECRET;
|
||||||
|
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url(url)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
try (Response response = client.newCall(request).execute()) {
|
||||||
|
if (!response.isSuccessful()) throw new IOException("Failed to retrieve access token");
|
||||||
|
|
||||||
|
String responseBody = response.body().string();
|
||||||
|
JSONObject jsonObject = new JSONObject(responseBody);
|
||||||
|
return jsonObject.getString("access_token");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送消息
|
||||||
|
* @param accessToken 调用接口的身份凭证
|
||||||
|
* @param agentId 应用的 AgentId
|
||||||
|
* @param userId 用户id
|
||||||
|
* @param chatId 群聊id
|
||||||
|
* @param message 消息
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public static void sendTextMessage(String accessToken, String agentId, String userId, String chatId, String message) throws IOException {
|
||||||
|
OkHttpClient client = new OkHttpClient();
|
||||||
|
String json = "{\"agent_id\":\"" + agentId + "\",\"userid_list\":\"" + userId + "\",\"deptid_list\":[\"" + userId + "\"],\"chatid\":\"" + chatId + "\",\"msg\":{\"msgtype\": \"text\",\"text\": {\"content\": \"" + message + "\"}}}";
|
||||||
|
|
||||||
|
RequestBody body = RequestBody.create(json, JSON);
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url("https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2?access_token=" + accessToken)
|
||||||
|
.post(body)
|
||||||
|
.build();
|
||||||
|
try (Response response = client.newCall(request).execute()) {
|
||||||
|
if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
|
||||||
|
System.out.println(response.body().string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过手机号获取用户的 userId
|
||||||
|
* @param accessToken 调用接口的身份凭证
|
||||||
|
* @param mobile 手机号
|
||||||
|
* @return
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public static JSONObject getUserByMobile(String accessToken, String mobile) throws IOException {
|
||||||
|
OkHttpClient client = new OkHttpClient();
|
||||||
|
HttpUrl url = HttpUrl.parse("https://oapi.dingtalk.com/user/get_by_mobile")
|
||||||
|
.newBuilder()
|
||||||
|
.addQueryParameter("access_token", accessToken)
|
||||||
|
.addQueryParameter("mobile", mobile)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url(url)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
try (Response response = client.newCall(request).execute()) {
|
||||||
|
if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
|
||||||
|
|
||||||
|
String responseBody = response.body().string();
|
||||||
|
return new JSONObject(responseBody);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
try {
|
||||||
|
String accessToken = DingTalkUtils.getAccessToken();
|
||||||
|
String agentId = "3206304704"; // 如果API调用不需要,则忽略此参数
|
||||||
|
// String chatId = "095452471826097763,02000826241189265"; // 账号
|
||||||
|
String chatId = "620665223329579"; // 账号
|
||||||
|
String message = "Hello, this is a test message from Java!"; //发送内容
|
||||||
|
sendTextMessage(accessToken, agentId, chatId, chatId,message);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user