类型管理

This commit is contained in:
sxu 2024-11-27 16:50:21 +08:00
parent 35defa1ab7
commit 23a4edc63f
14 changed files with 2416 additions and 0 deletions

View File

@ -0,0 +1,309 @@
package com.bonus.material.ma.controller;
import cn.hutool.core.convert.Convert;
import com.bonus.common.biz.config.ListPagingUtil;
import com.bonus.common.core.utils.ServletUtils;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.ma.mapper.MaTypeMapper;
import com.bonus.material.ma.service.ITypeService;
import com.bonus.material.ma.vo.MaType;
import com.bonus.material.ma.vo.TreeSelect;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.java.Log;
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 java.util.Objects;
import java.util.stream.Collectors;
import static com.bonus.common.core.constant.Constants.PAGE_NUM;
import static com.bonus.common.core.constant.Constants.PAGE_SIZE;
/**
* 工机具类型管理控制层
*/
@RestController
@Api(value = "工机具类型管理控制层")
@RequestMapping("/type")
public class MaTypeController extends BaseController {
@Autowired
private ITypeService iTypeService;
@Resource
private MaTypeMapper maTypeMapper;
/**
* 根据类型名称查询类型
*
* @return 结果
*/
@ApiOperation(value = "根据类型名称查询类型")
@GetMapping("/getMaTypeList")
public AjaxResult getMaTypeList(@RequestParam(required = false, defaultValue = "", value = "typeName") String typeName, @RequestParam(required = false, defaultValue = "", value = "parentId") String parentId) {
List<TreeSelect> 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) {
List<TreeSelect> maTypeList = iTypeService.getMaTypeSelect(typeName, parentId);
return AjaxResult.success(maTypeList);
}
@ApiOperation(value = "获取机具设备的具体规格")
@GetMapping(value = "/selectMaTypeTreeByLevel")
public AjaxResult selectMaTypeTreeByLevel(@RequestParam(value = "typeId") String typeId) {
List<MaType> maTypeList = maTypeMapper.selectMaTypeTreeByLevel(typeId);
return AjaxResult.success(maTypeList);
}
/**
* 根据左列表类型id查询右表格
*
* @param typeId
* @return
*/
@ApiOperation(value = "工器具类型")
@GetMapping("/equipmentType")
public AjaxResult equipmentType(@RequestParam(required = false) Long typeId,
@RequestParam(required = false) String typeName) {
List<MaType> 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("参数错误,类型不能为空");
}
if (type == 0) {
// 查询全部机具类型
if (level == 0 || level == 1) {
// 查询全部等级一级
List<TreeSelect> treeSelectList = iTypeService.buildDeptTreeSelect(maTypeMapper.selectMaTypeListByLevelNotFour(null, null));
List<TreeSelect> children = treeSelectList.get(0).getChildren();
TreeSelect zero = new TreeSelect();
zero.setLevel(2);
zero.setId(0L);
zero.setLabel("全部");
zero.setParentId(0L);
children.add(0, zero);
return AjaxResult.success(treeSelectList);
}
if (level == 2) {
// 查询二级
if (parentId == 0) {
List<MaType> maTypes = maTypeMapper.selectMaTypeListByLevelNotFour(null, keyword);
return AjaxResult.success(maTypes);
} else {
return AjaxResult.success(maTypeMapper.selectMaTypeListByLevelNotFour(parentId.toString(), keyword));
}
// List<TreeSelect> treeSelectList = iTypeService.buildDeptTreeSelect(maTypeMapper.selectMaTypeListByLevelNotFour(parentId.toString()));
//
// // 遍历剔除不符合的三级规格
// for (TreeSelect treeSelect : treeSelectList) {
// List<TreeSelect> children = treeSelect.getChildren();
// if (children != null) {
// for (TreeSelect child : children) {
// List<TreeSelect> grandChildren = child.getChildren();
// if (grandChildren!= null) {
// grandChildren.removeIf(obj -> !Objects.equals(obj.getParentId(), Long.valueOf(parentId)));
// }
// }
// }
// }
// return AjaxResult.success(treeSelectList);
}
}
if (type == 1) {
// 查询施工机具
List<TreeSelect> treeSelectList;
if (level != 2) {
treeSelectList = iTypeService.buildDeptTreeSelect(maTypeMapper.selectMaTypeListByLevelNotFour(null, null));
// treeSelectList.removeIf(item -> item.getId() == 1L);
//List<TreeSelect> 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));
// treeSelectList = iTypeService.buildDeptTreeSelect(maTypeMapper.selectMaTypeListByLevelNotFour(parentId.toString()));
// // 先过滤出施工机具
// treeSelectList = treeSelectList.stream().filter(item -> Objects.equals(item.getId(), 1L)).collect(Collectors.toList());
// // 再过滤出不符合的三级规格
// if (!treeSelectList.isEmpty()) {
// for (TreeSelect treeSelect : treeSelectList) {
// List<TreeSelect> children = treeSelect.getChildren();
// if (children != null) {
// for (TreeSelect child : children) {
// List<TreeSelect> grandChildren = child.getChildren();
// if (grandChildren != null) {
// grandChildren.removeIf(obj -> !Objects.equals(obj.getParentId(), Long.valueOf(parentId)));
// }
//
// }
// }
// }
// }
// return AjaxResult.success(treeSelectList);
}
}
if (type == 2) {
List<TreeSelect> 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));
// if (!treeSelectList.isEmpty()) {
// for (TreeSelect treeSelect : treeSelectList) {
// List<TreeSelect> children = treeSelect.getChildren();
// if (children != null) {
// for (TreeSelect child : children) {
// List<TreeSelect> grandChildren = child.getChildren();
// if (grandChildren != null) {
// grandChildren.removeIf(obj -> !Objects.equals(obj.getParentId(), Long.valueOf(parentId)));
// }
// }
// }
// }
// }
}
return AjaxResult.success(treeSelectList);
}
return AjaxResult.success(maTypeMapper.selectMaTypeListByLevelNotFour(null, null));
}
/**
* 根据左列表类型id查询右表格
*
* @param typeId
* @return
*/
@ApiOperation(value = "根据左列表类型id查询右表格")
@GetMapping("/getListByMaType")
public AjaxResult getListByMaType(Long typeId, @RequestParam(required = false) String typeName, Integer level) {
List<Integer> parentIds = iTypeService.selectParentId(typeId, level);
List<MaType> 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));
}
/**
* 根据左列表类型id查询右表格
*
* @param typeId
* @return
*/
@ApiOperation(value = "根据左列表类型id查询右表格")
@GetMapping("/getListByMaTypePid")
public AjaxResult getListByMaTypePid(Long typeId, @RequestParam(required = false) String typeName) {
List<MaType> listByParentId = iTypeService.getListByParentId(typeId, 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, listByParentId));
}
/**
* 根据左列表类型id查询右表格
* @param typeId
* @return
*/
// @ApiOperation(value = "根据左列表类型id查询右表格")
// @GetMapping("/getListByMaType")
// public TableDataInfo getListByMaType(@RequestParam(required = false) Long typeId,
// @RequestParam(required = false) String typeName,
// @RequestParam(required = false) Integer pageSize,
// @RequestParam(required = false) Integer pageNum){
// if(typeId==null){
// return null;
// }
// List<MaType> listByMaType = iTypeService.getListByMaType(typeId, typeName);
// TableDataInfo rspData = new TableDataInfo();
// rspData.setTotal(listByMaType.size());
// rspData.setCode(HttpStatus.SUCCESS);
// // listByMaType = listByMaType.stream().skip((long) (pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
// rspData.setRows(listByMaType);
// rspData.setMsg("查询成功");
//
// return rspData;
// }
/**
* 获取机具类型管理ma_type详细信息
*/
@ApiOperation(value = "获取机具类型管理ma_type详细信息")
@GetMapping(value = "/{typeId}")
public AjaxResult getInfo(@PathVariable("typeId") Long typeId) {
return success(iTypeService.selectMaTypeByTypeId(typeId));
}
/**
* 新增机具类型管理ma_type
*/
@ApiOperation(value = "新增机具类型管理ma_type")
//@Log(title = "机具类型管理ma_type", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody MaType maType) {
int result = iTypeService.insertMaType(maType);
if (result > 0) {
return success("新增成功");
} else {
return AjaxResult.error("未新增成功,请查看同一层级是否有重名的类型!");
}
}
/**
* 修改机具类型管理ma_type
*/
@ApiOperation(value = "修改机具类型管理ma_type")
//@Log(title = "机具类型管理ma_type", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody MaType maType) {
Long parentId = maType.getParentId();
List<MaType> subMas = maTypeMapper.getListByParentId(parentId, null);
List<MaType> filteredItems = subMas.stream().collect(Collectors.toList());
if (Objects.nonNull(maType.getTypeId())) {
filteredItems = subMas.stream().filter(item -> !maType.getTypeId().equals(item.getTypeId())).collect(Collectors.toList());
}
boolean containsSameBrother = filteredItems.stream().anyMatch(o -> o.getTypeName().equals(maType.getTypeName()));
if (containsSameBrother) {
return AjaxResult.error("修改失败,同级存在相同名称");
}
return toAjax(iTypeService.updateMaType(maType));
}
/**
* 删除机具类型管理ma_type
*/
@ApiOperation(value = "删除机具类型管理ma_type")
//@Log(title = "机具类型管理ma_type", businessType = BusinessType.DELETE)
@DeleteMapping("/{typeId}")
public AjaxResult remove(@PathVariable Long typeId) throws Exception {
return toAjax(iTypeService.deleteMaTypeByTypeId(typeId));
}
}

