From 88f1e9f954990c78229749355349712e7271a1e4 Mon Sep 17 00:00:00 2001 From: "liang.chao" <1360241448@qq.com> Date: Mon, 23 Sep 2024 16:35:29 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E5=BA=86=E9=9C=80=E6=B1=82=E5=8F=98?= =?UTF-8?q?=E6=9B=B4=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/controller/MaTypeController.java | 67 ++++++++++++------- .../bonus/sgzb/base/mapper/MaTypeMapper.java | 1 + .../bonus/sgzb/base/service/ITypeService.java | 1 + .../base/service/impl/MaTypeServiceImpl.java | 12 +++- .../material/domain/PurchaseCheckInfo.java | 11 +++ .../mapper/base/MaMachineTypeMapper.xml | 22 ++++++ .../material/PurchaseCheckInfoMapper.xml | 7 +- 7 files changed, 92 insertions(+), 29 deletions(-) diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaTypeController.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaTypeController.java index da1119f..8febe50 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaTypeController.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaTypeController.java @@ -1,10 +1,13 @@ package com.bonus.sgzb.base.controller; +import cn.hutool.core.convert.Convert; import com.bonus.sgzb.base.api.domain.MaType; import com.bonus.sgzb.base.domain.MaKeeperUser; import com.bonus.sgzb.base.domain.vo.TreeSelect; import com.bonus.sgzb.base.mapper.MaTypeMapper; import com.bonus.sgzb.base.service.ITypeService; +import com.bonus.sgzb.common.core.utils.ListPagingUtil; +import com.bonus.sgzb.common.core.utils.ServletUtils; import com.bonus.sgzb.common.core.web.controller.BaseController; import com.bonus.sgzb.common.core.web.domain.AjaxResult; import com.bonus.sgzb.common.log.annotation.Log; @@ -15,8 +18,12 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.List; +import static com.bonus.sgzb.common.core.web.page.TableSupport.PAGE_NUM; +import static com.bonus.sgzb.common.core.web.page.TableSupport.PAGE_SIZE; + /** * 工机具类型管理控制层 */ @@ -34,24 +41,25 @@ public class MaTypeController extends BaseController { /** * 根据类型名称查询类型 + * * @return 结果 */ @ApiOperation(value = "根据类型名称查询类型") @GetMapping("/getMaTypeList") - public AjaxResult getMaTypeList(@RequestParam(required = false, defaultValue = "", value = "typeName") String typeName, @RequestParam(required = false, defaultValue = "", value = "parentId") String parentId){ + public AjaxResult getMaTypeList(@RequestParam(required = false, defaultValue = "", value = "typeName") String typeName, @RequestParam(required = false, defaultValue = "", value = "parentId") String parentId) { List maTypeList = iTypeService.getMaTypeList(typeName, parentId); return AjaxResult.success(maTypeList); } - /** * 工机具类型下拉树 + * * @return 结果 */ @ApiOperation(value = "工机具类型下拉树") @GetMapping("/getMaTypeSelect") - public AjaxResult getMaTypeSelect(@RequestParam(required = false, defaultValue = "", value = "typeName") String typeName, @RequestParam(required = false, defaultValue = "", value = "parentId") String parentId){ + public AjaxResult getMaTypeSelect(@RequestParam(required = false, defaultValue = "", value = "typeName") String typeName, @RequestParam(required = false, defaultValue = "", value = "parentId") String parentId) { List maTypeList = iTypeService.getMaTypeSelect(typeName, parentId); return AjaxResult.success(maTypeList); } @@ -65,30 +73,34 @@ public class MaTypeController extends BaseController { /** * 根据左列表类型id查询右表格 + * * @param typeId * @return */ @ApiOperation(value = "工器具类型") @GetMapping("/equipmentType") public AjaxResult equipmentType(@RequestParam(required = false) Long typeId, - @RequestParam(required = false) String typeName){ - List listByMaType = iTypeService.getEquipmentType(typeId,typeName); + @RequestParam(required = false) String typeName) { + List listByMaType = iTypeService.getEquipmentType(typeId, typeName); return success(listByMaType); } /** * 获取规格层级为3的设备列表 + * * @return 结果 */ @ApiOperation(value = "获取规格层级的设备列表") @GetMapping("/selectMaTypeListByLevelIndex") - public AjaxResult selectMaTypeListByLevelIndex(@RequestParam(value = "level", required = false) Integer level, @RequestParam(value = "type") Integer type, @RequestParam(value = "parentId", required = false) Integer parentId, @RequestParam(value = "keyword", required = false) String keyword){ - if (type == null) { return AjaxResult.error("参数错误,类型不能为空"); } + public AjaxResult selectMaTypeListByLevelIndex(@RequestParam(value = "level", required = false) Integer level, @RequestParam(value = "type") Integer type, @RequestParam(value = "parentId", required = false) Integer parentId, @RequestParam(value = "keyword", required = false) String keyword) { + if (type == null) { + return AjaxResult.error("参数错误,类型不能为空"); + } if (type == 0) { // 查询全部机具类型 if (level == 0 || level == 1) { // 查询全部等级、一级 - List treeSelectList = iTypeService.buildDeptTreeSelect(maTypeMapper.selectMaTypeListByLevelNotFour(null,null)); + List treeSelectList = iTypeService.buildDeptTreeSelect(maTypeMapper.selectMaTypeListByLevelNotFour(null, null)); List children = treeSelectList.get(0).getChildren(); TreeSelect zero = new TreeSelect(); zero.setLevel(2); @@ -100,11 +112,11 @@ public class MaTypeController extends BaseController { } if (level == 2) { // 查询二级 - if (parentId == 0){ + if (parentId == 0) { List maTypes = maTypeMapper.selectMaTypeListByLevelNotFour(null, keyword); return AjaxResult.success(maTypes); - }else { - return AjaxResult.success(maTypeMapper.selectMaTypeListByLevelNotFour(parentId.toString(),keyword)); + } else { + return AjaxResult.success(maTypeMapper.selectMaTypeListByLevelNotFour(parentId.toString(), keyword)); } @@ -129,12 +141,12 @@ public class MaTypeController extends BaseController { // 查询施工机具 List treeSelectList; if (level != 2) { - treeSelectList = iTypeService.buildDeptTreeSelect(maTypeMapper.selectMaTypeListByLevelNotFour(null,null)); + treeSelectList = iTypeService.buildDeptTreeSelect(maTypeMapper.selectMaTypeListByLevelNotFour(null, null)); // treeSelectList.removeIf(item -> item.getId() == 1L); //List treeSelectList1 = treeSelectList.stream().filter(item -> Objects.equals(item.getId(), 1L)).collect(Collectors.toList()); return AjaxResult.success(treeSelectList); } else { - return AjaxResult.success(maTypeMapper.selectMaTypeListByLevelNotFour(parentId.toString(),keyword)); + return AjaxResult.success(maTypeMapper.selectMaTypeListByLevelNotFour(parentId.toString(), keyword)); // treeSelectList = iTypeService.buildDeptTreeSelect(maTypeMapper.selectMaTypeListByLevelNotFour(parentId.toString())); // // 先过滤出施工机具 // treeSelectList = treeSelectList.stream().filter(item -> Objects.equals(item.getId(), 1L)).collect(Collectors.toList()); @@ -157,11 +169,11 @@ public class MaTypeController extends BaseController { } } if (type == 2) { - List treeSelectList = iTypeService.buildDeptTreeSelect(maTypeMapper.selectMaTypeListByLevelNotFour(null,null)); + List treeSelectList = iTypeService.buildDeptTreeSelect(maTypeMapper.selectMaTypeListByLevelNotFour(null, null)); //treeSelectList = treeSelectList.stream().filter(item -> Objects.equals(item.getId(), 2L)).collect(Collectors.toList()); // 查询安全工器具 if (level == 2) { - return AjaxResult.success(maTypeMapper.selectMaTypeListByLevelNotFour(parentId.toString(),keyword)); + return AjaxResult.success(maTypeMapper.selectMaTypeListByLevelNotFour(parentId.toString(), keyword)); // if (!treeSelectList.isEmpty()) { // for (TreeSelect treeSelect : treeSelectList) { // List children = treeSelect.getChildren(); @@ -178,20 +190,26 @@ public class MaTypeController extends BaseController { } return AjaxResult.success(treeSelectList); } - return AjaxResult.success(maTypeMapper.selectMaTypeListByLevelNotFour(null,null)); + return AjaxResult.success(maTypeMapper.selectMaTypeListByLevelNotFour(null, null)); } /** * 根据左列表类型id查询右表格 + * * @param typeId * @return */ @ApiOperation(value = "根据左列表类型id查询右表格") @GetMapping("/getListByMaType") - public AjaxResult getListByMaType(@RequestParam(required = false) Long typeId, - @RequestParam(required = false) String typeName){ - List listByMaType = iTypeService.getListByParentId(typeId,typeName); - return success(listByMaType); + public AjaxResult getListByMaType(Long typeId, @RequestParam(required = false) String typeName, Integer level) { + List parentIds = iTypeService.selectParentId(typeId, level); + List listByMaType = new ArrayList<>(); + for (Integer parentId : parentIds) { + listByMaType.addAll(iTypeService.getListByParentId(parentId.longValue(), typeName)); + } + Integer pageIndex = Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1); + Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10); + return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, listByMaType)); } /** @@ -224,8 +242,7 @@ public class MaTypeController extends BaseController { */ @ApiOperation(value = "获取机具类型管理ma_type详细信息") @GetMapping(value = "/{typeId}") - public AjaxResult getInfo(@PathVariable("typeId") Long typeId) - { + public AjaxResult getInfo(@PathVariable("typeId") Long typeId) { return success(iTypeService.selectMaTypeByTypeId(typeId)); } @@ -235,8 +252,7 @@ public class MaTypeController extends BaseController { @ApiOperation(value = "新增机具类型管理ma_type") @Log(title = "机具类型管理ma_type", businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@RequestBody MaType maType) - { + public AjaxResult add(@RequestBody MaType maType) { int result = iTypeService.insertMaType(maType); if (result > 0) { return success(toAjax(iTypeService.insertMaType(maType))); @@ -251,8 +267,7 @@ public class MaTypeController extends BaseController { @ApiOperation(value = "修改机具类型管理ma_type") @Log(title = "机具类型管理ma_type", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(@RequestBody MaType maType) - { + public AjaxResult edit(@RequestBody MaType maType) { return toAjax(iTypeService.updateMaType(maType)); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/mapper/MaTypeMapper.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/mapper/MaTypeMapper.java index 4cd5aed..e8f18b7 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/mapper/MaTypeMapper.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/mapper/MaTypeMapper.java @@ -89,4 +89,5 @@ public interface MaTypeMapper { List selectMaTypeByUserId(Long userId); + List selectParentId( @Param("typeId")Long typeId, @Param("level")Integer level); } \ No newline at end of file diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/ITypeService.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/ITypeService.java index c1cbb7d..5f72485 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/ITypeService.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/ITypeService.java @@ -67,6 +67,7 @@ public interface ITypeService { public List buildDeptTreeSelect(List maTypeList); List getListByParentId(Long typeId, String typeName); + List selectParentId(Long typeId, Integer level); List getEquipmentType(Long typeId, String typeName); diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java index f72b4ee..9d63f52 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java @@ -58,7 +58,12 @@ public class MaTypeServiceImpl implements ITypeService { return 0; } MaType maType1 = maTypeMapper.selectMaTypeByTypeId(parentId); - String level = maType1.getLevel(); + String level; + if (maType1 == null) { + level = "0"; + } else { + level = maType1.getLevel(); + } maType.setLevel(String.valueOf(Integer.parseInt(level) + 1)); maType.setCreateTime(DateUtils.getNowDate()); System.out.println(maType); @@ -328,6 +333,11 @@ public class MaTypeServiceImpl implements ITypeService { return maTypeMapper.getListByParentId(typeId, typeName); } + @Override + public List selectParentId(Long typeId, Integer level) { + return maTypeMapper.selectParentId(typeId,level); + } + /** * 查询工器具类型四级组织树 * diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/PurchaseCheckInfo.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/PurchaseCheckInfo.java index 816b055..2c0a2a1 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/PurchaseCheckInfo.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/PurchaseCheckInfo.java @@ -120,6 +120,17 @@ public class PurchaseCheckInfo extends BaseEntity @ApiModelProperty(value="结束时间") private String endTime; + public String getPurchaseNumber() { + return purchaseNumber; + } + + public void setPurchaseNumber(String purchaseNumber) { + this.purchaseNumber = purchaseNumber; + } + + @ApiModelProperty(value="线下采购单编号") + private String purchaseNumber; + public String getKeyWord() { return keyWord; } diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/base/MaMachineTypeMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/base/MaMachineTypeMapper.xml index f87e3a7..66df3f6 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/base/MaMachineTypeMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/base/MaMachineTypeMapper.xml @@ -426,6 +426,28 @@ select * from ma_type_keeper where user_id = #{userId} + update ma_type set num = IFNULL( num, 0 ) + 1 where type_id = #{typeId} diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/PurchaseCheckInfoMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/PurchaseCheckInfoMapper.xml index 0b8b0f2..7900af8 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/PurchaseCheckInfoMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/PurchaseCheckInfoMapper.xml @@ -24,7 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select pci.id,pci.task_id, pci.purchase_time, pci.arrival_time, pci.purchaser, pci.create_by, pci.create_time, - pci.update_by, pci.update_time, pci.remark, pci.company_id, tk.code + pci.update_by, pci.update_time, pci.remark, pci.company_id, tk.code,pci.purchase_number from purchase_check_info pci left join tm_task tk on pci.task_id = tk.task_id where pci.task_id = #{taskId} @@ -79,6 +79,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update_time, remark, company_id, + purchase_number, #{taskId}, @@ -91,6 +92,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{updateTime}, #{remark}, #{companyId}, + #{purchaseNumber}, @@ -106,6 +108,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update_time = #{updateTime}, remark = #{remark}, company_id = #{companyId}, + purchase_number = #{purchaseNumber}, where task_id = #{taskId}