diff --git a/ktg-admin/src/test/BaseKnifeTest.java b/ktg-admin/src/test/BaseKnifeTest.java index 0b9b01e..c69c14f 100644 --- a/ktg-admin/src/test/BaseKnifeTest.java +++ b/ktg-admin/src/test/BaseKnifeTest.java @@ -8,6 +8,9 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.context.SecurityContext; +import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.bind.annotation.RequestBody; @@ -15,6 +18,8 @@ import org.springframework.web.bind.annotation.RequestBody; import javax.servlet.http.HttpServletResponse; import java.util.List; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.mockito.Mockito.mock; @RunWith(SpringRunner.class) @@ -108,10 +113,28 @@ public class BaseKnifeTest { */ @Test public void scrapKnifeTest(){ + // 创建一个 Authentication 对象 + UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken( + "star", "123456"); + + // 将 Authentication 对象放入 SecurityContext + SecurityContext context = SecurityContextHolder.createEmptyContext(); + context.setAuthentication(authentication); + SecurityContextHolder.setContext(context); + + // 验证 SecurityContext 中是否存储了 Authentication 对象 + assertNotNull(SecurityContextHolder.getContext().getAuthentication()); + assertEquals("star", SecurityContextHolder.getContext().getAuthentication().getName()); WmsZdTask wmsZdTask = new WmsZdTask(); wmsZdTask.setAttr1(8L); wmsZdTask.setmProductId(99L); - + wmsZdTask.setCode("280IF20241102004"); + wmsZdTask.setName("磨齿[测试刀具01]"); + wmsZdTask.setmProductId(99L); + wmsZdTask.setProductIdQty(4); + wmsZdTask.setQtyOk(4); + wmsZdTask.setAttr2("测试刀具01"); + wmsZdTask.setAttr3("XBKKW_VIRTUAL"); AjaxResult ajaxResult = baseKnifeController.zdTask(wmsZdTask); System.out.println(ajaxResult.toString()); } diff --git a/ktg-admin/src/test/WmsInPlanTest.java b/ktg-admin/src/test/WmsInPlanTest.java new file mode 100644 index 0000000..e18390d --- /dev/null +++ b/ktg-admin/src/test/WmsInPlanTest.java @@ -0,0 +1,90 @@ +import com.ktg.RuoYiApplication; +import com.ktg.mes.wm.domain.WmsInPlan; +import com.ktg.mes.wm.service.IWmsInPlanService; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import java.util.List; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = RuoYiApplication.class,webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class WmsInPlanTest { + @Autowired + private IWmsInPlanService wmsInPlanService; + + /** + * 查询入库计划列表 + */ + @Test + public void selectWmsInPlanList(){ + List wmsInPlans = wmsInPlanService.selectWmsInPlanList(null); + for (WmsInPlan wmsInPlan : wmsInPlans) { + System.out.println(wmsInPlan.toString()); + } + } + + /** + * 查询入库计划详情 + */ + @Test + public void selectWmsInPlanById(){ + WmsInPlan wmsInPlan = wmsInPlanService.selectWmsInPlanByPlanId("39"); + System.out.println(wmsInPlan.toString()); + } + + /** + * 新增入库计划 + */ + @Test + public void insertWmsInPlan() { + WmsInPlan wmsInPlan = new WmsInPlan(); + wmsInPlan.setState("0"); + wmsInPlan.setSourceType("SGLR"); + wmsInPlan.setWareId("10"); + wmsInPlan.setCellCode("A0089"); + wmsInPlan.setRelBillCode("123456"); + wmsInPlan.setPlanId("8"); + wmsInPlan.setPlanCode("入库0789"); + int i = wmsInPlanService.insertWmsInPlan(wmsInPlan); + System.out.println(i); + } + + /** + * 修改入库计划 + */ + @Test + public void UpdateWmsInPlan() { + WmsInPlan wmsInPlan = new WmsInPlan(); + wmsInPlan.setPlanId("41"); + wmsInPlan.setState("0"); + wmsInPlan.setSourceType("SGLR"); + wmsInPlan.setWareId("10"); + wmsInPlan.setCellCode("A0089"); + wmsInPlan.setRelBillCode("123456"); + wmsInPlan.setPlanId("8"); + wmsInPlan.setPlanCode("入库0889"); + int i = wmsInPlanService.updateWmsInPlan(wmsInPlan); + System.out.println(i); + } + /** + * 删除入库计划 + */ + @Test + public void deleteWmsInPlan() { + int i = wmsInPlanService.deleteWmsInPlanByPlanId("41"); + System.out.println(i); + } + + /** + * 批量删除入库计划 + */ + @Test + public void deleteWmsInPlans() { + String[] strings=new String[]{"42","44"}; + int i = wmsInPlanService.deleteWmsInPlanByPlanIds(strings); + System.out.println(i); + } +} diff --git a/ktg-admin/src/test/WmsInTaskTest.java b/ktg-admin/src/test/WmsInTaskTest.java new file mode 100644 index 0000000..f58e90d --- /dev/null +++ b/ktg-admin/src/test/WmsInTaskTest.java @@ -0,0 +1,93 @@ +import com.ktg.RuoYiApplication; +import com.ktg.mes.wm.domain.WmsInTask; +import com.ktg.mes.wm.service.IWmsInTaskService; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import java.util.List; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = RuoYiApplication.class,webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class WmsInTaskTest { + @Autowired + private IWmsInTaskService wmsInTaskService; + + /** + * 查询入库任务列表 + */ + @Test + public void selectWmsInTask(){ + List wmsInTasks = wmsInTaskService.selectWmsInTaskList(null); + for (WmsInTask wmsInTask : wmsInTasks) { + System.out.println(wmsInTask.toString()); + } + } + + /** + * 查询入库任务详情 + */ + @Test + public void selectWmsInTaskById(){ + WmsInTask wmsInTask = wmsInTaskService.selectWmsInTaskById("39"); + System.out.println(wmsInTask.toString()); + } + + /** + * 新增入库任务 + */ + @Test + public void insertWmsInTask() { + WmsInTask wmsInTask = new WmsInTask(); + wmsInTask.setTaskInCode("RKT202411020898"); + wmsInTask.setPlanInId("37"); + wmsInTask.setTaskInQuantity(4); + wmsInTask.setCellTgt(213L); + wmsInTask.setBatch("10011"); + wmsInTask.setPlanTypeId("9"); + wmsInTask.setPlanInCode("280IF2024110200451"); + wmsInTask.setMaterialCode("IF20241102004"); + int i = wmsInTaskService.insertWmsInTask(wmsInTask); + System.out.println(i); + } + /** + * 修改入库任务 + */ + @Test + public void UpdateWmsInTask() { + WmsInTask wmsInTask = new WmsInTask(); + wmsInTask.setId("48"); + wmsInTask.setTaskInCode("RKT20241102085698"); + wmsInTask.setPlanInId("37"); + wmsInTask.setTaskInQuantity(4); + wmsInTask.setCellTgt(213L); + wmsInTask.setBatch("10011"); + wmsInTask.setPlanTypeId("9"); + wmsInTask.setPlanInCode("280IF2024110200451"); + wmsInTask.setMaterialCode("IF20241102004"); + int i = wmsInTaskService.updateWmsInTask(wmsInTask); + System.out.println(i); + } + + + /** + * 删除入库任务 + */ + @Test + public void deleteWmsInTask() { + int i = wmsInTaskService.deleteWmsInTaskById("48"); + System.out.println(i); + } + + /** + * 批量删除入库任务 + */ + @Test + public void deleteWmsInTasks() { + String[] strings = {"49","50"}; + int i = wmsInTaskService.deleteWmsInTaskByIds(strings); + System.out.println(i); + } +} diff --git a/ktg-admin/src/test/WmsOutPlanTest.java b/ktg-admin/src/test/WmsOutPlanTest.java new file mode 100644 index 0000000..2c8f6e4 --- /dev/null +++ b/ktg-admin/src/test/WmsOutPlanTest.java @@ -0,0 +1,106 @@ +import com.ktg.RuoYiApplication; +import com.ktg.mes.md.domain.WmsOutPlan; +import com.ktg.mes.md.service.IWmsOutPlanService; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import java.util.HashMap; +import java.util.List; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = RuoYiApplication.class,webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class WmsOutPlanTest { + @Autowired + private IWmsOutPlanService wmsOutPlanService; + + /** + * 出库计划新增 + */ + @Test + public void saveWmsOutPlanTest(){ + WmsOutPlan wmsOutPlan = new WmsOutPlan(); + wmsOutPlan.setPlanCode("CKJH202411020949"); + wmsOutPlan.setWmsBusinessTypeId(12L); + wmsOutPlan.setPlanType("SGLR"); + wmsOutPlan.setPlanState("1"); + int i = wmsOutPlanService.insertWmsOutPlan(wmsOutPlan); + System.out.println(i); + } + + /** + * 出库计划修改 + */ + @Test + public void updateWmsOutPlanTest() { + WmsOutPlan wmsOutPlan = new WmsOutPlan(); + wmsOutPlan.setWmsOutPlanId(27L); + wmsOutPlan.setPlanCode("CKJH202411020949"); + wmsOutPlan.setWmsBusinessTypeId(12L); + wmsOutPlan.setPlanType("SGLR"); + wmsOutPlan.setPlanState("0"); + int i = wmsOutPlanService.updateWmsOutPlan(wmsOutPlan); + System.out.println(i); + } + + /** + * 获取出库详情 + */ + @Test + public void getWmsOutPlanTest() { + WmsOutPlan wmsOutPlan = wmsOutPlanService.selectWmsOutPlanByWmsOutPlanId(27L); + System.out.println(wmsOutPlan.toString()); + } + + /** + * 获取出库详情列表 + */ + @Test + public void getWmsOutPlanListTest() { + List wmsOutPlans = wmsOutPlanService.selectWmsOutPlanList(null); + for (WmsOutPlan wmsOutPlan : wmsOutPlans) { + System.out.println(wmsOutPlan.toString()); + } + } + + /** + * 出库计划执行 + */ + @Test + public void runWmsOutPlanTest() { + boolean b = wmsOutPlanService.runWmsOutPlan(new Long[]{27L}); + System.out.println(b); + } + + /** + * 出库计划删除 + */ + @Test + public void deleteWmsOutPlanTest() { + int i = wmsOutPlanService.deleteWmsOutPlanByWmsOutPlanId(27L); + System.out.println(i); + } + + /** + * 批量删除出库任务 + */ + @Test + public void deleteWmsOutPlanListTest() { + int i = wmsOutPlanService.deleteWmsOutPlanByWmsOutPlanIds(new Long[]{29L,28L}); + System.out.println(i); + } + + /** + * 查询出库计划管理列表携带出库明细 + */ + @Test + public void selectWmsOutPlanDetailEntityListTest() { + List> wmsOutPlanDetailEntityList = wmsOutPlanService.selectWmsOutPlanDetailEntityList(null); + for (HashMap map : wmsOutPlanDetailEntityList) { + System.out.println(map.toString()); + } + } + +} diff --git a/ktg-admin/src/test/WmsOutTaskTest.java b/ktg-admin/src/test/WmsOutTaskTest.java new file mode 100644 index 0000000..2c7b0db --- /dev/null +++ b/ktg-admin/src/test/WmsOutTaskTest.java @@ -0,0 +1,125 @@ +import com.ktg.RuoYiApplication; +import com.ktg.mes.md.domain.WmsOutTask; +import com.ktg.mes.md.service.IWmsOutTaskService; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import java.util.List; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = RuoYiApplication.class,webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class WmsOutTaskTest { + public static final String 测试物料 = "测试物料"; + @Autowired + private IWmsOutTaskService wmsOutTaskService; + + /** + * 新增出库任务 + */ + @Test + public void add() { + WmsOutTask wmsOutTask = new WmsOutTask(); + wmsOutTask.setWmsOutPlanId(26L); + wmsOutTask.setWmsOutPlanCode("CKJH202411020949"); + wmsOutTask.setWmsOutPlanDetailId(55L); + wmsOutTask.setWmsBusinessTypeId(12L); + wmsOutTask.setTaskCode("CK202411020949"); + wmsOutTask.setTaskNumber(4); + wmsOutTask.setOutNumber(4); + wmsOutTask.setWmStorageAreaId(213L); + wmsOutTask.setBatchNum("1"); + wmsOutTask.setMdItemId(99L); + wmsOutTask.setMdItemCode("IF202411020045"); + wmsOutTask.setMdItemName("测试物料"); + wmsOutTask.setMdItemUnit("个"); + wmsOutTask.setTaskState("0"); + wmsOutTaskService.insertWmsOutTask(wmsOutTask); + } + + /** + * 修改出库任务 + */ + @Test + public void Update() { + WmsOutTask wmsOutTask = new WmsOutTask(); + wmsOutTask.setWmsOutTaskId(33L); + wmsOutTask.setWmsOutPlanId(26L); + wmsOutTask.setWmsOutPlanCode("shjdhjshjhdjsjk"); + wmsOutTask.setWmsOutPlanDetailId(55L); + wmsOutTask.setWmsBusinessTypeId(12L); + wmsOutTask.setTaskCode("CK202411020949"); + wmsOutTask.setTaskNumber(4); + wmsOutTask.setOutNumber(4); + wmsOutTask.setWmStorageAreaId(213L); + wmsOutTask.setBatchNum("1"); + wmsOutTask.setMdItemId(99L); + wmsOutTask.setMdItemCode("IF202411020045"); + wmsOutTask.setMdItemName(测试物料); + wmsOutTask.setMdItemUnit("个"); + wmsOutTask.setTaskState("0"); + wmsOutTaskService.updateWmsOutTask(wmsOutTask); + } + + /** + * 查询出库任务列表 + */ + @Test + public void getList() { + List wmsOutTasks = wmsOutTaskService.selectWmsOutTaskList(new WmsOutTask()); + for (WmsOutTask wmsOutTask : wmsOutTasks) + System.out.println(wmsOutTask); + } + + /** + * 查询出库任务详情 + */ + @Test + public void getInfo() { + WmsOutTask wmsOutTask = wmsOutTaskService.selectWmsOutTaskByWmsOutTaskId(33L); + System.out.println(wmsOutTask); + } + + /** + * 手动出库 + */ + @Test + public void runWmsOutTask() { + Long[] longs = {33L}; + boolean b = wmsOutTaskService.runWmsOutTask(longs); + System.out.println(b); + } + + /** + * wcs下发任务 + */ + @Test + public void wcsSendTask() { + Long[] longs = {33L}; + boolean b = wmsOutTaskService.autoRunWmsOutTask(longs); + System.out.println(b); + } + + /** + * 删除出库任务 + */ + @Test + public void delete() { + int i = wmsOutTaskService.deleteWmsOutTaskByWmsOutTaskId(33L); + System.out.println(i); + } + + /** + * 批量删除任务 + */ + @Test + public void deleteBatch() { + Long[] longs = {35L, 34L}; + int i = wmsOutTaskService.deleteWmsOutTaskByWmsOutTaskIds(longs); + System.out.println(i); + } + + +} diff --git a/ktg-admin/src/test/WmsZdTaskTest.java b/ktg-admin/src/test/WmsZdTaskTest.java new file mode 100644 index 0000000..624033e --- /dev/null +++ b/ktg-admin/src/test/WmsZdTaskTest.java @@ -0,0 +1,93 @@ +import com.ktg.RuoYiApplication; +import com.ktg.mes.wm.domain.WmsZdTask; +import com.ktg.mes.wm.service.IWmsZdTaskService; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import java.util.List; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = RuoYiApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class WmsZdTaskTest { + @Autowired + private IWmsZdTaskService wmsZdTaskService; + + /** + * 查询组装任务 + */ + + @Test + public void selectWmsZdTaskByWmsZdTaskId() { + WmsZdTask wmsZdTask = wmsZdTaskService.selectWmsZdTaskByWmsZdTaskId("17"); + System.out.println(wmsZdTask.toString()); + } + + /** + * 查询组装任务列表 + */ + @Test + public void selectWmsZdTaskList() { + List wmsZdTasks = wmsZdTaskService.selectWmsZdTaskList(new WmsZdTask()); + for (WmsZdTask wmsZdTask : wmsZdTasks) { + System.out.println(wmsZdTask.toString()); + } + } + + /** + * 新增组装任务 + */ + @Test + public void insertWmsZdTask() { + WmsZdTask wmsZdTask = new WmsZdTask(); + wmsZdTask.setCode("280IF20241102008"); + wmsZdTask.setName("测试刀具"); + wmsZdTask.setQty(10); + wmsZdTask.setmProductId(99L); + wmsZdTask.setProductIdQty(4); + wmsZdTask.setQtyOk(0); + wmsZdTask.setAttr1(0L); + wmsZdTask.setAttr2("螺丝"); + int i = wmsZdTaskService.insertWmsZdTask(wmsZdTask); + System.out.println(i); + } + + /** + * 修改组装任务 + */ + @Test + public void UpdateWmsZdTask() { + WmsZdTask wmsZdTask = new WmsZdTask(); + wmsZdTask.setWmsZdTaskId("18"); + wmsZdTask.setCode("280IF20241102008"); + wmsZdTask.setName("测试"); + wmsZdTask.setQty(10); + wmsZdTask.setmProductId(99L); + wmsZdTask.setProductIdQty(4); + wmsZdTask.setQtyOk(0); + wmsZdTask.setAttr1(0L); + wmsZdTask.setAttr2("螺丝"); + int i = wmsZdTaskService.updateWmsZdTask(wmsZdTask); + System.out.println(i); + } + + /** + * 删除组装任务 + */ + @Test + public void deleteWmsZdTaskByWmsZdTaskId() { + int i = wmsZdTaskService.deleteWmsZdTaskByWmsZdTaskId("18"); + System.out.println(i); + } + + /** + * 批量删除组装任务 + */ + @Test + public void deleteWmsZdTaskByWmsZdTaskIds() { + int i = wmsZdTaskService.deleteWmsZdTaskByWmsZdTaskIds(new String[]{"19","20"}); + System.out.println(i); + } +}