View File

@ -0,0 +1,64 @@
package com.bonus.material.ma.mapper;
import com.bonus.material.ma.vo.MaTypeFile;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 机具类型文件ma_type_fileMapper接口
*
* @author bonus
* @date 2023-12-11
*/
@Mapper
public interface MaTypeFileMapper {
/**
* 查询机具类型文件ma_type_file
*
* @param typeId 机具类型文件ma_type_file主键
* @return 机具类型文件ma_type_file
*/
public MaTypeFile selectMaTypeFileByTypeId(Long typeId);
/**
* 查询机具类型文件ma_type_file列表
*
* @param maTypeFile 机具类型文件ma_type_file
* @return 机具类型文件ma_type_file集合
*/
public List<MaTypeFile> selectMaTypeFileList(MaTypeFile maTypeFile);
/**
* 新增机具类型文件ma_type_file
*
* @param maTypeFile 机具类型文件ma_type_file
* @return 结果
*/
public int insertMaTypeFile(MaTypeFile maTypeFile);
/**
* 修改机具类型文件ma_type_file
*
* @param maTypeFile 机具类型文件ma_type_file
* @return 结果
*/
public int updateMaTypeFile(MaTypeFile maTypeFile);
/**
* 删除机具类型文件ma_type_file
*
* @param typeId 机具类型文件ma_type_file主键
* @return 结果
*/
public int deleteMaTypeFileByTypeId(@Param("typeId") Long typeId, @Param("fileType") String fileType);
/**
* 批量删除机具类型文件ma_type_file
*
* @param typeIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteMaTypeFileByTypeIds(Long[] typeIds);
}

View File

@ -0,0 +1,87 @@
package com.bonus.material.ma.mapper;
import com.bonus.material.ma.vo.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 工机具类型管理 数据层
*
* @author ruoyi
*/
@Mapper
public interface MaTypeMapper {
List<MaType> selectMaTypeList(String typeName);
/**
* 查询机具类型管理ma_type
*
* @param typeId 机具类型管理ma_type主键
* @return 机具类型管理ma_type
*/
public MaType selectMaTypeByTypeId(Long typeId);
/**
* 新增机具类型管理ma_type
*
* @param maType 机具类型管理ma_type
* @return 结果
*/
public int insertType(MaType maType);
/**
* 修改机具类型管理ma_type
*
* @param maType 机具类型管理ma_type
* @return 结果
*/
public int updateType(MaType maType);
/**
* 删除机具类型管理ma_type
*
* @param typeId 机具类型管理ma_type主键
* @return 结果
*/
public int deleteTypeById(Long typeId);
int insertKeeper(MaTypeKeeper typeKeeper);
int insertRepair(MaTypeRepair typeRepair);
int insertMaPropSet(MaPropSet propSet);
int updateKeeperByTypeId(MaTypeKeeper typeKeeper);
int updateRepairByTypeId(MaTypeRepair typeRepair);
int updatePropSetByTypeId(MaPropSet propSet);
MaType selectTypeByTypeId(long typeId);
List<MaType> selectMaTypeTree(String parentId);
List<MaType> getListByParentId(@Param("typeId") Long typeId, @Param("typeName") String typeName);
List<MaType> selectMaTypeTreeByLevel(String id);
List<MaType> selectMaTypeListByLevelNotFour(@Param("parentId") String parentId,@Param("keyword")String keyword);
List<MaType> getMaTypeSelect(String parentId);
int deleteTypeByTypeId(Long typeId);
int deleteKeeperByTypeId(Long typeId);
int deletePropSetByTypeId(Long typeId);
int updateTypeNum(MaMachine maMachine);
List<MaTypeKeeper> selectMaTypeByUserId(Long userId);
List<Integer> selectParentId( @Param("typeId")Long typeId, @Param("level")Integer level);
}

View File

@ -0,0 +1,71 @@
package com.bonus.material.ma.service;
import com.bonus.material.ma.vo.MaType;
import com.bonus.material.ma.vo.TreeSelect;
import java.util.List;
public interface ITypeService {
List<TreeSelect> getMaTypeList(String typeName, String parentId);
List<TreeSelect> getMaTypeSelect(String typeName, String parentId);
List<MaType> getListByMaType(Long typeId, String typeName);
/**
* 查询机具类型管理ma_type
*
* @param typeId 机具类型管理ma_type主键
* @return 机具类型管理ma_type
*/
public MaType selectMaTypeByTypeId(Long typeId);
/**
* 新增机具类型管理ma_type
*
* @param maType 机具类型管理ma_type
* @return 结果
*/
public int insertMaType(MaType maType);
/**
* 修改机具类型管理ma_type
*
* @param maType 机具类型管理ma_type
* @return 结果
*/
public int updateMaType(MaType maType);
/**
* 删除机具类型管理ma_type信息
*
* @param typeId 机具类型管理ma_type主键
* @return 结果
*/
public int deleteMaTypeByTypeId(Long typeId) throws Exception;
/**
* 构建前端所需要树结构
*
* @param maTypeList 状态列表
* @return 树结构列表
*/
public List<MaType> buildDeptTree(List<MaType> maTypeList);
/**
* 构建前端所需要下拉树结构
*
* @param maTypeList 工机具列表
* @return 下拉树结构列表
*/
public List<TreeSelect> buildDeptTreeSelect(List<MaType> maTypeList);
List<MaType> getListByParentId(Long typeId, String typeName);
List<Integer> selectParentId(Long typeId, Integer level);
List<MaType> getEquipmentType(Long typeId, String typeName);
}

View File

@ -0,0 +1,432 @@
package com.bonus.material.ma.service.impl;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.core.utils.StringUtils;
import com.bonus.material.ma.mapper.MaTypeFileMapper;
import com.bonus.material.ma.mapper.MaTypeMapper;
import com.bonus.material.ma.service.ITypeService;
import com.bonus.material.ma.vo.*;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
/**
* 工机具类型管理实现层
*/
@Service
public class MaTypeServiceImpl implements ITypeService {
@Resource
private MaTypeMapper maTypeMapper;
@Resource
private MaTypeFileMapper typeFileMapper;
/**
* 查询机具类型管理ma_type
*
* @param typeId 机具类型管理ma_type主键
* @return 机具类型管理ma_type
*/
@Override
public MaType selectMaTypeByTypeId(Long typeId) {
return maTypeMapper.selectMaTypeByTypeId(typeId);
}
/**
* 新增机具类型管理ma_type
*
* @param maType 机具类型管理ma_type
* @return 结果
*/
@Override
@Transactional
public int insertMaType(MaType maType) {
Long parentId = maType.getParentId();
List<MaType> subMas = maTypeMapper.getListByParentId(parentId, null);
boolean containsSameBrother = subMas.stream().anyMatch(o -> o.getTypeName().equals(maType.getTypeName()));
if (containsSameBrother) {
return 0;
}
MaType maType1 = maTypeMapper.selectMaTypeByTypeId(parentId);
String level;
if (maType1 == null) {
level = "0";
} else {
level = maType1.getLevel();
}
maType.setLevel(String.valueOf(Integer.parseInt(level) + 1));
maType.setCreateTime(DateUtils.getNowDate());
if (parentId == 0) {
maType.setCompanyId("101");
} else {
maType.setCompanyId(maType1.getCompanyId());
}
int i = maTypeMapper.insertType(maType);
Long typeId = maType.getTypeId();
// 图片路径保存
if (StringUtils.isNotEmpty(maType.getPhotoName()) && StringUtils.isNotEmpty(maType.getPhotoUrl())) {
MaTypeFile typeFile = new MaTypeFile();
typeFile.setTypeId(typeId);
typeFile.setFileName(maType.getPhotoName());
typeFile.setFileUrl(maType.getPhotoUrl());
typeFile.setFileType("1");
typeFile.setCreateTime(DateUtils.getNowDate());
typeFileMapper.insertMaTypeFile(typeFile);
}
// 文档路径保存
if (StringUtils.isNotEmpty(maType.getDocumentName()) && StringUtils.isNotEmpty(maType.getDocumentUrl())) {
MaTypeFile typeFile1 = new MaTypeFile();
typeFile1.setTypeId(typeId);
typeFile1.setFileName(maType.getDocumentName());
typeFile1.setFileUrl(maType.getDocumentUrl());
typeFile1.setFileType("2");
typeFile1.setCreateTime(DateUtils.getNowDate());
typeFileMapper.insertMaTypeFile(typeFile1);
}
// 库管员配置
if (Objects.nonNull(maType.getKeeperUserId())) {
MaTypeKeeper typeKeeper = new MaTypeKeeper();
typeKeeper.setUserId(maType.getKeeperUserId());
typeKeeper.setTypeId(typeId);
typeKeeper.setCreateTime(DateUtils.getNowDate());
maTypeMapper.insertKeeper(typeKeeper);
}
// 维修员配置
if (Objects.nonNull(maType.getRepairUserId())) {
MaTypeRepair typeRepair = new MaTypeRepair();
typeRepair.setUserId(maType.getRepairUserId());
typeRepair.setTypeId(typeId);
typeRepair.setCreateTime(DateUtils.getNowDate());
maTypeMapper.insertRepair(typeRepair);
}
// 资产属性配置
if (maType.getPropId() > 0) {
MaPropSet propSet = new MaPropSet();
propSet.setTypeId(typeId);
propSet.setPropId(maType.getPropId());
propSet.setCreateTime(DateUtils.getNowDate());
maTypeMapper.insertMaPropSet(propSet);
}
return i;
}
/**
* 修改机具类型管理ma_type
*
* @param maType 机具类型管理ma_type
* @return 结果
*/
@Override
public int updateMaType(MaType maType) {
Long typeId = maType.getTypeId();
maType.setUpdateTime(DateUtils.getNowDate());
int i = maTypeMapper.updateType(maType);
// 图片路径保存
if (StringUtils.isNotEmpty(maType.getPhotoName()) && StringUtils.isNotEmpty(maType.getPhotoUrl())) {
typeFileMapper.deleteMaTypeFileByTypeId(typeId, "1");
MaTypeFile typeFile = new MaTypeFile();
typeFile.setTypeId(typeId);
typeFile.setFileName(maType.getPhotoName());
typeFile.setFileUrl(maType.getPhotoUrl());
typeFile.setFileType("1");
typeFile.setCreateTime(DateUtils.getNowDate());
typeFile.setUpdateTime(DateUtils.getNowDate());
typeFileMapper.insertMaTypeFile(typeFile);
}
// 文档路径保存
if (StringUtils.isNotEmpty(maType.getDocumentName()) && StringUtils.isNotEmpty(maType.getDocumentUrl())) {
typeFileMapper.deleteMaTypeFileByTypeId(typeId, "2");
MaTypeFile typeFile1 = new MaTypeFile();
typeFile1.setTypeId(typeId);
typeFile1.setFileName(maType.getDocumentName());
typeFile1.setFileUrl(maType.getDocumentUrl());
typeFile1.setFileType("2");
typeFile1.setCreateTime(DateUtils.getNowDate());
typeFile1.setUpdateTime(DateUtils.getNowDate());
typeFileMapper.insertMaTypeFile(typeFile1);
}
// 库管员配置
if (maType.getKeeperUserId() != null) {
maTypeMapper.deleteKeeperByTypeId(typeId);
MaTypeKeeper typeKeeper = new MaTypeKeeper();
typeKeeper.setUserId(maType.getKeeperUserId());
typeKeeper.setTypeId(typeId);
typeKeeper.setCreateTime(DateUtils.getNowDate());
typeKeeper.setUpdateTime(DateUtils.getNowDate());
maTypeMapper.insertKeeper(typeKeeper);
}
// 维修员配置
if (maType.getRepairUserId() != null) {
maTypeMapper.deleteTypeByTypeId(typeId);
MaTypeRepair typeRepair = new MaTypeRepair();
typeRepair.setUserId(maType.getRepairUserId());
typeRepair.setTypeId(typeId);
maTypeMapper.insertRepair(typeRepair);
}
// 资产属性配置
if (maType.getPropId() >= 0L) {
maTypeMapper.deletePropSetByTypeId(typeId);
MaPropSet propSet = new MaPropSet();
propSet.setTypeId(typeId);
propSet.setPropId(maType.getPropId());
propSet.setCreateTime(DateUtils.getNowDate());
propSet.setUpdateTime(DateUtils.getNowDate());
maTypeMapper.insertMaPropSet(propSet);
}
return i;
}
/**
* 删除机具类型管理ma_type信息
*
* @param typeId 机具类型管理ma_type主键
* @return 结果
*/
@Override
public int deleteMaTypeByTypeId(Long typeId) throws Exception {
List<MaType> listByParentId = maTypeMapper.getListByParentId(typeId, "");
if (listByParentId.size() > 0) {
throw new Exception("子级类型不为空!!!");
}
return maTypeMapper.deleteTypeById(typeId);
}
@Override
public List<TreeSelect> getMaTypeList(String typeName, String parentId) {
List<MaType> maTypes = maTypeMapper.selectMaTypeTree(parentId);
List<TreeSelect> treeSelectList = buildDeptTreeSelect(maTypes);
//如果没有查询到那么返回空
return treeSelectList;
}
@Override
public List<TreeSelect> getMaTypeSelect(String typeName, String parentId) {
List<MaType> maTypes = maTypeMapper.getMaTypeSelect(parentId);
List<TreeSelect> treeSelectList = buildDeptTreeSelect(maTypes);
//如果没有查询到那么返回空
return treeSelectList;
}
/**
* 根据左列表类型id查询右表格
*
* @param typeId
* @return
*/
@Override
public List<MaType> getListByMaType(Long typeId, String typeName) {
List<MaType> maTypes = maTypeMapper.selectMaTypeList("");
MaType maType = new MaType();
maType.setTypeId(typeId);
List<MaType> typeListByMaType = getTypeListByMaType(Collections.singletonList(maType), maTypes, new ArrayList<>());
if (StringUtils.isNotNull(typeName)) {
//根据类型名称过滤集合
List<MaType> types = typeListByMaType
.stream()
.filter(ma -> ma.getTypeName().contains(typeName))
.collect(Collectors.toList());
//如果没有查询到那么返回空
return types;
}
return typeListByMaType;
}
/**
* 根据父级类型递归获取树结构
*
* @param
* @return
*/
private List<MaType> getTypeListByMaType(List<MaType> parentTypes, List<MaType> oldMaTypes, List<MaType> newMaTypes) {
//初始化新容器
if (newMaTypes == null) {
newMaTypes = new ArrayList<>();
//添加父级对象 左边需要添加因为需要显示 右边不需要添加因为不需要显示
newMaTypes.addAll(parentTypes);
}
//递归父级容器
List<MaType> parentList = new ArrayList<>();
//过滤相同数据,减少循环,性能优化
oldMaTypes = oldMaTypes.stream().filter(oldMaType -> !parentTypes.contains(oldMaType)).collect(Collectors.toList());
for (MaType maType : oldMaTypes) {
for (MaType parentType : parentTypes) {
if (maType.getParentId().equals(parentType.getTypeId())) {
newMaTypes.add(maType);
parentList.add(maType);
}
}
}
//如果还有父级递归查询
if (parentList.size() > 0) {
return getTypeListByMaType(parentList, oldMaTypes, newMaTypes);
} else {
List<MaType> result = new ArrayList<>();
for (MaType type : newMaTypes) {
boolean a = true;
Long typeId1 = type.getTypeId();
for (MaType type1 : newMaTypes) {
Long pid = type1.getParentId();
if (typeId1.equals(pid)) {
a = false;
}
}
if (a) {
result.add(type);
}
}
//返回
return result;
}
}
/**
* 构建前端所需要下拉树结构
*
* @param depts 部门列表
* @return 下拉树结构列表
*/
@Override
public List<TreeSelect> buildDeptTreeSelect(List<MaType> depts) {
List<MaType> deptTrees = buildDeptTree(depts);
return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
}
/**
* 构建前端所需要树结构
*
* @param maTypeList 部门列表
* @return 树结构列表
*/
@Override
public List<MaType> buildDeptTree(List<MaType> maTypeList) {
List<MaType> returnList = new ArrayList<MaType>();
List<Long> tempList = maTypeList.stream().map(MaType::getTypeId).collect(Collectors.toList());
for (MaType maType : maTypeList) {
// 如果是顶级节点, 遍历该父节点的所有子节点
if (!tempList.contains(maType.getParentId())) {
recursionFn(maTypeList, maType);
returnList.add(maType);
}
}
if (returnList.isEmpty()) {
returnList = maTypeList;
}
return returnList;
}
/**
* 根据组织树parent_id查询结果
*
* @param typeId 父级id
* @param typeName 名称筛选
* @return
*/
@Override
public List<MaType> getListByParentId(Long typeId, String typeName) {
return maTypeMapper.getListByParentId(typeId, typeName);
}
@Override
public List<Integer> selectParentId(Long typeId, Integer level) {
return maTypeMapper.selectParentId(typeId, level);
}
/**
* 查询工器具类型四级组织树
*
* @param typeId
* @param typeName
* @return
*/
@Override
public List<MaType> getEquipmentType(Long typeId, String typeName) {
List<MaType> maTypes = maTypeMapper.selectMaTypeList("");
List<MaType> list = new ArrayList<>();
for (MaType maType : maTypes) {
if (maType.getParentId() == 0) {
list.add(maType);
}
}
List<MaType> tree = new ArrayList<>();
//根据父节点获取对应的儿子节点
for (MaType maType : list) {
List<MaType> child = getChild(maTypes, maType.getTypeId());
maType.setChildren(child);
tree.add(maType);
}
return list;
}
/**
* @Author dingjie
* @Date 2023/12/14
* @Description 递归调用获取儿子
*/
public List<MaType> getChild(List<MaType> list, Long parentId) {
List<MaType> childList = new ArrayList<MaType>();
for (MaType maType : list) {
Long typeId = maType.getTypeId();
Long pid = maType.getParentId();
if (parentId.equals(pid)) {
List<MaType> childLists = getChild(list, typeId);
maType.setChildren(childLists);
childList.add(maType);
}
}
return childList;
}
/**
* 递归列表
*/
private void recursionFn(List<MaType> list, MaType t) {
// 得到子节点列表
List<MaType> childList = getChildList(list, t);
t.setChildren(childList);
for (MaType tChild : childList) {
if (hasChild(list, tChild)) {
recursionFn(list, tChild);
}
}
}
/**
* 得到子节点列表
*/
private List<MaType> getChildList(List<MaType> list, MaType t) {
List<MaType> tlist = new ArrayList<MaType>();
Iterator<MaType> it = list.iterator();
while (it.hasNext()) {
MaType n = (MaType) it.next();
if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getTypeId().longValue()) {
tlist.add(n);
}
}
return tlist;
}
/**
* 判断是否有子节点
*/
private boolean hasChild(List<MaType> list, MaType t) {
return getChildList(list, t).size() > 0 ? true : false;
}
}

