|
@ -7,6 +7,9 @@ import com.google.common.annotations.VisibleForTesting; |
|
|
import com.win.framework.common.exception.ServiceException; |
|
|
import com.win.framework.common.exception.ServiceException; |
|
|
import com.win.framework.common.pojo.PageResult; |
|
|
import com.win.framework.common.pojo.PageResult; |
|
|
import com.win.framework.datapermission.core.util.DataPermissionUtils; |
|
|
import com.win.framework.datapermission.core.util.DataPermissionUtils; |
|
|
|
|
|
import com.win.module.infra.api.trends.TrendsApi; |
|
|
|
|
|
import com.win.module.infra.api.trends.dto.TrendsCreateReqDTO; |
|
|
|
|
|
import com.win.module.infra.enums.TrendsTypeEnum; |
|
|
import com.win.module.wms.controller.itembasic.vo.*; |
|
|
import com.win.module.wms.controller.itembasic.vo.*; |
|
|
import com.win.module.wms.convert.itembasic.ItembasicConvert; |
|
|
import com.win.module.wms.convert.itembasic.ItembasicConvert; |
|
|
import com.win.module.wms.dal.dataobject.itembasic.ItembasicDO; |
|
|
import com.win.module.wms.dal.dataobject.itembasic.ItembasicDO; |
|
@ -34,6 +37,8 @@ public class ItembasicServiceImpl implements ItembasicService { |
|
|
|
|
|
|
|
|
@Resource |
|
|
@Resource |
|
|
private ItembasicMapper itembasicMapper; |
|
|
private ItembasicMapper itembasicMapper; |
|
|
|
|
|
@Resource |
|
|
|
|
|
private TrendsApi trendsApi; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public Long createItembasic(ItembasicCreateReqVO createReqVO) { |
|
|
public Long createItembasic(ItembasicCreateReqVO createReqVO) { |
|
@ -43,6 +48,7 @@ public class ItembasicServiceImpl implements ItembasicService { |
|
|
// 插入
|
|
|
// 插入
|
|
|
ItembasicDO itembasic = ItembasicConvert.INSTANCE.convert(createReqVO); |
|
|
ItembasicDO itembasic = ItembasicConvert.INSTANCE.convert(createReqVO); |
|
|
itembasicMapper.insert(itembasic); |
|
|
itembasicMapper.insert(itembasic); |
|
|
|
|
|
trendsApi.createTrends(this.newTrendsCreateReqDTO(itembasic.getId(), null, TrendsTypeEnum.CREATE)); |
|
|
// 返回
|
|
|
// 返回
|
|
|
return itembasic.getId(); |
|
|
return itembasic.getId(); |
|
|
} |
|
|
} |
|
@ -54,16 +60,39 @@ public class ItembasicServiceImpl implements ItembasicService { |
|
|
,updateReqVO.getEnableMake(),updateReqVO.getEnableOutsourcing(),updateReqVO.getIsRecycled(),updateReqVO.getIsPhantom(),updateReqVO.getAbcClass(),updateReqVO.getType() |
|
|
,updateReqVO.getEnableMake(),updateReqVO.getEnableOutsourcing(),updateReqVO.getIsRecycled(),updateReqVO.getIsPhantom(),updateReqVO.getAbcClass(),updateReqVO.getType() |
|
|
,updateReqVO.getValidityDays(),updateReqVO.getAvailable()); |
|
|
,updateReqVO.getValidityDays(),updateReqVO.getAvailable()); |
|
|
// 更新
|
|
|
// 更新
|
|
|
|
|
|
ItembasicDO itembasic = this.getItembasic(updateReqVO.getId()); |
|
|
|
|
|
trendsApi.createTrends(this.newTrendsCreateReqDTO(updateReqVO.getId(), itembasic.toString(), TrendsTypeEnum.UPDATE)); |
|
|
ItembasicDO updateObj = ItembasicConvert.INSTANCE.convert(updateReqVO); |
|
|
ItembasicDO updateObj = ItembasicConvert.INSTANCE.convert(updateReqVO); |
|
|
itembasicMapper.updateById(updateObj); |
|
|
itembasicMapper.updateById(updateObj); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void updateItembasicStatus(ItembasicUpdateReqVO updateReqVO) { |
|
|
|
|
|
// 校验存在
|
|
|
|
|
|
ItembasicDO updateObj = validateItembasicExists(updateReqVO.getId()); |
|
|
|
|
|
trendsApi.createTrends(this.newTrendsCreateReqDTO(updateObj.getId(), "状态由" + updateObj.getStatus() + "改为" + updateReqVO.getStatus(), TrendsTypeEnum.UPDATE_STATUS)); |
|
|
|
|
|
// 更新
|
|
|
|
|
|
updateObj.setId(updateReqVO.getId()); |
|
|
|
|
|
updateObj.setStatus(updateReqVO.getStatus()); |
|
|
|
|
|
itembasicMapper.updateById(updateObj); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void deleteItembasic(Long id) { |
|
|
public void deleteItembasic(Long id) { |
|
|
// 校验存在
|
|
|
// 校验存在
|
|
|
validateItembasicExists(id); |
|
|
ItembasicDO itembasic = validateItembasicExists(id); |
|
|
// 删除
|
|
|
// 删除
|
|
|
itembasicMapper.deleteById(id); |
|
|
itembasicMapper.deleteById(id); |
|
|
|
|
|
trendsApi.createTrends(this.newTrendsCreateReqDTO(id, itembasic.toString(), TrendsTypeEnum.DELETE)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private TrendsCreateReqDTO newTrendsCreateReqDTO(Long id, String content, TrendsTypeEnum trendsTypeEnum) { |
|
|
|
|
|
TrendsCreateReqDTO trendsCreateReqDTO = new TrendsCreateReqDTO(); |
|
|
|
|
|
trendsCreateReqDTO.setTableName("basicItembasic"); |
|
|
|
|
|
trendsCreateReqDTO.setTableId(id); |
|
|
|
|
|
trendsCreateReqDTO.setType(trendsTypeEnum.getType()); |
|
|
|
|
|
trendsCreateReqDTO.setContent(content); |
|
|
|
|
|
return trendsCreateReqDTO; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
@ -145,14 +174,15 @@ public class ItembasicServiceImpl implements ItembasicService { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
@VisibleForTesting |
|
|
@VisibleForTesting |
|
|
private void validateItembasicExists(Long id) { |
|
|
private ItembasicDO validateItembasicExists(Long id) { |
|
|
if (id == null) { |
|
|
if (id == null) { |
|
|
return; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
ItembasicDO itembasic = itembasicMapper.selectById(id); |
|
|
ItembasicDO itembasic = itembasicMapper.selectById(id); |
|
|
if (itembasic == null) { |
|
|
if (itembasic == null) { |
|
|
throw exception(ITEMBASIC_NOT_EXISTS); |
|
|
throw exception(ITEMBASIC_NOT_EXISTS); |
|
|
} |
|
|
} |
|
|
|
|
|
return itembasic; |
|
|
} |
|
|
} |
|
|
@VisibleForTesting |
|
|
@VisibleForTesting |
|
|
private void validateCodeExists(Long id,String code) { |
|
|
private void validateCodeExists(Long id,String code) { |
|
|