package com.xintong.visualinspection.visuallnspection_qzd.service.impl;

/**
 * 文件名：TaskServiceImpl_F
 * 版本信息：日期：2017/4/7 Copyright 江苏省交通规划设计院 Corporation 2017 版权所有.
 *
 * @author wenhongquan
 * @date 2018/04/11
 */

import com.alibaba.dubbo.config.annotation.Reference;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xintong.visualinspection.bean.*;
import com.xintong.visualinspection.pojo.fwq.CheckAreaData;
import com.xintong.visualinspection.pojo.fwq.TaskData_F;
import com.xintong.visualinspection.service.CommonService;
import com.xintong.visualinspection.service.RecordService_Q;
import com.xintong.visualinspection.service.TaskService_F;
import com.xintong.visualinspection.util.Constants;
import com.xintong.visualinspection.visuallnspection_qzd.dao.FwqTaskDao;
import com.xintong.visualinspection.visuallnspection_qzd.dao.QzdRecordDao;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@com.alibaba.dubbo.config.annotation.Service(
        version = "1.0.0",
        application = "${dubbo.application.id}",
        protocol = "${dubbo.protocol.id}",
        registry = "${dubbo.registry.id}"
)
public class RecordServiceImpl implements RecordService_Q {
    private static final org.slf4j.Logger logger = LoggerFactory.getLogger(RecordServiceImpl.class);

    @Autowired
    private QzdRecordDao qzdRecordDao;


    @Reference(version = "1.0.0",
            application = "${dubbo.application.id}",
            registry = "${dubbo.registry.address}")
    private CommonService commonService;

    @Override
    public Object getAllRecord(Integer page, Integer size, QzdRecord qzdRecord) {
        if (!(page.equals(0) && size.equals(0))) {
            PageHelper.startPage(page, size);
        }

        List<QzdRecord> qzdRecordList = qzdRecordDao.getall(qzdRecord == null ? new QzdRecord() : qzdRecord);

        Map<Long, Organ> deptMap = commonService.getDeptMap();
        Map<Long, User> userMap = commonService.getUserMap();
        Map<String, Constant> codeMap = commonService.getCodeMap();

        if (!(page.equals(0) && size.equals(0))) {
            return new PageInfo<QzdRecord>(qzdRecordList);
        }
        return qzdRecordList;
    }

    @Override
    public void addRecord(QzdRecord qzdRecord) {
        qzdRecordDao.addRecord(qzdRecord);
    }

    @Override
    public void updateRecord(QzdRecord qzdRecord) {
        qzdRecordDao.updateRecord(qzdRecord);
    }

    @Override
    public QzdRecord getRecord(QzdRecord qzdRecord) {
        return qzdRecordDao.getone(qzdRecord);
    }



}
