资产属性管理
This commit is contained in:
parent
ecddcb5307
commit
36f10b16b3
|
|
@ -0,0 +1,123 @@
|
|||
package com.bonus.material.basic.controller;
|
||||
|
||||
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.log.annotation.SysLog;
|
||||
import com.bonus.common.log.enums.OperaType;
|
||||
import com.bonus.common.security.annotation.RequiresPermissions;
|
||||
import com.bonus.material.basic.domain.BmAssetAttributes;
|
||||
import com.bonus.material.basic.domain.BmUnitType;
|
||||
import com.bonus.material.basic.service.BmAssetAttributesService;
|
||||
import com.bonus.material.common.annotation.PreventRepeatSubmit;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 资产属性表(BmAssetAttributes)表控制层
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-10-15 10:38:58
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/bmAssetAttributes")
|
||||
public class BmAssetAttributesController extends BaseController {
|
||||
/**
|
||||
* 服务对象
|
||||
*/
|
||||
@Resource
|
||||
private BmAssetAttributesService bmAssetAttributesService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param bmAssetAttributes 筛选条件
|
||||
* @return 查询结果
|
||||
*/
|
||||
@RequiresPermissions("basic:asset:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo queryByPage(BmAssetAttributes bmAssetAttributes) {
|
||||
startPage();
|
||||
List<BmAssetAttributes> list = bmAssetAttributesService.queryByPage(bmAssetAttributes);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 单条数据
|
||||
*/
|
||||
@RequiresPermissions("basic:asset:query")
|
||||
@GetMapping("/{id}")
|
||||
public AjaxResult queryById(@PathVariable("id") Long id) {
|
||||
return AjaxResult.success(bmAssetAttributesService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param bmAssetAttributes 实体
|
||||
* @return 新增结果
|
||||
*/
|
||||
@PreventRepeatSubmit
|
||||
@RequiresPermissions("basic:asset:add")
|
||||
@SysLog(title = "资产属性管理", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增资产属性管理")
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody BmAssetAttributes bmAssetAttributes) {
|
||||
return bmAssetAttributesService.insert(bmAssetAttributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑数据
|
||||
*
|
||||
* @param bmAssetAttributes 实体
|
||||
* @return 编辑结果
|
||||
*/
|
||||
@PreventRepeatSubmit
|
||||
@RequiresPermissions("basic:asset:edit")
|
||||
@SysLog(title = "资产属性管理", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->修改资产属性管理")
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody BmAssetAttributes bmAssetAttributes) {
|
||||
return bmAssetAttributesService.update(bmAssetAttributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 删除是否成功
|
||||
*/
|
||||
@PreventRepeatSubmit
|
||||
@RequiresPermissions("basic:asset:remove")
|
||||
@SysLog(title = "资产属性管理", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除资产属性管理")
|
||||
@DeleteMapping("/{id}")
|
||||
public AjaxResult deleteById(@PathVariable("id") Long id) {
|
||||
return bmAssetAttributesService.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出资产属性管理列表
|
||||
*/
|
||||
@ApiOperation(value = "导出资产属性管理列表")
|
||||
@PreventRepeatSubmit
|
||||
@RequiresPermissions("basic:asset:export")
|
||||
@SysLog(title = "资产属性管理", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出资产属性管理")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, BmAssetAttributes bmAssetAttributes)
|
||||
{
|
||||
List<BmAssetAttributes> list = bmAssetAttributesService.queryByPage(bmAssetAttributes);
|
||||
ExcelUtil<BmAssetAttributes> util = new ExcelUtil<BmAssetAttributes>(BmAssetAttributes.class);
|
||||
util.exportExcel(response, list, "资产属性管理数据");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -124,9 +124,9 @@ public class BmProjectController extends BaseController
|
|||
@PreventRepeatSubmit
|
||||
@RequiresPermissions("basic:project:remove")
|
||||
@SysLog(title = "标段工程管理", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除标段工程管理")
|
||||
@DeleteMapping("/{proIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] proIds)
|
||||
@DeleteMapping("/{proId}")
|
||||
public AjaxResult remove(@PathVariable Long proId)
|
||||
{
|
||||
return bmProjectService.deleteBmProjectByProIds(proIds);
|
||||
return bmProjectService.deleteBmProjectByProId(proId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
package com.bonus.material.basic.domain;
|
||||
|
||||
import com.bonus.common.core.annotation.Excel;
|
||||
import com.bonus.common.core.web.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 资产属性表(BmAssetAttributes)实体类
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-10-15 10:39:00
|
||||
*/
|
||||
@Data
|
||||
public class BmAssetAttributes extends BaseEntity implements Serializable {
|
||||
private static final long serialVersionUID = -16238021609223792L;
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 资产类型名称
|
||||
*/
|
||||
@Excel(name = "资产类型名称")
|
||||
private String assetName;
|
||||
|
||||
/**
|
||||
* 资产编码
|
||||
*/
|
||||
@Excel(name = "资产编码")
|
||||
private String assetCode;
|
||||
/**
|
||||
* 删除标志(0代表存在 2代表删除)
|
||||
*/
|
||||
private String delFlag;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
package com.bonus.material.basic.mapper;
|
||||
|
||||
import com.bonus.material.basic.domain.BmAssetAttributes;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 资产属性表(BmAssetAttributes)表数据库访问层
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-10-15 10:38:58
|
||||
*/
|
||||
public interface BmAssetAttributesMapper {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
BmAssetAttributes queryById(Long id);
|
||||
|
||||
/**
|
||||
* 查询指定行数据
|
||||
*
|
||||
* @param bmAssetAttributes 查询条件
|
||||
* @return 对象列表
|
||||
*/
|
||||
List<BmAssetAttributes> queryAllByLimit(BmAssetAttributes bmAssetAttributes);
|
||||
|
||||
/**
|
||||
* 统计总行数
|
||||
*
|
||||
* @param bmAssetAttributes 查询条件
|
||||
* @return 总行数
|
||||
*/
|
||||
long count(BmAssetAttributes bmAssetAttributes);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param bmAssetAttributes 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insert(BmAssetAttributes bmAssetAttributes);
|
||||
|
||||
/**
|
||||
* 批量新增数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<BmAssetAttributes> 实例对象列表
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insertBatch(@Param("entities") List<BmAssetAttributes> entities);
|
||||
|
||||
/**
|
||||
* 批量新增或按主键更新数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<BmAssetAttributes> 实例对象列表
|
||||
* @return 影响行数
|
||||
* @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参
|
||||
*/
|
||||
int insertOrUpdateBatch(@Param("entities") List<BmAssetAttributes> entities);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param bmAssetAttributes 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int update(BmAssetAttributes bmAssetAttributes);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 影响行数
|
||||
*/
|
||||
int deleteById(Long id);
|
||||
|
||||
/**
|
||||
* 根据资产名称或编号查询数据
|
||||
* @param bmAssetAttributes
|
||||
* @return
|
||||
*/
|
||||
List<BmAssetAttributes> selectBmAssetAttributesByAssetCode(BmAssetAttributes bmAssetAttributes);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
package com.bonus.material.basic.service;
|
||||
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.material.basic.domain.BmAssetAttributes;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 资产属性表(BmAssetAttributes)表服务接口
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-10-15 10:39:02
|
||||
*/
|
||||
public interface BmAssetAttributesService {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
BmAssetAttributes queryById(Long id);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param bmAssetAttributes 筛选条件
|
||||
* @return 查询结果
|
||||
*/
|
||||
List<BmAssetAttributes> queryByPage(BmAssetAttributes bmAssetAttributes);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param bmAssetAttributes 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
AjaxResult insert(BmAssetAttributes bmAssetAttributes);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param bmAssetAttributes 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
AjaxResult update(BmAssetAttributes bmAssetAttributes);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
AjaxResult deleteById(Long id);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,113 @@
|
|||
package com.bonus.material.basic.service.impl;
|
||||
|
||||
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||
import com.bonus.common.biz.enums.HttpCodeEnum;
|
||||
import com.bonus.common.core.utils.DateUtils;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import com.bonus.material.basic.domain.BmAssetAttributes;
|
||||
import com.bonus.material.basic.mapper.BmAssetAttributesMapper;
|
||||
import com.bonus.material.basic.service.BmAssetAttributesService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 资产属性表(BmAssetAttributes)表服务实现类
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-10-15 10:39:02
|
||||
*/
|
||||
@Service("bmAssetAttributesService")
|
||||
public class BmAssetAttributesServiceImpl implements BmAssetAttributesService {
|
||||
@Resource
|
||||
private BmAssetAttributesMapper bmAssetAttributesDao;
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public BmAssetAttributes queryById(Long id) {
|
||||
return bmAssetAttributesDao.queryById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param bmAssetAttributes 筛选条件
|
||||
* @return 查询结果
|
||||
*/
|
||||
@Override
|
||||
public List<BmAssetAttributes> queryByPage(BmAssetAttributes bmAssetAttributes) {
|
||||
return bmAssetAttributesDao.queryAllByLimit(bmAssetAttributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param bmAssetAttributes 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult insert(BmAssetAttributes bmAssetAttributes) {
|
||||
//先判断物资类型名称是否存在
|
||||
List<BmAssetAttributes> attributesList = bmAssetAttributesDao.selectBmAssetAttributesByAssetCode(bmAssetAttributes);
|
||||
if (CollectionUtils.isNotEmpty(attributesList)) {
|
||||
return AjaxResult.error(HttpCodeEnum.NAME_DUPLICATE.getCode(), "资产类型名称或资产编码与库中重复");
|
||||
}
|
||||
bmAssetAttributes.setCreateBy(SecurityUtils.getUserId().toString());
|
||||
bmAssetAttributes.setCreateTime(DateUtils.getNowDate());
|
||||
int result = bmAssetAttributesDao.insert(bmAssetAttributes);
|
||||
if (result > 0) {
|
||||
return AjaxResult.success();
|
||||
}
|
||||
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param bmAssetAttributes 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult update(BmAssetAttributes bmAssetAttributes) {
|
||||
//先判断物资类型名称是否存在
|
||||
List<BmAssetAttributes> attributesList = bmAssetAttributesDao.selectBmAssetAttributesByAssetCode(bmAssetAttributes);
|
||||
if (attributesList.size() > 1) {
|
||||
return AjaxResult.error(HttpCodeEnum.NAME_DUPLICATE.getCode(), "资产类型名称或资产编码与库中重复");
|
||||
}
|
||||
if (attributesList.size() == 1) {
|
||||
if (!Objects.equals(attributesList.get(0).getId(), bmAssetAttributes.getId())) {
|
||||
return AjaxResult.error(HttpCodeEnum.NAME_DUPLICATE.getCode(), "资产类型名称或资产编码与库中重复");
|
||||
}
|
||||
}
|
||||
bmAssetAttributes.setUpdateBy(SecurityUtils.getUserId().toString());
|
||||
bmAssetAttributes.setUpdateTime(DateUtils.getNowDate());
|
||||
int result = bmAssetAttributesDao.update(bmAssetAttributes);
|
||||
if (result > 0) {
|
||||
return AjaxResult.success();
|
||||
}
|
||||
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult deleteById(Long id) {
|
||||
int result = bmAssetAttributesDao.deleteById(id);
|
||||
if (result > 0) {
|
||||
return AjaxResult.success();
|
||||
}
|
||||
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
<?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.basic.mapper.BmAssetAttributesMapper">
|
||||
|
||||
<insert id="insertBmUnitType">
|
||||
insert into bm_unit_type
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="typeName != null and typeName != ''">type_name,</if>
|
||||
<if test="companyId != null">company_id,</if>
|
||||
del_flag,
|
||||
<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>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="typeName != null and typeName != ''">#{typeName},</if>
|
||||
<if test="companyId != null">#{companyId},</if>
|
||||
0,
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<insert id="insert">
|
||||
insert into bm_asset_attributes
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="assetCode != null and assetCode != ''">asset_code,</if>
|
||||
<if test="assetName != null and assetName != ''">asset_name,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
del_flag
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="assetCode != null and assetCode != ''">#{assetCode},</if>
|
||||
<if test="assetName != null and assetName != ''">#{assetName},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
0
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="update">
|
||||
update bm_asset_attributes
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="assetCode != null and assetCode != ''">asset_code = #{assetCode},</if>
|
||||
<if test="assetName != null and assetName != ''">asset_name = #{assetName},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime !=null">update_time = #{updateTime},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteById">
|
||||
update bm_asset_attributes set del_flag = 2 where id = #{id}
|
||||
</delete>
|
||||
|
||||
<select id="queryAllByLimit" resultType="com.bonus.material.basic.domain.BmAssetAttributes">
|
||||
select bma.id as id, bma.asset_code as assetCode, bma.asset_name as assetName, bma.create_by as createBy,
|
||||
bma.create_time as createTime, bma.del_flag as delFlag, bma.update_by as updateBy, bma.update_time as updateTime
|
||||
from bm_asset_attributes bma
|
||||
where bma.del_flag = '0'
|
||||
<if test="assetName != null and assetName!= ''">
|
||||
and bma.asset_name like concat('%', #{assetName}, '%')
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="queryById" resultType="com.bonus.material.basic.domain.BmAssetAttributes">
|
||||
select bma.id as id, bma.asset_code as assetCode, bma.asset_name as assetName, bma.create_by as createBy,
|
||||
bma.create_time as createTime, bma.del_flag as delFlag, bma.update_by as updateBy, bma.update_time as updateTime
|
||||
from bm_asset_attributes bma
|
||||
where bma.del_flag = '0' and bma.id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectBmAssetAttributesByAssetCode"
|
||||
resultType="com.bonus.material.basic.domain.BmAssetAttributes">
|
||||
select bma.id as id, bma.asset_code as assetCode, bma.asset_name as assetName, bma.create_by as createBy,
|
||||
bma.create_time as createTime, bma.del_flag as delFlag, bma.update_by as updateBy, bma.update_time as updateTime
|
||||
from bm_asset_attributes bma
|
||||
where bma.del_flag = '0'
|
||||
<if test="assetName != null and assetName != ''">
|
||||
<if test="assetCode != null and assetCode != ''">
|
||||
and (bma.asset_name = #{assetName} or bma.asset_code = #{assetCode})
|
||||
</if>
|
||||
<if test="assetCode == null or assetCode == ''">
|
||||
and bma.asset_code = #{assetCode}
|
||||
</if>
|
||||
</if>
|
||||
<if test="assetName == null or assetName == ''">
|
||||
<if test="assetCode != null and assetCode != ''">
|
||||
and bma.asset_code = #{assetCode}
|
||||
</if>
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue