diff --git a/ktg-admin/src/test/BomRouteUnitTest.java b/ktg-admin/src/test/BomRouteUnitTest.java new file mode 100644 index 0000000..7ee3483 --- /dev/null +++ b/ktg-admin/src/test/BomRouteUnitTest.java @@ -0,0 +1,66 @@ +import com.alibaba.fastjson.JSON; +import com.ktg.RuoYiApplication; +import com.ktg.mes.md.domain.BomRoute; +import com.ktg.mes.md.service.IBomRouteService; +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.ArrayList; +import java.util.List; + +/** + * BOM管理单元测试 + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = RuoYiApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class BomRouteUnitTest { + @Autowired + private IBomRouteService bomRouteService; + + @Test + public void add() { + BomRoute bomRoute = new BomRoute(); + bomRoute.setBomCode("UNIT_TEST_002"); + bomRoute.setBomName("单元测试002"); + bomRoute.setBomVersion("V1.0"); + bomRoute.setMdItemId(75L); + bomRoute.setIsDefault("true"); + bomRoute.setMbbProduBomList(new ArrayList<>()); + bomRouteService.insertBomRoute(bomRoute); + System.out.println("add:" + bomRoute.getBomRouteId()); // 10 + } + + @Test + public void list() { + List list = bomRouteService.selectBomRouteList(new BomRoute()); + System.out.println("list:" + JSON.toJSONString(list)); + } + + @Test + public void getInfo() { + System.out.println("getInfo:" + JSON.toJSONString(bomRouteService.selectBomRouteByBomRouteId(10L))); + } + + @Test + public void edit() { + BomRoute bomRoute = new BomRoute(); + bomRoute.setBomRouteId(10L); + bomRoute.setBomName("单元测试001"); + bomRoute.setBomVersion("V1.0"); + bomRoute.setMdItemId(75L); + bomRoute.setIsDefault("true"); + bomRoute.setMbbProduBomList(new ArrayList<>()); + int count = bomRouteService.updateBomRoute(bomRoute); + System.out.println("edit:" + count); + } + + @Test + public void remove() { + Long[] ids = {10L}; + int count = bomRouteService.deleteBomRouteByBomRouteIds(ids); + System.out.println("remove:" + count); + } +} diff --git a/ktg-admin/src/test/MdItemUnitTest.java b/ktg-admin/src/test/MdItemUnitTest.java new file mode 100644 index 0000000..1645903 --- /dev/null +++ b/ktg-admin/src/test/MdItemUnitTest.java @@ -0,0 +1,149 @@ +import com.alibaba.fastjson.JSON; +import com.ktg.RuoYiApplication; +import com.ktg.common.core.domain.entity.ItemType; +import com.ktg.common.utils.StringUtils; +import com.ktg.mes.md.domain.MdItem; +import com.ktg.mes.md.domain.MdUnitMeasure; +import com.ktg.mes.md.mapper.ItemTypeMapper; +import com.ktg.mes.md.service.IMdItemService; +import com.ktg.mes.md.service.IMdUnitMeasureService; +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.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 角色管理单元测试 + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = RuoYiApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class MdItemUnitTest { + @Autowired + private IMdItemService mdItemService; + + @Autowired + private ItemTypeMapper itemTypeMapper; + + @Autowired + private IMdUnitMeasureService mdUnitMeasureService; + + @Test + public void add() { + MdItem mdItem = new MdItem(); + mdItem.setItemTypeId(288L); + mdItem.setItemCode("IF20241107002"); + mdItem.setItemName("单元测试物料002"); + mdItem.setStandardNumber(10); + mdItem.setEnableFlag("Y"); + mdItem.setSafeStockFlag("N"); + mdItem.setMinStock((double) 0); + mdItem.setMaxStock((double) 0); + mdItem.setAttr1(5); + mdItem.setUnitOfMeasure("PCS"); + ItemType type = itemTypeMapper.selectItemTypeById(mdItem.getItemTypeId()); + if (StringUtils.isNotNull(type)) { + mdItem.setItemTypeCode(type.getItemTypeCode()); + mdItem.setItemTypeName(type.getItemTypeName()); + mdItem.setItemOrProduct(type.getItemOrProduct()); + } + MdUnitMeasure measure = mdUnitMeasureService.selectMdUnitByCode(mdItem.getUnitOfMeasure()); + if (StringUtils.isNotNull(measure)) { + mdItem.setUnitName(measure.getMeasureName()); + } + mdItemService.insertMdItem(mdItem); + System.out.println("add:" + mdItem.getItemId()); // 102 + } + + @Test + public void list() { + List list = mdItemService.selectMdItemList(new MdItem()); + System.out.println("list:" + JSON.toJSONString(list)); + } + + @Test + public void getInfo() { + System.out.println("getInfo:" + JSON.toJSONString(mdItemService.selectMdItemById(102L))); + } + + @Test + public void edit() { + MdItem mdItem = new MdItem(); + mdItem.setItemId(102L); + mdItem.setItemTypeId(288L); + mdItem.setItemName("单元测试物料001"); + mdItem.setStandardNumber(10); + mdItem.setEnableFlag("Y"); + mdItem.setSafeStockFlag("N"); + mdItem.setMinStock((double) 0); + mdItem.setMaxStock((double) 0); + mdItem.setAttr1(5); + mdItem.setUnitOfMeasure("PCS"); + ItemType type = itemTypeMapper.selectItemTypeById(mdItem.getItemTypeId()); + if (StringUtils.isNotNull(type)) { + mdItem.setItemTypeCode(type.getItemTypeCode()); + mdItem.setItemTypeName(type.getItemTypeName()); + mdItem.setItemOrProduct(type.getItemOrProduct()); + } + if (StringUtils.isNotNull(mdItem.getSafeStockFlag()) && "N".equals(mdItem.getSafeStockFlag())) { + mdItem.setMinStock(0D); + mdItem.setMaxStock(0D); + } + MdUnitMeasure measure = mdUnitMeasureService.selectMdUnitByCode(mdItem.getUnitOfMeasure()); + if (StringUtils.isNotNull(measure)) { + mdItem.setUnitName(measure.getMeasureName()); + } + int count = mdItemService.updateMdItem(mdItem); + System.out.println("edit:" + count); + } + + @Test + public void remove() { + Long[] ids = {102L}; + int count = mdItemService.deleteByItemIds(ids); + System.out.println("remove:" + count); + } + + @Test + public void selectItem() { + MdItem mdItem = new MdItem(); + mdItem.setItemOrProduct("ITEM"); + List list = mdItemService.selectMdItemList(mdItem); + List> result = new ArrayList<>(); + list.forEach(item -> { + Map map = new HashMap<>(); + map.put("gid", item.getItemId().toString()); + map.put("code", item.getItemCode()); + map.put("safeInventory", item.getMinStock().toString().split("\\.")[0]); + map.put("pmbbMeasure", item.getItemTypeName()); + map.put("name", item.getItemName()); + map.put("count", mdItemService.getMdItemCount(item.getItemId()).toString()); + result.add(map); + }); + System.out.println("selectItem:" + JSON.toJSONString(list)); + } + + @Test + public void selectProduct() { + MdItem mdItem = new MdItem(); + mdItem.setItemOrProduct("PRODUCT"); + List list = mdItemService.selectMdItemList(mdItem); + List> result = new ArrayList<>(); + list.forEach(item -> { + Map map = new HashMap<>(); + map.put("gid", item.getItemId().toString()); + map.put("code", item.getItemCode()); + map.put("safeInventory", item.getMinStock().toString().split("\\.")[0]); + map.put("pmbbMeasure", item.getItemTypeName()); + map.put("name", item.getItemName()); + map.put("count", mdItemService.getMdItemCount(item.getItemId()).toString()); + result.add(map); + }); + System.out.println("selectProduct:" + JSON.toJSONString(list)); + } +} diff --git a/ktg-admin/src/test/MdUnitMeasureUnitTest.java b/ktg-admin/src/test/MdUnitMeasureUnitTest.java new file mode 100644 index 0000000..6b5f56b --- /dev/null +++ b/ktg-admin/src/test/MdUnitMeasureUnitTest.java @@ -0,0 +1,78 @@ +import com.alibaba.fastjson.JSON; +import com.ktg.RuoYiApplication; +import com.ktg.mes.md.domain.MdUnitMeasure; +import com.ktg.mes.md.service.IMdUnitMeasureService; +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 MdUnitMeasureUnitTest { + @Autowired + private IMdUnitMeasureService mdUnitMeasureService; + + @Test + public void add() { + MdUnitMeasure mdUnitMeasure = new MdUnitMeasure(); + mdUnitMeasure.setMeasureCode("打"); + mdUnitMeasure.setMeasureName("一打"); + mdUnitMeasure.setPrimaryFlag("Y"); + mdUnitMeasure.setEnableFlag("Y"); + mdUnitMeasureService.insertMdUnitMeasure(mdUnitMeasure); + System.out.println("add:" + mdUnitMeasure.getMeasureId()); // 225 + } + + @Test + public void list() { + List list = mdUnitMeasureService.selectMdUnitMeasureList(new MdUnitMeasure()); + System.out.println("list:" + JSON.toJSONString(list)); + } + + @Test + public void getInfo() { + System.out.println("getInfo:" + JSON.toJSONString(mdUnitMeasureService.selectMdUnitMeasureByMeasureId(225L))); + } + + @Test + public void edit() { + MdUnitMeasure mdUnitMeasure = new MdUnitMeasure(); + mdUnitMeasure.setMeasureId(225L); + mdUnitMeasure.setMeasureCode("dozen"); + mdUnitMeasure.setMeasureName("一打"); + mdUnitMeasure.setPrimaryFlag("Y"); + mdUnitMeasure.setEnableFlag("Y"); + int count = mdUnitMeasureService.updateMdUnitMeasure(mdUnitMeasure); + System.out.println("edit:" + count); + } + + @Test + public void remove() { + Long[] ids = {225L}; + int count = mdUnitMeasureService.deleteMdUnitMeasureByMeasureIds(ids); + System.out.println("remove:" + count); + } + + @Test + public void listPrimary() { + MdUnitMeasure mdUnitMeasure = new MdUnitMeasure(); + mdUnitMeasure.setPrimaryFlag("Y"); + List list = mdUnitMeasureService.selectMdUnitMeasureList(mdUnitMeasure); + System.out.println("listPrimary:" + JSON.toJSONString(list)); + } + + @Test + public void selectAll() { + MdUnitMeasure mdUnitMeasure = new MdUnitMeasure(); + mdUnitMeasure.setEnableFlag("Y"); + List list = mdUnitMeasureService.selectMdUnitMeasureList(mdUnitMeasure); + System.out.println("selectAll:" + JSON.toJSONString(list)); + } +} diff --git a/ktg-admin/src/test/SysRoleUnitTest.java b/ktg-admin/src/test/SysRoleUnitTest.java new file mode 100644 index 0000000..c1958dd --- /dev/null +++ b/ktg-admin/src/test/SysRoleUnitTest.java @@ -0,0 +1,122 @@ +import com.alibaba.fastjson.JSON; +import com.ktg.RuoYiApplication; +import com.ktg.common.core.domain.entity.SysRole; +import com.ktg.common.core.domain.entity.SysUser; +import com.ktg.system.domain.SysUserRole; +import com.ktg.system.service.ISysRoleService; +import com.ktg.system.service.ISysUserService; +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 SysRoleUnitTest { + @Autowired + private ISysRoleService roleService; + + @Autowired + private ISysUserService userService; + + @Test + public void add() { + SysRole sysRole = new SysRole(); + sysRole.setRoleName("测试角色112"); + sysRole.setRoleKey("TEST_ROLE_112"); + sysRole.setRoleSort("0"); + sysRole.setStatus("0"); + sysRole.setMenuIds(new Long[]{2394L}); + sysRole.setMenuCheckStrictly(true); + sysRole.setDeptCheckStrictly(true); + roleService.insertRole(sysRole); + System.out.println("add:" + sysRole.getRoleId()); // 108 + } + + @Test + public void list() { + List list = roleService.selectRoleList(new SysRole()); + System.out.println("list:" + JSON.toJSONString(list)); + } + + @Test + public void getInfo() { + System.out.println("getInfo:" + JSON.toJSONString(roleService.selectRoleById(108L))); + } + + @Test + public void edit() { + SysRole sysRole = new SysRole(); + sysRole.setRoleId(108L); + sysRole.setRoleName("测试角色111"); + sysRole.setRoleKey("TEST_ROLE_111"); + sysRole.setRoleSort("0"); + sysRole.setStatus("0"); + sysRole.setMenuIds(new Long[]{2394L}); + sysRole.setMenuCheckStrictly(true); + sysRole.setDeptCheckStrictly(true); + int count = roleService.updateRole(sysRole); + System.out.println("edit:" + count); + } + + @Test + public void remove() { + Long[] ids = {108L}; + int count = roleService.deleteRoleByIds(ids); + System.out.println("remove:" + count); + } + + @Test + public void changeStatus() { + SysRole sysRole = new SysRole(); + sysRole.setRoleId(108L); + sysRole.setStatus("0"); + int count = roleService.updateRoleStatus(sysRole); + System.out.println("changeStatus:" + count); + } + + @Test + public void optionselect() { + List list = roleService.selectRoleAll(); + System.out.println("optionselect:" + JSON.toJSONString(list)); + } + + @Test + public void allocatedList() { + List list = userService.selectAllocatedList(new SysUser()); + System.out.println("allocatedList:" + JSON.toJSONString(list)); + } + + @Test + public void unallocatedList() { + List list = userService.selectUnallocatedList(new SysUser()); + System.out.println("unallocatedList:" + JSON.toJSONString(list)); + } + + @Test + public void cancelAuthUser() { + SysUserRole sysUserRole = new SysUserRole(); + sysUserRole.setUserId(117L); + sysUserRole.setRoleId(104L); + int count = roleService.deleteAuthUser(sysUserRole); + System.out.println("cancelAuthUser:" + count); + } + + @Test + public void cancelAuthUserAll() { + int count = roleService.deleteAuthUsers(104L, new Long[]{116L, 117L}); + System.out.println("cancelAuthUserAll:" + count); + } + + @Test + public void selectAuthUserAll() { + int count = roleService.insertAuthUsers(104L, new Long[]{116L, 117L}); + System.out.println("selectAuthUserAll:" + count); + } +} diff --git a/ktg-admin/src/test/UcmCtBaseUnitTest.java b/ktg-admin/src/test/UcmCtBaseUnitTest.java new file mode 100644 index 0000000..c401dc1 --- /dev/null +++ b/ktg-admin/src/test/UcmCtBaseUnitTest.java @@ -0,0 +1,61 @@ +import com.alibaba.fastjson.JSON; +import com.ktg.RuoYiApplication; +import com.ktg.mes.wm.domain.UcmCtBase; +import com.ktg.mes.wm.service.IUcmCtBaseService; +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.ArrayList; +import java.util.List; + +/** + * 料箱管理单元测试 + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = RuoYiApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class UcmCtBaseUnitTest { + @Autowired + private IUcmCtBaseService ucmCtBaseService; + + @Test + public void add() { + UcmCtBase ucmCtBase = new UcmCtBase(); + ucmCtBase.setCode("UNIT_TEST_02"); + ucmCtBase.setType("0"); + ucmCtBase.setBaseKnifeList(new ArrayList<>()); + ucmCtBaseService.insertUcmCtBase(ucmCtBase); + System.out.println("add:" + ucmCtBase.getCtBaseId()); // 13 + } + + @Test + public void list() { + List list = ucmCtBaseService.selectUcmCtBaseList(new UcmCtBase()); + System.out.println("list:" + JSON.toJSONString(list)); + } + + @Test + public void getInfo() { + System.out.println("getInfo:" + JSON.toJSONString(ucmCtBaseService.selectUcmCtBaseByCtBaseId("13"))); + } + + @Test + public void edit() { + UcmCtBase ucmCtBase = new UcmCtBase(); + ucmCtBase.setCtBaseId("13"); + ucmCtBase.setCode("UNIT_TEST_01"); + ucmCtBase.setType("0"); + ucmCtBase.setBaseKnifeList(new ArrayList<>()); + int count = ucmCtBaseService.updateUcmCtBase(ucmCtBase); + System.out.println("edit:" + count); + } + + @Test + public void remove() { + String[] ids = {"13"}; + int count = ucmCtBaseService.deleteUcmCtBaseByCtBaseIds(ids); + System.out.println("remove:" + count); + } +} diff --git a/ktg-admin/src/test/WmStorageLocationUnitTest.java b/ktg-admin/src/test/WmStorageLocationUnitTest.java index 9f13d83..6921570 100644 --- a/ktg-admin/src/test/WmStorageLocationUnitTest.java +++ b/ktg-admin/src/test/WmStorageLocationUnitTest.java @@ -11,7 +11,7 @@ import org.springframework.test.context.junit4.SpringRunner; import java.util.List; /** - * 库区管理 + * 库区管理单元测试 */ @RunWith(SpringRunner.class) @SpringBootTest(classes = RuoYiApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) diff --git a/ktg-admin/src/test/WmWarehouseUnitTest.java b/ktg-admin/src/test/WmWarehouseUnitTest.java index 3a0dbe5..46b624f 100644 --- a/ktg-admin/src/test/WmWarehouseUnitTest.java +++ b/ktg-admin/src/test/WmWarehouseUnitTest.java @@ -11,7 +11,7 @@ import org.springframework.test.context.junit4.SpringRunner; import java.util.List; /** - * 库房管理 + * 库房管理单元测试 */ @RunWith(SpringRunner.class) @SpringBootTest(classes = RuoYiApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)