类型管理

This commit is contained in:
mashuai 2024-08-19 15:59:55 +08:00
parent 76d497aebf
commit 4379d64217
10 changed files with 218 additions and 111 deletions

View File

@ -21,6 +21,8 @@ import java.util.List;
@NoArgsConstructor
public class MaType extends BaseEntity implements Serializable {
private static final long serialVersionUID = 135108051525707131L;
private Integer isExport;
/**
* id
*/
@ -51,21 +53,26 @@ public class MaType extends BaseEntity implements Serializable {
/**
* 库存
*/
private String storageNum;
private Integer storageNum;
/**
* 计量单位id
*/
private String unitId;
/**
* 计量单位名称
*/
private String unitName;
/**
* 采购单价
*/
private String buyPrice;
private Integer buyPrice;
/**
* 租赁单价
*/
private String leasePrice;
private Integer leasePrice;
/**
* 管理类型0是编码1
* 管理类型0是编码 1数量和编码 2数量
*/
private String manageType;
/**
@ -81,7 +88,7 @@ public class MaType extends BaseEntity implements Serializable {
*/
private String testLoad;
/**
* 持荷时间
* 持荷时间 (分钟)
*/
private String holdTime;
/**
@ -93,6 +100,11 @@ public class MaType extends BaseEntity implements Serializable {
*/
private String companyId;
/**
* 是否试验0 1是
*/
private String isTest;
/** 子节点 */
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<MaType> children = new ArrayList<>();

View File

@ -42,20 +42,4 @@ public interface RemoteDictService {
@GetMapping(value = "/dict/data/type/{dictType}")
public R<List<Object>> getDictData(@RequestParam(value = "dictType", required = false) String dictType);
/**
* 往来单位树
* @param sysDept
* @return
*/
@GetMapping("/customer/customerTree")
public R<List<TreeSelect>> selectCustomerTree(SysDeptTree sysDept);
/**
* 工程树
* @param sysDept
* @return
*/
@GetMapping("/customer/projectTree")
public R<List<TreeSelect>> selectProjectTree(SysDeptTree sysDept);
}

View File

@ -36,15 +36,6 @@ public class RemoteDictFallbackFactory implements FallbackFactory<RemoteDictServ
return R.fail("获取字典数据失败" + throwable.getMessage());
}
@Override
public R<List<TreeSelect>> selectCustomerTree(SysDeptTree sysDept) {
return R.fail("获取往来单位树数据失败" + throwable.getMessage());
}
@Override
public R<List<TreeSelect>> selectProjectTree(SysDeptTree sysDept) {
return R.fail("获取工程树数据失败" + throwable.getMessage());
}
};
}
}

View File

@ -89,4 +89,13 @@ public class BaseTreeController {
return AjaxResult.success(deptList);
}
/**
* 获取计量单位
*/
@RequestMapping("/getUnitName")
public R<Object> getUnitName(){
R<List<Object>> bmProNature = remoteDictService.getDictData("ma_unit");
return R.ok(bmProNature);
}
}

View File

@ -10,6 +10,7 @@ import com.bonus.material.service.MaTypeService;
import com.bonus.material.vo.MaTypeVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -25,6 +26,7 @@ import java.util.List;
@Api(tags = "机具类型管理")
@RestController
@RequestMapping("/maType")
@Slf4j
public class MaTypeController extends BaseController {
/**
* 服务对象
@ -60,6 +62,18 @@ public class MaTypeController extends BaseController {
return success(getDataTable(listByMaType));
}
/**
* 根据id查询用于回显
* @param id
* @return
*/
@ApiOperation(value = "根据id查询")
@GetMapping("/selectById")
public AjaxResult selectById(@RequestParam(value = "id") Integer id) {
MaType maType = maTypeService.selectById(id);
return success(maType);
}
/**
* 新增数据返回code
*
@ -124,6 +138,7 @@ public class MaTypeController extends BaseController {
@PostMapping("/export")
public void export(HttpServletResponse response, MaType maType)
{
maType.setIsExport(1);
List<MaTypeVo> list = maTypeService.getListByParentId(maType);
ExcelUtil<MaTypeVo> util = new ExcelUtil<>(MaTypeVo.class);
util.exportExcel(response, list, "物资类型数据");

View File

@ -2,7 +2,6 @@ package com.bonus.material.mapper;
import com.bonus.base.api.domain.MaType;
import com.bonus.material.vo.MaTypeVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -22,23 +21,6 @@ public interface MaTypeMapper {
*/
int insert(MaType maType);
/**
* 批量新增数据MyBatis原生foreach方法
*
* @param entities List<MaType> 实例对象列表
* @return 影响行数
*/
int insertBatch(@Param("entities") List<MaType> entities);
/**
* 批量新增或按主键更新数据MyBatis原生foreach方法
*
* @param entities List<MaType> 实例对象列表
* @return 影响行数
* @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常请自行校验入参
*/
int insertOrUpdateBatch(@Param("entities") List<MaType> entities);
/**
* 修改数据
*
@ -100,5 +82,12 @@ public interface MaTypeMapper {
* @return
*/
int deleteById(Integer id);
/**
* 根据id查询
* @param id
* @return
*/
MaType select(Integer id);
}

