mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
Merge remote-tracking branch 'origin/main'
This commit is contained in:
+75
-44
@@ -1,10 +1,12 @@
|
||||
package com.cf.imes.module.executor.controller.admin.order;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
|
||||
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
|
||||
import com.cf.imes.framework.common.pojo.PageParam;
|
||||
import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import com.cf.imes.framework.web.config.WebProperties;
|
||||
import com.cf.imes.framework.web.core.util.WebFrameworkUtils;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.*;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.product.OrderBodyRespVO;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.product.OrderRoomBodyRespVO;
|
||||
@@ -21,6 +23,7 @@ import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.VO.OrderX
|
||||
import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.XMLReadUtil;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springdoc.webmvc.core.RequestService;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -189,62 +192,90 @@ public class OrderController {
|
||||
// api-生产单导入
|
||||
@GetMapping("getApiData")
|
||||
@Operation(summary = "生产单api数据导入新增")
|
||||
@Parameter(name = "orderNo", description = "原订单号", required = true, example = "20230809027818")
|
||||
@PreAuthorize("@ss.hasPermission('production:manager-list:create')")
|
||||
public CommonResult<Long> test(@RequestParam(value = "orderNo", required = false, defaultValue = "20230809027818") String orderNo)
|
||||
public CommonResult<Long> getApiData(@RequestParam(value = "orderNo") String orderNo)
|
||||
throws InterruptedException, ExecutionException {
|
||||
|
||||
Long orderId = (Long) identifierGenerator.nextId(null);
|
||||
Long organId = getUserOrganId();
|
||||
// final RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
|
||||
//// 从HttpServletRequest中提取servletPath
|
||||
// String servletPath = request.getServletPath();
|
||||
// System.out.println("servletPath = " + servletPath.startsWith(properties.getAdminApi().getPrefix()));
|
||||
try {
|
||||
Long orderId = (Long) identifierGenerator.nextId(null);
|
||||
Long organId = getUserOrganId();
|
||||
JSONObject oauth = apiDataAchieve.getApiToken(organId).get();
|
||||
String token = oauth.getJSONObject("info").getString("access_token");
|
||||
String shopId = oauth.getJSONObject("info").getString("shop_id");
|
||||
JSONObject order = apiDataAchieve.getApiOrder(token, shopId, orderNo).get();
|
||||
if (!order.getString("err_code").equals("0")) {
|
||||
throw exception(PLATE_PLAN_DATA_ERROR);
|
||||
}
|
||||
if (order.getJSONArray("data") == null) {
|
||||
throw exception(PLATE_PLAN_DATA_NULL);
|
||||
}
|
||||
JSONObject dataPlates = apiDataAchieve.getApiPlateProData(token, orderNo).get();
|
||||
JSONObject dataParts = apiDataAchieve.getApiPartsMessage(token, orderNo).get();
|
||||
JSONObject dataBody = apiDataAchieve.getApiBodyMessage(token, orderNo).get();
|
||||
JSONObject dataGoods = apiDataAchieve.getApiGoodsMessage(token, orderNo).get();
|
||||
JSONObject plate = apiDataAchieve.getApiPlateDetailMessage(token, orderNo).get();
|
||||
JSONObject dataModule = apiDataAchieve.getApiGroupMessage(token, orderNo).get();
|
||||
JSONObject block = apiDataAchieve.getApiBlocksMessage(token, orderNo).get();
|
||||
Map<String, List<?>> listMap = apiTypeRealize.apiPlateDataChange(
|
||||
order,
|
||||
dataPlates,//板件生产信息
|
||||
dataParts,// 配件信息
|
||||
dataBody, // 柜体信息
|
||||
dataGoods, // 商品信息
|
||||
plate, // 板件明细
|
||||
dataModule,// 加工组信息
|
||||
block,// 板材数据
|
||||
orderNo,// 原始板编号
|
||||
orderId,
|
||||
organId);
|
||||
return success(orderService.importApiData(listMap));
|
||||
} catch (Exception e) {
|
||||
log.error("api数据导入异常", e);
|
||||
throw exception(PLATE_PLAN_DATA_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
// public CommonResult<Long> test(@RequestParam(value = "orderNo") String orderNo)
|
||||
// throws InterruptedException, ExecutionException {
|
||||
//
|
||||
// Long orderId = (Long) identifierGenerator.nextId(null);
|
||||
// Long organId = getUserOrganId();
|
||||
//
|
||||
// JSONObject oauth = apiDataAchieve.getApiToken(organId).get();
|
||||
// String token = oauth.getJSONObject("info").getString("access_token");
|
||||
// String shopId = oauth.getJSONObject("info").getString("shop_id");
|
||||
// JSONObject order = apiDataAchieve.getApiOrder(token, shopId, orderNo).get();
|
||||
// if (!order.getString("err_code").equals("0")) {
|
||||
// throw exception(PLATE_PLAN_DATA_ERROR);
|
||||
// }
|
||||
// if (order.getJSONArray("data") == null) {
|
||||
// throw exception(PLATE_PLAN_DATA_NULL);
|
||||
// }
|
||||
// JSONObject dataPlates = apiDataAchieve.getApiPlateProData(token, orderNo).get();
|
||||
// JSONObject dataParts = apiDataAchieve.getApiPartsMessage(token, orderNo).get();
|
||||
// JSONObject dataBody = apiDataAchieve.getApiBodyMessage(token, orderNo).get();
|
||||
// JSONObject dataGoods = apiDataAchieve.getApiGoodsMessage(token, orderNo).get();
|
||||
// JSONObject plate = apiDataAchieve.getApiPlateDetailMessage(token, orderNo).get();
|
||||
// JSONObject dataModule = apiDataAchieve.getApiGroupMessage(token, orderNo).get();
|
||||
// JSONObject block = apiDataAchieve.getApiBlocksMessage(token, orderNo).get();
|
||||
//
|
||||
// CompletableFuture.runAsync(() -> {
|
||||
//// System.out.println(String.join("-", Thread.currentThread().getName(), " i = " + i.getAndIncrement()));
|
||||
// RequestContextHolder.setRequestAttributes(requestAttributes);
|
||||
// try {
|
||||
// orderService.importApiData(orderNo, orderId, organId);
|
||||
// DynamicDataSourceContextHolder.push("slave");
|
||||
// orderService.importApiData(order,dataPlates,dataParts,dataBody,dataGoods,plate,dataModule,block,orderNo, orderId, organId);
|
||||
// DynamicDataSourceContextHolder.clear();
|
||||
// } catch (Exception e) {
|
||||
//
|
||||
// log.error(" 1: ", e);
|
||||
// }
|
||||
// }, asyncExecutor).exceptionally(e -> {
|
||||
// log.error("error", e);
|
||||
// return null;
|
||||
// });
|
||||
// Long organId = SecurityFrameworkUtils.getLoginUser().getOrganId();
|
||||
JSONObject oauth = apiDataAchieve.getApiToken(organId).get();
|
||||
String token = oauth.getJSONObject("info").getString("access_token");
|
||||
String shopId = oauth.getJSONObject("info").getString("shop_id");
|
||||
JSONObject order = apiDataAchieve.getApiOrder(token, shopId, orderNo).get();
|
||||
if (!order.getString("err_code").equals("0")) {
|
||||
throw exception(PLATE_PLAN_DATA_ERROR);
|
||||
}
|
||||
if (order.getJSONArray("data") == null) {
|
||||
throw exception(PLATE_PLAN_DATA_NULL);
|
||||
}
|
||||
JSONObject dataPlates = apiDataAchieve.getApiPlateProData(token, orderNo).get();
|
||||
JSONObject dataParts = apiDataAchieve.getApiPartsMessage(token, orderNo).get();
|
||||
JSONObject dataBody = apiDataAchieve.getApiBodyMessage(token, orderNo).get();
|
||||
JSONObject dataGoods = apiDataAchieve.getApiGoodsMessage(token, orderNo).get();
|
||||
JSONObject plate = apiDataAchieve.getApiPlateDetailMessage(token, orderNo).get();
|
||||
JSONObject dataModule = apiDataAchieve.getApiGroupMessage(token, orderNo).get();
|
||||
JSONObject block = apiDataAchieve.getApiBlocksMessage(token, orderNo).get();
|
||||
Map<String, List<?>> listMap = apiTypeRealize.apiPlateDataChange(
|
||||
order,
|
||||
dataPlates,//板件生产信息
|
||||
dataParts,// 配件信息
|
||||
dataBody, // 柜体信息
|
||||
dataGoods, // 商品信息
|
||||
plate, // 板件明细
|
||||
dataModule,// 加工组信息
|
||||
block,// 板材数据
|
||||
orderNo,// 原始板编号
|
||||
orderId,
|
||||
organId);
|
||||
return success(orderService.importApiData(listMap));
|
||||
|
||||
//
|
||||
// return success(orderId);
|
||||
}
|
||||
// }
|
||||
|
||||
@PostMapping("/importFile")
|
||||
@Operation(summary = "生产单文件导入新增/导入板材")
|
||||
@@ -256,7 +287,7 @@ public class OrderController {
|
||||
})
|
||||
@OperateLog(type = IMPORT)
|
||||
@PreAuthorize("@ss.hasPermission('production:manager-list:create')")
|
||||
public void exportTestTwo(@RequestPart("file") MultipartFile file,
|
||||
public void exportFile(@RequestPart("file") MultipartFile file,
|
||||
@RequestParam(value = "type") Integer type,
|
||||
@RequestParam(value = "index", required = false, defaultValue = "0") Integer index,
|
||||
@RequestParam(value = "id", required = false, defaultValue = "0") Long orderId,
|
||||
|
||||
+4
-1
@@ -105,7 +105,10 @@ public interface OrderService {
|
||||
* @date 2024/3/30
|
||||
*/
|
||||
Long importApiData(Map<String, List<?>> listMap);
|
||||
void importApiData(String orderNo, Long orderId, Long organId) throws InterruptedException, ExecutionException;
|
||||
void importApiData(JSONObject order, JSONObject dataPlates, JSONObject dataParts
|
||||
, JSONObject dataBody, JSONObject dataGoods
|
||||
, JSONObject plates, JSONObject dataModule
|
||||
, JSONObject dataBlocks, String orderNo,Long orderId, Long organId);
|
||||
|
||||
/**
|
||||
* 文件数据导入
|
||||
|
||||
+13
-22
@@ -13,6 +13,7 @@ import com.cf.imes.framework.common.pojo.PageParam;
|
||||
import com.cf.imes.framework.mybatis.core.generator.SnowFlakeGenerator;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||
import com.cf.imes.framework.web.core.util.WebFrameworkUtils;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.*;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.product.OrderBodyRespVO;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.product.OrderRoomBodyRespVO;
|
||||
@@ -259,7 +260,9 @@ public class OrderServiceImpl implements OrderService {
|
||||
|
||||
orderBodyMapper.updateDeletedById(bodyIds, status, getUserOrganId(), orderId);// 柜体
|
||||
orderGroupMapper.updateDeletedById(bodyIds, status, getUserOrganId(), orderId);// 加工组
|
||||
plateMapper.updateDeletedById(plateDOList, status, getUserOrganId(), orderId);// 删小板
|
||||
if (plateDOList != null && plateDOList.size() != 0) {
|
||||
plateMapper.updateDeletedById(plateDOList, status, getUserOrganId(), orderId);// 删小板
|
||||
}
|
||||
// 删除大板
|
||||
List<PlateDO> goodsIdList = plateMapper.selectPlateNum(orderId, getUserOrganId());
|
||||
Map<Long, List<PlateDO>> goodsIdMap = goodsIdList.stream()
|
||||
@@ -358,35 +361,22 @@ public class OrderServiceImpl implements OrderService {
|
||||
@Override
|
||||
// @Async
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void importApiData(String orderNo, Long orderId, Long organId) throws InterruptedException, ExecutionException {
|
||||
public void importApiData(JSONObject order, JSONObject dataPlates, JSONObject dataParts
|
||||
, JSONObject dataBody, JSONObject dataGoods
|
||||
, JSONObject plates, JSONObject dataModule
|
||||
, JSONObject dataBlocks, String orderNo,Long orderId, Long organId) {
|
||||
// RequestContextHolder.setRequestAttributes(requestAttributes);
|
||||
|
||||
JSONObject oauth = apiDataAchieve.getApiToken(organId).get();
|
||||
String token = oauth.getJSONObject("info").getString("access_token");
|
||||
String shopId = oauth.getJSONObject("info").getString("shop_id");
|
||||
JSONObject order = apiDataAchieve.getApiOrder(token, shopId, orderNo).get();
|
||||
if (!order.getString("err_code").equals("0")) {
|
||||
throw exception(PLATE_PLAN_DATA_ERROR);
|
||||
}
|
||||
if (order.getJSONArray("data") == null) {
|
||||
throw exception(PLATE_PLAN_DATA_NULL);
|
||||
}
|
||||
JSONObject dataPlates = apiDataAchieve.getApiPlateProData(token, orderNo).get();
|
||||
JSONObject dataParts = apiDataAchieve.getApiPartsMessage(token, orderNo).get();
|
||||
JSONObject dataBody = apiDataAchieve.getApiBodyMessage(token, orderNo).get();
|
||||
JSONObject dataGoods = apiDataAchieve.getApiGoodsMessage(token, orderNo).get();
|
||||
JSONObject plate = apiDataAchieve.getApiPlateDetailMessage(token, orderNo).get();
|
||||
JSONObject dataModule = apiDataAchieve.getApiGroupMessage(token, orderNo).get();
|
||||
JSONObject block = apiDataAchieve.getApiBlocksMessage(token, orderNo).get();
|
||||
String nickName = SecurityFrameworkUtils.getLoginUser().getNickname();
|
||||
Map<String, List<?>> listMap = apiTypeRealize.apiPlateDataChange(
|
||||
order,
|
||||
dataPlates,//板件生产信息
|
||||
dataParts,// 配件信息
|
||||
dataBody, // 柜体信息
|
||||
dataGoods, // 商品信息
|
||||
plate, // 板件明细
|
||||
plates, // 板件明细
|
||||
dataModule,// 加工组信息
|
||||
block,// 板材数据
|
||||
dataBlocks,// 板材数据
|
||||
orderNo,// 原始板编号
|
||||
orderId,
|
||||
organId);
|
||||
@@ -395,7 +385,8 @@ public class OrderServiceImpl implements OrderService {
|
||||
if (orderDOS != null && orderDOS.size() > 0) {
|
||||
OrderDO orderDO = orderDOS.get(0);
|
||||
validateCustomOrderNoExists(orderDO.getCustomOrderNo());
|
||||
String nickName = SecurityFrameworkUtils.getLoginUser().getNickname();
|
||||
|
||||
orderDO.setCreator(nickName).setUpdater(nickName);
|
||||
if (orderDO.getSalesman() == null || orderDO.getSalesman().equals("")) {
|
||||
orderDO.setSalesman(nickName);
|
||||
}
|
||||
|
||||
+12
-15
@@ -55,10 +55,9 @@ public class ApiDataAchieve {
|
||||
@Async
|
||||
public Future<JSONObject> getApiPlateProData(String token, String orderNo) {
|
||||
JSONObject jsonPlatesData = new JSONObject();
|
||||
jsonPlatesData.put("order_no", orderNo);//生产单号需要传入赋值
|
||||
jsonPlatesData.put("order_no", "N" + orderNo);//生产单号需要传入赋值
|
||||
jsonPlatesData.put("format", "json");
|
||||
JSONObject dataPlates = apiDataProduction.getApiOrderMessage(token, jsonPlatesData);
|
||||
|
||||
return new AsyncResult<>(dataPlates);
|
||||
}
|
||||
|
||||
@@ -68,10 +67,10 @@ public class ApiDataAchieve {
|
||||
JSONObject jsonParts = new JSONObject();
|
||||
jsonParts.put("curr_page", 1);
|
||||
jsonParts.put("page_count", PARTS_PAGE_MAX);
|
||||
jsonParts.put("order_no", orderNo);
|
||||
jsonParts.put("order_no", "N" + orderNo);
|
||||
JSONObject parts = apiDataProduction.getApiOrderPartsMessage(token, jsonParts);
|
||||
if (!parts.getString("err_code").equals("0")) {
|
||||
log.error("配件数据获取错误" + orderNo);
|
||||
log.error("配件数据获取错误" + "N" + orderNo);
|
||||
throw exception(PARTS_DATA_ERROR);
|
||||
}
|
||||
JSONObject dataParts = new JSONObject();
|
||||
@@ -89,10 +88,10 @@ public class ApiDataAchieve {
|
||||
JSONObject jsonBody = new JSONObject();
|
||||
jsonBody.put("curr_page", 1);
|
||||
jsonBody.put("page_count", PARTS_PAGE_MAX);
|
||||
jsonBody.put("order_no", orderNo);
|
||||
jsonBody.put("order_no", "N" + orderNo);
|
||||
JSONObject body = apiDataProduction.getApiOrderBodyMessage(token, jsonBody);
|
||||
if (!body.getString("err_code").equals("0")) {
|
||||
log.error("柜体数据获取错误" + orderNo);
|
||||
log.error("柜体数据获取错误" + "N" + orderNo);
|
||||
throw exception(BODY_DATA_ERROR);
|
||||
}
|
||||
JSONObject dataBody = new JSONObject();
|
||||
@@ -110,10 +109,10 @@ public class ApiDataAchieve {
|
||||
JSONObject jsonGoods = new JSONObject();
|
||||
jsonGoods.put("curr_page", 1);
|
||||
jsonGoods.put("page_count", PARTS_PAGE_MAX);
|
||||
jsonGoods.put("order_no", orderNo);
|
||||
jsonGoods.put("order_no", "N" + orderNo);
|
||||
JSONObject goods = apiDataProduction.getApiOrderGoodsMessage(token, jsonGoods);
|
||||
if (!goods.getString("err_code").equals("0")) {
|
||||
log.error("商品信息转换失败" + orderNo);
|
||||
log.error("商品信息转换失败" + "N" + orderNo);
|
||||
throw exception(GOODS_DATA_ERROR);
|
||||
}
|
||||
JSONObject dataGoods = new JSONObject();
|
||||
@@ -131,10 +130,10 @@ public class ApiDataAchieve {
|
||||
JSONObject jsonPlates = new JSONObject();
|
||||
jsonPlates.put("curr_page", 1);
|
||||
jsonPlates.put("page_count", PARTS_PAGE_MAX);
|
||||
jsonPlates.put("order_no", orderNo);
|
||||
jsonPlates.put("order_no", "N" + orderNo);
|
||||
JSONObject plates = apiDataProduction.getApiBlocksDataMessage(token, jsonPlates);
|
||||
if (!plates.getString("err_code").equals("0")) {
|
||||
log.error("板材明细获取错误" + orderNo);
|
||||
log.error("板材明细获取错误" + "N" + orderNo);
|
||||
throw exception(PLATE_DATA_ERROR);
|
||||
}
|
||||
JSONObject plate = new JSONObject();
|
||||
@@ -150,7 +149,7 @@ public class ApiDataAchieve {
|
||||
@Async
|
||||
public Future<JSONObject> getApiGroupMessage(String token, String orderNo) {
|
||||
JSONObject jsonModule = new JSONObject();
|
||||
jsonModule.put("order_no", orderNo);
|
||||
jsonModule.put("order_no", "N" + orderNo);
|
||||
JSONObject dataModule = apiDataProduction.getApiModuleTypeDataMessage(token, jsonModule);
|
||||
return new AsyncResult<>(dataModule);
|
||||
}
|
||||
@@ -161,12 +160,10 @@ public class ApiDataAchieve {
|
||||
JSONObject jsonBlocks = new JSONObject();
|
||||
jsonBlocks.put("curr_page", 1);
|
||||
jsonBlocks.put("page_count", PARTS_PAGE_MAX);
|
||||
jsonBlocks.put("order_no", orderNo);
|
||||
jsonBlocks.put("order_no", "N" + orderNo);
|
||||
JSONObject blocks = apiDataProduction.getApiBlocksMessage(token, jsonBlocks);
|
||||
if (!blocks.getString("err_code").equals("0")) {
|
||||
// throw new IllegalArgumentException(String.valueOf(ErrorCodeConstants.PLATE_DATA_ERROR));
|
||||
log.error("板材数据获取错误" + orderNo);
|
||||
// throw exception(PLATE_DATA_ERROR);
|
||||
log.error("板材数据获取错误" + "N" + orderNo);
|
||||
}
|
||||
JSONObject block = new JSONObject();
|
||||
for (int i = 1; i <= blocks.getJSONObject("value").getInteger("PageCount"); i++) {
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ spring:
|
||||
# password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W
|
||||
slave: # 模拟从库,可根据自己需要修改
|
||||
name: imes_prod
|
||||
url: jdbc:mysql://192.168.1.205:8066/${spring.datasource.dynamic.datasource.slave.name}?allowMultiQueries=true&useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
||||
url: jdbc:mysql://192.168.1.205:3307/${spring.datasource.dynamic.datasource.slave.name}?allowMultiQueries=true&useUnicode=true&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
|
||||
# url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT # MySQL Connector/J 5.X 连接的示例
|
||||
# url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.slave.name} # PostgreSQL 连接的示例
|
||||
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
|
||||
|
||||
+34
-34
@@ -42,19 +42,19 @@ public class PlanServiceImplTest extends BaseDbUnitTest {
|
||||
@Resource
|
||||
private PlanMapper planMapper;
|
||||
|
||||
@Test
|
||||
public void testCreatePlan_success() {
|
||||
// 准备参数
|
||||
PlanSaveReqVO createReqVO = randomPojo(PlanSaveReqVO.class).setId(null);
|
||||
|
||||
// 调用
|
||||
Long planId = planService.createPlan(createReqVO);
|
||||
// 断言
|
||||
assertNotNull(planId);
|
||||
// 校验记录的属性是否正确
|
||||
PlanDO plan = planMapper.selectById(planId);
|
||||
assertPojoEquals(createReqVO, plan, "id");
|
||||
}
|
||||
// @Test
|
||||
// public void testCreatePlan_success() {
|
||||
// // 准备参数
|
||||
// PlanSaveReqVO createReqVO = randomPojo(PlanSaveReqVO.class).setId(null);
|
||||
//
|
||||
// // 调用
|
||||
// Long planId = planService.createPlan(createReqVO);
|
||||
// // 断言
|
||||
// assertNotNull(planId);
|
||||
// // 校验记录的属性是否正确
|
||||
// PlanDO plan = planMapper.selectById(planId);
|
||||
// assertPojoEquals(createReqVO, plan, "id");
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void testUpdatePlan_success() {
|
||||
@@ -82,28 +82,28 @@ public class PlanServiceImplTest extends BaseDbUnitTest {
|
||||
assertServiceException(() -> planService.updatePlan(updateReqVO), PLAN_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeletePlan_success() {
|
||||
// mock 数据
|
||||
PlanDO dbPlan = randomPojo(PlanDO.class);
|
||||
planMapper.insert(dbPlan);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
Long id = dbPlan.getId();
|
||||
// @Test
|
||||
// public void testDeletePlan_success() {
|
||||
// // mock 数据
|
||||
// PlanDO dbPlan = randomPojo(PlanDO.class);
|
||||
// planMapper.insert(dbPlan);// @Sql: 先插入出一条存在的数据
|
||||
// // 准备参数
|
||||
// Long id = dbPlan.getId();
|
||||
//
|
||||
// // 调用
|
||||
// planService.deletePlan(id);
|
||||
// // 校验数据不存在了
|
||||
// assertNull(planMapper.selectById(id));
|
||||
// }
|
||||
|
||||
// 调用
|
||||
planService.deletePlan(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(planMapper.selectById(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeletePlan_notExists() {
|
||||
// 准备参数
|
||||
Long id = randomLongId();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> planService.deletePlan(id), PLAN_NOT_EXISTS);
|
||||
}
|
||||
// @Test
|
||||
// public void testDeletePlan_notExists() {
|
||||
// // 准备参数
|
||||
// Long id = randomLongId();
|
||||
//
|
||||
// // 调用, 并断言异常
|
||||
// assertServiceException(() -> planService.deletePlan(id), PLAN_NOT_EXISTS);
|
||||
// }
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
|
||||
Reference in New Issue
Block a user