View File

@ -0,0 +1,273 @@
package com.bonus.material.ma.vo;
import com.bonus.common.core.annotation.Excel;
import com.bonus.common.core.web.domain.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import java.util.List;
/**
*
* @author Dingjie
* @date
*/
@ApiModel(value="com.bonus.sgzb.base.api.domain.MaMachine")
@Data
public class MaMachine extends BaseEntity {
/**
* 机具ID
*/
@ApiModelProperty(value = "机具ID")
private long maId;
/**
* 类型ID
*/
@ApiModelProperty(value = "类型ID")
private long typeId;
/**
* 类型ID
*/
@ApiModelProperty(value = "资产属性id")
private long propId;
/**
* 物品种类
*/
@ApiModelProperty(value = "物品种类id")
private long itemId;
/**
* 设备类型
*/
@ApiModelProperty(value = "设备类型id")
private long deviceId;
/**
* 物品种类
*/
@ApiModelProperty(value = "物品种类")
@Excel(name = "物品种类", sort = 1)
private String itemType;
/**
* 设备类型
*/
@ApiModelProperty(value = "设备类型")
@Excel(name = "设备类型", sort = 2)
private String deviceType;
/**
* 规格型号
*/
@ApiModelProperty(value = "规格型号")
@Excel(name = "规格型号", sort = 3)
private String specificationType;
/**
* 机具编号
*/
@ApiModelProperty(value = "机具编号")
@Excel(name = "设备编码", sort = 4)
private String maCode;
/**
* 原编号
*/
@ApiModelProperty(value = "原编号")
@Excel(name = "设备原编号", sort = 8)
private String preCode;
/**
* 机具状态数据字典
*/
@ApiModelProperty(value = "机具状态(数据字典)")
private String maStatus;
/**
* 机具状态数据字典
*/
@ApiModelProperty(value = "机具状态(数据字典)名称")
@Excel(name = "设备状态", sort = 6)
private String maStatusName;
/**
* 二维码
*/
@ApiModelProperty(value = "二维码")
@Excel(name = "二维码", sort = 9)
private String qrCode;
/**
* 购置价
*/
@ApiModelProperty(value = "购置价")
private String buyPrice;
/**
* 厂家
*/
@ApiModelProperty(value = "厂家")
private String maVender;
/**
* 出厂日期
*/
@ApiModelProperty(value = "出厂日期")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date outFacTime;
/**
* 出厂编号
*/
@ApiModelProperty(value = "出厂编号")
private String outFacCode;
/**
* 固定资产编号
*/
@ApiModelProperty(value = "固定资产编号")
@Excel(name = "固定资产编号", sort = 7)
private String assetsCode;
/**
* 本次检验人
*/
@ApiModelProperty(value = "本次检验人")
private String checkMan;
/**
* 本次检验日期
*/
@ApiModelProperty(value = "本次检验日期")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date thisCheckTime;
/**
* 下次检验日期
*/
@ApiModelProperty(value = "下次检验日期")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date nextCheckTime;
/**
* gps编号
*/
@ApiModelProperty(value = "gps编号")
private String gpsCode;
/**
* rfid编号
*/
@ApiModelProperty(value = "rfid编号")
private String rfidCode;
/**
* erp编号
*/
@ApiModelProperty(value = "erp编号")
private String erpCode;
/**
* 调拨编号
*/
@ApiModelProperty(value = "调拨编号")
private String transferCode;
/**
* 出入库次数
*/
@ApiModelProperty(value = "出入库次数")
private String inOutNum;
/**
* 购置批次
*/
@ApiModelProperty(value = "购置批次")
@Excel(name = "采购单号", sort = 5)
private String buyTask;
/**
* 所在仓库
*/
@ApiModelProperty(value = "所在仓库")
private String ownHouse;
/**
* 数据所属组织
*/
@ApiModelProperty(value = "数据所属组织")
private String companyId;
/**
* 绑定人
*/
@ApiModelProperty(value = "绑定人")
private String binder;
/**
* 标签编号
*/
@ApiModelProperty(value = "标签编号")
private String labelCode;
@ApiModelProperty(value = "筛选名称")
private String keyWord;
@ApiModelProperty(value = "开始时间")
private String beginTime;
@ApiModelProperty(value = "结束时间")
private String endTime;
@ApiModelProperty(value = "仓库名称")
@Excel(name = "所在仓库", sort = 10)
private String ownHouseName;
@ApiModelProperty(value = "仓库id")
private Long houseId;
@ApiModelProperty(value = "厂家名称")
private String supplier;
/**
* 检验人员
*/
private String inspectMan;
/**
* 检验结论
*/
private String inspectStatus;
/**
* 联系电话
*/
private String phone;
/**
* 领料单位
*/
private String leaseUnit;
/**
* 领料工程
*/
private String leasePro;
/**
* 领料时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date leaseTime;
/**
* 退料单位
*/
private String backUnit;
/**
* 退料工程
*/
private String backPro;
/**
* 退料时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date backTime;
@ApiModelProperty(value = "1二维码绑定标识 2rfid绑定标识")
private Integer flag;
@ApiModelProperty(value = "数据来源0新购 1盘点 2数据推送")
private Integer souceBy;
@ApiModelProperty(value = "数据推送id")
private Integer dataReceiveId;
/** 导出选中列表 */
private List<Long> dataCondition;
@ApiModelProperty(value = "绑定IOT设备数量")
private Integer IotNum;
@ApiModelProperty(value = "Iot定位设备编号")
private String iotCode;
@ApiModelProperty(value = "推送到租赁标识0未推送 1推送")
private Integer pushStatus;
}

