This commit is contained in:
sxu 2024-10-28 08:59:47 +08:00
commit 4b98e41364
9 changed files with 249 additions and 54 deletions

View File

@ -0,0 +1,100 @@
package com.bonus.common.biz.config;
import java.util.List;
/**
* 分页索引
*/
public class ListPagingUtil {
private Integer currentPage;//当前页
private Integer pageSize;//每页显示记录条数
private Integer totalPage;//总页数
private Integer star;//开始数据
private Integer total;//总条数
private List<?> rows;//每页显示的数据
public Integer getCurrentPage() {
return currentPage;
}
public void setCurrentPage(Integer currentPage) {
this.currentPage = currentPage;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
public Integer getTotalPage() {
return totalPage;
}
public void setTotalPage(Integer totalPage) {
this.totalPage = totalPage;
}
public List<?> getRows() {
return rows;
}
public void setRows(List<?> rows) {
this.rows = rows;
}
public Integer getStar() {
return star;
}
public void setStar(Integer star) {
this.star = star;
}
public Integer getTotal() {
return total;
}
public void setTotal(Integer total) {
this.total = total;
}
@Override
public String toString() {
return "ListPagingUtil{" +
"currentPage=" + currentPage +
", pageSize=" + pageSize +
", totalPage=" + totalPage +
", rows=" + rows +
", star=" + star +
", total=" + total +
'}';
}
public void pageStartInfo(Integer currentPage, Integer pageSize){
//如果传入的pageNumber为null给pageNumber赋为1
currentPage = currentPage == null ? 1 : currentPage;
//如果传入的pageSize为null给pageSize赋为10
pageSize = pageSize == null ? 10 : pageSize;
this.setCurrentPage(currentPage);
this.setPageSize(pageSize);
}
public static ListPagingUtil paging(Integer currentPage, Integer pageSize, List<?> list) {
ListPagingUtil pagingUtil = new ListPagingUtil();
//初始化
pagingUtil.pageStartInfo(currentPage, pageSize);
//设置起始数据
pagingUtil.setStar((pagingUtil.getCurrentPage()-1)*pagingUtil.getPageSize());
//设置总数
pagingUtil.setTotal(list.size());
//设置总页数
pagingUtil.setTotalPage(pagingUtil.getTotal() % pagingUtil.getPageSize() == 0 ? pagingUtil.getTotal()/pagingUtil.getPageSize() :pagingUtil.getTotal()/pagingUtil.getPageSize()+1);
//截取list
pagingUtil.setRows(list.subList(pagingUtil.getStar(), pagingUtil.getTotal()-pagingUtil.getStar()>pagingUtil.getPageSize()?pagingUtil.getStar()+pagingUtil.getPageSize():pagingUtil.getTotal()));
return pagingUtil;
}
}

View File

@ -188,6 +188,10 @@ public class BmUnitServiceImpl implements IBmUnitService
@Override
public AjaxResult deleteBmUnitByUnitId(Long unitId)
{
//先查看往来单位是否被绑定绑定则不能删除
if (bmUnitMapper.selectBmUnitPersonByUnitId(unitId) > 0) {
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), "该单位还绑定相关人员,无法删除");
}
int result = bmUnitMapper.deleteBmUnitByUnitId(unitId);
if (result > 0) {
return AjaxResult.success(HttpCodeEnum.SUCCESS.getMsg(), result);

View File

@ -6,7 +6,10 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotNull;
import cn.hutool.core.convert.Convert;
import com.bonus.common.biz.config.ListPagingUtil;
import com.bonus.common.biz.domain.TreeSelect;
import com.bonus.common.core.utils.ServletUtils;
import com.bonus.common.log.enums.OperaType;
import com.bonus.material.common.annotation.PreventRepeatSubmit;
import com.bonus.material.ma.MaTypeConfigDto;
@ -50,6 +53,25 @@ public class TypeController extends BaseController {
return getDataTable(list);
}
/**
* 根据左列表类型id查询右表格
*
* @param type
* @return
*/
@ApiOperation(value = "根据左列表类型id查询右表格")
@GetMapping("/getListByMaType")
public AjaxResult getListByMaType(MaTypeListVo type) {
List<Integer> parentIds = typeService.selectParentId(type);
List<MaTypeListVo> listByMaType = new ArrayList<>();
for (Integer parentId : parentIds) {
listByMaType.addAll(typeService.getListByParentId(parentId.longValue(), type));
}
Integer pageIndex = Convert.toInt(ServletUtils.getParameter("pageNum"), 1);
Integer pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10);
return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, listByMaType));
}
/**
* 根据物资仓库ID查询施工类型
*/
@ -152,9 +174,9 @@ public class TypeController extends BaseController {
@PreventRepeatSubmit
@RequiresPermissions("ma:type:remove")
@SysLog(title = "物资类型管理", businessType = OperaType.DELETE, module = "仓储管理->删除物资类型")
@DeleteMapping("/{typeIds}")
public AjaxResult remove(@PathVariable Long[] typeIds) {
return toAjax(typeService.deleteTypeByTypeIds(typeIds));
@DeleteMapping("/{typeId}")
public AjaxResult remove(@PathVariable Long typeId) {
return typeService.deleteTypeByTypeId(typeId);
}
/**

View File

@ -29,7 +29,7 @@ public class Type extends BaseEntity {
private Long typeId;
/** 类型名称 */
@Excel(name = "类型名称")
@Excel(name = "规格型号")
@ApiModelProperty(value = "类型名称")
private String typeName;
@ -132,7 +132,7 @@ public class Type extends BaseEntity {
@ApiModelProperty(value = "持荷时间")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "持荷时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date holdingTime;
private String holdingTime;
/** 库存预警数量 */
@Excel(name = "库存预警数量")
@ -160,6 +160,8 @@ public class Type extends BaseEntity {
@ApiModelProperty(value = "推送智慧工程定义的门类分类机具编码")
private String intelligentCode;
private String keyword;
/** 子节点 */
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<Type> children = new ArrayList<>();

View File

@ -27,10 +27,9 @@ public interface TypeMapper {
/**
* 根据level层级和typeID 查询父级ID
* @param typeId 物资类型主键
* @param level 类型层级
* @param type
*/
List<Integer> selectParentId( @Param("typeId")Long typeId, @Param("level")Integer level);
List<Integer> selectParentId(MaTypeListVo type);
/**
* 根据物资仓库的ID查询物资类型列表
@ -38,7 +37,7 @@ public interface TypeMapper {
*/
List<MaTypeSelectVo> selectMaTypeListByHouseId(Long houseId);
List<Type> getListByTypeName(@Param("typeId") Long typeId, @Param("typeName") String typeName);
List<MaTypeListVo> getListByTypeName(@Param("typeId") Long typeId, @Param("type") MaTypeListVo type);
/**
* 查询物资类型下拉树结构--根据上级ID
@ -123,4 +122,13 @@ public interface TypeMapper {
* @return 结果
*/
int logicDeleteTypeByTypeIds(Long[] typeIds);
Type queryByName(String typeName);
/**
* 根据ID查询
* @param typeId
* @return
*/
List<Type> selectById(Long typeId);
}

View File

@ -23,13 +23,13 @@ public interface ITypeService {
*/
Type selectTypeByTypeId(Long typeId);
List<Integer> selectParentId(Long typeId, Integer level);
List<Integer> selectParentId(MaTypeListVo type);
List<Type> getEquipmentType(Long typeId, String typeName);
List<MaTypeSelectVo> selectMaTypeListByHouseId(Long houseId);
List<Type> getListByParentId(Long typeId, String typeName);
List<MaTypeListVo> getListByParentId(Long typeId, MaTypeListVo type);
/**
* 查询物资类型下拉树结构--根据上级ID
@ -84,7 +84,7 @@ public interface ITypeService {
* @param typeId 物资类型主键
* @return 结果
*/
int deleteTypeByTypeId(Long typeId);
AjaxResult deleteTypeByTypeId(Long typeId);
List<TreeSelect> getMaTypeTree(String typeName, String parentId);

View File

@ -6,9 +6,11 @@ import java.util.stream.Collectors;
import cn.hutool.core.util.ArrayUtil;
import com.bonus.common.biz.domain.TreeSelect;
import com.bonus.common.biz.enums.DataCodeEnum;
import com.bonus.common.biz.enums.HttpCodeEnum;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.core.utils.StringUtils;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.material.ma.MaTypeConfigDto;
import com.bonus.material.ma.domain.TypeKeeper;
import com.bonus.material.ma.domain.TypeRepair;
@ -19,6 +21,7 @@ import com.bonus.material.ma.vo.MaTypeListVo;
import com.bonus.material.ma.vo.MaTypeSelectVo;
import com.bonus.material.warehouse.domain.WhHouseSet;
import com.bonus.material.warehouse.service.IWhHouseSetService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import com.bonus.material.ma.mapper.TypeMapper;
import com.bonus.material.ma.domain.Type;
@ -61,8 +64,8 @@ public class TypeServiceImpl implements ITypeService {
}
@Override
public List<Integer> selectParentId(Long typeId, Integer level) {
return typeMapper.selectParentId(typeId, level);
public List<Integer> selectParentId(MaTypeListVo type) {
return typeMapper.selectParentId(type);
}
/**
@ -97,11 +100,11 @@ public class TypeServiceImpl implements ITypeService {
* 根据组织树parent_id查询结果
*
* @param typeId 父级id
* @param typeName 名称筛选
* @param type 名称筛选
*/
@Override
public List<Type> getListByParentId(Long typeId, String typeName) {
return typeMapper.getListByTypeName(typeId, typeName);
public List<MaTypeListVo> getListByParentId(Long typeId, MaTypeListVo type) {
return typeMapper.getListByTypeName(typeId, type);
}
@Override
@ -179,12 +182,12 @@ public class TypeServiceImpl implements ITypeService {
switch (maTypeListVo.getLevel()) {
case "2":
// 二级节点父级是一级节点所以要拿到父节点名称并赋值至ONE_LEVEL_NAME字段
maTypeListVo.setParentOneLevelName(maTypeListVo.getParentThreeLevelName() == null ? "" : maTypeListVo.getParentThreeLevelName());
maTypeListVo.setItemType(maTypeListVo.getMaterialName() == null ? "" : maTypeListVo.getMaterialName());
break;
case "3":
// 三级节点父级是二级节点和一级节点 要把祖父类型名称放入一级字段把父类型名称存入二级字段
maTypeListVo.setParentOneLevelName(maTypeListVo.getParentTwoLevelName() == null ? "" : maTypeListVo.getParentTwoLevelName());
maTypeListVo.setParentTwoLevelName(maTypeListVo.getParentThreeLevelName() == null ? "" : maTypeListVo.getParentThreeLevelName());
maTypeListVo.setItemType(maTypeListVo.getMaterialType() == null ? "" : maTypeListVo.getMaterialType());
maTypeListVo.setMaterialType(maTypeListVo.getMaterialName() == null ? "" : maTypeListVo.getMaterialName());
break;
case "4":
// 四级节点父级是三级节点和二级节点和一级节点 要把祖父类型名称放入一级字段把父类型名称存入二级字段子类型名称存入三级字段
@ -245,7 +248,14 @@ public class TypeServiceImpl implements ITypeService {
*/
@Override
public int insertType(Type type) {
//根据类型名称判断去重
Type maType = typeMapper.queryByName(type.getTypeName());
if (maType != null && maType.getParentId().equals(type.getParentId())) {
throw new RuntimeException("同级下类型名称存在重复!");
}
type.setLevel(String.valueOf(Integer.parseInt(type.getLevel()) + 1));
type.setCreateTime(DateUtils.getNowDate());
type.setCreateBy(SecurityUtils.getUserId().toString());
return typeMapper.insertType(type);
}
@ -257,7 +267,13 @@ public class TypeServiceImpl implements ITypeService {
*/
@Override
public int updateType(Type type) {
//根据类型名称判断去重
Type maType = typeMapper.queryByName(type.getTypeName());
if (maType != null && !maType.getTypeId().equals(type.getTypeId()) && maType.getParentId().equals(type.getParentId())) {
throw new RuntimeException("同级下类型名称存在重复!");
}
type.setUpdateTime(DateUtils.getNowDate());
type.setUpdateBy(SecurityUtils.getUserId().toString());
return typeMapper.updateType(type);
}
@ -279,8 +295,17 @@ public class TypeServiceImpl implements ITypeService {
* @return 结果
*/
@Override
public int deleteTypeByTypeId(Long typeId) {
return typeMapper.logicDeleteTypeByTypeId(typeId);
public AjaxResult deleteTypeByTypeId(Long typeId) {
//根据id查询删除类型下属是否有关联有关联无法删除
List<Type> list = typeMapper.selectById(typeId);
if (CollectionUtils.isNotEmpty(list)) {
return AjaxResult.error("该类型下有子类型,无法删除");
}
int result = typeMapper.logicDeleteTypeByTypeId(typeId);
if (result > 0) {
return AjaxResult.success(HttpCodeEnum.SUCCESS.getMsg(), result);
}
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
}

View File

@ -1,6 +1,9 @@
package com.bonus.material.ma.vo;
import com.bonus.common.core.annotation.Excel;
import com.bonus.material.ma.domain.Type;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.Getter;
import lombok.Setter;
@ -15,12 +18,16 @@ import lombok.Setter;
@Setter
public class MaTypeListVo extends Type {
private String parentOneLevelName;
@Excel(name = "施工类型")
@ApiModelProperty(value = "施工类型")
private String itemType;
private String parentTwoLevelName;
@Excel(name = "物资类型")
@ApiModelProperty(value = "施工类型")
private String materialType;
private String parentThreeLevelName;
private String parentFourLevelName;
@Excel(name = "物资名称")
@ApiModelProperty(value = "物资名称")
private String materialName;
}

View File

@ -70,10 +70,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="remark" column="remark" />
<result property="facModel" column="fac_model" />
<result property="intelligentCode" column="intelligent_code" />
<result property="parentOneLevelName" column="parentFourLevelName" />
<result property="parentTwoLevelName" column="parentThreeLevelName" />
<result property="parentThreeLevelName" column="parentTwoLevelName" />
<result property="parentFourLevelName" column="parentOneLevelName" />
<result property="itemType" column="itemType" />
<result property="materialType" column="materialType" />
<result property="materialName" column="materialName" />
<result property="houseName" column="house_name" />
</resultMap>
@ -321,29 +320,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</select>
<select id="getListByTypeName" resultMap="TypeResult">
select DISTINCT
m.type_id, m.type_name, m.parent_id, m.manage_type,
m.lease_price,m.rent_price, m.eff_time, m.buy_price, m.level, m.rated_load, m.test_load,
m.holding_time, m.warn_num,
mtk.user_id keeperUserId,
mpi.prop_name, m.del_flag, m.create_by, m.create_time,
m.remark, 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
ma_type_keeper mtk on m.type_id = mtk.type_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="selectMaTypeListByHouseId" resultType="com.bonus.material.ma.vo.MaTypeSelectVo">
select
wh_house_set.type_id AS typeId,
@ -429,4 +405,55 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</select>
<select id="getListByTypeName" resultType="com.bonus.material.ma.vo.MaTypeListVo">
SELECT DISTINCT
m3.type_name AS itemType,
m2.type_name AS materialType,
m1.type_name AS materialName,
m.type_id AS typeId,
m.type_name AS typeName,
m.parent_id as parentId,
m.manage_type as manageType,
m.unit_name as unitName,
m.lease_price as leasePrice,
m.rent_price as rentPrice,
m.eff_time as effTime,
m.buy_price as buyPrice,
m.LEVEL as level,
m.rated_load as ratedLoad,
m.test_load as testLoad,
m.holding_time as holdingTime,
m.remark as remark,
m.fac_model AS facModel
FROM
ma_type m
LEFT JOIN ma_type m1 ON m.parent_id = m1.type_id
and m1.del_flag = '0'
LEFT JOIN ma_type m2 ON m1.parent_id = m2.type_id
and m2.del_flag = '0'
LEFT JOIN ma_type m3 ON m2.parent_id = m3.type_id
and m3.del_flag = '0'
WHERE m.parent_id = #{typeId} and m.del_flag = '0'
<if test="type.keyword != null and type.keyword !=''">
AND (m.type_name like concat('%',#{type.keyword},'%')
or m1.type_name like concat('%',#{type.keyword},'%')
or m2.type_name like concat('%',#{type.keyword},'%')
or m3.type_name like concat('%',#{type.keyword},'%')
)
</if>
</select>
<select id="queryByName" resultType="com.bonus.material.ma.domain.Type">
select
type_id as typeId, parent_id as parentId, type_name as typeName, level as level
from ma_type
where type_name = #{typeName} and del_flag = '0'
</select>
<select id="selectById" resultType="com.bonus.material.ma.domain.Type">
select
type_id as typeId, parent_id as parentId, type_name as typeName, level as level
from ma_type
where parent_id = #{typeId} and del_flag = '0'
</select>
</mapper>