package com.yc.action.panval;
|
|
import com.yc.action.grid.GridUtils;
|
import com.yc.service.datacheck.DataCheckIfc;
|
import com.yc.service.panel.PanelServiceIfc;
|
import com.yc.utils.GTJson;
|
import com.yc.utils.SessionKey;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.dao.DataAccessException;
|
import org.springframework.stereotype.Controller;
|
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
@Controller
|
public class DataCheck {
|
@Autowired
|
DataCheckIfc dIfc;
|
@Autowired
|
PanelServiceIfc pIfc;
|
|
/**
|
* @param formid 功能号
|
* @param point 检查点:2表示保存时检查,3表示确定时检查
|
* @param request
|
* @param out 输出信息
|
* @param hasGrid 包含表格出理 因不在页面调用 当参数出来
|
* @param json json数据格式
|
* @return List<Object> 索引 0:出错信息 1:信息类型 -1(没有错误) 1(错误) 0(警告)
|
* @throws Exception
|
*/
|
public String excelDataCheck(int formid, GTJson json, HttpServletRequest request, HttpServletResponse response) throws DataAccessException {
|
|
int point = (json.getClickTran() == 1|| json.getClickTran() == 2)? 3 : 2;//判断是执行哪一个操作
|
Object num = request.getSession().getAttribute(SessionKey.DATACHECK_PAGENUM);
|
HashMap<String, String> sessionClone = (HashMap) GridUtils.getSessionAttributes(request.getSession(), formid, json.getDoccode(), false).clone();//clone一份出来,避免串数据
|
return dIfc.getErrorList(formid, point, json, (num == null ? "" : String.valueOf(num)), sessionClone);
|
|
}
|
|
/**
|
* 组装集合
|
*
|
* @param mapListTo 需要检查的总集合
|
* @param panS 给总集合添加的集合信息
|
* @param check 检查点 保存2 确定 3
|
* @param key 信息的key 1为面板 2为表格(做标识无意义)
|
*/
|
private void getListByListIn(Map<String, List<Map<String, String>>> mapListTo, List<HashMap<String, String>> panS, String check, String key) {
|
Map<String, String> mapIs = null;
|
List<Map<String, String>> infoAll = new ArrayList<Map<String, String>>();
|
if (panS != null) {// 有面板
|
for (int i = 0; i < panS.size(); i++) {
|
if (panS.get(i) != null) {// 面板不为null
|
mapIs = new HashMap<String, String>();
|
mapIs.putAll(panS.get(i));// 添加
|
mapIs.put("check", check);// 设置信息,让程序知道 保存2 确定 3
|
infoAll.add(mapIs);
|
}
|
}
|
}
|
if (mapListTo.containsKey(key)) {// 如果有集合添加
|
mapListTo.get(key).addAll(infoAll);// 更改应该下面是正确的
|
} else {
|
if (infoAll.size() > 0) {
|
mapListTo.put(key, infoAll);
|
}
|
}
|
}
|
|
/**
|
* 组装修改后的集合信息
|
*
|
* @param upFelid 修改字段集合
|
* @param oldInfo 未修改时的原集合
|
* @return List<HashMap < String, String>>
|
*/
|
private List<HashMap<String, String>> getUpdatedInfo(List<HashMap<String, String>> upFelid, List<HashMap<String, String>> oldInfo) {
|
List<HashMap<String, String>> reList = new ArrayList<HashMap<String, String>>();
|
HashMap<String, String> map = null;
|
for (int i = 0; i < oldInfo.size(); i++) {
|
map = oldInfo.get(i);
|
map.putAll(upFelid.get(i));
|
reList.add(map);
|
}
|
return reList;
|
}
|
}
|