//package com.dsh.guns.modular.system.controller.specialTrain;
|
//
|
//import com.alibaba.fastjson.JSON;
|
//import com.alibaba.fastjson.JSONArray;
|
//import com.alibaba.fastjson.JSONObject;
|
//import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
//import com.baomidou.mybatisplus.plugins.Page;
|
//import com.dsh.guns.core.base.controller.BaseController;
|
//import com.dsh.guns.core.common.constant.factory.PageFactory;
|
//import com.dsh.guns.core.shiro.ShiroKit;
|
//import com.dsh.guns.core.util.SinataUtil;
|
//import com.dsh.guns.modular.system.model.*;
|
//import com.dsh.guns.modular.system.service.*;
|
//import com.dsh.guns.modular.system.util.ResultUtil;
|
//import org.springframework.stereotype.Controller;
|
//import org.springframework.web.bind.annotation.RequestMapping;
|
//import org.springframework.web.bind.annotation.ResponseBody;
|
//import org.springframework.ui.Model;
|
//import org.springframework.web.bind.annotation.PathVariable;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
//import com.dsh.guns.core.log.LogObjectHolder;
|
//import org.springframework.web.bind.annotation.RequestParam;
|
//
|
//import java.text.SimpleDateFormat;
|
//import java.util.ArrayList;
|
//import java.util.Date;
|
//import java.util.List;
|
//import java.util.Map;
|
//
|
///**
|
// * 跨城线路管理控制器
|
// *
|
// * @author fengshuonan
|
// * @Date 2020-09-15 16:17:29
|
// */
|
//@Controller
|
//@RequestMapping("/tLine")
|
//public class TLineController extends BaseController {
|
//
|
// private String PREFIX = "/system/tLine/";
|
//
|
// @Autowired
|
// private ITLineService tLineService;
|
//
|
// @Autowired
|
// private ITSiteService itSiteService;
|
//
|
// @Autowired
|
// private ITServerCarmodelService itServerCarmodelService;
|
//
|
// @Autowired
|
// private ITLineSiteService itLineSiteService;
|
//
|
// @Autowired
|
// private ITLinePriceService itLinePriceService;
|
//
|
// @Autowired
|
// private ITLineShiftService itLineShiftService;
|
//
|
// @Autowired
|
// private ITCompanyService itCompanyService;
|
//
|
// @Autowired
|
// private ITLineCompanyService itLineCompanyService;
|
//
|
// /**
|
// * 跳转到跨城站点管理首页
|
// */
|
// @RequestMapping("")
|
// public String index() {
|
// return PREFIX + "tLine.html";
|
// }
|
//
|
// /**
|
// * 跳转到添加跨城站点管理
|
// */
|
// @RequestMapping("/tLine_add")
|
// public String tLineAdd(Model model) {
|
// //站点
|
// List<TSite> siteList = itSiteService.selectList(new EntityWrapper<TSite>().eq("state", 1));
|
// model.addAttribute("siteList",siteList);
|
// //跨城车型
|
// List<TServerCarmodel> carmodelList = itServerCarmodelService.selectList(new EntityWrapper<TServerCarmodel>().eq("type", 2).eq("state", 1));
|
// model.addAttribute("carmodelList",carmodelList);
|
// return PREFIX + "tLine_add.html";
|
// }
|
//
|
// /**
|
// * 分配企业页面
|
// */
|
// @RequestMapping("/tLine_addCompany/{tLineId}")
|
// public String tLine_addCompany(@PathVariable Integer tLineId,Model model) {
|
// TLine tLine = tLineService.selectById(tLineId);
|
// model.addAttribute("tLine",tLine);
|
// //查询所有企业
|
// List<TCompany> companyList = itCompanyService.selectList(new EntityWrapper<TCompany>().last(" where not FIND_IN_SET(state,'1') and not FIND_IN_SET(flag,'3')"));
|
// model.addAttribute("companyList",companyList);
|
// //查询已分配企业
|
// List<Map<String, Object>> lineCompanyList = tLineService.getLineCompanyList(tLineId);
|
// model.addAttribute("lineCompanyList",lineCompanyList);
|
// return PREFIX + "tLine_addCompany.html";
|
// }
|
//
|
// /**
|
// * 跳转到修改跨城站点管理
|
// */
|
// @RequestMapping("/tLine_update/{tLineId}")
|
// public String tLineUpdate(@PathVariable Integer tLineId, Model model) {
|
// TLine tLine = tLineService.selectById(tLineId);
|
// model.addAttribute("item",tLine);
|
// LogObjectHolder.me().set(tLine);
|
//
|
// //查找站点起点+终点
|
// TLineSite start = itLineSiteService.selectOne(new EntityWrapper<TLineSite>().eq("lineId", tLineId).eq("type", 1));
|
// model.addAttribute("start",start);
|
// TLineSite end = itLineSiteService.selectOne(new EntityWrapper<TLineSite>().eq("lineId", tLineId).eq("type", 2));
|
// model.addAttribute("end",end);
|
// //站点
|
// List<TSite> siteList = itSiteService.selectList(new EntityWrapper<TSite>().eq("state", 1));
|
// model.addAttribute("siteList",siteList);
|
// //跨城车型
|
// List<TServerCarmodel> carmodelList = itServerCarmodelService.selectList(new EntityWrapper<TServerCarmodel>().eq("type", 2).eq("state", 1));
|
// model.addAttribute("carmodelList",carmodelList);
|
// //查询所有站点
|
// List<Map<String, Object>> linePriceList = tLineService.getLinePriceList(tLineId);
|
// model.addAttribute("linePriceList",linePriceList);
|
// //查询所有班次
|
// List<TLineShift> lineShiftList = itLineShiftService.selectList(new EntityWrapper<TLineShift>().eq("lineId", tLineId).last(" and not FIND_IN_SET(state,'3')"));
|
// model.addAttribute("lineShiftList",lineShiftList);
|
// return PREFIX + "tLine_edit.html";
|
// }
|
//
|
// /**
|
// * 获取跨城站点管理列表
|
// */
|
// @RequestMapping(value = "/list")
|
// @ResponseBody
|
// public Object list(String insertTime,String name,String insertUser,String modelStr,Integer state) {
|
// String beginTime = null;
|
// String endTime = null;
|
// if (SinataUtil.isNotEmpty(insertTime)){
|
// String[] timeArray = insertTime.split(" - ");
|
// beginTime = timeArray[0];
|
// endTime = timeArray[1];
|
// }
|
// Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
|
// if (ShiroKit.getUser().getRoleType() != 1){
|
// page.setRecords(null);
|
// }else{
|
// page.setRecords(tLineService.getLineList(page,beginTime,endTime,name,insertUser,modelStr,state));
|
// }
|
// return super.packForBT(page);
|
// }
|
//
|
// /**
|
// * 新增跨城站点管理
|
// */
|
// @RequestMapping(value = "/add")
|
// @ResponseBody
|
// public ResultUtil add(TLine tLine,Integer startSiteId,Integer endSiteId,@RequestParam String subArr,@RequestParam String shuArr) {
|
// String name = tLine.getName();
|
// name = name.replaceAll("& lt;", "<");
|
// name = name.replaceAll("& gt;", ">");
|
// name = name.replaceAll("& #40;", "(");
|
// name = name.replaceAll("& #41;", ")");
|
// tLine.setName(name);
|
// tLine.setState(1);
|
// tLine.setInsertTime(new Date());
|
// tLine.setInsertUserId(ShiroKit.getUser().getId());
|
// tLineService.insert(tLine);
|
//
|
// //添加线路站点起点+终点
|
// TLineSite start = new TLineSite();
|
// start.setLineId(tLine.getId());
|
// start.setSiteId(startSiteId);
|
// start.setType(1);
|
// itLineSiteService.insert(start);
|
// TLineSite end = new TLineSite();
|
// end.setLineId(tLine.getId());
|
// end.setSiteId(endSiteId);
|
// end.setType(2);
|
// itLineSiteService.insert(end);
|
//
|
// //添加价格设置
|
// addPrice(tLine.getId(), subArr);
|
//
|
// //添加班次设置
|
// return addShift(tLine.getId(), shuArr);
|
// }
|
//
|
// /**
|
// * 添加线路班次
|
// * @param lineId
|
// * @param shuArr
|
// */
|
// private ResultUtil addShift(Integer lineId, @RequestParam String shuArr) {
|
// try {
|
// JSONArray jsonArray1 = JSON.parseArray(shuArr);
|
// int size1 = jsonArray1.size();
|
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
// List<String> list = new ArrayList<>();
|
// for (int i = 0; i < size1; i++) {
|
// List<TLineShift> tLineShifts = itLineShiftService.selectList(new EntityWrapper<TLineShift>().eq("lineId", lineId).ne("state", 3).orderBy("startTime"));
|
// JSONObject jsonObject = jsonArray1.getJSONObject(i);
|
// TLineShift shift = new TLineShift();
|
// shift.setLineId(lineId);
|
// String shiftTime = jsonObject.getString("shiftTime");
|
// String startTime = null;
|
// String endTime = null;
|
// if (SinataUtil.isNotEmpty(shiftTime)){
|
// String[] timeArray = shiftTime.split(" - ");
|
// startTime = timeArray[0];
|
// endTime = timeArray[1];
|
// }
|
// Date s1 = sdf.parse("2020-11-11 " + startTime + ":00");
|
// Date e1 = sdf.parse("2020-11-11 " + endTime + ":00");
|
// boolean b = false;
|
// for(TLineShift lineShift : tLineShifts){
|
// Date s2 = sdf.parse("2020-11-11 " + lineShift.getStartTime() + ":00");
|
// Date e2 = sdf.parse("2020-11-11 " + lineShift.getEndTime() + ":00");
|
// if(s2.getTime() <= s1.getTime() && e1.getTime() <= e2.getTime()){
|
// list.add(startTime + " - " + endTime);
|
// b = true;
|
// break;
|
// }
|
// if(s1.getTime() <= s2.getTime() && s1.getTime() <= e2.getTime() && e1.getTime() >= s2.getTime()){
|
// list.add(startTime + " - " + endTime);
|
// b = true;
|
// break;
|
// }
|
// if(s1.getTime() >= s2.getTime() && s1.getTime() <= e2.getTime() && e1.getTime() >= e2.getTime()){
|
// list.add(startTime + " - " + endTime);
|
// b = true;
|
// break;
|
// }
|
// }
|
// if(b){
|
// continue;
|
// }
|
// shift.setStartTime(startTime);
|
// shift.setEndTime(endTime);
|
// shift.setCarNum(jsonObject.getInteger("carNum"));
|
// shift.setInsertTime(new Date());
|
// shift.setAddTime(jsonObject.getString("time2"));
|
// shift.setState(1);
|
// itLineShiftService.insert(shift);
|
// }
|
// if(list.size() > 0){
|
// return ResultUtil.error("【" + JSON.toJSONString(list) + "】时间段与现存时间段重合,添加失败!");
|
// }
|
// return ResultUtil.success();
|
// }catch (Exception e){
|
// e.printStackTrace();
|
// return ResultUtil.runErr();
|
// }
|
// }
|
//
|
// /**
|
// * 添加线路价格
|
// * @param lineId
|
// * @param subArr
|
// */
|
// private void addPrice(Integer lineId, @RequestParam String subArr) {
|
// JSONArray jsonArray = JSON.parseArray(subArr);
|
// int size = jsonArray.size();
|
// for (int i = 0; i < size; i++) {
|
// JSONObject jsonObject = jsonArray.getJSONObject(i);
|
// TLinePrice price = new TLinePrice();
|
// price.setLineId(lineId);
|
// price.setServerCarModelId(jsonObject.getInteger("serverModelId"));
|
// price.setType(jsonObject.getInteger("type"));
|
// price.setContent(jsonObject.getString("content"));
|
// price.setContentStr(jsonObject.getString("contentStr"));
|
// price.setState(1);
|
// price.setInsertTime(new Date());
|
// price.setAddTime(jsonObject.getString("time"));
|
// itLinePriceService.insert(price);
|
// }
|
// }
|
//
|
// /**
|
// * 操作跨城站点管理
|
// * optType 1=删除 2=冻结 3=解冻
|
// */
|
// @RequestMapping(value = "/opt")
|
// @ResponseBody
|
// public Object opt(@RequestParam Integer tLineId,@RequestParam Integer optType) {
|
// TLine tLine = tLineService.selectById(tLineId);
|
// if (1 == optType){
|
// tLine.setState(3);
|
// }else if (2 == optType){
|
// tLine.setState(2);
|
// }else if (3 == optType){
|
// tLine.setState(1);
|
// }
|
// tLineService.updateById(tLine);
|
// return SUCCESS_TIP;
|
// }
|
//
|
// /**
|
// * 分配企业操作
|
// */
|
// @RequestMapping(value = "/addCompany")
|
// @ResponseBody
|
// public Object addCompany(Integer lineId,@RequestParam String comArr) {
|
// //删除分配企业
|
// itLineCompanyService.delete(new EntityWrapper<TLineCompany>().eq("lineId",lineId));
|
// //添加企业
|
// if (SinataUtil.isNotEmpty(comArr)){
|
// JSONArray jsonArray = JSON.parseArray(comArr);
|
// int size = jsonArray.size();
|
// for (int i = 0; i < size; i++) {
|
// JSONObject jsonObject = jsonArray.getJSONObject(i);
|
// TLineCompany lineCompany = new TLineCompany();
|
// lineCompany.setLineId(lineId);
|
// lineCompany.setCompanyId(jsonObject.getInteger("companyId"));
|
// lineCompany.setInsertTime(new Date());
|
// lineCompany.setInsertUserId(ShiroKit.getUser().getId());
|
// itLineCompanyService.insert(lineCompany);
|
// }
|
// }
|
// return SUCCESS_TIP;
|
// }
|
// /**
|
// * 修改跨城站点管理
|
// */
|
// @RequestMapping(value = "/update")
|
// @ResponseBody
|
// public ResultUtil update(TLine tLine,Integer startSiteId,Integer endSiteId,@RequestParam String subArr,@RequestParam String shuArr) {
|
// String name = tLine.getName();
|
// name = name.replaceAll("& lt;", "<");
|
// name = name.replaceAll("& gt;", ">");
|
// name = name.replaceAll("& #40;", "(");
|
// name = name.replaceAll("& #41;", ")");
|
// tLine.setName(name);
|
// tLineService.updateById(tLine);
|
//
|
// //修改站点起点
|
// TLineSite start = itLineSiteService.selectOne(new EntityWrapper<TLineSite>().eq("lineId", tLine.getId()).eq("type", 1));
|
// if (SinataUtil.isNotEmpty(start)){
|
// if (start.getSiteId().intValue() != startSiteId.intValue()){
|
// start.setSiteId(startSiteId);
|
// itLineSiteService.updateById(start);
|
// }
|
// }else{
|
// start = new TLineSite();
|
// start.setLineId(tLine.getId());
|
// start.setSiteId(startSiteId);
|
// start.setType(1);
|
// itLineSiteService.insert(start);
|
// }
|
// //修改站点终点
|
// TLineSite end = itLineSiteService.selectOne(new EntityWrapper<TLineSite>().eq("lineId", tLine.getId()).eq("type", 2));
|
// if (SinataUtil.isNotEmpty(end)){
|
// if (end.getSiteId().intValue() != endSiteId.intValue()){
|
// end.setSiteId(endSiteId);
|
// itLineSiteService.updateById(end);
|
// }
|
// }else{
|
// end = new TLineSite();
|
// end.setLineId(tLine.getId());
|
// end.setSiteId(endSiteId);
|
// end.setType(2);
|
// itLineSiteService.insert(end);
|
// }
|
//
|
// //删除线路价格
|
// itLinePriceService.delete(new EntityWrapper<TLinePrice>().eq("lineId",tLine.getId()));
|
// //添加价格设置
|
// addPrice(tLine.getId(), subArr);
|
// //删除线路班次
|
// itLineShiftService.delete(new EntityWrapper<TLineShift>().eq("lineId",tLine.getId()));
|
// //添加班次设置
|
// return addShift(tLine.getId(), shuArr);
|
//
|
// }
|
//
|
//}
|