View File

@ -0,0 +1,63 @@
package com.bonus.material.ma.vo;
import com.bonus.common.core.web.domain.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@Data
public class MaPropSet extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* ID
*/
private long id;
/**
* 资产ID
*/
private long propId;
/**
* 类型ID
*/
private long typeId;
@ApiModelProperty(value = "类型ids")
private String typeIds;
/**
* 帐号状态0正常 1停用
*/
private String status;
/**
* 删除标志0代表存在 2代表删除
*/
private String delFlag;
/**
* 创建者
*/
private String createBy;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新者
*/
private String updateBy;
/**
* 更新时间
*/
private Date updateTime;
/**
* 备注
*/
private String remark;
/**
* 数据所属组织
*/
private String companyId;
private String propName;
}

View File

@ -0,0 +1,217 @@
package com.bonus.material.ma.vo;
import com.bonus.common.core.annotation.Excel;
import com.bonus.common.core.web.domain.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 工机具类型管理实体类
*/
/**
*
* @author rsyao
* @date
*/
@Data
public class MaType extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 类型ID */
@ApiModelProperty(value = "类型ID")
private Long typeId;
/** 类型名称 */
@ApiModelProperty(value = "类型名称")
@Excel(name = "名称")
private String typeName;
/** 类型ID */
@ApiModelProperty(value = "类型ID,用作组织树筛选")
private Long id;
/** 类型名称 */
@ApiModelProperty(value = "类型名称,用作组织树筛选")
private String label;
/** 上级ID */
@ApiModelProperty(value = "上级ID")
private Long parentId;
/** 帐号状态0正常 1停用 */
@ApiModelProperty(value = "帐号状态0正常 1停用")
private String status;
/** 实时库存 */
@ApiModelProperty(value = "实时库存")
private Integer storageNum;
/** 计量单位id */
@ApiModelProperty(value = "计量单位id")
private String unitId;
/** 计量单位 */
@ApiModelProperty(value = "计量单位")
@Excel(name = "计量单位")
private String unitName;
/** 管理方式 */
@ApiModelProperty(value = "管理方式")
private String manageType;
/** 租赁单价 */
@ApiModelProperty(value = "租赁单价")
@Excel(name = "租赁价格")
private BigDecimal leasePrice;
/** 租赁单价 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "租赁单价")
private Date effTime;
@ApiModelProperty(value = "外部价格")
private BigDecimal rentPrice;
private BigDecimal finalPrice;
/** 原价 */
@ApiModelProperty(value = "原价")
@Excel(name = "原值")
private BigDecimal buyPrice;
/** 丢失赔偿价 */
@ApiModelProperty(value = "丢失|赔偿价")
@Excel(name = "丢失赔偿价")
private BigDecimal payPrice;
/** 层级 */
@ApiModelProperty(value = "层级")
private String level;
/** 额定载荷 */
@ApiModelProperty(value = "额定载荷")
private String ratedLoad;
/** 试验载荷 */
@ApiModelProperty(value = "试验载荷")
private String testLoad;
/** 持荷时间 */
@ApiModelProperty(value = "持荷时间")
private String holdingTime;
/** 库存预警数量 */
@ApiModelProperty(value = "库存预警数量")
private Integer warnNum;
/** 库存预警数量 */
@ApiModelProperty(value = "是否计划管理0代表否 1代表是")
private String isPlan;
/** 库存预警数量 */
@ApiModelProperty(value = "是否安措费机具0代表否1代表是")
private String isAncuo;
/** 删除标志0代表存在 2代表删除 */
@ApiModelProperty(value = "删除标志0代表存在 2代表删除")
private String delFlag;
/** 创建者 */
@ApiModelProperty(value = "创建者")
private String createBy;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建时间")
private Date createTime;
/** 更新者 */
@ApiModelProperty(value = "更新者")
private String updateBy;
/** 更新时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新时间")
private Date updateTime;
/** 备注 */
@ApiModelProperty(value = "备注")
@Excel(name = "备注信息")
private String remark;
/** 数据所属组织 */
@ApiModelProperty(value = "数据所属组织")
private String companyId;
/** 图片名称 */
@ApiModelProperty(value = "图片名称")
@Excel(name = "图片")
private String photoName;
/** 图片路径 */
@ApiModelProperty(value = "图片路径")
private String photoUrl;
private String childPhoto;
/** 文档名称 */
@ApiModelProperty(value = "文档名称")
@Excel(name = "文档资料")
private String documentName;
/** 文档路径 */
@ApiModelProperty(value = "文档路径")
private String documentUrl;
/** 库管员id */
@ApiModelProperty(value = "库管员id")
private Integer keeperUserId;
/** 库管员名称 */
@ApiModelProperty(value = "库管员名称")
@Excel(name = "库管员")
private String keeperUserName;
/** 库管员id */
@ApiModelProperty(value = "维修员id")
private Integer repairUserId;
/** 维修员名称 */
@ApiModelProperty(value = "维修员名称")
private String repairUserName;
/** 资产属性id */
@ApiModelProperty(value = "资产属性id")
private long propId;
/** 资产属性名称 */
@ApiModelProperty(value = "资产属性名称")
@Excel(name = "资产属性")
private String propName;
/** 资产属性名称 */
@ApiModelProperty(value = "类型编码")
private String code;
/** 子节点 */
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<MaType> children = new ArrayList<>();
/**
* 厂家规格型号
*/
@ApiModelProperty(value = "厂家规格型号")
private String facModel;
/*
* 推送智慧工程定义的门类分类机具编码
* */
@ApiModelProperty(value = "推送智慧工程定义的门类分类机具编码")
private String intelligentCode;
}

