You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
aggregation-platform/src/com/platform/controller/CheckoutController.java

210 lines
6.3 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.platform.controller;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.base.BaseController;
import com.platform.entities.CheckoutEntity;
import com.platform.entities.PreDataInfo;
import com.platform.service.DataInfoService;
import com.platform.service.ICheckoutService;
import com.platform.utils.CacheSetCantDelete;
/** 信息系统--校验
* @author chen
*
*/
@Controller
@RequestMapping("/checkout")
public class CheckoutController extends BaseController {
//日志
public final static Logger log = Logger.getLogger(CheckoutController.class);
@Resource(name = "checkoutService")
private ICheckoutService checkoutService;
/**
* 数据管理业务层
*/
@Resource(name = "dataInfoService")
private DataInfoService dataInfoService;
/**
* 信息系统--校验--查看所有系统的 标准表情况
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/findAll")
public ModelMap findAll() throws Exception {
log.info("---------/findAll--- ");
ModelMap modelMap = new ModelMap();
List<CheckoutEntity> result = checkoutService.findAll();
modelMap.addAttribute("data", result);
modelMap.addAttribute("length", result.size());
return modelMap;
}
/**
* 信息系统--校验--查看系统的 标准表情况
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/findByCity")
public ModelMap findByCity(@RequestBody String cityName, HttpServletRequest req, HttpServletResponse res) throws Exception {
log.info("---------/findByCity--- "+cityName);
ModelMap modelMap = new ModelMap();
List<CheckoutEntity> result = checkoutService.findByCity(cityName);
modelMap.addAttribute("data", result);
modelMap.addAttribute("length", result.size());
return modelMap;
}
/**
* 信息系统--校验--校验勾选的数据
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/checkList")
public ModelMap checkList(@RequestBody List<CheckoutEntity> form, HttpServletRequest req, HttpServletResponse res) throws Exception {
ModelMap modelMap = new ModelMap();
if (null != form) {
log.info("---------/checkList--- "+ form.size());
List<CheckoutEntity> result = checkoutService.checkAll(form);
modelMap.addAttribute("data", result);
modelMap.addAttribute("length", result.size());
}
else {
log.info("---------/checkList--- "+ form);
}
return modelMap;
}
/**
* 信息系统--校验--查看单条数据的详情
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/findDetails")
public ModelMap findDetails(@RequestBody CheckoutEntity form, HttpServletRequest req, HttpServletResponse res) throws Exception {
ModelMap modelMap = new ModelMap();
if (null != form) {
log.info("---------/findDetails--- "+ form);
Map<String, PreDataInfo> result = checkoutService.findDetail(form);
modelMap.addAllAttributes(result);
}
else {
log.info("---------/findDetails--- "+ form);
}
return modelMap;
}
/**
* 信息系统--校验--(查看后 )单条数据的修改详情
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/update")
public ModelMap update(@RequestBody PreDataInfo form, HttpServletRequest req, HttpServletResponse res) throws Exception {
ModelMap modelMap = new ModelMap();
if (null != form) {
log.info("---------/update--- "+ form);
int result = checkoutService.updateStandardInfo(form);
if (result == 0) {
res.setStatus(500);
}
else {
List<CheckoutEntity> data = checkoutService.findByCity(form.getCityName());
modelMap.addAttribute("data", data);
modelMap.addAttribute("length", data.size());
}
}
else {
log.info("---------/update--- "+ form);
res.setStatus(500);
}
return modelMap;
}
/**
* 信息系统--校验--删除勾选的数据
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/deleteList")
public ModelMap deleteList(@RequestBody List<CheckoutEntity> form, HttpServletRequest req, HttpServletResponse res) throws Exception {
ModelMap modelMap = new ModelMap();
log.info("---------/deleteList--- "+ form.size());
if (null != form) {
List<Integer> dataIds = new ArrayList<Integer>();
List<CheckoutEntity> errCk = new ArrayList<CheckoutEntity>();
for (CheckoutEntity checkoutEntity : form) {
int dataInfoId = checkoutEntity.getDataId();
if (dataInfoId > 0) {
if(CacheSetCantDelete.containsId(String.valueOf(dataInfoId)))
errCk.add(checkoutEntity);
else
dataIds.add(dataInfoId);
}
}
if (dataIds.size() > 0) {
dataInfoService.deleteData(dataIds);
// 根据 dataIds 删除
}
List<CheckoutEntity> result = new ArrayList<CheckoutEntity>();
if (form.size() > 0) {
result = checkoutService.findByCity(form.get(0).getCityName());
}
if (errCk.size() > 0) {
modelMap.put("err", errCk);
res.setStatus(500);
}
// List<CheckoutEntity> result = checkoutService.deleteAll(form);
modelMap.addAttribute("data", result);
modelMap.addAttribute("length", result.size());
}
return modelMap;
}
/** 信息系统--校验--抽取标准表sqlserver
* @param form
* @param req
* @param res
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/extractList")
public ModelMap extractList(@RequestBody List<CheckoutEntity> form, HttpServletRequest req, HttpServletResponse res) throws Exception {
ModelMap modelMap = new ModelMap();
if (null != form) {
log.info("---------/extractList--- "+ form.size());
List<CheckoutEntity> result = checkoutService.extractSqlServer(form);
modelMap.addAttribute("data", result);
modelMap.addAttribute("length", result.size());
}
else {
log.info("---------/extractList--- "+ form);
}
return modelMap;
}
}