Merge remote-tracking branch 'origin/master'

# Conflicts:
#	bonus-common/bonus-common-security/src/main/java/com/bonus/common/security/handler/GlobalExceptionHandler.java
This commit is contained in:
syruan 2024-08-15 10:36:00 +08:00
commit 2dbbb68def
18 changed files with 948 additions and 177 deletions

View File

@ -51,6 +51,12 @@ public class BmProject extends BaseEntity implements Serializable {
@Min(value = 1, message = "项目类型不能为空") @Min(value = 1, message = "项目类型不能为空")
private Integer projectType; private Integer projectType;
/**
* 项目类型 1线路工程2:变电工程3:业务工程4:其他工程
*/
@ApiModelProperty(value = "工程类型名称")
private String projectTypeName;
/** /**
* i8工程id * i8工程id
*/ */
@ -97,6 +103,12 @@ public class BmProject extends BaseEntity implements Serializable {
@ApiModelProperty(value = "项目性质") @ApiModelProperty(value = "项目性质")
private String nature; private String nature;
/**
* 项目性质
*/
@ApiModelProperty(value = "项目性质名称")
private String natureName;
/** /**
* 联系方式 * 联系方式
*/ */
@ -112,6 +124,12 @@ public class BmProject extends BaseEntity implements Serializable {
@Excel(name = "工程状态") @Excel(name = "工程状态")
private String stats; private String stats;
/**
* 工程状态
*/
@ApiModelProperty(value = "工程状态名称")
private String statsName;
/** /**
* 传真 * 传真
*/ */

View File

@ -0,0 +1,36 @@
package com.bonus.base.api.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* ma_house物资仓库(MaHouse)实体类
*
* @author makejava
* @since 2024-08-14 09:22:54
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MaHouse implements Serializable {
private static final long serialVersionUID = -11758888261312379L;
private Integer id;
/**
* 0不启用1启用
*/
private String isActive;
/**
* 备注
*/
private String remark;
/**
* 仓库名称
*/
private String name;
}

View File

@ -1,5 +1,6 @@
package com.bonus.base.api.domain; package com.bonus.base.api.domain;
import com.bonus.common.core.web.domain.BaseEntity;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
@ -18,7 +19,7 @@ import java.util.List;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
public class MaType implements Serializable { public class MaType extends BaseEntity implements Serializable {
private static final long serialVersionUID = 135108051525707131L; private static final long serialVersionUID = 135108051525707131L;
/** /**
* id * id
@ -32,6 +33,17 @@ public class MaType implements Serializable {
* 名称 * 名称
*/ */
private String name; private String name;
/**
* 父级名称
*/
private String parentName;
/**
* 编码
*/
private String code;
/** /**
* 层级 * 层级
*/ */

View File

@ -23,6 +23,11 @@ public class TreeSelect implements Serializable
private Integer level; private Integer level;
/**
* 编码
*/
private String code;
private Integer parentId; private Integer parentId;
private String companyId; private String companyId;
@ -34,6 +39,7 @@ public class TreeSelect implements Serializable
public TreeSelect(MaType maType) public TreeSelect(MaType maType)
{ {
this.parentId = maType.getParentId(); this.parentId = maType.getParentId();
this.code = maType.getCode();
this.level = Integer.valueOf(maType.getLevel()); this.level = Integer.valueOf(maType.getLevel());
this.id = maType.getId(); this.id = maType.getId();
this.label = maType.getName(); this.label = maType.getName();
@ -50,6 +56,14 @@ public class TreeSelect implements Serializable
this.parentId = parentId; this.parentId = parentId;
} }
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public Integer getId() public Integer getId()
{ {

View File

@ -45,6 +45,8 @@ public class BaseEntity implements Serializable
/** 创建人 */ /** 创建人 */
private String creator; private String creator;
private String keyWord;
/** 请求参数 */ /** 请求参数 */
@JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonInclude(JsonInclude.Include.NON_EMPTY)
private Map<String, Object> params; private Map<String, Object> params;
@ -113,6 +115,14 @@ public class BaseEntity implements Serializable
this.creator = creator; this.creator = creator;
} }
public String getKeyWord() {
return keyWord;
}
public void setKeyWord(String keyWord) {
this.keyWord = keyWord;
}
public Map<String, Object> getParams() public Map<String, Object> getParams()
{ {

View File

@ -34,17 +34,23 @@
<sql id="Base_Column_List"> <sql id="Base_Column_List">
<!--@mbg.generated--> <!--@mbg.generated-->
id, project_type, `name`, num, manager, nature, telphone, phone, fax, address, remark, bmp.id, bmp.project_type, sda1.dict_label AS projectTypeName, bmp.name, bmp.num, bmp.manager,bmp.nature,
material_clerk, company_id, `time`, sda2.dict_label AS natureName, bmp.telphone, bmp.phone, bmp.fax, bmp.address,
is_active, lon, lat, company, imp_unit, dept_name, pro_id, dept_id, cvo, stats, htzt, is_match bmp.remark, bmp.material_clerk, bmp.company_id, bmp.time,
bmp.is_active, bmp.lon, bmp.lat, bmp.company, bmp.imp_unit,
bmp.dept_name, bmp.pro_id, bmp.dept_id, bmp.cvo, bmp.stats, sda3.dict_label AS statsName,
bmp.htzt, bmp.is_match
</sql> </sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
<!--@mbg.generated--> <!--@mbg.generated-->
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
from bm_project from bm_project bmp
where id = #{id,jdbcType=INTEGER} LEFT JOIN sys_dict_data sda1 ON bmp.project_type = sda1.dict_code
LEFT JOIN sys_dict_data sda2 ON bmp.nature = sda2.dict_code
LEFT JOIN sys_dict_data sda3 ON bmp.stats = sda3.dict_code
where is_active = '1' and id = #{id,jdbcType=INTEGER}
</select> </select>
<select id="selectAll" resultMap="BaseResultMap"> <select id="selectAll" resultMap="BaseResultMap">
@ -52,6 +58,9 @@
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
from bm_project bmp from bm_project bmp
LEFT JOIN sys_dict_data sda1 ON bmp.project_type = sda1.dict_code
LEFT JOIN sys_dict_data sda2 ON bmp.nature = sda2.dict_code
LEFT JOIN sys_dict_data sda3 ON bmp.stats = sda3.dict_code
where is_active = '1' where is_active = '1'
<if test="name != null and name !=''"> <if test="name != null and name !=''">
and bmp.name LIKE CONCAT('%',#{name},'%') and bmp.name LIKE CONCAT('%',#{name},'%')

View File

@ -0,0 +1,118 @@
package com.bonus.material.controller;
import com.bonus.base.api.domain.MaHouse;
import com.bonus.base.api.domain.MaType;
import com.bonus.common.core.utils.poi.ExcelUtil;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.core.web.page.TableDataInfo;
import com.bonus.common.security.annotation.RequiresPermissions;
import com.bonus.material.service.MaHouseService;
import com.bonus.material.vo.MaTypeVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* ma_house物资仓库(MaHouse)表控制层
*
* @author makejava
* @since 2024-08-14 09:21:18
*/
@RestController
@RequestMapping("/maHouse")
public class MaHouseController extends BaseController {
/**
* 服务对象
*/
@Resource
private MaHouseService maHouseService;
/**
* 分页查询
*
* @param maHouse 筛选条件
* @return 查询结果
*/
@ApiOperation(value = "分页查询")
@GetMapping("/list")
@RequiresPermissions("material:maHouse:query")
public TableDataInfo queryByPage(MaHouse maHouse) {
startPage();
List<MaHouse> list = maHouseService.queryByPage(maHouse);
return getDataTable(list);
}
/**
* 通过主键查询单条数据
*
* @param id 主键
* @return 单条数据
*/
@ApiOperation(value = "通过主键查询单条数据")
@GetMapping("{id}")
@RequiresPermissions("material:maHouse:query")
public AjaxResult queryById(@PathVariable("id") Integer id) {
return success(maHouseService.queryById(id));
}
/**
* 新增数据
*
* @param maHouse 实体
* @return 新增结果
*/
@ApiOperation(value = "新增数据")
@PostMapping("/add")
@RequiresPermissions("material:maHouse:add")
public AjaxResult add(@RequestBody MaHouse maHouse) {
return maHouseService.insert(maHouse);
}
/**
* 编辑数据
*
* @param maHouse 实体
* @return 编辑结果
*/
@ApiOperation(value = "编辑数据")
@PostMapping("/update")
@RequiresPermissions("material:maHouse:edit")
public AjaxResult edit(@RequestBody MaHouse maHouse) {
return maHouseService.update(maHouse);
}
/**
* 删除数据
*
* @param id 主键
* @return 删除是否成功
*/
@ApiOperation(value = "删除数据")
@DeleteMapping("/{id}")
@RequiresPermissions("material:maHouse:remove")
public AjaxResult deleteById(@PathVariable("id") Integer id) {
return maHouseService.deleteById(id);
}
/**
* 导出仓库列表
*/
@ApiOperation(value = "导出仓库列表")
@RequiresPermissions("material:maHouse:export")
@PostMapping("/export")
public void export(HttpServletResponse response, MaHouse maHouse)
{
List<MaHouse> list = maHouseService.queryByPage(maHouse);
ExcelUtil<MaHouse> util = new ExcelUtil<>(MaHouse.class);
util.exportExcel(response, list, "仓库列表数据");
}
}

View File

@ -2,17 +2,18 @@ package com.bonus.material.controller;
import com.bonus.base.api.domain.MaType; import com.bonus.base.api.domain.MaType;
import com.bonus.base.api.domain.TreeSelect; import com.bonus.base.api.domain.TreeSelect;
import com.bonus.common.core.utils.poi.ExcelUtil;
import com.bonus.common.core.web.controller.BaseController; import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.security.annotation.RequiresPermissions;
import com.bonus.material.service.MaTypeService; import com.bonus.material.service.MaTypeService;
import com.bonus.material.vo.MaTypeVo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
/** /**
@ -34,16 +35,49 @@ public class MaTypeController extends BaseController {
/** /**
* 根据类型名称查询类型树 * 根据类型名称查询类型树
* *
* @param typeName 类型名称
* @return 查询结果 * @return 查询结果
*/ */
@ApiOperation(value = "根据类型名称查询类型树") @ApiOperation(value = "根据类型名称查询类型树")
@RequiresPermissions("material:maType:query")
@GetMapping("/getMaTypeList") @GetMapping("/getMaTypeList")
public AjaxResult queryByPage(@RequestParam(required = false, value = "typeName") String typeName) { public AjaxResult queryByPage() {
List<TreeSelect> maTypeList = maTypeService.getMaTypeList(typeName); List<TreeSelect> maTypeList = maTypeService.getMaTypeList();
return AjaxResult.success(maTypeList); return AjaxResult.success(maTypeList);
} }
/**
* 根据左列表类型id查询右表格
*
* @param maType
* @return
*/
@ApiOperation(value = "根据左列表类型id查询右表格")
@RequiresPermissions("material:maType:query")
@GetMapping("/getListByMaType")
public AjaxResult getListByMaType(MaType maType) {
startPage();
List<MaTypeVo> listByMaType = maTypeService.getListByParentId(maType);
return success(getDataTable(listByMaType));
}
/**
* 新增数据返回code
*
* @param id
* @return 新增结果
*/
@ApiOperation(value = "新增数据返回code")
@GetMapping("/addMaType")
public AjaxResult addMaType(@RequestParam(value = "id") Integer id) {
MaType maType ;
if (id == 0) {
return success(maTypeService.getNextChildCode(null));
} else {
maType = maTypeService.findById(id);
return success(maTypeService.getNextChildCode(maType));
}
}
/** /**
* 新增数据 * 新增数据
* *
@ -51,6 +85,7 @@ public class MaTypeController extends BaseController {
* @return 新增结果 * @return 新增结果
*/ */
@ApiOperation(value = "新增数据") @ApiOperation(value = "新增数据")
@RequiresPermissions("material:maType:add")
@PostMapping("/add") @PostMapping("/add")
public AjaxResult add(@RequestBody MaType maType) { public AjaxResult add(@RequestBody MaType maType) {
return maTypeService.insert(maType); return maTypeService.insert(maType);
@ -63,10 +98,36 @@ public class MaTypeController extends BaseController {
* @return 编辑结果 * @return 编辑结果
*/ */
@ApiOperation(value = "编辑数据") @ApiOperation(value = "编辑数据")
@RequiresPermissions("material:maType:edit")
@PostMapping("/update") @PostMapping("/update")
public AjaxResult edit(@RequestBody MaType maType) { public AjaxResult edit(@RequestBody MaType maType) {
return maTypeService.update(maType); return maTypeService.update(maType);
} }
/**
* 逻辑删除
*
* @param id 主键
* @return 删除是否成功
*/
@DeleteMapping("/{id}")
@RequiresPermissions("material:maType:remove")
public AjaxResult deleteById(@PathVariable("id") Integer id) {
return maTypeService.deleteById(id);
}
/**
* 导出物资类型列表
*/
@ApiOperation(value = "导出物资类型列表")
@RequiresPermissions("material:maType:export")
@PostMapping("/export")
public void export(HttpServletResponse response, MaType maType)
{
List<MaTypeVo> list = maTypeService.getListByParentId(maType);
ExcelUtil<MaTypeVo> util = new ExcelUtil<>(MaTypeVo.class);
util.exportExcel(response, list, "物资类型数据");
}
} }

View File

@ -0,0 +1,61 @@
package com.bonus.material.mapper;
import com.bonus.base.api.domain.MaHouse;
import java.util.List;
/**
* ma_house物资仓库(MaHouse)表数据库访问层
*
* @author makejava
* @since 2024-08-14 09:24:39
*/
public interface MaHouseMapper {
/**
* 通过ID查询单条数据
*
* @param id
* @return 实例对象
*/
MaHouse queryById(Integer id);
/**
* 查询指定行数据
*
* @param maHouse 查询条件
* @return 对象列表
*/
List<MaHouse> queryAllByLimit(MaHouse maHouse);
/**
* 新增数据
*
* @param maHouse 实例对象
* @return 影响行数
*/
int insert(MaHouse maHouse);
/**
* 修改数据
*
* @param maHouse 实例对象
* @return 影响行数
*/
int update(MaHouse maHouse);
/**
* 通过主键删除数据
*
* @param id
* @return 影响行数
*/
int deleteById(Integer id);
/**
* 根据名称查询
* @param name
* @return
*/
MaHouse queryByName(String name);
}

View File

@ -1,6 +1,7 @@
package com.bonus.material.mapper; package com.bonus.material.mapper;
import com.bonus.base.api.domain.MaType; import com.bonus.base.api.domain.MaType;
import com.bonus.material.vo.MaTypeVo;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import java.util.List; import java.util.List;
@ -13,23 +14,6 @@ import java.util.List;
*/ */
public interface MaTypeMapper { public interface MaTypeMapper {
/**
* 查询指定行数据
*
* @param maType 查询条件
* @param pageable 分页对象
* @return 对象列表
*/
List<MaType> queryAllByLimit(MaType maType, @Param("pageable") Pageable pageable);
/**
* 统计总行数
*
* @param maType 查询条件
* @return 总行数
*/
long count(MaType maType);
/** /**
* 新增数据 * 新增数据
* *
@ -72,9 +56,49 @@ public interface MaTypeMapper {
/** /**
* 根据名称查询 * 根据名称查询
* @param typeName
* @return * @return
*/ */
List<MaType> selectMaTypeTree(String typeName); List<MaType> selectMaTypeTree();
/**
* 根据父级id查询
* @param maType
* @return
*/
List<MaTypeVo> getListByParentId(MaType maType);
/**
* 查询最大code
* @return
*/
String selectCode();
/**
* 根据父级id查询
* @param maType
* @return
*/
MaType getNextChildCode(MaType maType);
/**
* 根据id查询
* @param id
* @return
*/
MaType findById(Integer id);
/**
* 根据id查询
* @param id
* @return
*/
List<MaTypeVo> selectById(Integer id);
/**
* 根据id删除
* @param id
* @return
*/
int deleteById(Integer id);
} }

View File

@ -0,0 +1,59 @@
package com.bonus.material.service;
import com.bonus.base.api.domain.MaHouse;
import com.bonus.common.core.web.domain.AjaxResult;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import java.util.List;
/**
* ma_house物资仓库(MaHouse)表服务接口
*
* @author makejava
* @since 2024-08-14 09:24:40
*/
public interface MaHouseService {
/**
* 通过ID查询单条数据
*
* @param 主键
* @return 实例对象
*/
MaHouse queryById(Integer id);
/**
* 分页查询
*
* @param maHouse 筛选条件
* @return 查询结果
*/
List<MaHouse> queryByPage(MaHouse maHouse);
/**
* 新增数据
*
* @param maHouse 实例对象
* @return 实例对象
*/
AjaxResult insert(MaHouse maHouse);
/**
* 修改数据
*
* @param maHouse 实例对象
* @return 实例对象
*/
AjaxResult update(MaHouse maHouse);
/**
* 通过主键删除数据
*
* @param id
* @return 是否成功
*/
AjaxResult deleteById(Integer id);
}

View File

@ -3,6 +3,7 @@ package com.bonus.material.service;
import com.bonus.base.api.domain.MaType; import com.bonus.base.api.domain.MaType;
import com.bonus.base.api.domain.TreeSelect; import com.bonus.base.api.domain.TreeSelect;
import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.vo.MaTypeVo;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
@ -16,15 +17,6 @@ import java.util.List;
*/ */
public interface MaTypeService { public interface MaTypeService {
/**
* 分页查询
*
* @param maType 筛选条件
* @param pageRequest 分页对象
* @return 查询结果
*/
Page<MaType> queryByPage(MaType maType, PageRequest pageRequest);
/** /**
* 新增数据 * 新增数据
* *
@ -43,8 +35,35 @@ public interface MaTypeService {
/** /**
* 根据类型名称查询类型树 * 根据类型名称查询类型树
* @param typeName
* @return * @return
*/ */
List<TreeSelect> getMaTypeList(String typeName); List<TreeSelect> getMaTypeList();
/**
* 根据左列表类型id查询右表格
* @param maType
* @return
*/
List<MaTypeVo> getListByParentId(MaType maType);
/**
* 根据id查询code
* @param maType
* @return
*/
MaTypeVo getNextChildCode(MaType maType);
/**
* 根据id查询
* @param id
* @return
*/
MaType findById(Integer id);
/**
* 根据id删除
* @param id
* @return
*/
AjaxResult deleteById(Integer id);
} }

View File

@ -0,0 +1,103 @@
package com.bonus.material.service.impl;
import com.bonus.base.api.domain.MaHouse;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.mapper.MaHouseMapper;
import com.bonus.material.service.MaHouseService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* ma_house物资仓库(MaHouse)表服务实现类
*
* @author makejava
* @since 2024-08-14 09:24:40
*/
@Service("maHouseService")
public class MaHouseServiceImpl implements MaHouseService {
@Resource
private MaHouseMapper maHouseDao;
/**
* 通过ID查询单条数据
*
* @param id
* @return 实例对象
*/
@Override
public MaHouse queryById(Integer id) {
return maHouseDao.queryById(id);
}
/**
* 分页查询
*
* @param maHouse 筛选条件
* @return 查询结果
*/
@Override
public List<MaHouse> queryByPage(MaHouse maHouse) {
List<MaHouse> maHouses = maHouseDao.queryAllByLimit(maHouse);
return maHouses;
}
/**
* 新增数据
*
* @param maHouse 实例对象
* @return 实例对象
*/
@Override
public AjaxResult insert(MaHouse maHouse) {
//根据名称查询去重
MaHouse house = maHouseDao.queryByName(maHouse.getName());
if (house != null) {
return AjaxResult.error("仓库名称重复");
}
int result = maHouseDao.insert(maHouse);
if (result > 0) {
return AjaxResult.success("新增成功");
} else {
return AjaxResult.error("新增失败");
}
}
/**
* 修改数据
*
* @param maHouse 实例对象
* @return 实例对象
*/
@Override
public AjaxResult update(MaHouse maHouse) {
//根据名称查询去重
MaHouse house = maHouseDao.queryByName(maHouse.getName());
if (house != null && !house.getId().equals(maHouse.getId())) {
return AjaxResult.error("仓库名称重复");
}
int result = maHouseDao.update(maHouse);
if (result > 0) {
return AjaxResult.success("修改成功");
} else {
return AjaxResult.error("修改失败");
}
}
/**
* 通过主键删除数据
*
* @param id
* @return 是否成功
*/
@Override
public AjaxResult deleteById(Integer id) {
int result = maHouseDao.deleteById(id);
if (result > 0) {
return AjaxResult.success("删除成功");
} else {
return AjaxResult.error("删除失败");
}
}
}

View File

@ -6,6 +6,8 @@ import com.bonus.common.core.utils.StringUtils;
import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.mapper.MaTypeMapper; import com.bonus.material.mapper.MaTypeMapper;
import com.bonus.material.service.MaTypeService; import com.bonus.material.service.MaTypeService;
import com.bonus.material.vo.MaTypeVo;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageImpl;
@ -28,19 +30,6 @@ public class MaTypeServiceImpl implements MaTypeService {
@Resource @Resource
private MaTypeMapper maTypeDao; private MaTypeMapper maTypeDao;
/**
* 分页查询
*
* @param maType 筛选条件
* @param pageRequest 分页对象
* @return 查询结果
*/
@Override
public Page<MaType> queryByPage(MaType maType, PageRequest pageRequest) {
long total = this.maTypeDao.count(maType);
return new PageImpl<>(this.maTypeDao.queryAllByLimit(maType, pageRequest), pageRequest, total);
}
/** /**
* 新增数据 * 新增数据
* *
@ -51,9 +40,10 @@ public class MaTypeServiceImpl implements MaTypeService {
public AjaxResult insert(MaType maType) { public AjaxResult insert(MaType maType) {
//根据类型名称判断去重 //根据类型名称判断去重
MaType type = maTypeDao.queryByName(maType.getName()); MaType type = maTypeDao.queryByName(maType.getName());
if (type!=null){ if (type != null && maType.getId().equals(type.getParentId())) {
return AjaxResult.error("类型名称重复"); return AjaxResult.error("同级下类型名称存在重复");
} }
maType.setLevel(String.valueOf(Integer.parseInt(maType.getLevel()) + 1));
int result = maTypeDao.insert(maType); int result = maTypeDao.insert(maType);
if (result > 0) { if (result > 0) {
return AjaxResult.success("添加成功"); return AjaxResult.success("添加成功");
@ -83,17 +73,126 @@ public class MaTypeServiceImpl implements MaTypeService {
/** /**
* 根据类型名称查询类型树 * 根据类型名称查询类型树
* @param typeName
* @return * @return
*/ */
@Override @Override
public List<TreeSelect> getMaTypeList(String typeName) { public List<TreeSelect> getMaTypeList() {
List<MaType> maTypes = maTypeDao.selectMaTypeTree(typeName); List<MaType> maTypes = maTypeDao.selectMaTypeTree();
List<TreeSelect> treeSelectList = buildDeptTreeSelect(maTypes); List<TreeSelect> treeSelectList = buildDeptTreeSelect(maTypes);
//如果没有查询到那么返回空 //如果没有查询到那么返回空
return treeSelectList; return treeSelectList;
} }
/**
* 根据左列表类型id查询右表格
* @param maType
* @return
*/
@Override
public List<MaTypeVo> getListByParentId(MaType maType) {
return maTypeDao.getListByParentId(maType);
}
/**
* 根据id查询code
* @param maType
* @return
*/
@Override
public MaTypeVo getNextChildCode(MaType maType) {
String code = "";
String c = "";
String str = "";
try {
if (maType != null) {
code = maType.getCode();
c = maType.getCode();
int len = code.length();
if (len == 2) {
code += "__";
} else if (len == 4 || len == 7) {
code += "___";
}
maType.setCode(code);
maType = maTypeDao.getNextChildCode(maType);
} else {
maType = new MaType();
maType.setCode("__");
maType = maTypeDao.getNextChildCode(maType);
}
if (maType == null) {
if (c.length() == 0 || c.length() == 2) {
code = c + "01";
} else {
code = c + "001";
}
} else {
code = maType.getCode();
if (code.length() == 2) {
code = Integer.parseInt(code) + 1 + "";
if (code.length() == 1) {
code = "0" + code;
}
} else if (code.length() == 4) {
str = code.substring(2, 4);
str = Integer.parseInt(str) + 1 + "";
if (str.length() == 1) {
str = "0" + str;
}
code = code.substring(0, 2) + str;
} else if (code.length() == 7) {
str = code.substring(4, 7);
str = Integer.parseInt(str) + 1 + "";
if (str.length() == 1) {
str = "00" + str;
} else if (str.length() == 2) {
str = "0" + str;
}
code = code.substring(0, 4) + str;
} else if (code.length() == 10) {
str = code.substring(7, 10);
str = Integer.parseInt(str) + 1 + "";
if (str.length() == 1) {
str = "00" + str;
} else if (str.length() == 2) {
str = "0" + str;
}
code = code.substring(0, 7) + str;
}
}
} catch (Exception e) {
e.printStackTrace();
}
MaTypeVo maTypeVo = new MaTypeVo();
maTypeVo.setCode(code);
return maTypeVo;
}
@Override
public MaType findById(Integer id) {
return maTypeDao.findById(id);
}
/**
* 根据id删除
* @param id
* @return
*/
@Override
public AjaxResult deleteById(Integer id) {
//根据id查询删除类型下属是否有关联有关联无法删除
List<MaTypeVo> list = maTypeDao.selectById(id);
if (CollectionUtils.isNotEmpty(list)) {
return AjaxResult.error("该类型下有子类型,无法删除");
}
int result = maTypeDao.deleteById(id);
if (result > 0) {
return AjaxResult.success("删除成功");
}
return AjaxResult.error("删除失败");
}
/** /**
* 构建前端所需要下拉树结构 * 构建前端所需要下拉树结构
* *

View File

@ -0,0 +1,45 @@
package com.bonus.material.vo;
import com.bonus.base.api.domain.MaType;
import com.bonus.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 物资类型返回vo
* @Author ma_sh
* @create 2024/8/13 14:43
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MaTypeVo extends MaType {
@ApiModelProperty("类型编码")
@Excel(name = "类型编码")
private String code;
@ApiModelProperty("仓库信息")
private String wareHouse ;
@ApiModelProperty("施工类型")
@Excel(name = "施工类型")
private String constructionType;
@ApiModelProperty("物资类型")
@Excel(name = "物资类型")
private String materialType;
@ApiModelProperty("物资名称")
@Excel(name = "物资名称")
private String materialName;
@ApiModelProperty("规格型号")
@Excel(name = "规格型号")
private String specificationCode;
@ApiModelProperty("新增类型编码")
private String newCode;
}

View File

@ -0,0 +1,66 @@
<?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.mapper.MaHouseMapper">
<resultMap type="com.bonus.base.api.domain.MaHouse" id="MaHouseMap">
<result property="isActive" column="is_active" jdbcType="VARCHAR"/>
<result property="remark" column="remark" jdbcType="VARCHAR"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="id" column="id" jdbcType="INTEGER"/>
</resultMap>
<!--查询单个-->
<select id="queryById" resultMap="MaHouseMap">
select
is_active, remark, name, id
from ma_house
where id = #{id}
</select>
<!--查询指定行数据-->
<select id="queryAllByLimit" resultMap="MaHouseMap">
select
is_active, remark, name, id
from ma_house
where is_active = '1'
<if test="name != null and name != ''">
and name like concat('%',#{name},'%')
</if>
</select>
<select id="queryByName" resultType="com.bonus.base.api.domain.MaHouse">
select
is_active, remark, name, id
from ma_house
where is_active = '1' and name = #{name}
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="" useGeneratedKeys="true">
insert into ma_house(is_active, remark, name)
values (1, #{remark}, #{name})
</insert>
<!--通过主键修改数据-->
<update id="update">
update ma_house
<set>
<if test="remark != null and remark != ''">
remark = #{remark},
</if>
<if test="name != null and name != ''">
name = #{name},
</if>
</set>
where id = #{id}
</update>
<!--通过主键删除-->
<delete id="deleteById">
update ma_house
set is_active = '0'
where id = #{id}
</delete>
</mapper>

View File

@ -68,127 +68,144 @@
where id = #{id} where id = #{id}
</set> </set>
</update> </update>
<delete id="deleteById">
update ma_type set is_active = '0' where id = #{id}
</delete>
<!--查询指定行数据--> <select id="queryByName" resultMap="MaTypeMap">
<select id="queryAllByLimit" resultMap="MaTypeMap">
select select
id, parent_id, name, level, storage_num, unit_id, buy_price, lease_price, manage_type, is_active, rate_load, test_load, hold_time, file_url, company_id id, parent_id, name, level, storage_num, unit_id, buy_price, lease_price, manage_type, is_active, rate_load, test_load, hold_time, file_url, company_id
from ma_type from ma_type
<where> where name = #{name} and is_active = '1'
<if test="id != null">
and id = #{id}
</if>
<if test="parentId != null">
and parent_id = #{parentId}
</if>
<if test="name != null and name != ''">
and name = #{name}
</if>
<if test="level != null and level != ''">
and level = #{level}
</if>
<if test="storageNum != null and storageNum != ''">
and storage_num = #{storageNum}
</if>
<if test="unitId != null and unitId != ''">
and unit_id = #{unitId}
</if>
<if test="buyPrice != null and buyPrice != ''">
and buy_price = #{buyPrice}
</if>
<if test="leasePrice != null and leasePrice != ''">
and lease_price = #{leasePrice}
</if>
<if test="manageType != null and manageType != ''">
and manage_type = #{manageType}
</if>
<if test="isActive != null and isActive != ''">
and is_active = #{isActive}
</if>
<if test="rateLoad != null and rateLoad != ''">
and rate_load = #{rateLoad}
</if>
<if test="testLoad != null and testLoad != ''">
and test_load = #{testLoad}
</if>
<if test="holdTime != null and holdTime != ''">
and hold_time = #{holdTime}
</if>
<if test="fileUrl != null and fileUrl != ''">
and file_url = #{fileUrl}
</if>
<if test="companyId != null and companyId != ''">
and company_id = #{companyId}
</if>
</where>
limit #{pageable.offset}, #{pageable.pageSize}
</select> </select>
<select id="selectMaTypeTree" resultMap="MaTypeMap" parameterType="java.lang.String">
<!--统计总行数-->
<select id="count" resultType="java.lang.Long">
select count(1)
from ma_type
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="parentId != null">
and parent_id = #{parentId}
</if>
<if test="name != null and name != ''">
and name = #{name}
</if>
<if test="level != null and level != ''">
and level = #{level}
</if>
<if test="storageNum != null and storageNum != ''">
and storage_num = #{storageNum}
</if>
<if test="unitId != null and unitId != ''">
and unit_id = #{unitId}
</if>
<if test="buyPrice != null and buyPrice != ''">
and buy_price = #{buyPrice}
</if>
<if test="leasePrice != null and leasePrice != ''">
and lease_price = #{leasePrice}
</if>
<if test="manageType != null and manageType != ''">
and manage_type = #{manageType}
</if>
<if test="isActive != null and isActive != ''">
and is_active = #{isActive}
</if>
<if test="rateLoad != null and rateLoad != ''">
and rate_load = #{rateLoad}
</if>
<if test="testLoad != null and testLoad != ''">
and test_load = #{testLoad}
</if>
<if test="holdTime != null and holdTime != ''">
and hold_time = #{holdTime}
</if>
<if test="fileUrl != null and fileUrl != ''">
and file_url = #{fileUrl}
</if>
<if test="companyId != null and companyId != ''">
and company_id = #{companyId}
</if>
</where>
</select>
<select id="queryByName" resultType="com.bonus.base.api.domain.MaType">
select select
id, parent_id, name, level, storage_num, unit_id, buy_price, lease_price, manage_type, is_active, rate_load, test_load, hold_time, file_url, company_id id, code, parent_id, name, level, storage_num, unit_id, buy_price, lease_price, manage_type, is_active, rate_load, test_load, hold_time, file_url, company_id
from ma_type from ma_type
where name = #{name} where level != '4' and is_active = '1'
</select> </select>
<select id="selectMaTypeTree" resultType="com.bonus.base.api.domain.MaType"> <select id="getListByParentId" resultType="com.bonus.material.vo.MaTypeVo">
select SELECT
id, parent_id, name, level, storage_num, unit_id, buy_price, lease_price, manage_type, is_active, rate_load, test_load, hold_time, file_url, company_id t.*
from ma_type FROM
where level != 5 and is_active = '1' (
SELECT
mt.id,
mt.`name` AS specificationCode,
mt.`level`,
mtp.`name` AS materialName,
s.`name` AS materialType,
f.`name` AS constructionType,
mt.`code`,
mt.is_active
FROM
ma_type mt
LEFT JOIN ma_type mtp ON mtp.id = mt.parent_id
LEFT JOIN ma_type s ON s.id = mtp.parent_id
LEFT JOIN ma_type f ON f.id = s.parent_id
WHERE
mt.`LEVEL` = 4 UNION
SELECT
mt.id,
NULL AS `NAME`,
mt.`level`,
mt.`name` AS materialName,
mtp.`name` AS materialType,
s.`name` AS constructionType,
mt.`CODE`,
mt.is_active
FROM
ma_type mt
LEFT JOIN ma_type mtp ON mtp.id = mt.PARENT_ID
LEFT JOIN ma_type s ON s.id = mtp.PARENT_ID
WHERE
mt.`LEVEL` = 3 UNION
SELECT
mt.id AS id,
NULL AS `NAME`,
mt.`level`,
NULL AS materialName,
mt.`NAME` AS materialType,
mtp.`NAME` AS constructionType,
mt.`CODE`,
mt.IS_ACTIVE AS enabled
FROM
ma_type mt
LEFT JOIN ma_type mtp ON mtp.id = mt.PARENT_ID
WHERE
mt.`LEVEL` = 2 UNION
SELECT
mt.id AS id,
NULL AS `NAME`,
mt.`level`,
NULL AS materialName,
NULL AS materialType,
mt.`NAME` AS constructionType,
mt.`CODE`,
mt.IS_ACTIVE AS enabled
FROM
ma_type mt
WHERE
mt.`LEVEL` = 1
) t
WHERE
t.IS_ACTIVE = '1'
<if test="keyWord != null and keyWord != ''">
and (
t.specificationCode like CONCAT('%',#{keyWord},'%') or
t.`CODE` like CONCAT('%',#{keyWord},'%') or
t.materialName like CONCAT('%',#{keyWord},'%') or
t.materialType like CONCAT('%',#{keyWord},'%') or
t.constructionType like CONCAT('%',#{keyWord},'%')
)
</if>
<if test="code != null and code != ''">
and t.`CODE` like CONCAT(#{code},'%')
</if>
ORDER BY t.`CODE`
</select>
<select id="selectCode" resultType="java.lang.String">
SELECT code
FROM ma_type
WHERE code like '__'
ORDER BY code DESC
LIMIT 1
</select>
<select id="getNextChildCode" resultType="com.bonus.base.api.domain.MaType">
SELECT `code`
FROM ma_type
WHERE `code` like #{code}
ORDER BY `code` DESC
LIMIT 1
</select>
<select id="findById" resultType="com.bonus.base.api.domain.MaType">
SELECT DISTINCT
mt.id AS id,
mt.`code`,
mt.`level`,
mt.storage_num AS storageNum,
mt.hold_time,
mt1.`name` AS parentName,
mt.`name`
FROM
ma_type mt
LEFT JOIN ma_type mt1 ON mt1.id = mt.parent_id
WHERE
mt.is_active = '1' and mt.id = #{id}
</select>
<select id="selectById" resultType="com.bonus.material.vo.MaTypeVo">
SELECT
mt.id,
mt.`code`,
mt.`level`,
mt.storage_num,
mt.hold_time,
mt.`name`
FROM
ma_type mt
WHERE
mt.is_active = '1' and mt.parent_id = #{id}
</select> </select>
<insert id="insertBatch" keyProperty="" useGeneratedKeys="true"> <insert id="insertBatch" keyProperty="" useGeneratedKeys="true">
insert into ma_type(id, parent_id, name, level, storage_num, unit_id, buy_price, lease_price, manage_type, is_active, rate_load, test_load, hold_time, file_url, company_id) insert into ma_type(id, parent_id, name, level, storage_num, unit_id, buy_price, lease_price, manage_type, is_active, rate_load, test_load, hold_time, file_url, company_id)
@ -224,16 +241,16 @@
<insert id="insert"> <insert id="insert">
INSERT INTO ma_type INSERT INTO ma_type
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null and id != ''">id,</if> <if test="id != null and id != ''">parent_id,</if>
<if test="parentId != null and parentId != ''">parent_id,</if>
<if test="name != null and name != ''">name,</if> <if test="name != null and name != ''">name,</if>
<if test="code != null and code != ''">code,</if>
<if test="level != null and level != ''">level,</if> <if test="level != null and level != ''">level,</if>
<if test="storageNum != null and storageNum != ''">storage_num,</if> <if test="storageNum != null and storageNum != ''">storage_num,</if>
<if test="unitId != null and unitId != ''">unit_id,</if> <if test="unitId != null and unitId != ''">unit_id,</if>
<if test="buyPrice != null and buyPrice != ''">buy_price,</if> <if test="buyPrice != null and buyPrice != ''">buy_price,</if>
<if test="leasePrice != null and leasePrice != ''">lease_price,</if> <if test="leasePrice != null and leasePrice != ''">lease_price,</if>
<if test="manageType != null and manageType != ''">manage_type,</if> <if test="manageType != null and manageType != ''">manage_type,</if>
<if test="isActive != null and isActive != ''">is_active,</if> is_active,
<if test="rateLoad != null and rateLoad != ''">rate_load,</if> <if test="rateLoad != null and rateLoad != ''">rate_load,</if>
<if test="testLoad != null and testLoad != ''">test_load,</if> <if test="testLoad != null and testLoad != ''">test_load,</if>
<if test="holdTime != null and holdTime != ''">hold_time,</if> <if test="holdTime != null and holdTime != ''">hold_time,</if>
@ -243,8 +260,8 @@
VALUES VALUES
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null and id != ''">#{id},</if> <if test="id != null and id != ''">#{id},</if>
<if test="parentId != null and parentId != ''">#{parentId},</if>
<if test="name != null and name != ''">#{name},</if> <if test="name != null and name != ''">#{name},</if>
<if test="code != null and code != ''">#{code},</if>
<if test="level != null and level != ''">#{level},</if> <if test="level != null and level != ''">#{level},</if>
<if test="storageNum != null and storageNum != ''">#{storageNum},</if> <if test="storageNum != null and storageNum != ''">#{storageNum},</if>
<if test="unitId != null and unitId != ''">#{unitId},</if> <if test="unitId != null and unitId != ''">#{unitId},</if>

View File

@ -110,7 +110,7 @@ public class SysProfileController extends BaseController
String username = SecurityUtils.getUsername(); String username = SecurityUtils.getUsername();
SysUser user = userService.selectUserByUserName(username); SysUser user = userService.selectUserByUserName(username);
String password = user.getPassword(); String password = user.getPassword();
String msg= ValidateUtils.isPwd(oldPassword); String msg= ValidateUtils.isPwd(newPassword);
if (StringUtils.isNotEmpty(msg)) { if (StringUtils.isNotEmpty(msg)) {
return error(msg); return error(msg);
} }