xuhy
6 天以前 f2057bd69558d42de70a4b8a169a2b86e49b9b19
ManagementOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TLineController.java
@@ -13,6 +13,7 @@
import com.stylefeng.guns.modular.system.service.*;
import com.stylefeng.guns.modular.system.util.ResultUtil;
import org.springframework.stereotype.Controller;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
@@ -115,6 +116,8 @@
        model.addAttribute("start",start);
        TLineSite end = itLineSiteService.selectOne(new EntityWrapper<TLineSite>().eq("lineId", tLineId).eq("type", 2));
        model.addAttribute("end",end);
        List<TLineSite> stopoverList = itLineSiteService.selectList(new EntityWrapper<TLineSite>().eq("lineId", tLineId).eq("type", 3));
        model.addAttribute("stopoverList",stopoverList);
        //站点
        List<TSite> siteList = itSiteService.selectList(new EntityWrapper<TSite>().eq("state", 1));
        model.addAttribute("siteList",siteList);
@@ -157,7 +160,10 @@
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public ResultUtil add(TLine tLine,Integer startSiteId,Integer endSiteId,@RequestParam String subArr,@RequestParam String shuArr) {
    public ResultUtil add(TLine tLine,Integer startSiteId,Integer endSiteId,
                          @RequestParam String subArr,
                          @RequestParam String shuArr,
                          @RequestParam String stopoverValues) {
        String name = tLine.getName();
        name = name.replaceAll("& lt;", "<");
        name = name.replaceAll("& gt;", ">");
@@ -180,6 +186,20 @@
        end.setSiteId(endSiteId);
        end.setType(2);
        itLineSiteService.insert(end);
        // 添加经停站
        List<TLineSite> stopoverList = new ArrayList<>();
        JSONArray jsonArray = JSON.parseArray(stopoverValues);
        for (int i = 0; i < jsonArray.size(); i++) {
            JSONObject jsonObject = jsonArray.getJSONObject(i);
            TLineSite stopover = new TLineSite();
            stopover.setLineId(tLine.getId());
            stopover.setSiteId(jsonObject.getInteger("id"));
            stopover.setType(3);
            stopoverList.add(stopover);
        }
        if(!CollectionUtils.isEmpty(stopoverList)){
            itLineSiteService.insertBatch(stopoverList);
        }
        //添加价格设置
        addPrice(tLine.getId(), subArr);
@@ -326,7 +346,10 @@
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public ResultUtil update(TLine tLine,Integer startSiteId,Integer endSiteId,@RequestParam String subArr,@RequestParam String shuArr) {
    public ResultUtil update(TLine tLine,Integer startSiteId,Integer endSiteId,
                             @RequestParam String subArr,
                             @RequestParam String shuArr,
                             @RequestParam String stopoverValues) {
        String name = tLine.getName();
        name = name.replaceAll("& lt;", "<");
        name = name.replaceAll("& gt;", ">");
@@ -364,6 +387,23 @@
            itLineSiteService.insert(end);
        }
        // 删除经停站
        itLineSiteService.delete(new EntityWrapper<TLineSite>().eq("lineId",tLine.getId()).eq("type",3));
        // 添加经停站
        List<TLineSite> stopoverList = new ArrayList<>();
        JSONArray jsonArray = JSON.parseArray(stopoverValues);
        for (int i = 0; i < jsonArray.size(); i++) {
            JSONObject jsonObject = jsonArray.getJSONObject(i);
            TLineSite stopover = new TLineSite();
            stopover.setLineId(tLine.getId());
            stopover.setSiteId(jsonObject.getInteger("id"));
            stopover.setType(3);
            stopoverList.add(stopover);
        }
        if(!CollectionUtils.isEmpty(stopoverList)){
            itLineSiteService.insertBatch(stopoverList);
        }
        //删除线路价格
        itLinePriceService.delete(new EntityWrapper<TLinePrice>().eq("lineId",tLine.getId()));
        //添加价格设置