|
@@ -8,7 +8,6 @@ import com.warewms.common.core.domain.base.page.PageDomain;
|
|
|
import com.warewms.common.core.domain.base.page.TableDataInfo;
|
|
|
import com.warewms.common.exception.ServiceException;
|
|
|
import com.warewms.common.utils.StringUtils;
|
|
|
-import com.warewms.hailiang.domain.DeviceLog;
|
|
|
import com.warewms.hailiang.domain.RetroactiveHistory;
|
|
|
import com.warewms.hailiang.domain.RetroactiveNow;
|
|
|
import com.warewms.hailiang.mapper.RetroactiveHistoryMapper;
|
|
@@ -19,18 +18,19 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
-* @author AD
|
|
|
-* @description 针对表【retroactive_now(生产追溯表)】的数据库操作Service实现
|
|
|
-* @createDate 2023-08-22 11:02:17
|
|
|
-*/
|
|
|
+ * @author AD
|
|
|
+ * @description 针对表【retroactive_now(生产追溯表)】的数据库操作Service实现
|
|
|
+ * @createDate 2023-08-22 11:02:17
|
|
|
+ */
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
public class RetroactiveNowServiceImpl extends ServiceImpl<RetroactiveNowMapper, RetroactiveNow>
|
|
|
- implements RetroactiveNowService{
|
|
|
+ implements RetroactiveNowService {
|
|
|
|
|
|
@Autowired
|
|
|
private RetroactiveNowMapper retroactiveNowMapper;
|
|
@@ -39,13 +39,13 @@ public class RetroactiveNowServiceImpl extends ServiceImpl<RetroactiveNowMapper,
|
|
|
private RetroactiveHistoryMapper retroactiveHistoryMapper;
|
|
|
|
|
|
@Override
|
|
|
- public TableDataInfo<RetroactiveNow> getList(RetroactiveNow retroactiveNow, PageDomain pageDomain) {
|
|
|
+ public TableDataInfo<RetroactiveNow> getList(RetroactiveNow retroactiveNow, PageDomain pageDomain, List<String> inStatus) {
|
|
|
Map<String, Object> params = retroactiveNow.getParams();
|
|
|
- return TableDataInfo.build(retroactiveNowMapper.selectPage(pageDomain.build(),new LambdaQueryWrapper<RetroactiveNow>()
|
|
|
- .like(StringUtils.isNotEmpty(retroactiveNow.getProductionLine()),RetroactiveNow::getProductionLine,retroactiveNow.getProductionLine())
|
|
|
- .like(StringUtils.isNotEmpty(retroactiveNow.getBatchNo()),RetroactiveNow::getBatchNo,retroactiveNow.getBatchNo())
|
|
|
- .like(StringUtils.isNotEmpty(retroactiveNow.getLotNo()),RetroactiveNow::getLotNo,retroactiveNow.getLotNo())
|
|
|
- .eq(StringUtils.isNotEmpty(retroactiveNow.getStatus()),RetroactiveNow::getStatus,retroactiveNow.getStatus())
|
|
|
+ return TableDataInfo.build(retroactiveNowMapper.selectPage(pageDomain.build(), new LambdaQueryWrapper<RetroactiveNow>()
|
|
|
+ .like(StringUtils.isNotEmpty(retroactiveNow.getProductionLine()), RetroactiveNow::getProductionLine, retroactiveNow.getProductionLine())
|
|
|
+ .like(StringUtils.isNotEmpty(retroactiveNow.getBatchNo()), RetroactiveNow::getBatchNo, retroactiveNow.getBatchNo())
|
|
|
+ .like(StringUtils.isNotEmpty(retroactiveNow.getLotNo()), RetroactiveNow::getLotNo, retroactiveNow.getLotNo())
|
|
|
+ .in(inStatus.size() > 0, RetroactiveNow::getStatus, inStatus)
|
|
|
.orderByDesc(RetroactiveNow::getCreateTime)
|
|
|
));
|
|
|
}
|
|
@@ -55,19 +55,19 @@ public class RetroactiveNowServiceImpl extends ServiceImpl<RetroactiveNowMapper,
|
|
|
List<RetroactiveNow> retroactiveNows = retroactiveNowMapper.selectList(new LambdaQueryWrapper<RetroactiveNow>()
|
|
|
.eq(RetroactiveNow::getBatchNo, retroactiveNow.getBatchNo())
|
|
|
);
|
|
|
- if (retroactiveNows.size()>0){
|
|
|
+ if (retroactiveNows.size() > 0) {
|
|
|
throw new ServiceException("数据库中已存在相同批次号");
|
|
|
}
|
|
|
retroactiveNowMapper.insert(retroactiveNow);
|
|
|
- return retroactiveHistoryMapper.insert(BeanUtil.copyProperties(retroactiveNow,RetroactiveHistory.class));
|
|
|
+ return retroactiveHistoryMapper.insert(BeanUtil.copyProperties(retroactiveNow, RetroactiveHistory.class));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public RetroactiveNow selectTheOneByParameter(RetroactiveNow retroactiveNow) {
|
|
|
return retroactiveNowMapper.selectOne(new LambdaQueryWrapper<RetroactiveNow>()
|
|
|
- .eq(StringUtils.isNotEmpty(retroactiveNow.getRetroactiveId()),RetroactiveNow::getRetroactiveId,retroactiveNow.getRetroactiveId())
|
|
|
- .eq(StringUtils.isNotEmpty(retroactiveNow.getBatchNo()),RetroactiveNow::getBatchNo,retroactiveNow.getBatchNo())
|
|
|
- .eq(StringUtils.isNotEmpty(retroactiveNow.getStatus()),RetroactiveNow::getStatus,retroactiveNow.getStatus())
|
|
|
+ .eq(StringUtils.isNotEmpty(retroactiveNow.getRetroactiveId()), RetroactiveNow::getRetroactiveId, retroactiveNow.getRetroactiveId())
|
|
|
+ .eq(StringUtils.isNotEmpty(retroactiveNow.getBatchNo()), RetroactiveNow::getBatchNo, retroactiveNow.getBatchNo())
|
|
|
+ .eq(StringUtils.isNotEmpty(retroactiveNow.getStatus()), RetroactiveNow::getStatus, retroactiveNow.getStatus())
|
|
|
);
|
|
|
}
|
|
|
|
|
@@ -75,20 +75,45 @@ public class RetroactiveNowServiceImpl extends ServiceImpl<RetroactiveNowMapper,
|
|
|
@Transactional
|
|
|
public int updateData(RetroactiveNow retroactiveNow) {
|
|
|
RetroactiveNow baseData = retroactiveNowMapper.selectOne(new LambdaQueryWrapper<RetroactiveNow>()
|
|
|
- .eq(RetroactiveNow::getBatchNo, retroactiveNow.getBatchNo())
|
|
|
+ .eq(StringUtils.isNotEmpty(retroactiveNow.getBatchNo()), RetroactiveNow::getBatchNo, retroactiveNow.getBatchNo())
|
|
|
+ .eq(StringUtils.isNotEmpty(retroactiveNow.getLotNo()), RetroactiveNow::getLotNo, retroactiveNow.getLotNo())
|
|
|
);
|
|
|
- if (ObjectUtil.isNull(baseData)){
|
|
|
- throw new ServiceException("数据库中不存在该批次号,"+ retroactiveNow.getBatchNo());
|
|
|
+ if (ObjectUtil.isNull(baseData)) {
|
|
|
+ throw new ServiceException("数据库中不存在该批次号或托盘号," + retroactiveNow.getBatchNo() + "," + retroactiveNow.getLotNo());
|
|
|
}
|
|
|
- if (baseData.getStatus().equals(retroactiveNow)){
|
|
|
- log.info("数据库存在该状态的数据");
|
|
|
- return 0;
|
|
|
+ if (baseData.getStatus().equals(retroactiveNow.getStatus())) {
|
|
|
+ throw new ServiceException("数据库存在该状态相同批次号或托盘号的数据");
|
|
|
}
|
|
|
- baseData.setStatus(retroactiveNow.getStatus());
|
|
|
- baseData.setDeviceId(retroactiveNow.getDeviceId());
|
|
|
- retroactiveNowMapper.updateById(baseData);
|
|
|
- return retroactiveHistoryMapper.insert(BeanUtil.copyProperties(baseData,RetroactiveHistory.class));
|
|
|
+ baseData.setStatus(retroactiveNow.getStatus());
|
|
|
+ baseData.setDeviceId(retroactiveNow.getDeviceId());
|
|
|
+ baseData.setUpdateBy("system");
|
|
|
+ retroactiveNowMapper.updateById(baseData);
|
|
|
+ RetroactiveHistory retroactiveHistory = BeanUtil.copyProperties(baseData, RetroactiveHistory.class);
|
|
|
+ retroactiveHistory.setCreateTime(baseData.getUpdateTime());
|
|
|
+ return retroactiveHistoryMapper.insert(retroactiveHistory);
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public int finishProduce(RetroactiveNow retroactiveNow) {
|
|
|
+ RetroactiveNow baseData = retroactiveNowMapper.selectOne(new LambdaQueryWrapper<RetroactiveNow>()
|
|
|
+ .eq(StringUtils.isNotEmpty(retroactiveNow.getBatchNo()), RetroactiveNow::getBatchNo, retroactiveNow.getBatchNo())
|
|
|
+ .eq(StringUtils.isNotEmpty(retroactiveNow.getLotNo()), RetroactiveNow::getLotNo, retroactiveNow.getLotNo())
|
|
|
+ );
|
|
|
+ if (ObjectUtil.isNull(baseData)) {
|
|
|
+ throw new ServiceException("数据库中不存在该批次号或托盘号," + retroactiveNow.getBatchNo() + "," + retroactiveNow.getLotNo());
|
|
|
+ }
|
|
|
+ if (baseData.getStatus().equals(retroactiveNow.getStatus())) {
|
|
|
+ throw new ServiceException("数据库存在该状态相同批次号或托盘号的数据");
|
|
|
+ }
|
|
|
+ baseData.setStatus(retroactiveNow.getStatus());
|
|
|
+ baseData.setDeviceId(retroactiveNow.getDeviceId());
|
|
|
+ baseData.setUpdateBy("system");
|
|
|
+ RetroactiveHistory retroactiveHistory = BeanUtil.copyProperties(baseData, RetroactiveHistory.class);
|
|
|
+ retroactiveHistory.setCreateTime(new Date());
|
|
|
+ retroactiveHistoryMapper.insert(retroactiveHistory);
|
|
|
+ return retroactiveNowMapper.deleteById(baseData);
|
|
|
}
|
|
|
}
|
|
|
|