提交 4558db0e 编写于 作者: doc_wei's avatar doc_wei

问卷回答完成

上级 c317b240
此差异已折叠。
此差异已折叠。
package com.skyeye.common.util;
public class IPEntry {
public String beginIp;
public String endIp;
public String country;
public String area;
public IPEntry() {
beginIp = endIp = country = area = "";
}
public String toString() {
return this.area + " " + this.country + "IP范围:" + this.beginIp + "-" + this.endIp;
}
}
package com.skyeye.common.util;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteOrder;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import org.springframework.stereotype.Component;
@Component
public class IPSeeker {
private static class IPLocation {
public String country;
public String area;
public IPLocation() {
country = area = "";
}
public IPLocation getCopy() {
IPLocation ret = new IPLocation();
ret.country = country;
ret.area = area;
return ret;
}
}
private static final String IP_FILE = IPSeeker.class.getResource("qqwry.dat").toString().substring(5);
// 一些固定常量,比如记录长度等等
private static final int IP_RECORD_LENGTH = 7;
private static final byte AREA_FOLLOWED = 0x01;
private static final byte NO_AREA = 0x2;
// 用来做为cache,查询一个ip时首先查看cache,以减少不必要的重复查找
@SuppressWarnings("rawtypes")
private static Hashtable ipCache;
// 随机文件访问类
private static RandomAccessFile ipFile;
// 内存映射文件
private static MappedByteBuffer mbb;
// 单一模式实例
private static IPSeeker instance = new IPSeeker();
// 起始地区的开始和结束的绝对偏移
private static long ipBegin, ipEnd;
// 为提高效率而采用的临时变量
private static IPLocation loc;
private static byte[] buf;
private static byte[] b4;
private static byte[] b3;
/**
* 私有构造函数
*/
private IPSeeker() {
ipCache = new Hashtable<>();
loc = new IPLocation();
buf = new byte[100];
b4 = new byte[4];
b3 = new byte[3];
try {
ipFile = new RandomAccessFile(IP_FILE, "r");
} catch (FileNotFoundException e) {
System.out.println(IPSeeker.class.getResource("qqwry.dat")
.toString());
System.out.println(IP_FILE);
System.out.println("IP地址信息文件没有找到,IP显示功能将无法使用");
ipFile = null;
}
// 如果打开文件成功,读取文件头信息
if (ipFile != null) {
try {
ipBegin = readLong4(0);
ipEnd = readLong4(4);
if (ipBegin == -1 || ipEnd == -1) {
ipFile.close();
ipFile = null;
}
} catch (IOException e) {
System.out.println("IP地址信息文件格式有错误,IP显示功能将无法使用");
ipFile = null;
}
}
}
/**
* @return 单一实例
*/
public static IPSeeker getInstance() {
return instance;
}
/**
* 给定一个地点的不完全名字,得到一系列包含s子串的IP范围记录
*
* @param s
* 地点子串
* @return 包含IPEntry类型的List
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public List getIPEntriesDebug(String s) {
List ret = new ArrayList();
long endOffset = ipEnd + 4;
for (long offset = ipBegin + 4; offset <= endOffset; offset += IP_RECORD_LENGTH) {
// 读取结束IP偏移
long temp = readLong3(offset);
// 如果temp不等于-1,读取IP的地点信息
if (temp != -1) {
IPLocation loc = getIPLocation(temp);
// 判断是否这个地点里面包含了s子串,如果包含了,添加这个记录到List中,如果没有,继续
if (loc.country.indexOf(s) != -1 || loc.area.indexOf(s) != -1) {
IPEntry entry = new IPEntry();
entry.country = loc.country;
entry.area = loc.area;
// 得到起始IP
readIP(offset - 4, b4);
entry.beginIp = Utils.getIpStringFromBytes(b4);
// 得到结束IP
readIP(temp, b4);
entry.endIp = Utils.getIpStringFromBytes(b4);
// 添加该记录
ret.add(entry);
}
}
}
return ret;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public static List getIPEntries(String s) {
List ret = new ArrayList();
try {
// 映射IP信息文件到内存中
if (mbb == null) {
FileChannel fc = ipFile.getChannel();
mbb = fc.map(FileChannel.MapMode.READ_ONLY, 0, ipFile.length());
mbb.order(ByteOrder.LITTLE_ENDIAN);
}
int endOffset = (int) ipEnd;
for (int offset = (int) ipBegin + 4; offset <= endOffset; offset += IP_RECORD_LENGTH) {
int temp = readInt3(offset);
if (temp != -1) {
IPLocation loc = getIPLocation(temp);
// 判断是否这个地点里面包含了s子串,如果包含了,添加这个记录到List中,如果没有,继续
if (loc.country.indexOf(s) != -1
|| loc.area.indexOf(s) != -1) {
IPEntry entry = new IPEntry();
entry.country = loc.country;
entry.area = loc.area;
// 得到起始IP
readIP(offset - 4, b4);
entry.beginIp = Utils.getIpStringFromBytes(b4);
// 得到结束IP
readIP(temp, b4);
entry.endIp = Utils.getIpStringFromBytes(b4);
// 添加该记录
ret.add(entry);
}
}
}
} catch (IOException e) {
System.out.println(e.getMessage());
}
return ret;
}
private static int readInt3(int offset) {
mbb.position(offset);
return mbb.getInt() & 0x00FFFFFF;
}
/**
* 从内存映射文件的当前位置开始的3个字节读取一个int
*
* @return
*/
private static int readInt3() {
return mbb.getInt() & 0x00FFFFFF;
}
/**
* 根据IP得到国家名
*
* @param ip
* ip的字节数组形式
* @return 国家名字符串
*/
@SuppressWarnings("unchecked")
public static String getCountry(byte[] ip) {
// 检查ip地址文件是否正常
if (ipFile == null)
return "错误的IP数据库文件";
// 保存ip,转换ip字节数组为字符串形式
String ipStr = Utils.getIpStringFromBytes(ip);
// 先检查cache中是否已经包含有这个ip的结果,没有再搜索文件
if (ipCache.containsKey(ipStr)) {
IPLocation loc = (IPLocation) ipCache.get(ipStr);
return loc.country;
} else {
IPLocation loc = getIPLocation(ip);
ipCache.put(ipStr, loc.getCopy());
return loc.country;
}
}
/**
* 根据IP得到国家名
*
* @param ip
* IP的字符串形式
* @return 国家名字符串
*/
public static String getCountry(String ip) {
return getCountry(Utils.getIpByteArrayFromString(ip));
}
/**
* 根据IP得到地区名
*
* @param ip
* ip的字节数组形式
* @return 地区名字符串
*/
@SuppressWarnings("unchecked")
public String getArea(byte[] ip) {
// 检查ip地址文件是否正常
if (ipFile == null)
return "错误的IP数据库文件";
// 保存ip,转换ip字节数组为字符串形式
String ipStr = Utils.getIpStringFromBytes(ip);
// 先检查cache中是否已经包含有这个ip的结果,没有再搜索文件
if (ipCache.containsKey(ipStr)) {
IPLocation loc = (IPLocation) ipCache.get(ipStr);
return loc.area;
} else {
IPLocation loc = getIPLocation(ip);
ipCache.put(ipStr, loc.getCopy());
return loc.area;
}
}
/**
* 根据IP得到地区名
*
* @param ip
* IP的字符串形式
* @return 地区名字符串
*/
public String getArea(String ip) {
return getArea(Utils.getIpByteArrayFromString(ip));
}
/**
* 根据ip搜索ip信息文件,得到IPLocation结构,所搜索的ip参数从类成员ip中得到
*
* @param ip
* 要查询的IP
* @return IPLocation结构
*/
private static IPLocation getIPLocation(byte[] ip) {
IPLocation info = null;
long offset = locateIP(ip);
if (offset != -1)
info = getIPLocation(offset);
if (info == null) {
info = new IPLocation();
info.country = "未知国家";
info.area = "未知地区";
}
return info;
}
/**
* 从offset位置读取4个字节为一个long,因为java为big-endian格式,所以没办法 用了这么一个函数来做转换
*
* @param offset
* @return 读取的long值,返回-1表示读取文件失败
*/
private static long readLong4(long offset) {
long ret = 0;
try {
ipFile.seek(offset);
ret |= (ipFile.readByte() & 0xFF);
ret |= ((ipFile.readByte() << 8) & 0xFF00);
ret |= ((ipFile.readByte() << 16) & 0xFF0000);
ret |= ((ipFile.readByte() << 24) & 0xFF000000);
return ret;
} catch (IOException e) {
return -1;
}
}
/**
* 从offset位置读取3个字节为一个long,因为java为big-endian格式,所以没办法 用了这么一个函数来做转换
*
* @param offset
* @return 读取的long值,返回-1表示读取文件失败
*/
private static long readLong3(long offset) {
long ret = 0;
try {
ipFile.seek(offset);
ipFile.readFully(b3);
ret |= (b3[0] & 0xFF);
ret |= ((b3[1] << 8) & 0xFF00);
ret |= ((b3[2] << 16) & 0xFF0000);
return ret;
} catch (IOException e) {
return -1;
}
}
/**
* 从当前位置读取3个字节转换成long
*
* @return
*/
private static long readLong3() {
long ret = 0;
try {
ipFile.readFully(b3);
ret |= (b3[0] & 0xFF);
ret |= ((b3[1] << 8) & 0xFF00);
ret |= ((b3[2] << 16) & 0xFF0000);
return ret;
} catch (IOException e) {
return -1;
}
}
/**
* 从offset位置读取四个字节的ip地址放入ip数组中,读取后的ip为big-endian格式,但是
* 文件中是little-endian形式,将会进行转换
*
* @param offset
* @param ip
*/
private static void readIP(long offset, byte[] ip) {
try {
ipFile.seek(offset);
ipFile.readFully(ip);
byte temp = ip[0];
ip[0] = ip[3];
ip[3] = temp;
temp = ip[1];
ip[1] = ip[2];
ip[2] = temp;
} catch (IOException e) {
System.out.println(e.getMessage());
}
}
/**
* 从offset位置读取四个字节的ip地址放入ip数组中,读取后的ip为big-endian格式,但是
* 文件中是little-endian形式,将会进行转换
*
* @param offset
* @param ip
*/
private static void readIP(int offset, byte[] ip) {
mbb.position(offset);
mbb.get(ip);
byte temp = ip[0];
ip[0] = ip[3];
ip[3] = temp;
temp = ip[1];
ip[1] = ip[2];
ip[2] = temp;
}
/**
* 把类成员ip和beginIp比较,注意这个beginIp是big-endian的
*
* @param ip
* 要查询的IP
* @param beginIp
* 和被查询IP相比较的IP
* @return 相等返回0,ip大于beginIp则返回1,小于返回-1。
*/
private static int compareIP(byte[] ip, byte[] beginIp) {
for (int i = 0; i < 4; i++) {
int r = compareByte(ip[i], beginIp[i]);
if (r != 0)
return r;
}
return 0;
}
/**
* 把两个byte当作无符号数进行比较
*
* @param b1
* @param b2
* @return 若b1大于b2则返回1,相等返回0,小于返回-1
*/
private static int compareByte(byte b1, byte b2) {
if ((b1 & 0xFF) > (b2 & 0xFF)) // 比较是否大于
return 1;
else if ((b1 ^ b2) == 0)// 判断是否相等
return 0;
else
return -1;
}
/**
* 这个方法将根据ip的内容,定位到包含这个ip国家地区的记录处,返回一个绝对偏移 方法使用二分法查找。
*
* @param ip
* 要查询的IP
* @return 如果找到了,返回结束IP的偏移,如果没有找到,返回-1
*/
private static long locateIP(byte[] ip) {
long m = 0;
int r;
// 比较第一个ip项
readIP(ipBegin, b4);
r = compareIP(ip, b4);
if (r == 0)
return ipBegin;
else if (r < 0)
return -1;
// 开始二分搜索
for (long i = ipBegin, j = ipEnd; i < j;) {
m = getMiddleOffset(i, j);
readIP(m, b4);
r = compareIP(ip, b4);
// log.debug(Utils.getIpStringFromBytes(b));
if (r > 0)
i = m;
else if (r < 0) {
if (m == j) {
j -= IP_RECORD_LENGTH;
m = j;
} else
j = m;
} else
return readLong3(m + 4);
}
// 如果循环结束了,那么i和j必定是相等的,这个记录为最可能的记录,但是并非
// 肯定就是,还要检查一下,如果是,就返回结束地址区的绝对偏移
m = readLong3(m + 4);
readIP(m, b4);
r = compareIP(ip, b4);
if (r <= 0)
return m;
else
return -1;
}
/**
* 得到begin偏移和end偏移中间位置记录的偏移
*
* @param begin
* @param end
* @return
*/
private static long getMiddleOffset(long begin, long end) {
long records = (end - begin) / IP_RECORD_LENGTH;
records >>= 1;
if (records == 0)
records = 1;
return begin + records * IP_RECORD_LENGTH;
}
/**
* 给定一个ip国家地区记录的偏移,返回一个IPLocation结构
*
* @param offset
* @return
*/
private static IPLocation getIPLocation(long offset) {
try {
// 跳过4字节ip
ipFile.seek(offset + 4);
// 读取第一个字节判断是否标志字节
byte b = ipFile.readByte();
if (b == AREA_FOLLOWED) {
// 读取国家偏移
long countryOffset = readLong3();
// 跳转至偏移处
ipFile.seek(countryOffset);
// 再检查一次标志字节,因为这个时候这个地方仍然可能是个重定向
b = ipFile.readByte();
if (b == NO_AREA) {
loc.country = readString(readLong3());
ipFile.seek(countryOffset + 4);
} else
loc.country = readString(countryOffset);
// 读取地区标志
loc.area = readArea(ipFile.getFilePointer());
} else if (b == NO_AREA) {
loc.country = readString(readLong3());
loc.area = readArea(offset + 8);
} else {
loc.country = readString(ipFile.getFilePointer() - 1);
loc.area = readArea(ipFile.getFilePointer());
}
return loc;
} catch (IOException e) {
return null;
}
}
/**
* @param offset
* @return
*/
private static IPLocation getIPLocation(int offset) {
// 跳过4字节ip
mbb.position(offset + 4);
// 读取第一个字节判断是否标志字节
byte b = mbb.get();
if (b == AREA_FOLLOWED) {
// 读取国家偏移
int countryOffset = readInt3();
// 跳转至偏移处
mbb.position(countryOffset);
// 再检查一次标志字节,因为这个时候这个地方仍然可能是个重定向
b = mbb.get();
if (b == NO_AREA) {
loc.country = readString(readInt3());
mbb.position(countryOffset + 4);
} else
loc.country = readString(countryOffset);
// 读取地区标志
loc.area = readArea(mbb.position());
} else if (b == NO_AREA) {
loc.country = readString(readInt3());
loc.area = readArea(offset + 8);
} else {
loc.country = readString(mbb.position() - 1);
loc.area = readArea(mbb.position());
}
return loc;
}
/**
* 从offset偏移开始解析后面的字节,读出一个地区名
*
* @param offset
* @return 地区名字符串
* @throws IOException
*/
private static String readArea(long offset) throws IOException {
ipFile.seek(offset);
byte b = ipFile.readByte();
if (b == 0x01 || b == 0x02) {
long areaOffset = readLong3(offset + 1);
if (areaOffset == 0)
return "未知地区";
else
return readString(areaOffset);
} else
return readString(offset);
}
/**
* @param offset
* @return
*/
private static String readArea(int offset) {
mbb.position(offset);
byte b = mbb.get();
if (b == 0x01 || b == 0x02) {
int areaOffset = readInt3();
if (areaOffset == 0)
return "未知地区";
else
return readString(areaOffset);
} else
return readString(offset);
}
/**
* 从offset偏移处读取一个以0结束的字符串
*
* @param offset
* @return 读取的字符串,出错返回空字符串
*/
private static String readString(long offset) {
try {
ipFile.seek(offset);
int i;
for (i = 0, buf[i] = ipFile.readByte(); buf[i] != 0; buf[++i] = ipFile
.readByte())
;
if (i != 0)
return Utils.getString(buf, 0, i, "GBK");
} catch (IOException e) {
System.out.println(e.getMessage());
}
return "";
}
/**
* 从内存映射文件的offset位置得到一个0结尾字符串
*
* @param offset
* @return
*/
private static String readString(int offset) {
try {
mbb.position(offset);
int i;
for (i = 0, buf[i] = mbb.get(); buf[i] != 0; buf[++i] = mbb.get())
;
if (i != 0)
return Utils.getString(buf, 0, i, "GBK");
} catch (IllegalArgumentException e) {
System.out.println(e.getMessage());
}
return "";
}
public static String getAddress(String ip) {
String country = getCountry(ip).equals(" CZ88.NET") ? "" : getCountry(ip);
String address = country;// + " " + area;
return address.trim();
}
}
\ No newline at end of file
......@@ -983,6 +983,62 @@ public class ToolUtil {
return textStr;// 返回文本字符串
}
/**
* 两个时间之间相差距离多少分
*
* @param one
* 时间参数 1:
* @param two
* 时间参数 2:
* @return 相差天数
*/
public static long getDistanceDays(String str1, String str2) throws Exception {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date one;
Date two;
long min = 0;
try {
one = df.parse(str1);
two = df.parse(str2);
long time1 = one.getTime();
long time2 = two.getTime();
long diff;
if (time1 < time2) {
diff = time2 - time1;
} else {
diff = time1 - time2;
}
min = diff / (1000 * 60);
} catch (ParseException e) {
e.printStackTrace();
}
return min;
}
/**
*
* @Title: compare
* @Description: 时间字符串比较大小
* @param @param time1
* @param @param time2
* @param @return
* @param @throws ParseException 参数
* @return boolean 返回类型
* @throws
*/
public static boolean compare(String time1, String time2) throws ParseException {
// 如果想比较日期则写成"yyyy-MM-dd"就可以了
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
// 将字符串形式的时间转化为Date类型的时间
Date a = sdf.parse(time1);
Date b = sdf.parse(time2);
// Date类的一个方法,如果a早于b返回true,否则返回false
if (a.before(b))
return true;
else
return false;
}
public static void main(String[] args) throws Exception {
List<Map<String, Object>> data = new ArrayList<>();
Map<String, Object> map = new HashMap<>();
......
package com.skyeye.common.util;
import java.io.UnsupportedEncodingException;
import org.springframework.beans.factory.annotation.Autowired;
public class Utils {
@Autowired
private IPSeeker ipSeeker;
/**
* 从ip的字符串形式得到字节数组形式
* @param ip 字符串形式的ip
* @return 字节数组形式的ip
*/
public static byte[] getIpByteArrayFromString(String ip) {
byte[] ret = new byte[4];
java.util.StringTokenizer st = new java.util.StringTokenizer(ip, ".");
try {
ret[0] = (byte)(Integer.parseInt(st.nextToken()) & 0xFF);
ret[1] = (byte)(Integer.parseInt(st.nextToken()) & 0xFF);
ret[2] = (byte)(Integer.parseInt(st.nextToken()) & 0xFF);
ret[3] = (byte)(Integer.parseInt(st.nextToken()) & 0xFF);
} catch (Exception e) {
System.out.println(e.getMessage());
}
return ret;
}
public static void main(String args[]){
byte[] a=getIpByteArrayFromString(args[0]);
for(int i=0;i< a.length;i++)
System.out.println(a[i]);
System.out.println(getIpStringFromBytes(a));
}
/**
* 对原始字符串进行编码转换,如果失败,返回原始的字符串
* @param s 原始字符串
* @param srcEncoding 源编码方式
* @param destEncoding 目标编码方式
* @return 转换编码后的字符串,失败返回原始字符串
*/
public static String getString(String s, String srcEncoding, String destEncoding) {
try {
return new String(s.getBytes(srcEncoding), destEncoding);
} catch (UnsupportedEncodingException e) {
return s;
}
}
/**
* 根据某种编码方式将字节数组转换成字符串
* @param b 字节数组
* @param encoding 编码方式
* @return 如果encoding不支持,返回一个缺省编码的字符串
*/
public static String getString(byte[] b, String encoding) {
try {
return new String(b, encoding);
} catch (UnsupportedEncodingException e) {
return new String(b);
}
}
/**
* 根据某种编码方式将字节数组转换成字符串
* @param b 字节数组
* @param offset 要转换的起始位置
* @param len 要转换的长度
* @param encoding 编码方式
* @return 如果encoding不支持,返回一个缺省编码的字符串
*/
public static String getString(byte[] b, int offset, int len, String encoding) {
try {
return new String(b, offset, len, encoding);
} catch (UnsupportedEncodingException e) {
return new String(b, offset, len);
}
}
/**
* @param ip ip的字节数组形式
* @return 字符串形式的ip
*/
public static String getIpStringFromBytes(byte[] ip) {
StringBuffer sb = new StringBuffer();
sb.append(ip[0] & 0xFF);
sb.append('.');
sb.append(ip[1] & 0xFF);
sb.append('.');
sb.append(ip[2] & 0xFF);
sb.append('.');
sb.append(ip[3] & 0xFF);
return sb.toString();
}
}
......@@ -448,4 +448,36 @@ public class DwSurveyDirectoryController {
dwSurveyDirectoryService.insertSurveyMationCopyById(inputObject, outputObject);
}
/**
*
* @Title: queryAnswerSurveyMationByIp
* @Description: 判断该ip的用户是否回答过此问卷
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@RequestMapping("/post/DwSurveyDirectoryController/queryAnswerSurveyMationByIp")
@ResponseBody
public void queryAnswerSurveyMationByIp(InputObject inputObject, OutputObject outputObject) throws Exception{
dwSurveyDirectoryService.queryAnswerSurveyMationByIp(inputObject, outputObject);
}
/**
*
* @Title: insertAnswerSurveyMationByIp
* @Description: 用户回答问卷
* @param @param inputObject
* @param @param outputObject
* @param @throws Exception 参数
* @return void 返回类型
* @throws
*/
@RequestMapping("/post/DwSurveyDirectoryController/insertAnswerSurveyMationByIp")
@ResponseBody
public void insertAnswerSurveyMationByIp(InputObject inputObject, OutputObject outputObject) throws Exception{
dwSurveyDirectoryService.insertAnswerSurveyMationByIp(inputObject, outputObject);
}
}
......@@ -194,4 +194,48 @@ public interface DwSurveyDirectoryDao {
public int addQuestionOrderByMationCopyList(List<Map<String, Object>> questionOrderBys) throws Exception;
public int editSurveyAnswerNumById(Map<String, Object> surveyMation) throws Exception;
public int saveAnYesnoMaps(List<Map<String, Object>> beans) throws Exception;
public int saveAnRadioMaps(List<Map<String, Object>> beans) throws Exception;
public int saveAnMultiFillMaps(List<Map<String, Object>> beans) throws Exception;
public int saveScoreMaps(List<Map<String, Object>> beans) throws Exception;
public int saveChenCheckboxMaps(List<Map<String, Object>> beans) throws Exception;
public int saveCompAnRadioMaps(List<Map<String, Object>> beans) throws Exception;
public int saveCompChehRadioMaps(List<Map<String, Object>> beans) throws Exception;
public int saveChenScoreMaps(List<Map<String, Object>> beans) throws Exception;
public int saveAnCheckboxMaps(List<Map<String, Object>> beans) throws Exception;
public int saveAnFillMaps(List<Map<String, Object>> beans) throws Exception;
public int saveAnAnswerMaps(List<Map<String, Object>> beans) throws Exception;
public int saveCompAnCheckboxMaps(List<Map<String, Object>> beans) throws Exception;
public int saveEnumMaps(List<Map<String, Object>> beans) throws Exception;
public int saveQuOrderMaps(List<Map<String, Object>> beans) throws Exception;
public int saveChenRadioMaps(List<Map<String, Object>> beans) throws Exception;
public int saveChenFbkMaps(List<Map<String, Object>> beans) throws Exception;
public int insertSurveyAnswer(Map<String, Object> surveyAnswer) throws Exception;
public Map<String, Object> querySurveyAnswerMationByIp(Map<String, Object> map) throws Exception;
public List<Map<String, Object>> querySurveyAnswerMationOverFiveMinByIp(Map<String, Object> map) throws Exception;
public int editSurveyStateToEndNumById(Map<String, Object> surveyMation) throws Exception;
public int editSurveyStateToEndNumZdById(Map<String, Object> map) throws Exception;
}
......@@ -59,4 +59,8 @@ public interface DwSurveyDirectoryService {
public void insertSurveyMationCopyById(InputObject inputObject, OutputObject outputObject) throws Exception;
public void queryAnswerSurveyMationByIp(InputObject inputObject, OutputObject outputObject) throws Exception;
public void insertAnswerSurveyMationByIp(InputObject inputObject, OutputObject outputObject) throws Exception;
}
package com.skyeye.quartz.config;
import java.util.HashMap;
import java.util.Map;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobDataMap;
......@@ -8,6 +11,8 @@ import org.quartz.SchedulerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.skyeye.common.util.ToolUtil;
import com.skyeye.eve.dao.DwSurveyDirectoryDao;
import com.skyeye.eve.dao.SysQuartzDao;
import com.skyeye.quartz.entity.SysQuartz;
......@@ -22,6 +27,9 @@ public class QuartzJobFactory implements Job{
@Autowired
private SysQuartzDao sysQuartzDao;
@Autowired
private DwSurveyDirectoryDao dwSurveyDirectoryDao;
/**
* 任务监听
*/
......@@ -49,9 +57,9 @@ public class QuartzJobFactory implements Job{
* @throws
*/
private void handleJob(SysQuartz sysQuartz) throws SchedulerException {
if("test".equals(sysQuartz.getGroups())){//根据分组进行任务调度
if("endSurveyMation".equals(sysQuartz.getGroups())){//文件调查
try {
test(sysQuartz);
endSurveyMation(sysQuartz);
} catch (Exception e) {
e.printStackTrace();
}
......@@ -59,13 +67,18 @@ public class QuartzJobFactory implements Job{
}
/**
* 测试
* 问卷调查
* @param sysQuartz
* @throws Exception
*/
private void test(SysQuartz sysQuartz) throws Exception{
System.out.println(sysQuartz.getName());
System.out.println("我是任务,执行完成拉");
private void endSurveyMation(SysQuartz sysQuartz) throws Exception{
Map<String, Object> map = new HashMap<>();
map.put("id", sysQuartz.getName());
Map<String, Object> surveyMation = dwSurveyDirectoryDao.querySurveyMationById(map);//获取问卷信息
if("1".equals(surveyMation.get("surveyState").toString())){//执行中
map.put("realEndTime", ToolUtil.getTimeAndToString());
dwSurveyDirectoryDao.editSurveyStateToEndNumZdById(map);
}
quartzService.delete(sysQuartz);
sysQuartzDao.deleteByPrimaryKey(sysQuartz.getId());
}
......
......@@ -176,7 +176,8 @@
a.option_title optionTitle,
a.order_by_id orderById,
a.qu_id quId,
a.visibility
a.visibility,
#{quType} quType
FROM
dw_qu_checkbox a
WHERE
......@@ -208,7 +209,8 @@
a.option_title optionTitle,
a.order_by_id orderById,
a.visibility,
#{paramInt02} paramInt02
#{paramInt02} paramInt02,
#{quType} quType
FROM
dw_qu_score a
WHERE
......@@ -281,6 +283,7 @@
a.survey_name surveyName,
a.survey_note surveyNote,
a.survey_qu_num surveyQuNum,
a.survey_state surveyState,
a.an_item_least_num anItemLeastNum,
a.an_item_most_num anItemMostNum,
a.effective,
......@@ -874,6 +877,8 @@
<set>
survey_state = '1',
real_start_time = #{startTime},
survey_qu_num = #{questionNum},
an_item_least_num = #{questionNum},
</set>
WHERE id = #{id}
</update>
......@@ -976,7 +981,8 @@
SELECT
qu_row_id quRowId,
qu_col_id quColId,
count(qu_col_id) count
count(qu_col_id) count,
#{quType} quType
FROM
dw_an_chen_radio
WHERE
......@@ -991,7 +997,8 @@
SELECT
qu_row_id quRowId,
qu_col_id quColId,
count(qu_col_id) count
count(qu_col_id) count,
#{quType} quType
FROM
dw_an_chen_fbk
WHERE
......@@ -1006,7 +1013,8 @@
SELECT
qu_row_id quRowId,
qu_col_id quColId,
count(qu_col_id) count
count(qu_col_id) count,
#{quType} quType
FROM
dw_an_chen_checkbox
WHERE
......@@ -1021,7 +1029,8 @@
SELECT
qu_row_id quRowId,
qu_col_id quColId,
AVG(answser_score) avgScore
AVG(answser_score) avgScore,
#{quType} quType
FROM
dw_an_chen_score
WHERE
......@@ -1332,4 +1341,204 @@
</foreach>
</insert>
<update id="editSurveyAnswerNumById" parameterType="java.util.Map">
UPDATE dw_survey_directory
<set>
answer_num = #{answerNum},
</set>
WHERE id = #{id}
</update>
<insert id="saveAnYesnoMaps" parameterType="java.util.Map">
insert into dw_an_yesno
(id, belong_answer_id, belong_id, qu_id, visibility, yesno_answer)
values
<foreach collection="list" item="item" index="index" separator="," >
(#{item.id}, #{item.surveyAnswerId}, #{item.surveyId}, #{item.quId}, '1', #{item.yesnoAnswer})
</foreach>
</insert>
<insert id="saveAnRadioMaps" parameterType="java.util.Map">
insert into dw_an_radio
(id, belong_answer_id, belong_id, other_text, qu_id, visibility, qu_item_id)
values
<foreach collection="list" item="item" index="index" separator="," >
(#{item.id}, #{item.surveyAnswerId}, #{item.surveyId}, #{item.otherText}, #{item.quId}, '1', #{item.quItemId})
</foreach>
</insert>
<insert id="saveAnMultiFillMaps" parameterType="java.util.Map">
insert into dw_an_dfillblank
(id, answer, belong_answer_id, belong_id, qu_id, visibility, qu_item_id)
values
<foreach collection="list" item="item" index="index" separator="," >
(#{item.id}, #{item.answerValue}, #{item.surveyAnswerId}, #{item.surveyId}, #{item.quId}, '1', #{item.quItemId})
</foreach>
</insert>
<insert id="saveScoreMaps" parameterType="java.util.Map">
insert into dw_an_score
(id, answser_score, belong_answer_id, belong_id, qu_id, visibility, qu_row_id)
values
<foreach collection="list" item="item" index="index" separator="," >
(#{item.id}, #{item.scoreValue}, #{item.surveyAnswerId}, #{item.surveyId}, #{item.quId}, '1', #{item.rowId})
</foreach>
</insert>
<insert id="saveChenCheckboxMaps" parameterType="java.util.Map">
insert into dw_an_chen_checkbox
(id, belong_answer_id, belong_id, qu_id, visibility, qu_row_id, qu_col_id)
values
<foreach collection="list" item="item" index="index" separator="," >
(#{item.id}, #{item.surveyAnswerId}, #{item.surveyId}, #{item.quId}, '1', #{item.rowId}, #{item.colId})
</foreach>
</insert>
<insert id="saveCompAnRadioMaps" parameterType="java.util.Map">
insert into dw_an_radio
(id, belong_answer_id, belong_id, other_text, qu_id, visibility, qu_item_id)
values
<foreach collection="list" item="item" index="index" separator="," >
(#{item.id}, #{item.surveyAnswerId}, #{item.surveyId}, #{item.otherText}, #{item.quId}, '1', #{item.quItemId})
</foreach>
</insert>
<insert id="saveCompChehRadioMaps" parameterType="java.util.Map">
insert into dw_an_comp_chen_radio
(id, belong_answer_id, belong_id, qu_col_id, qu_id, visibility, qu_option_id, qu_row_id)
values
<foreach collection="list" item="item" index="index" separator="," >
(#{item.id}, #{item.surveyAnswerId}, #{item.surveyId}, #{item.colId}, #{item.quId}, '1', #{item.optionId}, #{item.rowId})
</foreach>
</insert>
<insert id="saveChenScoreMaps" parameterType="java.util.Map">
insert into dw_an_chen_score
(id, belong_answer_id, belong_id, qu_col_id, qu_id, visibility, answser_score, qu_row_id)
values
<foreach collection="list" item="item" index="index" separator="," >
(#{item.id}, #{item.surveyAnswerId}, #{item.surveyId}, #{item.colId}, #{item.quId}, '1', #{item.answerValue}, #{item.rowId})
</foreach>
</insert>
<insert id="saveAnCheckboxMaps" parameterType="java.util.Map">
insert into dw_an_checkbox
(id, belong_answer_id, belong_id, other_text, qu_id, visibility, qu_item_id)
values
<foreach collection="list" item="item" index="index" separator="," >
(#{item.id}, #{item.surveyAnswerId}, #{item.surveyId}, #{item.otherText}, #{item.quId}, '1', #{item.quItemId})
</foreach>
</insert>
<insert id="saveAnFillMaps" parameterType="java.util.Map">
insert into dw_an_fillblank
(id, belong_answer_id, belong_id, answer, qu_id, visibility)
values
<foreach collection="list" item="item" index="index" separator="," >
(#{item.id}, #{item.surveyAnswerId}, #{item.surveyId}, #{item.answerValue}, #{item.quId}, '1')
</foreach>
</insert>
<insert id="saveAnAnswerMaps" parameterType="java.util.Map">
insert into dw_an_answer
(id, belong_answer_id, belong_id, answer, qu_id, visibility)
values
<foreach collection="list" item="item" index="index" separator="," >
(#{item.id}, #{item.surveyAnswerId}, #{item.surveyId}, #{item.answerValue}, #{item.quId}, '1')
</foreach>
</insert>
<insert id="saveCompAnCheckboxMaps" parameterType="java.util.Map">
insert into dw_an_checkbox
(id, belong_answer_id, belong_id, other_text, qu_id, visibility, qu_item_id)
values
<foreach collection="list" item="item" index="index" separator="," >
(#{item.id}, #{item.surveyAnswerId}, #{item.surveyId}, #{item.otherText}, #{item.quId}, '1', #{item.quItemId})
</foreach>
</insert>
<insert id="saveEnumMaps" parameterType="java.util.Map">
insert into dw_an_enumqu
(id, belong_answer_id, belong_id, answer, qu_id, visibility, enum_item)
values
<foreach collection="list" item="item" index="index" separator="," >
(#{item.id}, #{item.surveyAnswerId}, #{item.surveyId}, #{item.answerValue}, #{item.quId}, '1', #{item.quItemNum})
</foreach>
</insert>
<insert id="saveQuOrderMaps" parameterType="java.util.Map">
insert into dw_an_order
(id, belong_answer_id, belong_id, ordery_num, qu_id, visibility, qu_row_id)
values
<foreach collection="list" item="item" index="index" separator="," >
(#{item.id}, #{item.surveyAnswerId}, #{item.surveyId}, #{item.orderNumValue}, #{item.quId}, '1', #{item.rowId})
</foreach>
</insert>
<insert id="saveChenRadioMaps" parameterType="java.util.Map">
insert into dw_an_chen_radio
(id, belong_answer_id, belong_id, qu_col_id, qu_id, visibility, qu_row_id)
values
<foreach collection="list" item="item" index="index" separator="," >
(#{item.id}, #{item.surveyAnswerId}, #{item.surveyId}, #{item.colId}, #{item.quId}, '1', #{item.rowId})
</foreach>
</insert>
<insert id="saveChenFbkMaps" parameterType="java.util.Map">
insert into dw_an_chen_fbk
(id, answer_value, belong_answer_id, belong_id, qu_col_id, qu_id, visibility, qu_row_id)
values
<foreach collection="list" item="item" index="index" separator="," >
(#{item.id}, #{item.answerValue}, #{item.surveyAnswerId}, #{item.surveyId}, #{item.colId}, #{item.quId}, '1', #{item.rowId})
</foreach>
</insert>
<insert id="insertSurveyAnswer" parameterType="java.util.Map">
INSERT into dw_survey_answer
(id, survey_id, bg_an_date, end_an_date, complete_num, complete_item_num, data_source, handle_state, ip_addr, addr, city, is_complete, is_effective,
qu_num, total_time, create_id)
VALUES
(#{answerId}, #{id}, #{bgAnDate}, #{endAnDate}, #{completeNum}, #{completeItemNum}, '0', '1', #{ipAddr}, #{addr}, #{city}, #{isComplete}, #{isEffective},
#{quNum}, #{totalTime}, #{createId})
</insert>
<select id="querySurveyAnswerMationByIp" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
a.id
FROM
dw_survey_answer a
WHERE a.ip_addr = #{ip}
AND a.survey_id = #{id}
</select>
<select id="querySurveyAnswerMationOverFiveMinByIp" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
a.id
FROM
dw_survey_answer a
WHERE a.ip_addr = #{ip}
AND a.survey_id = #{id}
AND a.end_an_date >= DATE_SUB(NOW(), INTERVAL 5 MINUTE)
</select>
<update id="editSurveyStateToEndNumById" parameterType="java.util.Map">
UPDATE dw_survey_directory
<set>
real_end_time = #{realEndTime},
survey_state = '2',
end_type = '3',
</set>
WHERE id = #{id}
</update>
<update id="editSurveyStateToEndNumZdById" parameterType="java.util.Map">
UPDATE dw_survey_directory
<set>
real_end_time = #{realEndTime},
survey_state = '2',
end_type = '2',
</set>
WHERE id = #{id}
</update>
</mapper>
\ No newline at end of file
......@@ -187,7 +187,7 @@
<url id="dwsurveydirectory023" path="/post/DwSurveyDirectoryController/editSurveyStateToReleaseById" val="问卷发布" allUse="1">
<property id="rowId" name="id" ref="required" var="问卷id"/>
</url>
<url id="dwsurveydirectory024" path="/post/DwSurveyDirectoryController/queryDwSurveyDirectoryMationByIdToHTML" val="获取调查问卷题目信息用来生成html页面" allUse="1">
<url id="dwsurveydirectory024" path="/post/DwSurveyDirectoryController/queryDwSurveyDirectoryMationByIdToHTML" val="获取调查问卷题目信息用来生成html页面" allUse="0">
<property id="rowId" name="id" ref="required" var="问卷id"/>
</url>
<url id="dwsurveydirectory025" path="/post/DwSurveyDirectoryController/deleteSurveyMationById" val="删除问卷" allUse="1">
......@@ -200,6 +200,15 @@
<property id="rowId" name="surveyCopyId" ref="required" var="问卷id"/>
<property id="surveyName" name="surveyName" ref="required" var="问卷名称"/>
</url>
<url id="dwsurveydirectory028" path="/post/DwSurveyDirectoryController/queryAnswerSurveyMationByIp" val="判断该ip的用户是否回答过此问卷" allUse="0">
<property id="surveyId" name="id" ref="required" var="问卷id"/>
<property id="ip" name="ip" ref="required,ip" var="ip"/>
</url>
<url id="dwsurveydirectory029" path="/post/DwSurveyDirectoryController/insertAnswerSurveyMationByIp" val="用户回答问卷" allUse="0">
<property id="jsonData" name="jsonData" ref="required" var="问卷回答json串"/>
<property id="ip" name="ip" ref="required,ip" var="ip"/>
<property id="bgAnDate" name="bgAnDate" ref="required" var="答卷开始时间"/>
</url>
<!-- 问卷调查结束 -->
</controller>
\ No newline at end of file
......@@ -34,5 +34,5 @@ listToTree(); 将JSONArray数组转为树状结
javaBean2Map(); 实体类转map
randomStr(); 获取指定的随机值
removeTagFromText(); 过滤html内容
getDistanceDays(); 两个时间之间相差距离多少分
......@@ -81,6 +81,77 @@ function _openNewWindows(mation){
}});
}
function _openNewWindowsNoRel(mation){
var index = layer.load(1);
if(isNull(mation.url)){
top.winui.window.msg("页面路径不能为空", {icon: 2,time: 2000});
return;
}
if(isNull(mation.pageId)){
top.winui.window.msg("缺少页面ID", {icon: 2,time: 2000});
return;
}
if(isNull(mation.title)){
mation.title = "窗口";
}
if(!isNull(mation.params)){
var s = "";
for(var param in mation.params)
s += "&" + param + "=" + mation.params[param];
mation.url = mation.url + "?" + s.slice(1);
}
if(isNull(mation.area)){
mation.area = [window.screen.width / 3 * 2 + 'px', (layui.$(window.parent.window).height() - 200) + 'px'];
}
if(isNull(mation.offset)){
mation.offset = 'auto';
}
if(isNull(mation.maxmin)){//是否最大化
mation.maxmin = false;
}
if(isNull(mation.shade)){//遮罩层
mation.shade = 0.5;
}
if(isNull(mation.closeBtn) && mation.closeBtn != '0'){//关闭按钮
mation.closeBtn = 1;
}
var index = layer.load(1);
refreshCode = "";
layui.$.ajax({
type: 'get',
url: mation.url,
async: true,
success: function (data) {
layer.close(index);
var pageIndex = layer.open({
id: mation.pageId,
type: 2,
title: mation.title,
content: mation.url,
area: mation.area,
offset: mation.offset,
maxmin: mation.maxmin,
shade: mation.shade,
zIndex: 20000000000,
scrollbar: false,
closeBtn: mation.closeBtn,
end: function(){
if(typeof(mation.callBack) == "function") {
mation.callBack(refreshCode);
}
}
});
if(mation.maxmin){
layer.full(pageIndex);
}
},
error: function (xml) {
layer.close(index);
top.winui.window.msg("获取页面失败", {icon: 2,time: 2000});
}
});
}
/**
* 非表格分页加载插件
*/
......
......@@ -1080,4 +1080,19 @@ function date(format, timestamp){
});
}
/**
* 获取当前时间
* @returns {String}
*/
function getFormatDate(){
var nowDate = new Date();
var year = nowDate.getFullYear();
var month = nowDate.getMonth() + 1 < 10 ? "0" + (nowDate.getMonth() + 1) : nowDate.getMonth() + 1;
var date = nowDate.getDate() < 10 ? "0" + nowDate.getDate() : nowDate.getDate();
var hour = nowDate.getHours()< 10 ? "0" + nowDate.getHours() : nowDate.getHours();
var minute = nowDate.getMinutes()< 10 ? "0" + nowDate.getMinutes() : nowDate.getMinutes();
var second = nowDate.getSeconds()< 10 ? "0" + nowDate.getSeconds() : nowDate.getSeconds();
return year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second;
}
......@@ -6109,6 +6109,15 @@ select option{
box-shadow: none! important;
}
.messageSpan{
margin: 0 auto;
width: 100%;
text-align: center;
display: block;
margin-top: 200px;
font-size: 25px;
font-family: serif;
}
/*******************************************自定义样式end********************************************/
......
layui.config({
base: basePath,
version: skyeyeVersion
}).define(['jquery', 'winui'], function (exports) {
winui.renderColor();
layui.use(['form'], function (form) {
var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
var $ = layui.$,
form = layui.form;
form.render();
form.on('submit(formAddBean)', function (data) {
//表单验证
if (winui.verifyForm(data.elem)) {
if($("#surveyName").val() == parent.ruleCode){
parent.layer.close(index);
parent.refreshCode = '0';
} else{
layer.msg("密码输入错误。", {icon: 2,time: 2000});
}
}
return false;
});
//取消
$("body").on("click", "#cancle", function(){
parent.layer.close(index);
});
});
});
\ No newline at end of file
......@@ -47,14 +47,6 @@ layui.config({
}
});
hdb.registerHelper('compare8', function(v1, v2, v31, v4, options) {
if(v1 == v3 && v2 == v4){
return options.fn(this);
}else{
return options.inverse(this);
}
});
},
ajaxSendAfter:function(json){
......@@ -98,8 +90,10 @@ layui.config({
}
return false;
});
$(".columnchart_pic").click();
resetQuNum();
setTimeout(function(){
$(".columnchart_pic").click();
}, 2000);
resetQuNum();
}
});
......@@ -171,7 +165,7 @@ layui.config({
anCount = 0;
}
categories.push(quOptionName);
if(quType === "SCORE") {
if(quType === "8") {
var avgScore = $(this).find("input[name='quItemAvgScore']").val();
//平均分 setAvgScore
avgScore = parseFloat(avgScore).toFixed(2);
......@@ -187,7 +181,7 @@ layui.config({
seriesData.push(parseFloat(avgScore));
}
tagText = "分数";
} else if(quType === "ORDERQU") {
} else if(quType === "9") {
if(charType === "PIE") {
var data = {};
data["value"] = parseInt(anCount);
......
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link href="../../assets/lib/layui/css/layui.css" rel="stylesheet" />
<link href="../../assets/lib/font-awesome-4.7.0/css/font-awesome.css" rel="stylesheet" />
<link href="../../assets/lib/winui/css/winui.css" rel="stylesheet" />
</head>
<body>
<div style="padding-top:20px; padding-left: 10px; padding-right: 10px">
<form class="layui-form" action="" id="showForm" autocomplete="off">
<div class="layui-form-item">
<input type="text" id="surveyName" name="surveyName" win-verify="required" placeholder="请输入密钥" class="layui-input" maxlength="50"/>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<button class="winui-btn" lay-submit lay-filter="formAddBean">确定</button>
</div>
</div>
</form>
</div>
<script src="../../assets/lib/layui/layui.js"></script>
<script src="../../assets/lib/layui/custom.js"></script>
<script type="text/javascript">
layui.config({base: '../../js/dwsurveydesign/'}).use('dwsurveydesignrulecode');
</script>
</body>
</html>
\ No newline at end of file
......@@ -129,7 +129,7 @@
<table class="suQuTable" border="0" cellpadding="0" cellspacing="0" style="border: none! important;margin-top: 8px;">
<tr>
<td width="15px">&nbsp;</td>
<td class="bfbTd">回答数:{{anCount}}条&nbsp;&nbsp;<a href="${ctx}/design/qu-fillblank!answers.action?quId={{id}}&surveyId={{belongId}}" class="fb_answer">查看</a></td>
<td class="bfbTd">回答数:{{anCount}}条&nbsp;&nbsp;</td>
<td colspan="4">&nbsp;</td>
</tr>
</table>
......@@ -167,7 +167,7 @@
<tr class="quTrOptions">
<td width="15px">&nbsp;</td>
<td width="520px">{{optionName}}</td>
<td class="bfbTd">回答数:{{anCount}}条&nbsp;&nbsp;<a href="#">查看</a></td></td>
<td class="bfbTd">回答数:{{anCount}}条</td></td>
<td colspan="4"></td>
</tr>
{{/each}}
......@@ -193,37 +193,12 @@
<tr class="columnItemTr">
<td width="15px">&nbsp;</td>
<td width="520" class="quChenRowTd" style="padding-left: 15px;"><label class="editAble quCoOptionEdit">{{optionName}}</label></td>
<td width="180px"><div id="bfbTd{{quType}}_{{rowId}}_{{id}}" class="progressbarDiv progress{{showXhIndex @index}}"></div></td>
<td width="50px" align="right" id="bfbNum{{quType}}_{{rowId}}_{{id}}" class="bfbTd">0%</td>
<td align="left" id="bfbAnCount{{quType}}_{{rowId}}_{{id}}" class="tdAnCount">&nbsp;0次</td>
<td width="180px"><div id="bfbTd{{quType}}_{{../id}}_{{id}}" class="progressbarDiv progress{{showXhIndex @index}}"></div></td>
<td width="50px" align="right" id="bfbNum{{quType}}_{{../id}}_{{id}}" class="bfbTd">0%</td>
<td align="left" id="bfbAnCount{{quType}}_{{../id}}_{{id}}" class="tdAnCount">&nbsp;0次</td>
<td>
<div class="columnItemOptionName" style="display: none;">{{optionName}}</div>
<input type="hidden" name="columnItemAnCount" value="0" id="coumneItemAnCount{{quType}}_{{rowId}}_{{id}}">
{{#each anChenRadios}}
{{#if quRowId}}
{{#compare8 [{{../rowId}}] [{{../id}}] quRowId quColId}}
<script type="text/javascript">
layui.define(["jquery", 'jqueryUI'], function(exports) {
var jQuery = layui.jquery;
(function($) {
var count = parseInt("[{{../../anCount}}]");
var anCount = parseInt("{{anCount}}");
var bfbFloat = anCount / count * 100;
var bfbVal = bfbFloat.toFixed(2);
if(bfbVal === "NaN"){
bfbVal = "0.00";
}
$("#bfbNum{{quType}}_{{rowId}}_{{id}}").html(bfbVal + "%");
$("#bfbAnCount{{quType}}_{{rowId}}_{{id}}").html("&nbsp;&nbsp;" + anCount + "");
$("#bfbTd{{quType}}_{{rowId}}_{{id}}").progressbar({value: bfbFloat});
$("#coumneItemAnCount{{quType}}_{{rowId}}_{{id}}").val(anCount);
})(jQuery);
});
</script>
{{else}}
{{/compare8}}
{{/if}}
{{/each}}
</td>
</tr>
{{/each}}
......@@ -231,6 +206,26 @@
</td>
</tr>
{{/each}}
{{#each anChenRadios}}
<script type="text/javascript">
layui.define(["jquery", 'jqueryUI'], function(exports) {
var jQuery = layui.jquery;
(function($) {
var count = parseInt("{{anAllCount}}");
var anCount = parseInt("{{anCount}}");
var bfbFloat = anCount / count * 100;
var bfbVal = bfbFloat.toFixed(2);
if(bfbVal === "NaN"){
bfbVal = "0.00";
}
$("#bfbNum{{quType}}_{{quRowId}}_quColId").html(bfbVal + "%");
$("#bfbAnCount{{quType}}_{{quRowId}}_quColId").html("&nbsp;&nbsp;" + anCount + "");
$("#bfbTd{{quType}}_{{quRowId}}_quColId").progressbar({value: bfbFloat});
$("#coumneItemAnCount{{quType}}_{{quRowId}}_quColId").val(anCount);
})(jQuery);
});
</script>
{{/each}}
</table>
<div class="reportPic">
<div class="chartBtnEvent">
......@@ -262,32 +257,12 @@
<tr class="columnItemTr">
<td width="15px">&nbsp;</td>
<td width="520" class="quChenRowTd" style="padding-left: 15px;"><label class="editAble quCoOptionEdit">{{optionName}}</label></td>
<td width="180px"><div id="bfbTd{{quType}}_{{rowId}}_{{id}}" class="progressbarDiv progress{{showXhIndex @index}}"></div></td>
<td width="50px" align="right" id="bfbNum{{quType}}_{{rowId}}_{{id}}" class="bfbTd">0%</td>
<td align="left" id="bfbAnCount{{quType}}_{{rowId}}_{{id}}" class="tdAnCount">&nbsp;0次</td>
<td width="180px"><div id="bfbTd{{quType}}_{{../id}}_{{id}}" class="progressbarDiv progress{{showXhIndex @index}}"></div></td>
<td width="50px" align="right" id="bfbNum{{quType}}_{{../id}}_{{id}}" class="bfbTd">0%</td>
<td align="left" id="bfbAnCount{{quType}}_{{../id}}_{{id}}" class="tdAnCount">&nbsp;0次</td>
<td>
<div class="columnItemOptionName" style="display: none;">{{optionName}}</div>
<input type="hidden" name="columnItemAnCount" value="0" id="coumneItemAnCount{{quType}}_{{rowId}}_{{id}}">
{{#each anChenCheckboxs}}
{{#if quRowId}}
{{#compare8 [{{../rowId}}] [{{../id}}] quRowId quColId}}
<script type="text/javascript">
var count = parseInt("[{{../../anCount}}]");
var anCount = parseInt("{{anCount}}");
var bfbFloat = anCount/count*100;
var bfbVal = bfbFloat.toFixed(2);
if(bfbVal === "NaN"){
bfbVal = "0.00";
}
$("#bfbNum{{quType}}_{{rowId}}_{{id}}").html(bfbVal + "%");
$("#bfbAnCount{{quType}}_{{rowId}}_{{id}}").html("&nbsp;&nbsp;" + anCount + "");
$("#bfbTd{{quType}}_{{rowId}}_{{id}}").progressbar({value: bfbFloat});
$("#coumneItemAnCount{{quType}}_{{rowId}}_{{id}}").val(anCount);
</script>
{{else}}
{{/compare8}}
{{/if}}
{{/each}}
<input type="hidden" name="columnItemAnCount" value="0" id="coumneItemAnCount{{quType}}_{{../id}}_{{id}}">
</td>
</tr>
{{/each}}
......@@ -295,6 +270,26 @@
</td>
</tr>
{{/each}}
{{#each anChenCheckboxs}}
<script type="text/javascript">
layui.define(["jquery", 'jqueryUI'], function(exports) {
var jQuery = layui.jquery;
(function($) {
var count = parseInt("{{anAllCount}}");
var anCount = parseInt("{{anCount}}");
var bfbFloat = anCount / count * 100;
var bfbVal = bfbFloat.toFixed(2);
if(bfbVal === "NaN"){
bfbVal = "0.00";
}
$("#bfbNum{{quType}}_{{quRowId}}_{{quColId}}").html(bfbVal + "%");
$("#bfbAnCount{{quType}}_{{quRowId}}_{{quColId}}").html("&nbsp;&nbsp;" + anCount + "");
$("#bfbTd{{quType}}_{{quRowId}}_{{quColId}}").progressbar({value: bfbFloat});
$("#coumneItemAnCount{{quType}}_{{quRowId}}_{{quColId}}").val(anCount);
})(jQuery);
});
</script>
{{/each}}
</table>
<div class="reportPic">
<div class="chartBtnEvent">
......@@ -320,30 +315,23 @@
<tr class="columnItemTr">
<td width="15px">&nbsp;</td>
<td width="520" class="quChenRowTd" style="padding-left: 15px;"><label class="editAble quCoOptionEdit">{{optionName}}</label></td>
<td width="120px" align="left" id="bfbNum{{quType}}_{{rowId}}_{{id}}" class="bfbTd">0%</td>
<td align="left" id="bfbAnCount{{quType}}_{{rowId}}_{{id}}" class="tdAnCount">&nbsp;0次</td>
<td width="120px" align="left" id="bfbNum{{quType}}_{{../id}}_{{id}}" class="bfbTd">0%</td>
<td align="left" id="bfbAnCount{{quType}}_{{../id}}_{{id}}" class="tdAnCount">&nbsp;0次</td>
<td width="40px">&nbsp;</td>
<td>
{{#each anChenFbks}}
{{#if quRowId}}
{{#compare8 [{{../rowId}}] [{{../id}}] quRowId quColId}}
<script type="text/javascript">
layui.define(["jquery"], function(exports) {
var jQuery = layui.jquery;
(function($) {
$("#bfbNum{{quType}}_{{rowId}}_{{id}}").html("回答数:{{anCount}}条");
$("#bfbAnCount{{quType}}_{{rowId}}_{{id}}").html("&nbsp;&nbsp;<a href=\"#\">查看</a>");
})(jQuery);
});
</script>
{{else}}
{{/compare8}}
{{/if}}
{{/each}}
</td>
<td></td>
</tr>
{{/each}}
{{/each}}
{{#each anChenFbks}}
<script type="text/javascript">
layui.define(["jquery"], function(exports) {
var jQuery = layui.jquery;
(function($) {
$("#bfbNum{{quType}}_{{quRowId}}_{{quColId}}").html("回答数:{{anCount}}条");
})(jQuery);
});
</script>
{{/each}}
</table>
<div class="reportPic"></div>
<div style="clear:both;"></div>
......@@ -367,38 +355,13 @@
<tr class="columnItemTr">
<td width="15px">&nbsp;</td>
<td width="520" class="quChenRowTd" style="padding-left: 15px;"><label class="editAble quCoOptionEdit">{{optionName}}</label></td>
<td width="180px"><div id="bfbTd{{quType}}{{rowId}}_{{id}}" class="progressbarDiv progress{{../_index}}"></div></td>
<td width="60px" align="right" id="bfbNum{{quType}}{{rowId}}_{{id}}" class="bfbTd">0%</td>
<td width="180px"><div id="bfbTd{{quType}}{{../id}}_{{id}}" class="progressbarDiv progress{{../_index}}"></div></td>
<td width="60px" align="right" id="bfbNum{{quType}}{{../id}}_{{id}}" class="bfbTd">0%</td>
<td align="left" class="tdAnCount">&nbsp;&nbsp;平均</td>
<td width="40px">&nbsp;</td>
<td>
<div class="columnItemOptionName" style="display: none;">{{optionName}}</div>
<input type="hidden" name="columnItemAnCount" value="0" id="coumneItemAnCount{{quType}}{{rowId}}_{{id}}">
{{#each anChenScores}}
{{#if quRowId}}
{{#compare8 [{{../rowId}}] [{{../id}}] quRowId quColId}}
<script type="text/javascript">
layui.define(["jquery", 'jqueryUI'], function(exports) {
var jQuery = layui.jquery;
(function($) {
var avgScore = parseFloat("{{avgScore}}");
var bfbFloat = avgScore / 5 * 100;
var bfbVal = bfbFloat.toFixed(2);
//平均分 setAvgScore
avgScore=avgScore.toFixed(2);
if(avgScore === "NaN"){
avgScore = "0.00";
}
$("#bfbNum{{quType}}{{rowId}}_{{id}}").html(avgScore + "");
$("#bfbTd{{quType}}{{rowId}}_{{id}}").progressbar({value: bfbFloat});
$("#coumneItemAnCount{{quType}}{{rowId}}_{{id}}").val(avgScore);
})(jQuery);
});
</script>
{{else}}
{{/compare8}}
{{/if}}
{{/each}}
<input type="hidden" name="columnItemAnCount" value="0" id="coumneItemAnCount{{quType}}{{../id}}_{{id}}">
</td>
</tr>
{{/each}}
......@@ -406,6 +369,26 @@
</td>
</tr>
{{/each}}
{{#each anChenScores}}
<script type="text/javascript">
layui.define(["jquery", 'jqueryUI'], function(exports) {
var jQuery = layui.jquery;
(function($) {
var avgScore = parseFloat("{{avgScore}}");
var bfbFloat = avgScore / 5 * 100;
var bfbVal = bfbFloat.toFixed(2);
//平均分 setAvgScore
avgScore = avgScore.toFixed(2);
if(avgScore === "NaN"){
avgScore = "0.00";
}
$("#bfbNum{{quType}}{{quRowId}}_{{quColId}}").html(avgScore + "");
$("#bfbTd{{quType}}{{quRowId}}_{{quColId}}").progressbar({value: bfbFloat});
$("#coumneItemAnCount{{quType}}{{quRowId}}_{{quColId}}").val(avgScore);
})(jQuery);
});
</script>
{{/each}}
</table>
<div class="reportPic">
<div class="chartBtnEvent">
......@@ -442,7 +425,7 @@
var count = parseInt("{{anCount}}");
var anCount = parseInt("{{anAllCount}}");
var avgScore = parseFloat("{{avgScore}}");
var bfbFloat = avgScore / "[{{../paramInt02}}]" * 100;
var bfbFloat = avgScore / {{../paramInt02}} * 100;
var bfbVal = bfbFloat.toFixed(2);
//平均分 setAvgScore
avgScore = avgScore.toFixed(2);
......
......@@ -424,8 +424,8 @@
<td>
<div class="dwQuOptionItemContent">
<label class="dwRedioStyle dwQuInputLabel" ></label>
<input type="hidden" class="dwChenInputTemp" disabled="disabled" value="{{rowId}}:{{id}}">
<input name="item_qu_{{quType}}_{{quId}}_{{rowId}}" value="{{id}}" type="radio">
<input type="hidden" class="dwChenInputTemp" disabled="disabled" value="{{../id}}:{{id}}">
<input name="item_qu_{{quType}}_{{quId}}_{{../id}}" value="{{id}}" type="radio">
</div>
</td>
{{/each}}
......@@ -479,15 +479,15 @@
{{#each questionChenRow}}
<tr class="dwQuCoChenRowTr">
<td class="quChenRowTd"><label class="quCoOptionEdit">{{optionName}}</label>
<input type="hidden" name="item_qu_{{quType}}_{{quId}}_{{rowId}}" value="ck_item_qu_{{quType}}_{{quId}}_{{rowId}}_" />
<input type="hidden" name="item_qu_{{quType}}_{{quId}}_{{id}}" value="ck_item_qu_{{quType}}_{{quId}}_{{id}}_" />
<input type="hidden" class="answerTag" value="0" >
</td>
{{#each questionChenColumn}}
<td>
<div class="dwQuOptionItemContent">
<label class="dwCheckboxStyle dwQuInputLabel" ></label>
<input type="hidden" class="dwChenInputTemp" disabled="disabled" value="{{rowId}}:{{id}}">
<input name="ck_item_qu_{{quType}}_{{quId}}_{{rowId}}_{{id}}" value="{{id}}" type="checkbox">
<input type="hidden" class="dwChenInputTemp" disabled="disabled" value="{{../id}}:{{id}}">
<input name="ck_item_qu_{{quType}}_{{quId}}_{{../id}}_{{id}}" value="{{id}}" type="checkbox">
</div>
</td>
{{/each}}
......@@ -545,8 +545,8 @@
{{#each questionChenColumn}}
<td>
<div class="dwQuChenFbkOptionItemContent">
<input type="hidden" class="dwChenInputTemp" disabled="disabled" value="{{rowId}}:{{id}}">
<input name="fbk_item_qu_{{quType}}_{{quId}}_{{rowId}}_{{id}}" class="inputSytle_1 dwChenMFillblankInput" type="text">
<input type="hidden" class="dwChenInputTemp" disabled="disabled" value="{{../id}}:{{id}}">
<input name="fbk_item_qu_{{quType}}_{{quId}}_{{../id}}_{{id}}" class="inputSytle_1 dwChenMFillblankInput" type="text">
<input type="hidden" class="answerTag" value="0" >
</div>
</td>
......@@ -605,8 +605,8 @@
{{#each questionChenColumn}}
<td>
<div class="dwQuScoreOptionItemContent">
<input type="hidden" class="dwChenInputTemp" disabled="disabled" value="{{rowId}}:{{id}}">
<select name="cs_item_qu_{{quType}}_{{quId}}_{{rowId}}_{{id}}" class="quChenScoreSelect" >
<input type="hidden" class="dwChenInputTemp" disabled="disabled" value="{{../id}}:{{id}}">
<select name="cs_item_qu_{{quType}}_{{quId}}_{{../id}}_{{id}}" class="quChenScoreSelect" >
<option value="0">-评分-</option>
{{#scoreNum001 5}}{{/scoreNum001}}
</select>
......@@ -709,8 +709,9 @@
<li class="li_surveyQuItemBody surveyQu_{{#compare6 quType}}{{/compare6}}" style="{{#compare4 pageNo}}{{/compare4}}">
<div class="surveyQuItemBody">
<div class="surveyQuItem">
<input type="hidden" class="quType" value="submitSurveyBtn">
<div class="surveyQuItemContent" style="padding-top: 12px;height: 30px;min-height: 30px;">
<a href="#" id="submitSurvey" class="sbtn24 sbtn24_0 submitSurvey" >&nbsp;</a>&nbsp;&nbsp;&nbsp;&nbsp;
<a href="javascript:;" id="submitSurvey" class="sbtn24 sbtn24_0 submitSurvey" >&nbsp;</a>&nbsp;&nbsp;&nbsp;&nbsp;
{{#if pageNo}}
{{#compare3 pageNo 1}}
<a href="#" class="sbtn24 sbtn24_1 prevPage_a">上一页</a>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册