View File

@ -4,8 +4,6 @@ import com.bonus.base.api.domain.MaType;
import com.bonus.base.api.domain.TreeSelect;
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.PageRequest;
import java.util.List;
@ -66,4 +64,11 @@ public interface MaTypeService {
* @return
*/
AjaxResult deleteById(Integer id);
/**
* 根据id查询
* @param id
* @return
*/
MaType selectById(Integer id);
}

View File

@ -37,7 +37,7 @@ public class MaTypeServiceImpl implements MaTypeService {
public AjaxResult insert(MaType maType) {
//根据类型名称判断去重
MaType type = maTypeDao.queryByName(maType.getName());
if (type != null && maType.getId().equals(type.getParentId())) {
if (type != null && maType.getParentId().equals(type.getParentId())) {
return AjaxResult.error("同级下类型名称存在重复!");
}
maType.setLevel(String.valueOf(Integer.parseInt(maType.getLevel()) + 1));
@ -58,8 +58,8 @@ public class MaTypeServiceImpl implements MaTypeService {
public AjaxResult update(MaType maType) {
//根据类型名称判断去重
MaType type = maTypeDao.queryByName(maType.getName());
if (type != null) {
return AjaxResult.error("类型名称重复");
if (type != null && maType.getParentId().equals(type.getParentId())) {
return AjaxResult.error("同级下类型名称存在重复");
}
int result = maTypeDao.update(maType);
if (result > 0) {
@ -87,7 +87,24 @@ public class MaTypeServiceImpl implements MaTypeService {
*/
@Override
public List<MaTypeVo> getListByParentId(MaType maType) {
return maTypeDao.getListByParentId(maType);
List<MaTypeVo> maTypeVos = maTypeDao.getListByParentId(maType);
if (CollectionUtils.isNotEmpty(maTypeVos)) {
for (MaTypeVo maTypeVo : maTypeVos) {
if (maTypeVo.getIsTest() != null && "1".equals(maTypeVo.getIsTest())) {
maTypeVo.setIsTest("");
} else {
maTypeVo.setIsTest("");
}
if (maTypeVo.getManageType() != null && "0".equals(maTypeVo.getManageType())) {
maTypeVo.setManageType("编码追溯");
} else if (maTypeVo.getManageType() != null && "1".equals(maTypeVo.getManageType())) {
maTypeVo.setManageType("数量+编码");
} else {
maTypeVo.setManageType("数量");
}
}
}
return maTypeVos;
}
/**
@ -190,6 +207,16 @@ public class MaTypeServiceImpl implements MaTypeService {
return AjaxResult.error("删除失败");
}
/**
* 根据id查询
* @param id
* @return
*/
@Override
public MaType selectById(Integer id) {
return maTypeDao.select(id);
}
/**
* 构建前端所需要下拉树结构
*

View File

@ -17,10 +17,6 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor
public class MaTypeVo extends MaType {
@ApiModelProperty("类型编码")
@Excel(name = "类型编码")
private String code;
@ApiModelProperty("仓库信息")
private String wareHouse ;
@ -40,6 +36,66 @@ public class MaTypeVo extends MaType {
@Excel(name = "规格型号")
private String specificationCode;
/**
* 层级
*/
private String level;
@ApiModelProperty("类型编码")
@Excel(name = "类型编码")
private String code;
@ApiModelProperty("单位名称")
@Excel(name = "单位")
private String unitName;
/**
* 管理类型0是编码 1数量和编码 2数量
*/
@Excel(name = "管理类型")
private String manageType;
/**
* 库存
*/
@Excel(name = "库存")
private Integer storageNum;
/**
* 采购单价
*/
@Excel(name = "购置价格")
private Integer buyPrice;
/**
* 租赁单价
*/
@Excel(name = "租赁价格")
private Integer leasePrice;
/**
* 持荷时间 (分钟)
*/
@Excel(name = "持荷时间 (分钟)")
private String holdTime;
/**
* 是否试验0 1是
*/
@Excel(name = "是否试验")
private String isTest;
/**
* 试验载荷
*/
@Excel(name = "试验载荷")
private String testLoad;
/**
* 额定载荷
*/
@Excel(name = "额定载荷")
private String rateLoad;
@ApiModelProperty("新增类型编码")
private String newCode;
}

View File

@ -7,10 +7,10 @@
<result property="parentId" column="parent_id" jdbcType="INTEGER"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="level" column="level" jdbcType="VARCHAR"/>
<result property="storageNum" column="storage_num" jdbcType="VARCHAR"/>
<result property="storageNum" column="storage_num" jdbcType="INTEGER"/>
<result property="unitId" column="unit_id" jdbcType="VARCHAR"/>
<result property="buyPrice" column="buy_price" jdbcType="VARCHAR"/>
<result property="leasePrice" column="lease_price" jdbcType="VARCHAR"/>
<result property="buyPrice" column="buy_price" jdbcType="INTEGER"/>
<result property="leasePrice" column="lease_price" jdbcType="INTEGER"/>
<result property="manageType" column="manage_type" jdbcType="VARCHAR"/>
<result property="isActive" column="is_active" jdbcType="VARCHAR"/>
<result property="rateLoad" column="rate_load" jdbcType="VARCHAR"/>
@ -18,6 +18,7 @@
<result property="holdTime" column="hold_time" jdbcType="VARCHAR"/>
<result property="fileUrl" column="file_url" jdbcType="VARCHAR"/>
<result property="companyId" column="company_id" jdbcType="VARCHAR"/>
<result property="isTest" column="is_test" jdbcType="VARCHAR"/>
</resultMap>
<update id="update">
@ -47,9 +48,6 @@
<if test="manageType != null">
manage_type = #{manageType},
</if>
<if test="isActive != null">
is_active = #{isActive},
</if>
<if test="rateLoad != null">
rate_load = #{rateLoad},
</if>
@ -65,8 +63,11 @@
<if test="companyId != null">
company_id = #{companyId},
</if>
where id = #{id}
<if test="isTest != null">
is_test = #{isTest}
</if>
</set>
where id = #{id}
</update>
<delete id="deleteById">
update ma_type set is_active = '0' where id = #{id}
@ -91,28 +92,47 @@
(
SELECT
mt.id,
f.`name` AS constructionType,
s.`name` AS materialType,
mtp.`name` AS materialName,
mt.`name` AS specificationCode,
mt.`level`,
mtp.`name` AS materialName,
s.`name` AS materialType,
f.`name` AS constructionType,
mt.`code`,
mt.`code` AS code,
sda.dict_label as unitName,
mt.manage_type as manageType,
mt.storage_num as storageNum,
mt.buy_price as buyPrice,
mt.lease_price as leasePrice,
mt.hold_time as hold_time,
mt.is_test as isTest,
mt.test_load as testLoad,
mt.rate_load as rateLoad,
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
LEFT JOIN sys_dict_data sda on mt.unit_id = sda.dict_code
WHERE
mt.`LEVEL` = 4 UNION
SELECT
mt.id,
s.`name` AS constructionType,
mtp.`name` AS materialType,
mt.`name` AS materialName,
NULL AS `NAME`,
mt.`level`,
mt.`name` AS materialName,
mtp.`name` AS materialType,
s.`name` AS constructionType,
mt.`CODE`,
mt.storage_num as storageNum,
mt.buy_price as buyPrice,
mt.lease_price as leasePrice,
mt.hold_time as hold_time,
mt.is_test as isTest,
mt.test_load as testLoad,
mt.rate_load as rateLoad,
NULL as unitName,
mt.manage_type as manageType,
mt.is_active
FROM
ma_type mt
@ -122,13 +142,22 @@
mt.`LEVEL` = 3 UNION
SELECT
mt.id AS id,
mtp.`NAME` AS constructionType,
mt.`NAME` AS materialType,
NULL AS materialName,
NULL AS `NAME`,
mt.`level`,
NULL AS materialName,
mt.`NAME` AS materialType,
mtp.`NAME` AS constructionType,
mt.`CODE`,
mt.IS_ACTIVE AS enabled
mt.storage_num as storageNum,
mt.buy_price as buyPrice,
mt.lease_price as leasePrice,
mt.hold_time as hold_time,
mt.is_test as isTest,
mt.test_load as testLoad,
mt.rate_load as rateLoad,
NULL as unitName,
mt.manage_type as manageType,
mt.IS_ACTIVE
FROM
ma_type mt
LEFT JOIN ma_type mtp ON mtp.id = mt.PARENT_ID
@ -136,13 +165,22 @@
mt.`LEVEL` = 2 UNION
SELECT
mt.id AS id,
mt.`NAME` AS constructionType,
NULL AS materialType,
NULL AS materialName,
NULL AS `NAME`,
mt.`level`,
NULL AS materialName,
NULL AS materialType,
mt.`NAME` AS constructionType,
mt.`CODE`,
mt.IS_ACTIVE AS enabled
mt.storage_num as storageNum,
mt.buy_price as buyPrice,
mt.lease_price as leasePrice,
mt.hold_time as hold_time,
mt.is_test as isTest,
mt.test_load as testLoad,
mt.rate_load as rateLoad,
NULL as unitName,
mt.manage_type as manageType,
mt.IS_ACTIVE
FROM
ma_type mt
WHERE
@ -150,6 +188,9 @@
) t
WHERE
t.IS_ACTIVE = '1'
<if test="isExport != null and isExport == 1">
and t.`level`=4
</if>
<if test="keyWord != null and keyWord != ''">
and (
t.specificationCode like CONCAT('%',#{keyWord},'%') or
@ -212,38 +253,14 @@
WHERE
mt.is_active = '1' and mt.parent_id = #{id}
</select>
<select id="select" resultType="com.bonus.base.api.domain.MaType">
select
id as id, code as code, parent_id as parentId, name as name, level as level, storage_num as storageNum, unit_id as unitId, sda.dict_label as unitName, buy_price as buyPrice, lease_price as leasePrice, manage_type as manageType, is_active as isActive, rate_load as rateLoad, test_load as testLoad, hold_time as holdTime, file_url as fileUrl, company_id as companyId, is_test as isTest
from ma_type mt
left join sys_dict_data sda on mt.unit_id = sda.dict_code
where is_active = '1' and id = #{id}
</select>
<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)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.id}, #{entity.parentId}, #{entity.name}, #{entity.level}, #{entity.storageNum}, #{entity.unitId}, #{entity.buyPrice}, #{entity.leasePrice}, #{entity.manageType}, #{entity.isActive}, #{entity.rateLoad}, #{entity.testLoad}, #{entity.holdTime}, #{entity.fileUrl}, #{entity.companyId})
</foreach>
</insert>
<insert id="insertOrUpdateBatch" 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)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.id}, #{entity.parentId}, #{entity.name}, #{entity.level}, #{entity.storageNum}, #{entity.unitId}, #{entity.buyPrice}, #{entity.leasePrice}, #{entity.manageType}, #{entity.isActive}, #{entity.rateLoad}, #{entity.testLoad}, #{entity.holdTime}, #{entity.fileUrl}, #{entity.companyId})
</foreach>
on duplicate key update
id = values(id),
parent_id = values(parent_id),
name = values(name),
level = values(level),
storage_num = values(storage_num),
unit_id = values(unit_id),
buy_price = values(buy_price),
lease_price = values(lease_price),
manage_type = values(manage_type),
is_active = values(is_active),
rate_load = values(rate_load),
test_load = values(test_load),
hold_time = values(hold_time),
file_url = values(file_url),
company_id = values(company_id)
</insert>
<insert id="insert">
INSERT INTO ma_type
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -262,6 +279,7 @@
<if test="holdTime != null and holdTime != ''">hold_time,</if>
<if test="fileUrl != null and fileUrl != ''">file_url,</if>
<if test="companyId != null and companyId != ''">company_id,</if>
<if test="isTest != null and isTest != ''">is_test,</if>
</trim>
VALUES
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -280,6 +298,7 @@
<if test="holdTime != null and holdTime != ''">#{holdTime},</if>
<if test="fileUrl != null and fileUrl != ''">#{fileUrl},</if>
<if test="companyId != null and companyId != ''">#{companyId},</if>
<if test="isTest != null and isTest != ''">#{isTest},</if>
</trim>
</insert>