自动化立体仓库 - WMS系统
cl
3 天以前 5677fd88b56cd69e416b52144734f3997ef8f8f4
src/main/java/com/zy/asrs/service/impl/WrkMastLogServiceImpl.java
@@ -2,11 +2,15 @@
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.core.common.Cools;
import com.core.common.R;
import com.zy.asrs.entity.InventoryFlowDto;
import com.zy.asrs.entity.LocMast;
import com.zy.asrs.entity.WrkMastLog;
import com.zy.asrs.mapper.WrkMastLogMapper;
import com.zy.asrs.service.LocMastService;
import com.zy.asrs.service.WrkMastLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
@@ -14,6 +18,15 @@
@Service("wrkMastLogService")
public class WrkMastLogServiceImpl extends ServiceImpl<WrkMastLogMapper, WrkMastLog> implements WrkMastLogService {
    @Autowired
    private LocMastService locMastService;
    @Override
    public boolean insert(WrkMastLog entity) {
        fillAreaId(entity);
        return super.insert(entity);
    }
    @Override
    public boolean save(Integer workNo) {
@@ -27,6 +40,15 @@
    }
    @Override
    public Long countInboundHistoryBySourceStaNo(Date startTime, Date endTime, Integer sourceStaNo) {
        if (sourceStaNo == null) {
            return 0L;
        }
        Long count = this.baseMapper.countInboundHistoryBySourceStaNo(startTime, endTime, sourceStaNo);
        return count == null ? 0L : count;
    }
    @Override
    public R inventoryFlowList(Integer curr, Integer limit, Map<String, Object> param) {
        Page<InventoryFlowDto> page = new Page<>();
        page.setCurrent(curr);
@@ -36,4 +58,33 @@
        return R.ok(page);
    }
    private void fillAreaId(WrkMastLog wrkMastLog) {
        if (wrkMastLog == null) {
            return;
        }
        LocMast locMast = resolveAreaLocMast(wrkMastLog);
        if (locMast != null) {
            wrkMastLog.setAreaId(locMast.getAreaId());
        }
    }
    private LocMast resolveAreaLocMast(WrkMastLog wrkMastLog) {
        boolean outbound = wrkMastLog.getIoType() != null && wrkMastLog.getIoType() >= 100;
        LocMast primary = outbound
                ? selectLocMast(wrkMastLog.getSourceLocNo())
                : selectLocMast(wrkMastLog.getLocNo());
        if (primary != null) {
            return primary;
        }
        return outbound
                ? selectLocMast(wrkMastLog.getLocNo())
                : selectLocMast(wrkMastLog.getSourceLocNo());
    }
    private LocMast selectLocMast(String locNo) {
        if (Cools.isEmpty(locNo)) {
            return null;
        }
        return locMastService.selectById(locNo);
    }
}