From 2974922d416c353b6f9af3798f5075d69c32d806 Mon Sep 17 00:00:00 2001 From: star <2755454208@qq.com> Date: Thu, 7 Nov 2024 08:39:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ktg-admin/src/test/BaseKnifeTest.java | 122 ++++++++++++++++++ .../src/test/InventoryTaskResultTest.java | 114 ++++++++++++++++ ktg-admin/src/test/InventoryTaskTest.java | 93 ++++++++++++- .../controller/InventoryTaskController.java | 4 + .../inventoryRequestController.java | 4 + .../ktg/mes/qc/domain/InventoryRequest.java | 21 ++- .../impl/InventoryRequestServiceImpl.java | 3 +- .../impl/InventoryTaskServiceImpl.java | 4 +- .../resources/mapper/md/BaseKnifeMapper.xml | 2 +- 9 files changed, 358 insertions(+), 9 deletions(-) create mode 100644 ktg-admin/src/test/BaseKnifeTest.java create mode 100644 ktg-admin/src/test/InventoryTaskResultTest.java diff --git a/ktg-admin/src/test/BaseKnifeTest.java b/ktg-admin/src/test/BaseKnifeTest.java new file mode 100644 index 0000000..0b9b01e --- /dev/null +++ b/ktg-admin/src/test/BaseKnifeTest.java @@ -0,0 +1,122 @@ +import com.ktg.RuoYiApplication; +import com.ktg.common.core.domain.AjaxResult; +import com.ktg.mes.md.controller.BaseKnifeController; +import com.ktg.mes.md.domain.BaseKnife; +import com.ktg.mes.md.service.IBaseKnifeService; +import com.ktg.mes.wm.domain.WmsZdTask; +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.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.web.bind.annotation.RequestBody; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; + +import static org.mockito.Mockito.mock; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = RuoYiApplication.class,webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class BaseKnifeTest { + @Autowired + private IBaseKnifeService iBaseKnifeService; + + @Autowired + private BaseKnifeController baseKnifeController; + + /** + * 台账新增 + */ + @Test + public void saveBaseKnifeTest(){ + BaseKnife baseKnife = new BaseKnife(); + baseKnife.setKnifeCode("knifeCode"); + baseKnife.setKnifeName("纸箱"); + baseKnife.setKnifeType("包装类"); + baseKnife.setMbbBdMrlId(86L); + baseKnife.setKnifeUnit("个"); + baseKnife.setSafeStock("1"); + baseKnife.setStandardQuantity("1"); + baseKnife.setAreaCode("A0033"); + baseKnife.setKnifeLife("100"); + baseKnife.setKnifeFineState(0); + iBaseKnifeService.insertBaseKnife(baseKnife); + } + + /** + * 台账修改 + */ + @Test + public void UpdateBaseKnifeTest(){ + BaseKnife baseKnife = new BaseKnife(); + baseKnife.setBaseKnifeId(76L); + baseKnife.setKnifeCode("knifeCode"); + baseKnife.setKnifeName("纸箱"); + baseKnife.setKnifeType("包装类"); + baseKnife.setMbbBdMrlId(86L); + baseKnife.setKnifeUnit("个"); + baseKnife.setSafeStock("1"); + baseKnife.setStandardQuantity("1"); + baseKnife.setAreaCode("A0055"); + baseKnife.setKnifeLife("100"); + baseKnife.setKnifeFineState(0); + iBaseKnifeService.updateBaseKnife(baseKnife); + } + + /** + * 台账详情查询 + */ + @Test + public void getBaseKnifeTest(){ + BaseKnife baseKnife = iBaseKnifeService.selectBaseKnifeByBaseKnifeId(86L); + System.out.println(baseKnife.toString()); + } + + /** + * 台账详情查询列表 + */ + @Test + public void getBaseKnifeTests(){ + List baseKnifes = iBaseKnifeService.selectBaseKnifeList(new BaseKnife()); + for (BaseKnife baseKnife : baseKnifes) { + System.out.println(baseKnife.toString()); + } + } + + /** + * 台账删除 + */ + @Test + public void delBaseKnifeTest(){ + int i = iBaseKnifeService.deleteBaseKnifeByBaseKnifeId(77L); + System.out.println(i); + + } + + /** + * 重置台账寿命 + */ + @Test + public void anewKnifeTest(){ + int i = iBaseKnifeService.resetBaseKnifeByBaseKnifeId(77L); + System.out.println(i); + } + /** + * 组刀 + */ + @Test + public void scrapKnifeTest(){ + WmsZdTask wmsZdTask = new WmsZdTask(); + wmsZdTask.setAttr1(8L); + wmsZdTask.setmProductId(99L); + + AjaxResult ajaxResult = baseKnifeController.zdTask(wmsZdTask); + System.out.println(ajaxResult.toString()); + } + + + + +} diff --git a/ktg-admin/src/test/InventoryTaskResultTest.java b/ktg-admin/src/test/InventoryTaskResultTest.java new file mode 100644 index 0000000..b401747 --- /dev/null +++ b/ktg-admin/src/test/InventoryTaskResultTest.java @@ -0,0 +1,114 @@ +import com.ktg.RuoYiApplication; +import com.ktg.mes.qc.domain.InventoryRequest; +import com.ktg.mes.qc.domain.InventoryTask; +import com.ktg.mes.qc.service.InventoryRequestService; +import com.ktg.mes.qc.service.InventoryTaskService; +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.sql.Timestamp; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.Date; +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 InventoryTaskResultTest { + @Autowired + private InventoryRequestService inventoryRequestService; + + /** + * 新增方法单元测试 + */ + @Test + public void saveTest(){ + //新建任务对象 + + InventoryRequest inventoryRequest = new InventoryRequest(); + Timestamp frockDate = Timestamp.valueOf("2022-01-01 00:00:00"); + inventoryRequest.setFrockDate(frockDate); + inventoryRequest.setFrockId(25L); + inventoryRequest.setRequestCode("TEST001"); + inventoryRequest.setFrockName("测试计划"); + inventoryRequest.setResultName("测试计划结果"); + inventoryRequest.setMrlWlGid("75"); + inventoryRequest.setFrockResult("0"); + inventoryRequest.setFrockUser("张三"); + //新增 + int i = inventoryRequestService.createInventoryRequest(inventoryRequest); + } + + /** + * 修改方法单元测试 + */ + @Test + public void UpdateTest(){ + InventoryRequest inventoryRequest = new InventoryRequest(); + Timestamp frockDate = Timestamp.valueOf("2022-01-01 00:00:00"); + inventoryRequest.setFrockDate(frockDate); + inventoryRequest.setRequestId(16L); + inventoryRequest.setFrockId(25L); + inventoryRequest.setRequestCode("TEST001"); + inventoryRequest.setFrockName("测试计划"); + inventoryRequest.setResultName("测试计划结果"); + inventoryRequest.setMrlWlGid("75"); + inventoryRequest.setFrockResult("0"); + inventoryRequest.setFrockUser("李四"); + //新增 + int i = inventoryRequestService.updateInventoryRequest(inventoryRequest); + } + + /** + * 获取工装定检结果详情 + */ + @Test + public void getInfoTest(){ + InventoryRequest inventoryRequest = inventoryRequestService.queryInventoryRequest(16L); + System.out.println(inventoryRequest.toString()); + } + + /** + * 删除工装定检 + */ + @Test + public void delTest(){ + int i = inventoryRequestService.deleteInventoryRequest(16L); + System.out.println(i); + } + + /** + * 批量删除工装定检 + */ + @Test + public void delIdsTest(){ + Long[] ids = {13L,16L}; + int i = inventoryRequestService.deleteInventoryRequestByIds(ids); + System.out.println(i); + } + + /** + * 查询结果集合 + */ + @Test + public void getListTest(){ + InventoryRequest inventoryRequest = new InventoryRequest(); + Map stringIntegerMap = new HashMap<>(); + stringIntegerMap.put("pageNum",1); + stringIntegerMap.put("pageSize",1); + inventoryRequest.setParams(stringIntegerMap); + List inventoryRequests = inventoryRequestService.queryInventoryRequestList(inventoryRequest); + System.out.println(inventoryRequests.size()); + for (InventoryRequest request : inventoryRequests) { + System.out.println(request.toString()); + } + } +} diff --git a/ktg-admin/src/test/InventoryTaskTest.java b/ktg-admin/src/test/InventoryTaskTest.java index a842a87..66a759a 100644 --- a/ktg-admin/src/test/InventoryTaskTest.java +++ b/ktg-admin/src/test/InventoryTaskTest.java @@ -1,4 +1,5 @@ import com.ktg.RuoYiApplication; +import com.ktg.mes.qc.domain.InventoryRequest; import com.ktg.mes.qc.domain.InventoryTask; import com.ktg.mes.qc.service.InventoryTaskService; import org.junit.Test; @@ -7,26 +8,114 @@ 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; +import java.util.Map; + +/** + * 工装定检对象对象 单元测试 + */ @RunWith(SpringRunner.class) @SpringBootTest(classes = RuoYiApplication.class,webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class InventoryTaskTest { @Autowired private InventoryTaskService inventoryTaskService; + + /** + * 新增方法单元测试 + */ @Test public void saveTest(){ //新建任务对象 InventoryTask inventoryTaskTest = new InventoryTask(); inventoryTaskTest.setWmsInventoryCode("TEST001"); - inventoryTaskTest.setUomId("TEST001"); + inventoryTaskTest.setUomId("200"); inventoryTaskTest.setName("测试计划"); inventoryTaskTest.setPlanPeriod("月"); inventoryTaskTest.setStartTime("2022-01-01"); inventoryTaskTest.setFinishTime("2022-12-31"); inventoryTaskTest.setSuperiorTime("2022-01-01"); inventoryTaskTest.setBelowTime("2022-12-31"); - inventoryTaskTest.setProductId("TEST001"); + inventoryTaskTest.setProductId("75"); + inventoryTaskTest.setMrlModel("19"); + inventoryTaskTest.setMrlPeriod("月"); //新增 int i = inventoryTaskService.insertInventoryTask(inventoryTaskTest); + } + /** + * 修改方法单元测试 + */ + @Test + public void UpdateTest(){ + //新建任务对象 + InventoryTask inventoryTaskTest = new InventoryTask(); + inventoryTaskTest.setWmsInventoryID(25L); + inventoryTaskTest.setWmsInventoryCode("TEST001"); + inventoryTaskTest.setUomId("200"); + inventoryTaskTest.setName("测试计划"); + inventoryTaskTest.setPlanPeriod("日"); + inventoryTaskTest.setStartTime("2022-01-01"); + inventoryTaskTest.setFinishTime("2022-12-31"); + inventoryTaskTest.setSuperiorTime("2022-01-01"); + inventoryTaskTest.setBelowTime("2022-12-31"); + inventoryTaskTest.setProductId("75"); + inventoryTaskTest.setMrlModel("19"); + inventoryTaskTest.setMrlPeriod("日"); + //新增 + int i = inventoryTaskService.updateInventoryTask(inventoryTaskTest); + } + + /** + * 获取工装定检详情 + */ + @Test + public void getInfoTest(){ + InventoryTask inventoryTask = inventoryTaskService.selectInventoryTaskById(25L); + System.out.println(inventoryTask.toString()); + } + + /** + * 删除工装定检 + */ + @Test + public void delTest(){ + int i = inventoryTaskService.delById(25L); + System.out.println(i); + } + + /** + * 批量删除工装定检 + */ + @Test + public void delIdsTest(){ + Long[] ids = {25L,26L}; + int i = inventoryTaskService.delByIds(ids); + System.out.println(i); + } + + /** + * 重新定检 + */ + @Test + public void anewTest(){ + int i = inventoryTaskService.recheck(25L); + System.out.println(i); + } + /** + * 查询结果集合 + */ + @Test + public void getListTest(){ + InventoryTask inventoryTask = new InventoryTask(); + Map stringIntegerMap = new HashMap<>(); + stringIntegerMap.put("pageNum",1); + stringIntegerMap.put("pageSize",1); + inventoryTask.setParams(stringIntegerMap); + List inventoryRequests = inventoryTaskService.getList(inventoryTask); + System.out.println(inventoryRequests.size()); + for (InventoryTask request : inventoryRequests) { + System.out.println(request.toString()); + } } } diff --git a/ktg-mes/src/main/java/com/ktg/mes/qc/controller/InventoryTaskController.java b/ktg-mes/src/main/java/com/ktg/mes/qc/controller/InventoryTaskController.java index e7f41c1..080b894 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/qc/controller/InventoryTaskController.java +++ b/ktg-mes/src/main/java/com/ktg/mes/qc/controller/InventoryTaskController.java @@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.*; import java.util.List; import static com.ktg.common.utils.PageUtils.startPage; +import static com.ktg.common.utils.SecurityUtils.getUsername; /** * 常见缺陷Controller @@ -47,6 +48,7 @@ public class InventoryTaskController extends BaseController { @PutMapping public AjaxResult edit(@RequestBody InventoryTask inventoryTask) { + inventoryTask.setUpdateBy(getUsername()); return toAjax(inventoryTaskService.updateInventoryTask(inventoryTask)); } @@ -58,6 +60,7 @@ public class InventoryTaskController extends BaseController { @PostMapping("/save") public AjaxResult add(@RequestBody InventoryTask inventoryTask) { + inventoryTask.setCreateBy(getUsername()); return toAjax(inventoryTaskService.insertInventoryTask(inventoryTask)); } @@ -68,6 +71,7 @@ public class InventoryTaskController extends BaseController { @GetMapping(value = "/{wmsInventoryID}") public AjaxResult getInfo(@PathVariable("wmsInventoryID") Long wmsInventoryID) { + return AjaxResult.success(inventoryTaskService.selectInventoryTaskById(wmsInventoryID)); } diff --git a/ktg-mes/src/main/java/com/ktg/mes/qc/controller/inventoryRequestController.java b/ktg-mes/src/main/java/com/ktg/mes/qc/controller/inventoryRequestController.java index 2b07476..1d9f559 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/qc/controller/inventoryRequestController.java +++ b/ktg-mes/src/main/java/com/ktg/mes/qc/controller/inventoryRequestController.java @@ -15,6 +15,8 @@ import org.springframework.web.bind.annotation.*; import java.util.List; +import static com.ktg.common.utils.SecurityUtils.getUsername; + @RestController @RequestMapping("inventoryRequestController") public class inventoryRequestController extends BaseController { @@ -40,6 +42,7 @@ public class inventoryRequestController extends BaseController { @PutMapping public AjaxResult edit(@RequestBody InventoryRequest InventoryRequest) { + InventoryRequest.setUpdateBy(getUsername()); return toAjax(inventoryRequestService.updateInventoryRequest(InventoryRequest)); } @@ -51,6 +54,7 @@ public class inventoryRequestController extends BaseController { @PostMapping("/save") public AjaxResult add(@RequestBody InventoryRequest inventoryRequest) { + inventoryRequest.setCreateBy(getUsername()); return toAjax(inventoryRequestService.createInventoryRequest(inventoryRequest)); } diff --git a/ktg-mes/src/main/java/com/ktg/mes/qc/domain/InventoryRequest.java b/ktg-mes/src/main/java/com/ktg/mes/qc/domain/InventoryRequest.java index fbb1137..688a827 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/qc/domain/InventoryRequest.java +++ b/ktg-mes/src/main/java/com/ktg/mes/qc/domain/InventoryRequest.java @@ -164,6 +164,23 @@ public class InventoryRequest extends BaseEntity { this.mrlWlName = mrlWlName; } - - + @Override + public String toString() { + return "InventoryRequest{" + + "requestId=" + requestId + + ", requestCode='" + requestCode + '\'' + + ", frockUser='" + frockUser + '\'' + + ", frockId=" + frockId + + ", frockName='" + frockName + '\'' + + ", mrlWlGid='" + mrlWlGid + '\'' + + ", mrlWlName='" + mrlWlName + '\'' + + ", resultName='" + resultName + '\'' + + ", frockResult='" + frockResult + '\'' + + ", frockError='" + frockError + '\'' + + ", frockDate=" + frockDate + + ", remark='" + remark + '\'' + + ", isDelete=" + isDelete + + ", isActive=" + isActive + + '}'; + } } diff --git a/ktg-mes/src/main/java/com/ktg/mes/qc/service/impl/InventoryRequestServiceImpl.java b/ktg-mes/src/main/java/com/ktg/mes/qc/service/impl/InventoryRequestServiceImpl.java index 1a83b5a..4788c83 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/qc/service/impl/InventoryRequestServiceImpl.java +++ b/ktg-mes/src/main/java/com/ktg/mes/qc/service/impl/InventoryRequestServiceImpl.java @@ -33,7 +33,6 @@ public class InventoryRequestServiceImpl implements InventoryRequestService { @Override public int createInventoryRequest(InventoryRequest inventoryRequest) { - inventoryRequest.setCreateBy(getUsername()); String s = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); try { @@ -49,7 +48,7 @@ public class InventoryRequestServiceImpl implements InventoryRequestService { @Override public int updateInventoryRequest(InventoryRequest inventoryRequest) { - inventoryRequest.setUpdateBy(getUsername()); + String s = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); try { diff --git a/ktg-mes/src/main/java/com/ktg/mes/qc/service/impl/InventoryTaskServiceImpl.java b/ktg-mes/src/main/java/com/ktg/mes/qc/service/impl/InventoryTaskServiceImpl.java index a449a62..45b9094 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/qc/service/impl/InventoryTaskServiceImpl.java +++ b/ktg-mes/src/main/java/com/ktg/mes/qc/service/impl/InventoryTaskServiceImpl.java @@ -79,7 +79,7 @@ public class InventoryTaskServiceImpl implements InventoryTaskService { @Override public int insertInventoryTask(InventoryTask inventoryTask) { String s = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); - inventoryTask.setCreateBy(getUsername()); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); try { Date parsedDate = format.parse(s); @@ -93,7 +93,7 @@ public class InventoryTaskServiceImpl implements InventoryTaskService { @Override public int updateInventoryTask(InventoryTask inventoryTask) { String s = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); - inventoryTask.setUpdateBy(getUsername()); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); try { Date parsedDate = format.parse(s); diff --git a/ktg-mes/src/main/resources/mapper/md/BaseKnifeMapper.xml b/ktg-mes/src/main/resources/mapper/md/BaseKnifeMapper.xml index 3dd0850..2c8c7c2 100644 --- a/ktg-mes/src/main/resources/mapper/md/BaseKnifeMapper.xml +++ b/ktg-mes/src/main/resources/mapper/md/BaseKnifeMapper.xml @@ -482,7 +482,7 @@ where BASE_KNIFE_ID = #{baseKnifeId} - + delete from BASE_KNIFE where BASE_KNIFE_ID = #{baseKnifeId}