测试问题提交

This commit is contained in:
liang.chao 2024-06-25 10:21:46 +08:00
parent 2df173ba58
commit 50de01d74d
6 changed files with 44 additions and 36 deletions

View File

@ -33,6 +33,7 @@ public class MaTypeController extends BaseController {
/** /**
* 根据类型名称查询类型 * 根据类型名称查询类型
*
* @return 结果 * @return 结果
*/ */
@ApiOperation(value = "根据类型名称查询类型") @ApiOperation(value = "根据类型名称查询类型")
@ -44,6 +45,7 @@ public class MaTypeController extends BaseController {
/** /**
* 工机具类型下拉树 * 工机具类型下拉树
*
* @return 结果 * @return 结果
*/ */
@ApiOperation(value = "工机具类型下拉树") @ApiOperation(value = "工机具类型下拉树")
@ -62,6 +64,7 @@ public class MaTypeController extends BaseController {
/** /**
* 根据左列表类型id查询右表格 * 根据左列表类型id查询右表格
*
* @param typeId * @param typeId
* @return * @return
*/ */
@ -75,12 +78,15 @@ public class MaTypeController extends BaseController {
/** /**
* 获取规格层级为3的设备列表 * 获取规格层级为3的设备列表
*
* @return 结果 * @return 结果
*/ */
@ApiOperation(value = "获取规格层级的设备列表") @ApiOperation(value = "获取规格层级的设备列表")
@GetMapping("/selectMaTypeListByLevelIndex") @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) { 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 == null) {
return AjaxResult.error("参数错误,类型不能为空");
}
if (type == 0) { if (type == 0) {
// 查询全部机具类型 // 查询全部机具类型
if (level == 0 || level == 1) { if (level == 0 || level == 1) {
@ -180,6 +186,7 @@ public class MaTypeController extends BaseController {
/** /**
* 根据左列表类型id查询右表格 * 根据左列表类型id查询右表格
*
* @param typeId * @param typeId
* @return * @return
*/ */
@ -221,8 +228,7 @@ public class MaTypeController extends BaseController {
*/ */
@ApiOperation(value = "获取机具类型管理ma_type详细信息") @ApiOperation(value = "获取机具类型管理ma_type详细信息")
@GetMapping(value = "/{typeId}") @GetMapping(value = "/{typeId}")
public AjaxResult getInfo(@PathVariable("typeId") Long typeId) public AjaxResult getInfo(@PathVariable("typeId") Long typeId) {
{
return success(iTypeService.selectMaTypeByTypeId(typeId)); return success(iTypeService.selectMaTypeByTypeId(typeId));
} }
@ -232,8 +238,7 @@ public class MaTypeController extends BaseController {
@ApiOperation(value = "新增机具类型管理ma_type") @ApiOperation(value = "新增机具类型管理ma_type")
@Log(title = "机具类型管理ma_type", businessType = BusinessType.INSERT) @Log(title = "机具类型管理ma_type", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(@RequestBody MaType maType) public AjaxResult add(@RequestBody MaType maType) {
{
return toAjax(iTypeService.insertMaType(maType)); return toAjax(iTypeService.insertMaType(maType));
} }
@ -243,8 +248,7 @@ public class MaTypeController extends BaseController {
@ApiOperation(value = "修改机具类型管理ma_type") @ApiOperation(value = "修改机具类型管理ma_type")
@Log(title = "机具类型管理ma_type", businessType = BusinessType.UPDATE) @Log(title = "机具类型管理ma_type", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody MaType maType) public AjaxResult edit(@RequestBody MaType maType) {
{
return toAjax(iTypeService.updateMaType(maType)); return toAjax(iTypeService.updateMaType(maType));
} }

View File

@ -82,5 +82,5 @@ public interface MaTypeMapper {
int deletePropSetByTypeId(Long typeId); int deletePropSetByTypeId(Long typeId);
MaType getMaType(MaType maType); int getMaType(MaType maType);
} }

View File

@ -55,7 +55,6 @@ public class MaTypeServiceImpl implements ITypeService {
} }
/** /**
* 新增机具类型管理ma_type * 新增机具类型管理ma_type
* *
@ -72,8 +71,8 @@ public class MaTypeServiceImpl implements ITypeService {
maType.setCreateTime(DateUtils.getNowDate()); maType.setCreateTime(DateUtils.getNowDate());
//根据类型名称判重 //根据类型名称判重
if (maType.getTypeName() != null && maType.getParentId() != null) { if (maType.getTypeName() != null && maType.getParentId() != null) {
MaType mapperMaType = maTypeMapper.getMaType(maType); int num = maTypeMapper.getMaType(maType);
if (mapperMaType != null) { if (num > 1) {
throw new ServiceException("机具类型名称与库中重复,请修改后重新提交!"); throw new ServiceException("机具类型名称与库中重复,请修改后重新提交!");
} }
} }
@ -127,17 +126,20 @@ public class MaTypeServiceImpl implements ITypeService {
* @return 结果 * @return 结果
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class)
public int updateMaType(MaType maType) { public int updateMaType(MaType maType) {
int i = 0;
Long typeId = maType.getTypeId(); Long typeId = maType.getTypeId();
maType.setUpdateTime(DateUtils.getNowDate()); maType.setUpdateTime(DateUtils.getNowDate());
i = maTypeMapper.updateType(maType);
//根据类型名称判重 //根据类型名称判重
if (maType.getTypeName() != null && maType.getParentId() != null) { if (maType.getTypeName() != null && maType.getParentId() != null) {
MaType mapperMaType = maTypeMapper.getMaType(maType); int num = maTypeMapper.getMaType(maType);
if (mapperMaType != null && mapperMaType.getTypeId() != null && !mapperMaType.getTypeId().equals(maType.getTypeId())) { if (num > 1) {
throw new ServiceException("机具类型名称与库中重复,请修改后重新提交!"); throw new RuntimeException("机具类型名称与库中重复,请修改后重新提交!");
} }
} }
int i = maTypeMapper.updateType(maType);
// 图片路径保存 // 图片路径保存
if (StringUtils.isNotEmpty(maType.getPhotoName()) && StringUtils.isNotEmpty(maType.getPhotoUrl())) { if (StringUtils.isNotEmpty(maType.getPhotoName()) && StringUtils.isNotEmpty(maType.getPhotoUrl())) {
typeFileMapper.deleteMaTypeFileByTypeId(typeId, "1"); typeFileMapper.deleteMaTypeFileByTypeId(typeId, "1");

View File

@ -416,16 +416,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if> </if>
</where> </where>
</select> </select>
<select id="getMaType" resultType="com.bonus.sgzb.base.api.domain.MaType"> <select id="getMaType" resultType="java.lang.Integer">
SELECT SELECT
type_id AS typeId, count(1)
type_name AS typeName,
parent_id AS parentId
FROM FROM
ma_type ma_type
WHERE WHERE
parent_id = #{parentId} and type_name = #{typeName} parent_id = #{parentId} and type_name = #{typeName}
</select> </select>
</mapper> </mapper>

View File

@ -27,6 +27,10 @@ public class MaWholeVo {
@ApiModelProperty(value = "规格型号") @ApiModelProperty(value = "规格型号")
private String typeModelName; private String typeModelName;
/** 配套名称 */
@ApiModelProperty(value = "配套名称")
private String wholeTypeName;
/** 套装所需配件数量 */ /** 套装所需配件数量 */
@ApiModelProperty(value = "套装所需配件数量") @ApiModelProperty(value = "套装所需配件数量")
private Integer totalNum; private Integer totalNum;

View File

@ -74,6 +74,7 @@
<select id="selectList" resultType="com.bonus.sgzb.material.domain.MaWholeVo"> <select id="selectList" resultType="com.bonus.sgzb.material.domain.MaWholeVo">
SELECT SELECT
mws.parent_id AS id, mws.parent_id AS id,
mws.whole_type_name AS wholeTypeName,
mt2.type_name AS typeName, mt2.type_name AS typeName,
mt.type_name AS typeModelName, mt.type_name AS typeModelName,
SUM(mws.part_num) AS totalNum SUM(mws.part_num) AS totalNum