|
|
@@ -168,6 +168,38 @@ public class ProductServiceImpl extends CommonBaseServiceImpl<ProductMapper, Pro
|
|
|
return errorMsg.toString();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public boolean deleteByPrimaryKey(Long id) {
|
|
|
+ //校验物料是否已经在使用状态(采购单、销售单、BOM、出入库单)
|
|
|
+ validEnableDel(id);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void validEnableDel(Long id) {
|
|
|
+ int count = 0;
|
|
|
+ //采购
|
|
|
+ count = getMapper().getCountFromPurc(id, BaseContextHolder.getCompanyId());
|
|
|
+ if (count > 0){
|
|
|
+ throw new BizException(BizExceptionCode.BIZ_RELDELETE);
|
|
|
+ }
|
|
|
+ //销售
|
|
|
+ count = getMapper().getCountFromSale(id, BaseContextHolder.getCompanyId());
|
|
|
+ if (count > 0){
|
|
|
+ throw new BizException(BizExceptionCode.BIZ_RELDELETE);
|
|
|
+ }
|
|
|
+ //BOM
|
|
|
+ count = getMapper().getCountFromBom(id, BaseContextHolder.getCompanyId());
|
|
|
+ if (count > 0){
|
|
|
+ throw new BizException(BizExceptionCode.BIZ_RELDELETE);
|
|
|
+ }
|
|
|
+ //出入库
|
|
|
+ count = getMapper().getCountFromProdIO(id, BaseContextHolder.getCompanyId());
|
|
|
+ if (count > 0){
|
|
|
+ throw new BizException(BizExceptionCode.BIZ_RELDELETE);
|
|
|
+ }
|
|
|
+ //batch
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public boolean batchDelete(BatchDealBaseDTO baseDTOs) {
|
|
|
for(DocBaseDTO docBaseDTO : baseDTOs.getBaseDTOs()){
|