ServiceDataInterface.java 2.8 KB
package com.bsth.controller.realcontrol;

import com.bsth.data.schedule.DayOfSchedule;
import com.bsth.entity.realcontrol.ScheduleRealInfo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

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

/**
 * 对外的营运数据接口,主要输出当日的数据
 * Created by panzhao on 2017/3/15.
 */
@RestController
@RequestMapping("/companyService")
public class ServiceDataInterface {

    private final static String SECRE_KEY = "dVPHJkWUt5FhMT7jrM2dLV7QvlHAmZFd42rs1P0usBx8A7HZki";

    @Autowired
    DayOfSchedule dayOfSchedule;

    @RequestMapping("/getCurrentDayPlan")
    public List<ScheduleRealInfo> getCurrentDayPlan(
            @RequestParam String companyId,
            @RequestParam String workId,
            @RequestParam String secretKey) {

        if (StringUtils.isEmpty(secretKey) || !secretKey.equals(SECRE_KEY))
            return null;

        List<ScheduleRealInfo> all = new ArrayList<>(dayOfSchedule.findAll()), rs = new ArrayList<>();
        for (ScheduleRealInfo sch : all) {
            if (sch.getGsBm() != null
                    && sch.getGsBm().equals(companyId)
                    && sch.getjGh().equals(workId)) {
                rs.add(sch);
            }
        }
        return rs;
    }

    @RequestMapping("/returnCCInfo")
    public List<ScheduleRealInfo> returnCCInfo(@RequestParam String companyId, @RequestParam String secretKey){
        if (StringUtils.isEmpty(secretKey) || !secretKey.equals(SECRE_KEY))
            return null;


        List<ScheduleRealInfo> all = new ArrayList<>(dayOfSchedule.findAll()), rs = new ArrayList<>();
        for (ScheduleRealInfo sch : all) {

            if (sch.getBcType().equals("out")
                    && sch.getGsBm() != null
                    && sch.getGsBm().equals(companyId)) {
                rs.add(sch);
            }
        }
        return rs;
    }

    @RequestMapping("/returnJCInfo")
    public List<ScheduleRealInfo> returnJCInfo(@RequestParam String companyId, @RequestParam String secretKey){
        if (StringUtils.isEmpty(secretKey) || !secretKey.equals(SECRE_KEY))
            return null;


        List<ScheduleRealInfo> all = new ArrayList<>(dayOfSchedule.findAll()), rs = new ArrayList<>();
        for (ScheduleRealInfo sch : all) {
            if (sch.getBcType().equals("in")
                    && sch.getGsBm() != null
                    && sch.getGsBm().equals(companyId)) {
                rs.add(sch);
            }
        }
        return rs;
    }
}