2024-07-05 设备-备品备件-导入和新增加限制

master
A0010407 7 months ago
parent fe306c43a7
commit 0463d5b512

@ -80,7 +80,11 @@ public class SparePartsLedgerController extends BaseController {
@Log(title = "备品备件台账管理", businessType = BusinessType.INSERT) @Log(title = "备品备件台账管理", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(@RequestBody SparePartsLedger sparePartsLedger) { public AjaxResult add(@RequestBody SparePartsLedger sparePartsLedger) {
return toAjax(sparePartsLedgerService.insertSparePartsLedger(sparePartsLedger)); if (sparePartsLedgerService.checkSpareCodeUnique(sparePartsLedger)) {
return AjaxResult.error("备品备件编码已存在!");
} else {
return toAjax(sparePartsLedgerService.insertSparePartsLedger(sparePartsLedger));
}
} }
/** /**

@ -87,4 +87,9 @@ public interface SparePartsLedgerMapper {
void updateAmount(SparePartsLedger sparePartsLedger); void updateAmount(SparePartsLedger sparePartsLedger);
SparePartsLedger selectExistByMaterialCode(String materialCode); SparePartsLedger selectExistByMaterialCode(String materialCode);
SparePartsLedger selectSpareDetailBySpareCode(String materialCode);
//检查spareCode
String checkSpareCodeUnique(SparePartsLedger sparePartsLedger);
} }

@ -61,4 +61,7 @@ public interface ISparePartsLedgerService {
public int deleteSparePartsLedgerByStorageId(String storageId); public int deleteSparePartsLedgerByStorageId(String storageId);
AjaxResult importFile(List<SparePartsLedger> orderList); AjaxResult importFile(List<SparePartsLedger> orderList);
//判断备品备件编码唯一性
boolean checkSpareCodeUnique(SparePartsLedger sparePartsLedger);
} }

@ -167,6 +167,9 @@ public class SparePartsLedgerServiceImpl implements ISparePartsLedgerService {
if (table.getMaterialCode().isEmpty() || table.getMaterialCode() == null) { if (table.getMaterialCode().isEmpty() || table.getMaterialCode() == null) {
return error(500, "备品备件编码不能为空!信息导入失败!"); return error(500, "备品备件编码不能为空!信息导入失败!");
} }
if (this.checkSpareCodeUnique(table)) {
return AjaxResult.error("存在重复的备品备件编码"+table.getMaterialCode()+"!信息导入失败!");
}
// 备品备件名称 // 备品备件名称
if (table.getMaterialDesc().isEmpty() || table.getMaterialDesc() == null) { if (table.getMaterialDesc().isEmpty() || table.getMaterialDesc() == null) {
return error(500, "备品备件名称不能为空!信息导入失败!"); return error(500, "备品备件名称不能为空!信息导入失败!");
@ -245,4 +248,20 @@ public class SparePartsLedgerServiceImpl implements ISparePartsLedgerService {
} }
return failSpareParts; return failSpareParts;
} }
/**
*
*
* @return
*/
@Override
@DS("#header.poolName")
public boolean checkSpareCodeUnique(SparePartsLedger sparePartsLedger) {
String spareCode = sparePartsLedgerMapper.checkSpareCodeUnique(sparePartsLedger);
if (spareCode == null) {
return false;
} else {
return true;
}
}
} }

@ -381,4 +381,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where material_code = #{materialCode} where material_code = #{materialCode}
and del_flag ='0' and del_flag ='0'
</select> </select>
<select id="selectSpareDetailBySpareCode" parameterType="String" resultMap="SparePartsLedgerResult">
<include refid="selectSparePartsLedgerVo"/>
where material_code = #{materialCode}
and del_flag ='0'
</select>
<select id="checkSpareCodeUnique" parameterType="SparePartsLedger" resultType="java.lang.String">
select material_code
from equ_spareparts_ledger
where material_code = #{materialCode}
and del_flag = '0'
</select>
</mapper> </mapper>
Loading…
Cancel
Save