EmployeeServiceImpl.java 2.04 KB
package com.bsth.service.schedule.impl;

import com.bsth.entity.Personnel;
import com.bsth.service.schedule.EmployeeService;
import com.bsth.service.schedule.exception.ScheduleException;
import com.bsth.service.schedule.utils.DataToolsFile;
import com.bsth.service.schedule.utils.DataToolsService;
import com.bsth.util.I18n;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by xu on 16/12/15.
 */
@Service
public class EmployeeServiceImpl extends BServiceImpl<Personnel, Integer> implements EmployeeService {
    @Autowired
    @Qualifier(value = "employee_dataTool")
    private DataToolsService dataToolsService;

    @Override
    public DataToolsFile uploadFile(String filename, byte[] filedata) throws ScheduleException {
        return dataToolsService.uploadFile(filename, filedata);
    }

    @Override
    public void importData(File file, Map<String, Object> params) throws ScheduleException {
        dataToolsService.importData(file, params);
    }

    @Override
    public DataToolsFile exportData(Map<String, Object> params) throws ScheduleException {
        return dataToolsService.exportData(params);
    }

    @Override
    @Transactional
    public void validate_gh(Personnel personnel) throws ScheduleException {
        // 查询条件
        Map<String, Object> param = new HashMap<>();
        if (personnel.getId() != null) {
            param.put("id_ne", personnel.getId());
        }
        param.put("companyCode_eq", personnel.getCompanyCode());
        param.put("jobCodeori_eq", personnel.getJobCode());
        if (!CollectionUtils.isEmpty(list(param))) {
            throw new ScheduleException(I18n.getInstance().getMessage("employeeServiceImpl-line54"));
        }
    }
}