View File

@ -0,0 +1,108 @@
package com.bonus.material.ma.vo;
import com.bonus.common.core.annotation.Excel;
import com.bonus.common.core.web.domain.BaseEntity;
@SuppressWarnings("serial")
public class MaTypeFile extends BaseEntity {
private static final long serialVersionUID = 1L;
//类型ID
@Excel(name = "类型ID")
private Long typeId;
//机具ID
@Excel(name = "机具ID")
private String maId;
//文件名称
@Excel(name = "文件名称")
private String fileName;
//文件地址
@Excel(name = "文件地址")
private String fileUrl;
//上传文件类型数据字典
@Excel(name = "上传文件类型(数据字典)")
private String fileType;
//上传人
@Excel(name = "上传人")
private String userId;
//帐号状态0正常 1停用
@Excel(name = "帐号状态0正常 1停用")
private String status;
//数据所属组织
@Excel(name = "数据所属组织")
private String companyId;
public Long getTypeId() {
return typeId;
}
public void setTypeId(Long typeId) {
this.typeId = typeId;
}
public String getMaId() {
return maId;
}
public void setMaId(String maId) {
this.maId = maId;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getFileUrl() {
return fileUrl;
}
public void setFileUrl(String fileUrl) {
this.fileUrl = fileUrl;
}
public String getFileType() {
return fileType;
}
public void setFileType(String fileType) {
this.fileType = fileType;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getCompanyId() {
return companyId;
}
public void setCompanyId(String companyId) {
this.companyId = companyId;
}
}

View File

@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.material.ma.mapper.MaTypeFileMapper">
<resultMap type="com.bonus.material.ma.vo.MaTypeFile" id="MaTypeFileResult">
<result property="typeId" column="type_id" />
<result property="maId" column="ma_id" />
<result property="fileName" column="file_name" />
<result property="fileUrl" column="file_url" />
<result property="fileType" column="file_type" />
<result property="userId" column="user_id" />
<result property="status" column="status" />
<result property="companyId" column="company_id" />
</resultMap>
<sql id="selectMaTypeFileVo">
select type_id, ma_id, file_name, file_url, file_type, user_id, status, company_id from ma_type_file
</sql>
<select id="selectMaTypeFileList" parameterType="com.bonus.material.ma.vo.MaTypeFile" resultMap="MaTypeFileResult">
<include refid="selectMaTypeFileVo"/>
<where>
<if test="maId != null and maId != ''"> and ma_id = #{maId}</if>
<if test="fileName != null and fileName != ''"> and file_name like concat('%', #{fileName}, '%')</if>
<if test="fileUrl != null and fileUrl != ''"> and file_url = #{fileUrl}</if>
<if test="fileType != null and fileType != ''"> and file_type = #{fileType}</if>
<if test="userId != null and userId != ''"> and user_id = #{userId}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
<if test="companyId != null and companyId != ''"> and company_id = #{companyId}</if>
</where>
</select>
<select id="selectMaTypeFileByTypeId" parameterType="Long" resultMap="MaTypeFileResult">
<include refid="selectMaTypeFileVo"/>
where type_id = #{typeId}
</select>
<insert id="insertMaTypeFile" parameterType="com.bonus.material.ma.vo.MaTypeFile">
insert into ma_type_file
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="typeId != null">type_id,</if>
<if test="maId != null">ma_id,</if>
<if test="fileName != null and fileName != ''">file_name,</if>
<if test="fileUrl != null">file_url,</if>
<if test="fileType != null">file_type,</if>
<if test="userId != null">user_id,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="status != null">status,</if>
<if test="companyId != null">company_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="typeId != null">#{typeId},</if>
<if test="maId != null">#{maId},</if>
<if test="fileName != null and fileName != ''">#{fileName},</if>
<if test="fileUrl != null">#{fileUrl},</if>
<if test="fileType != null">#{fileType},</if>
<if test="userId != null">#{userId},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="status != null">#{status},</if>
<if test="companyId != null">#{companyId},</if>
</trim>
</insert>
<update id="updateMaTypeFile" parameterType="com.bonus.material.ma.vo.MaTypeFile">
update ma_type_file
<trim prefix="SET" suffixOverrides=",">
<if test="maId != null">ma_id = #{maId},</if>
<if test="fileName != null and fileName != ''">file_name = #{fileName},</if>
<if test="fileUrl != null">file_url = #{fileUrl},</if>
<if test="userId != null">user_id = #{userId},</if>
update_time = now(),
<if test="status != null">status = #{status},</if>
<if test="companyId != null">company_id = #{companyId},</if>
</trim>
where type_id = #{typeId} and file_type = #{fileType}
</update>
<delete id="deleteMaTypeFileByTypeId">
delete from ma_type_file where type_id = #{typeId} and file_type = #{fileType}
</delete>
<delete id="deleteMaTypeFileByTypeIds" parameterType="String">
delete from ma_type_file where type_id in
<foreach item="typeId" collection="array" open="(" separator="," close=")">
#{typeId}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,47 @@
package com.bonus.material.ma.vo;
import com.bonus.common.core.annotation.Excel;
import com.bonus.common.core.web.domain.BaseEntity;
@SuppressWarnings("serial")
public class MaTypeKeeper extends BaseEntity {
private static final long serialVersionUID = 1L;
//类型ID
@Excel(name = "类型ID")
private Long typeId;
//用户
@Excel(name = "用户")
private Integer userId;
//数据所属组织
@Excel(name = "数据所属组织")
private String companyId;
public Long getTypeId() {
return typeId;
}
public void setTypeId(Long typeId) {
this.typeId = typeId;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public String getCompanyId() {
return companyId;
}
public void setCompanyId(String companyId) {
this.companyId = companyId;
}
}

View File

@ -0,0 +1,79 @@
package com.bonus.material.ma.vo;
import com.bonus.common.core.annotation.Excel;
import com.bonus.common.core.web.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* 维修班机具配置ma_type_repair对象 ma_type_repair
*
* @author bonus
* @date 2023-12-11
*/
public class MaTypeRepair extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 类型ID */
private Long typeId;
/** 用户 */
@Excel(name = "用户")
private Integer userId;
/** 创建时间 */
@Excel(name = "创建时间")
private String time;
/** 数据所属组织 */
@Excel(name = "数据所属组织")
private String companyId;
public void setTypeId(Long typeId)
{
this.typeId = typeId;
}
public Long getTypeId()
{
return typeId;
}
public void setUserId(Integer userId)
{
this.userId = userId;
}
public Integer getUserId()
{
return userId;
}
public void setTime(String time)
{
this.time = time;
}
public String getTime()
{
return time;
}
public void setCompanyId(String companyId)
{
this.companyId = companyId;
}
public String getCompanyId()
{
return companyId;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("typeId", getTypeId())
.append("userId", getUserId())
.append("time", getTime())
.append("companyId", getCompanyId())
.toString();
}
}

View File

@ -0,0 +1,118 @@
package com.bonus.material.ma.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;
/**
* Treeselect树结构实体类
*
* @author ruoyi
*/
public class TreeSelect implements Serializable
{
private static final long serialVersionUID = 1L;
/** 节点ID */
private Long id;
/** 节点名称 */
private String label;
private Integer level;
private Long parentId;
private String companyId;
/** 子节点 */
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<TreeSelect> children;
public TreeSelect()
{
}
// public TreeSelect(MaHouse maHouse)
// {
// this.level = maHouse.getLevel();
// this.id = maHouse.getHouseId();
// this.label = maHouse.getHouseName();
// this.children = maHouse.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
// }
public TreeSelect(MaType maType)
{
this.parentId = maType.getParentId();
this.level = Integer.valueOf(maType.getLevel());
this.id = maType.getTypeId();
this.label = maType.getTypeName();
this.companyId = maType.getCompanyId();
this.children = maType.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
}
// public TreeSelect(SysDept dept)
// {
// this.id = dept.getDeptId();
// this.label = dept.getDeptName();
// this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
// }
public Long getParentId() {
return parentId;
}
public void setParentId(Long parentId) {
this.parentId = parentId;
}
public Long getId()
{
return id;
}
public void setId(Long id)
{
this.id = id;
}
public Integer getLevel() {
return level;
}
public void setLevel(Integer level) {
this.level = level;
}
public String getLabel()
{
return label;
}
public void setLabel(String label)
{
this.label = label;
}
public String getCompanyId() {
return companyId;
}
public void setCompanyId(String companyId) {
this.companyId = companyId;
}
public List<TreeSelect> getChildren()
{
return children;
}
public void setChildren(List<TreeSelect> children)
{
this.children = children;
}
}

View File

@ -0,0 +1,456 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.material.ma.mapper.MaTypeMapper">
<resultMap type="com.bonus.material.ma.vo.MaType" id="MaTypeResult">
<result property="typeId" column="type_id" />
<result property="typeName" column="type_name" />
<result property="parentId" column="parent_id" />
<result property="status" column="status" />
<result property="storageNum" column="storage_num" />
<result property="companyId" column="company_id" />
<result property="code" column="code" />
<result property="unitId" column="unit_id" />
<result property="unitName" column="unit_name" />
<result property="manageType" column="manage_type" />
<result property="leasePrice" column="lease_price" />
<result property="effTime" column="eff_time" />
<result property="rentPrice" column="rent_price" />
<result property="buyPrice" column="buy_price" />
<result property="payPrice" column="pay_price" />
<result property="level" column="level" />
<result property="ratedLoad" column="rated_load" />
<result property="testLoad" column="test_load" />
<result property="holdingTime" column="holding_time" />
<result property="warnNum" column="warn_num" />
<result property="delFlag" column="del_flag" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="isPlan" column="is_plan" />
<result property="isAncuo" column="is_ancuo" />
<result property="remark" column="remark" />
<result property="childPhoto" column="childPhoto" />
<result property="intelligentCode" column="intelligent_code" />
</resultMap>
<sql id="selectMaTypeVo">
select type_id, type_name, parent_id, status, storage_num, company_id, code, unit_id, unit_name, manage_type, lease_price, eff_time, rent_price, buy_price, pay_price, level, rated_load, test_load, holding_time, warn_num, del_flag, create_by, create_time, update_by, update_time, is_plan, is_ancuo, remark,intelligent_code ,fac_model, child_photo from ma_type
</sql>
<insert id="insertType" parameterType="com.bonus.material.ma.vo.MaType" useGeneratedKeys="true" keyProperty="typeId">
insert into ma_type
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="typeName != null and typeName != ''">type_name,</if>
<if test="parentId != null">parent_id,</if>
<if test="status != null">status,</if>
<if test="storageNum != null">storage_num,</if>
<if test="companyId != null">company_id,</if>
<if test="code != null">code,</if>
<if test="unitId != null">unit_id,</if>
<if test="unitName != null">unit_name,</if>
<if test="manageType != null">manage_type,</if>
<if test="leasePrice != null">lease_price,</if>
<if test="effTime != null">eff_time,</if>
<if test="rentPrice != null">rent_price,</if>
<if test="buyPrice != null">buy_price,</if>
<if test="payPrice != null">pay_price,</if>
<if test="level != null">level,</if>
<if test="ratedLoad != null">rated_load,</if>
<if test="testLoad != null">test_load,</if>
<if test="holdingTime != null">holding_time,</if>
<if test="warnNum != null">warn_num,</if>
<if test="delFlag != null">del_flag,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="isPlan != null">is_plan,</if>
<if test="isAncuo != null">is_ancuo,</if>
<if test="remark != null">remark,</if>
<if test="facModel != null">fac_model,</if>
<if test="intelligentCode != null">intelligent_code,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="typeName != null and typeName != ''">#{typeName},</if>
<if test="parentId != null">#{parentId},</if>
<if test="status != null">#{status},</if>
<if test="storageNum != null">#{storageNum},</if>
<if test="companyId != null">#{companyId},</if>
<if test="code != null">#{code},</if>
<if test="unitId != null">#{unitId},</if>
<if test="unitName != null">#{unitName},</if>
<if test="manageType != null">#{manageType},</if>
<if test="leasePrice != null">#{leasePrice},</if>
<if test="effTime != null">#{effTime},</if>
<if test="rentPrice != null">#{rentPrice},</if>
<if test="buyPrice != null">#{buyPrice},</if>
<if test="payPrice != null">#{payPrice},</if>
<if test="level != null">#{level},</if>
<if test="ratedLoad != null">#{ratedLoad},</if>
<if test="testLoad != null">#{testLoad},</if>
<if test="holdingTime != null">#{holdingTime},</if>
<if test="warnNum != null">#{warnNum},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="isPlan != null">#{isPlan},</if>
<if test="isAncuo != null">#{isAncuo},</if>
<if test="remark != null">#{remark},</if>
<if test="facModel != null">#{facModel},</if>
<if test="intelligentCode != null">#{intelligentCode},</if>
</trim>
</insert>
<insert id="insertTypeFile" parameterType="com.bonus.material.ma.vo.MaTypeFile" useGeneratedKeys="true" keyProperty="typeId">
insert into ma_type_file(
<if test="typeId != null and typeId != 0">type_id,</if>
<if test="maId != null and maId != ''">ma_id,</if>
<if test="fileName != null and fileName != 0">file_name,</if>
<if test="fileUrl != null and fileUrl != ''">file_url,</if>
<if test="fileType != null and fileType != 0">file_type,</if>
<if test="userId != null and userId != 0">user_id,</if>
<if test="status != null and status != 0">status,</if>
<if test="companyId != null and companyId != ''">company_id,</if>
create_time
)values(
<if test="typeId != null and typeId != 0">#{typeId},</if>
<if test="maId != null and maId != ''">#{maId},</if>
<if test="fileName != null and fileName != 0">#{fileName},</if>
<if test="fileUrl != null and fileUrl != ''">#{fileUrl},</if>
<if test="fileType != null and fileType != ''">#{fileType},</if>
<if test="userId != null and userId != 0">#{userId},</if>
<if test="status != null and status != ''">#{status},</if>
<if test="companyId != null and companyId != ''">#{companyId},</if>
sysdate()
)
</insert>
<update id="updateType">
update ma_type
<trim prefix="SET" suffixOverrides=",">
<if test="typeName != null and typeName != ''">type_name = #{typeName},</if>
<if test="parentId != null">parent_id = #{parentId},</if>
<if test="status != null">status = #{status},</if>
<if test="storageNum != null">storage_num = #{storageNum},</if>
<if test="unitId != null">unit_id = #{unitId},</if>
<if test="unitName != null">unit_name = #{unitName},</if>
<if test="manageType != null">manage_type = #{manageType},</if>
<if test="leasePrice != null">lease_price = #{leasePrice},</if>
<if test="rentPrice != null">rent_price = #{rentPrice},</if>
<if test="effTime != null">eff_time = #{effTime},</if>
<if test="buyPrice != null">buy_price = #{buyPrice},</if>
<if test="payPrice != null">pay_price = #{payPrice},</if>
<if test="level != null">level = #{level},</if>
<if test="ratedLoad != null">rated_load = #{ratedLoad},</if>
<if test="testLoad != null">test_load = #{testLoad},</if>
<if test="holdingTime != null">holding_time = #{holdingTime},</if>
<if test="warnNum != null">warn_num = #{warnNum},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="isPlan != null">is_plan = #{isPlan},</if>
<if test="isAncuo != null">is_ancuo = #{isAncuo},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="companyId != null">company_id = #{companyId},</if>
<if test="facModel != null">fac_model = #{facModel},</if>
<if test="intelligentCode != null">intelligent_code = #{intelligentCode},</if>
</trim>
where type_id = #{typeId}
</update>
<delete id="deleteTypeById" parameterType="Long">
update ma_type set del_flag = '2' where type_id = #{typeId}
</delete>
<delete id="deleteTypeByTypeId">
delete from ma_type_repair where type_id = #{typeId}
</delete>
<delete id="deleteKeeperByTypeId">
delete from ma_type_keeper where type_id = #{typeId}
</delete>
<delete id="deletePropSetByTypeId">
delete from ma_prop_set where type_id = #{typeId}
</delete>
<select id="selectMaTypeList" parameterType="String" resultMap="MaTypeResult">
select DISTINCT m.type_id, m.type_name, m.parent_id, m.status, m.storage_num, m.unit_id, m.unit_name, m.manage_type,
m.lease_price,m.eff_time, m.rent_price, m.buy_price, m.pay_price, m.level, m.rated_load, m.test_load,
m.holding_time, m.warn_num, mtf.file_name photoName, mtf.file_url photoUrl,
mtf2.file_name documentName, mtf2.file_url documentUrl, mtk.user_id keeperUserId,
su.nick_name keeperUserName, mpi.prop_name, m.del_flag, m.create_by, m.create_time,
m.remark, m.company_id ,m.type_id id , m.type_name label
from ma_type m
left join ma_prop_set mps on m.type_id = mps.type_id and mps.`status`='0' and mps.del_flag='0'
left join ma_prop_info mpi on mps.prop_id = mpi.prop_id and mpi.`status`='0' and mpi.del_flag='0'
left join (select * from ma_type_file where file_type = '1') mtf on m.type_id = mtf.type_id
left join (select * from ma_type_file where file_type = '2') mtf2 on m.type_id = mtf2.type_id
left join ma_type_keeper mtk on mtf.type_id = mtk.type_id
left join sys_user su on mtk.user_id = su.user_id
<where>
m.status = '0'
and m.del_flag = '0'
<if test="typeName != null and typeName !=''">
AND type_name like concat('%',#{typeName},'%')
</if>
</where>
</select>
<select id="selectTypeList" resultType="com.bonus.material.ma.vo.MaType">
<include refid="selectMaTypeVo"/>
<where>
<if test="typeName != null and typeName != ''">
AND type_name like concat('%', #{typeName}, '%')
</if>
</where>
</select>
<select id="selectTypeById" resultType="java.lang.Integer">
select count(1) from ma_type
where del_flag = '0' and parent_id = #{typeId} limit 1
</select>
<select id="checkTypeNameUnique" resultType="com.bonus.material.ma.vo.MaType">
<include refid="selectMaTypeVo"/>
where type_name = #{typeName} limit 1
</select>
<insert id="insertKeeper">
insert into ma_type_keeper
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="typeId != null">type_id,</if>
<if test="userId != null">user_id,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="companyId != null">company_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="typeId != null">#{typeId},</if>
<if test="userId != null">#{userId},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="companyId != null">#{companyId},</if>
</trim>
</insert>
<insert id="insertRepair">
insert into ma_type_repair
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="typeId != null">type_id,</if>
<if test="userId != null">user_id,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="companyId != null">company_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="typeId != null">#{typeId},</if>
<if test="userId != null">#{userId},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="companyId != null">#{companyId},</if>
</trim>
</insert>
<insert id="insertMaPropSet">
insert into ma_prop_set
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="propId != null">prop_id,</if>
<if test="typeId != null">type_id,</if>
<if test="status != null">status,</if>
<if test="delFlag != null">del_flag,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
<if test="companyId != null">company_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="propId != null">#{propId},</if>
<if test="typeId != null">#{typeId},</if>
<if test="status != null">#{status},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
<if test="companyId != null">#{companyId},</if>
</trim>
</insert>
<select id="selectMaTypeByTypeId" resultMap="MaTypeResult">
select m.type_id, m.type_name, m.parent_id, m.status, m.storage_num, m.unit_id,m.unit_name, m.manage_type,
m.lease_price, m.eff_time, m.rent_price, m.buy_price, m.pay_price, m.level, m.rated_load, m.test_load,
m.holding_time, m.warn_num, mtf.file_name photoName, mtf.file_url photoUrl,
mtf2.file_name documentName, mtf2.file_url documentUrl, mtk.user_id keeperUserId,
su.nick_name keeperUserName, mtr.user_id repairUserId, su1.nick_name repairUserName,mpi.prop_id as propId, mpi.prop_name as propName,
m.del_flag, m.create_by, m.create_time,
m.remark, m.company_id,m.fac_model as facModel,m.intelligent_code
from ma_type m
left join ma_prop_set mps on m.type_id = mps.type_id
left join ma_prop_info mpi on mps.prop_id = mpi.prop_id
left join (select * from ma_type_file where file_type = '1') mtf on m.type_id = mtf.type_id
left join (select * from ma_type_file where file_type = '2') mtf2 on m.type_id = mtf2.type_id
left join ma_type_keeper mtk on m.type_id = mtk.type_id
left join sys_user su on mtk.user_id = su.user_id
left join ma_type_repair mtr on m.type_id = mtr.type_id
left join sys_user su1 on mtr.user_id = su1.user_id
where m.type_id = #{typeId} and m.status = '0'
</select>
<update id="updateKeeperByTypeId">
update ma_type_keeper set user_id = #{userId},update_time = now() where type_id = #{typeId}
</update>
<update id="updateRepairByTypeId">
update ma_type_repair set user_id = #{userId},update_time = now() where type_id = #{typeId}
</update>
<update id="updatePropSetByTypeId">
update ma_prop_set set prop_id = #{propId} where type_id = #{typeId}
</update>
<select id="selectTypeByTypeId" parameterType="long" resultMap="MaTypeResult">
<include refid="selectMaTypeVo"/>
where type_id = #{typeId}
</select>
<select id="selectMaTypeTree" resultMap="MaTypeResult" parameterType="java.lang.String">
select m.type_id, m.type_name, m.parent_id, m.status, m.storage_num, m.unit_id, m.manage_type,
m.lease_price, m.eff_time, m.rent_price, m.buy_price, m.pay_price, m.level, m.rated_load, m.test_load,
m.holding_time, m.warn_num, m.del_flag, m.create_by, m.create_time,
m.remark, m.company_id
from ma_type m
where level != 4 and m.status = '0' and del_flag = '0'
</select>
<select id="getMaTypeSelect" resultType="com.bonus.material.ma.vo.MaType">
select m.type_id, m.type_name, m.parent_id, m.status, m.storage_num, m.unit_id, m.manage_type,
m.lease_price,m.eff_time, m.rent_price, m.buy_price, m.pay_price, m.level, m.rated_load, m.test_load,
m.holding_time, m.warn_num, m.del_flag, m.create_by, m.create_time,
m.remark, m.company_id
from ma_type m
<where>
m.status = '0'
</where>
</select>
<select id="getListByParentId" resultMap="MaTypeResult">
select DISTINCT m.type_id, m.type_name, m.parent_id, m.status, m.storage_num, m.unit_id, m.unit_name, m.manage_type,
m.lease_price,m.rent_price, m.eff_time, m.buy_price, m.pay_price, m.level, m.rated_load, m.test_load,
m.holding_time, m.warn_num, mtf.file_name photoName, mtf.file_url photoUrl,
mtf2.file_name documentName, mtf2.file_url documentUrl, mtk.user_id keeperUserId,
su.nick_name keeperUserName, mpi.prop_name, m.del_flag, m.create_by, m.create_time,
m.remark, m.company_id,m.fac_model as facModel,m.intelligent_code
from ma_type m
left join ma_prop_set mps on m.type_id = mps.type_id
left join ma_prop_info mpi on mps.prop_id = mpi.prop_id
left join (select * from ma_type_file where file_type = '1') mtf on m.type_id = mtf.type_id
left join (select * from ma_type_file where file_type = '2') mtf2 on m.type_id = mtf2.type_id
left join ma_type_keeper mtk on m.type_id = mtk.type_id
left join sys_user su on mtk.user_id = su.user_id
where m.parent_id = #{typeId} and m.del_flag = '0'
<if test="typeName != null and typeName !=''">
AND type_name like concat('%',#{typeName},'%')
</if>
</select>
<select id="selectMaTypeTreeByLevel" resultMap="MaTypeResult" parameterType="java.lang.String">
select m.type_id, m.type_name, m.parent_id, m.status, m.storage_num, m.unit_id, m.manage_type,
m.lease_price, m.eff_time, m.rent_price, m.buy_price, m.pay_price, m.level, m.rated_load, m.test_load,
m.holding_time, m.warn_num, m.del_flag, m.create_by, m.create_time,
m.remark, m.company_id,mtf.file_url photoUrl
from ma_type m
left join (select * from ma_type_file where file_type = '1') mtf on m.type_id = mtf.type_id
<where>
m.level = '4' and m.parent_id = #{id,jdbcType=VARCHAR} and m.del_flag = '0'
</where>
</select>
<select id="selectMaTypeListByLevelNotFour" resultMap="MaTypeResult">
SELECT
m.type_id,
m.type_name,
m.parent_id,
m.STATUS,
m.storage_num,
m.unit_id,
m.manage_type,
m.lease_price,
m.eff_time,
m.rent_price,
m.buy_price,
m.pay_price,
m.LEVEL,
m.rated_load,
m.test_load,
m.holding_time,
m.warn_num,
m.del_flag,
m.create_by,
m.create_time,
m.remark,
m.company_id,
mtf.file_url photoUrl,
mt.photoUrl as childPhoto
FROM
ma_type m
LEFT JOIN ( SELECT * FROM ma_type_file WHERE file_type = '1' ) mtf ON m.type_id = mtf.type_id
LEFT JOIN (
SELECT
m.*,
mtf.file_url photoUrl
FROM
ma_type m
LEFT JOIN ( SELECT * FROM ma_type_file WHERE file_type = '1' ) mtf ON m.type_id = mtf.type_id
WHERE
m.del_flag = '0'
GROUP BY m.parent_id
) mt on mt.parent_id = m.type_id
<where>
m.level != 4 and m.del_flag = '0'
<if test="parentId!= null and parentId != ''">
and m.parent_id = #{parentId}
</if>
<if test="keyword!= null and keyword != ''">
and locate(#{keyword}, m.type_name) > 0
</if>
</where>
</select>
<select id="selectMaTypeByUserId" resultType="com.bonus.material.ma.vo.MaTypeKeeper">
select * from ma_type_keeper where user_id = #{userId}
</select>
<select id="selectParentId" resultType="java.lang.Integer">
SELECT DISTINCT
mt2.type_id
FROM
ma_type mt
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id
WHERE 1=1
<if test="level == 1">
and mt4.type_id = #{typeId}
</if>
<if test="level == 2">
and mt3.type_id = #{typeId}
</if>
<if test="level == 3">
and mt2.type_id = #{typeId}
</if>
<if test="level == 0">
and mt.level = 4
</if>
and mt2.type_id is not null
</select>
<update id="updateTypeNum">
update ma_type set storage_num = IFNULL( storage_num, 0 ) + 1 where type_id = #{typeId}
</update>
</mapper>