LineServiceImpl.java 2.4 KB
package com.bsth.service.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.bsth.common.ResponseCode;
import com.bsth.entity.Line;
import com.bsth.repository.LineRepository;
import com.bsth.service.LineService;

/**
 * 
 * @ClassName: LineServiceImpl(线路service业务层实现类)
 * 
 * @Extends : BaseService
 * 
 * @Description: TODO(线路service业务层)
 * 
 * @Author bsth@lq
 * 
 * @Date 2016年4月28日 上午9:21:17
 *
 * @Version 公交调度系统BS版 0.1
 * 
 */

@Service
public class LineServiceImpl extends BaseServiceImpl<Line, Integer> implements LineService {

	@Autowired
	private LineRepository repository;

	/**
	 * 获取线路编码
	 * 
	 * @return int <lineCode:线路编码>
	 */
	public long selectMaxIdToLineCode() {
		// TODO Auto-generated method stub
		return repository.selectMaxIdToLineCode();
	}

	@Override
	public Line findByLineCode(String lineCode) {
		return repository.findByLineCode(lineCode);
	}

	@Override
	public Line findById(Integer id) {
		// TODO Auto-generated method stub
		return repository.findOne(id);
	}

	@Override
	public String lineCodeVerification(String lineCode) {
		String state = "true";
		Line line = repository.findByLineCode(lineCode);
		if (line != null) {
			state = "false";
		}
		return state;
	}
	
	@Transactional
	@Override
	public Map<String, Object> update(Line l) {
		Map<String, Object> map = new HashMap<>();

		int status = repository.update(l.getName(), l.getCompany(), l.getBrancheCompany(), l.getLevel(), l.getNature(),
				l.getStartStationName(), l.getEndStationName(), l.getStartStationFirstTime(),
				l.getStartStationEndTime(), l.getEndStationFirstTime(), l.getEndStationEndTime(), l.getLinePlayType(),
				l.getOpenDate(), l.getEs(), l.getShortName(), l.getShanghaiLinecode(), l.getEqLinecode(),
				l.getStartPhone(), l.getEndPhone(), l.getCarSumNumber(), l.getHvacCarNumber(), l.getOrdCarNumber(),
				l.getHistory(), l.getDescriptions(), l.getDestroy(), l.getSupperLine(), l.getSpacGrade(),
				l.getWarrantCar(), l.getLineCode());
		if (status==1) {
			map.put("status", ResponseCode.SUCCESS);
		} else {
			map.put("status", ResponseCode.ERROR);
		}
		
		return map;
	}

}