jiazx0107@163.com
2023-05-31 7a7ccfd74dbdff086d2aabe5117ec1dc6f804d91
igds-inout/src/main/java/com/ld/igds/inout/service/impl/InoutServiceImpl.java
@@ -11,6 +11,9 @@
import com.ld.igds.inout.InoutConstant;
import com.ld.igds.inout.dto.InoutData;
import com.ld.igds.inout.dto.InoutParam;
import com.ld.igds.inout.dto.InoutCheckData;
import com.ld.igds.inout.dto.InoutCheckParam;
import com.ld.igds.inout.mapper.InoutCheckMapper;
import com.ld.igds.inout.mapper.InoutRecordMapper;
import com.ld.igds.inout.service.InoutService;
import com.ld.igds.io.constant.OrderRespEnum;
@@ -39,6 +42,8 @@
    @Resource
    private InoutRecordMapper inoutMapper;
    @Resource
    private InoutCheckMapper inoutCheckMapper;
    @Resource
    private RedisUtil redisUtil;
    @Resource
    private CoreCommonService commonService;
@@ -48,11 +53,14 @@
        if (StringUtils.isEmpty(param.getCompanyId())) {
            param.setCompanyId(ContextUtil.getCompanyId());
        }
        // 首先从缓存中获取,如果没有则从数据库获取
        InoutData result = this.getFromInoutCache(param);
        if (null != result) {
            return result;
        }
        List<InoutData> list = inoutMapper.inoutProgressQuery(param);
        if (null == list || list.size() == 0)
            return null;
@@ -452,6 +460,7 @@
        if (StringUtils.isEmpty(param.getDeptId())) {
            param.setDeptId(ContextUtil.subDeptId(null));
        }
        List<InoutData> list = getListInoutCache(param.getDeptId());
        if (null == list || list.isEmpty())
            return null;
@@ -674,9 +683,7 @@
     * @param data
     */
    private void setInoutCache(String deptId, InoutData data) {
        String key = this.buildInoutKey(deptId,
                InoutConstant.KEY_INOUT_LIST, data.getType(), data.getId());
        String key = this.buildInoutKey(deptId, InoutConstant.KEY_INOUT_LIST, data.getType(), data.getId());
        redisUtil.set(key, data, InoutConstant.KEY_INOUT_LIST_TIME);
    }
@@ -750,4 +757,46 @@
    public String buildInoutKey(String deptId, String key, String type, String bizId) {
        return Constant.APP_NAME + ":" + deptId + ":" + key + ":" + type + ":" + bizId;
    }
    @Override
    public Page<InoutCheckData> pageSampleData(InoutCheckParam param) {
        //设置起始和截止时间
        if (null != param.getStart()) {
            param.setStart(DateUtil.getCurZero(param.getStart()));
        }
        if (null != param.getEnd()) {
            param.setEnd(DateUtil.getNextZero(param.getEnd()));
        }
        // 设置车牌和检验单据的模糊查询
        if (StringUtils.isNotEmpty(param.getPlateNum())) {
            param.setPlateNum("%" + param.getPlateNum() + "%");
        }
        if (StringUtils.isNotEmpty(param.getCheckId())) {
            param.setCheckId("%" + param.getCheckId() + "%");
        }
        Page<InoutCheckData> page = new Page<>(param.getPage(), param.getLimit());
        page.setSearchCount(true);
        List<InoutCheckData> records = inoutCheckMapper.pageSampleData(page, param);
        page.setRecords(records);
        return page;
    }
    @Override
    public String updateSampleData(InoutData data) {
        if (StringUtils.isEmpty(data.getCompanyId())) {
            data.setCompanyId(ContextUtil.getCompanyId());
        }
        if (StringUtils.isEmpty(data.getDeptId())) {
            data.setCompanyId(ContextUtil.subDeptId(null));
        }
        int num = inoutCheckMapper.updateSampleData(data);
        return null;
    }
}