配件管理新增bug修改 机具状态导出问题修改

This commit is contained in:
wcy 2024-09-24 16:18:53 +08:00
parent 2894862a48
commit 8527b34ab9
7 changed files with 45 additions and 6 deletions

View File

@ -66,6 +66,7 @@ public class MaPartTypeController extends BaseController {
*/
@PostMapping
public AjaxResult add(@Validated @RequestBody MaPartType maPartType) {
System.out.println(maPartType);
if (!maPartTypeService.checkPaNameUnique(maPartType)) {
return error("新增配件名称'" + maPartType.getPaName() + "'失败,配件名称已存在");
}

View File

@ -52,5 +52,9 @@ public interface MaPartTypeMapper {
MaPartType getById(Long paId);
int updateById(MaPartType maPartType);
int checkPartName(String paName);
List<MaPartType> selectPartName(String paName);
}

View File

@ -37,11 +37,35 @@ public class MaPartTypeServiceImpl implements IPartTypeService {
*/
@Override
public boolean checkPaNameUnique(MaPartType maPartType) {
Long paId = StringUtils.isNull(maPartType.getPaId()) ? -1L : maPartType.getPaId();
MaPartType info = maPartTypeMapper.checkPartNameUnique(maPartType.getPaId());
if (StringUtils.isNotNull(info) && info.getPaId().longValue() != paId.longValue()) {
// Long paId = StringUtils.isNull(maPartType.getPaId()) ? -1L : maPartType.getPaId();
// MaPartType info = maPartTypeMapper.checkPartNameUnique(maPartType.getPaId());
// if (StringUtils.isNotNull(info) && info.getPaId().longValue() != paId.longValue()) {
// return UserConstants.NOT_UNIQUE;
// }
// 查询具有相同paName的所有MaPartType对象
List<MaPartType> maPartTypes = maPartTypeMapper.selectPartName(maPartType.getPaName());
// 用于存储第一个level=1的MaPartType的索引
Integer num = null;
// 遍历查询结果
for (int i = 0; i < maPartTypes.size(); i++) {
MaPartType maPart = maPartTypes.get(i);
if ("1".equals(maPart.getLevel())) {
// 如果找到level=1的MaPartType则记录其索引
num = i;
break; // 假设我们只需要第一个找到的所以找到后退出循环
}
}
// 检查是否存在相同paName的条目并且该条目level为1
int count = maPartTypeMapper.checkPartName(maPartType.getPaName());
if (count > 0 && num != null && maPartTypes.get(num).getLevel().equals("1")) {
// 如果存在且找到的条目level为1则名称不唯一
return UserConstants.NOT_UNIQUE;
}
// 如果没有找到符合条件的条目则名称唯一
return UserConstants.UNIQUE;
}

View File

@ -32,6 +32,7 @@ public class BackRecordController extends BaseController {
@Autowired
private BackRecordService backRecordService;
/**
* 退料记录列表
*/

View File

@ -112,14 +112,12 @@ public class StorageStatus {
* 租赁数量
*/
@ApiModelProperty(value = "租赁数量")
@Excel(name = "租赁数量",cellType = Excel.ColumnType.NUMERIC)
private Integer outNum;
/**
* 归还数量
*/
@ApiModelProperty(value = "归还数量")
@Excel(name = "归还数量",cellType = Excel.ColumnType.NUMERIC)
private Integer backNum;

View File

@ -105,4 +105,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from ma_part_type
where pa_id = #{paId}
</select>
<select id="checkPartName" resultType="java.lang.Integer">
select count(*) from ma_part_type where pa_name = #{paName}
</select>
<select id="selectPartName" resultType="com.bonus.sgzb.base.domain.MaPartType">
select pa_id, pa_name, parent_id, status, num, unit_id, buy_price, level, warn_num, del_flag, create_by, create_time, remark, company_id
from ma_part_type
where pa_name = #{paName}
</select>
</mapper>

View File

@ -399,7 +399,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where task_id = #{taskId} and rd.STATUS = '0'
</select>
<select id="getPartRecord" resultType="com.bonus.sgzb.material.domain.RepairPart">
select mpt.pa_name as partName,
select concat(mpt2.pa_name,'-',mpt1.pa_name,'-',mpt.pa_name) as partName,
rpd.part_num as partNum,
rpd.part_cost as partCost,
rpd.part_type as partType,
@ -407,6 +407,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
rpd.repair_content as repairContent
from repair_part_details rpd
left join ma_part_type mpt on mpt.pa_id = rpd.part_id
left join ma_part_type mpt1 on mpt1.pa_id = mpt.parent_id
left join ma_part_type mpt2 on mpt2.pa_id = mpt1.parent_id
where 1=1
<if test="taskId != null and taskId != ''">
and rpd.task_id = #{taskId}