Commit e2d755af authored by xinglei's avatar xinglei

修改bug

parent 51694ad2
...@@ -1175,7 +1175,7 @@ public class CheckServiceImpl implements ICheckService { ...@@ -1175,7 +1175,7 @@ public class CheckServiceImpl implements ICheckService {
if (!stateMap.containsKey(finalSp[i])) { if (!stateMap.containsKey(finalSp[i])) {
properties.put(finalSp[i], ""); properties.put(finalSp[i], "");
} else { } else {
properties.put(finalSp[i], CheckStatusEnum.getEnum(stateMap.get(finalSp[i]).toString()).getName()); properties.put(finalSp[i], stateMap.get(finalSp[i]));
} }
} }
try { try {
...@@ -1236,10 +1236,11 @@ public class CheckServiceImpl implements ICheckService { ...@@ -1236,10 +1236,11 @@ public class CheckServiceImpl implements ICheckService {
sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, mergeNum)); sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, mergeNum));
//第一行 //第一行
String title = String.format("%s %s 每日巡检情况表", companyName, linkMap.get("departmentName").toString()); String title1 = String.format("%s %s 每日巡检情况表", companyName, linkMap.get("departmentName").toString());
PoiUtil.setTitleValue(sheet.createRow(rowNum++), title, headerStyle); String title2 = String.format("巡检人:____________ 日期:%s 至 %s", param.getBeginDate(), param.getEndDate());
PoiUtil.setTitleValue(sheet.createRow(rowNum++), title1, headerStyle);
//第二行 //第二行
PoiUtil.setTitleValue(sheet.createRow(rowNum++), "巡检人:____________ 日期: ___年___月___日至___日", headerStyle); PoiUtil.setTitleValue(sheet.createRow(rowNum++), title2, headerStyle);
HSSFRow row = sheet.createRow(rowNum++); HSSFRow row = sheet.createRow(rowNum++);
HSSFCell cell = null; HSSFCell cell = null;
...@@ -1260,6 +1261,11 @@ public class CheckServiceImpl implements ICheckService { ...@@ -1260,6 +1261,11 @@ public class CheckServiceImpl implements ICheckService {
//PoiUtil.exportLocal(wb, "D:/upload", "机构客户信息表.xls"); //PoiUtil.exportLocal(wb, "D:/upload", "机构客户信息表.xls");
} }
/**
* 返回时间-状态Map
* @param idState
* @return
*/
private Map<String, Object> getStateMap(String idState) { private Map<String, Object> getStateMap(String idState) {
Map<String, Object> idStateMap = Maps.newHashMap(); Map<String, Object> idStateMap = Maps.newHashMap();
if (ObjectUtils.isEmpty(idState)) { if (ObjectUtils.isEmpty(idState)) {
...@@ -1268,7 +1274,11 @@ public class CheckServiceImpl implements ICheckService { ...@@ -1268,7 +1274,11 @@ public class CheckServiceImpl implements ICheckService {
String[] split = idState.split(","); String[] split = idState.split(",");
for (int i = 0; i < split.length; i++) { for (int i = 0; i < split.length; i++) {
String[] sp = split[i].split("_"); String[] sp = split[i].split("_");
idStateMap.put(sp[0], sp[1]); if (ObjectUtils.isEmpty(sp[1])) {//文本类的输入值
idStateMap.put(sp[0], CheckStatusEnum.getEnum(sp[2]).getName());
} else {
idStateMap.put(sp[0], sp[1]);
}
} }
return idStateMap; return idStateMap;
} }
...@@ -1403,7 +1413,7 @@ public class CheckServiceImpl implements ICheckService { ...@@ -1403,7 +1413,7 @@ public class CheckServiceImpl implements ICheckService {
cell3.setCellValue(checkInputBo.getInputItemName()); cell3.setCellValue(checkInputBo.getInputItemName());
cell3.setCellStyle(alignLeftStyle); cell3.setCellStyle(alignLeftStyle);
HSSFCell cell4 = row.createCell(4); HSSFCell cell4 = row.createCell(4);
if ("选择".equals(checkInputBo.getItemType())){ if ("选择".equals(checkInputBo.getItemType()) && ObjectUtils.isEmpty(checkInputBo.getInputValue())) {
cell4.setCellValue(checkInputBo.getIsOK()); cell4.setCellValue(checkInputBo.getIsOK());
} else { } else {
cell4.setCellValue(checkInputBo.getInputValue()); cell4.setCellValue(checkInputBo.getInputValue());
......
...@@ -707,4 +707,16 @@ public class DateUtil { ...@@ -707,4 +707,16 @@ public class DateUtil {
public static String splitDate(String Date){ public static String splitDate(String Date){
return Date.substring(11, Date.length()); return Date.substring(11, Date.length());
} }
/**
* 当前日期毫秒.xls
*
* @return
*/
public static String formatName() {
Calendar calen = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
String name = sdf.format(calen.getTime());
return name;
}
} }
...@@ -10,6 +10,7 @@ import java.io.File; ...@@ -10,6 +10,7 @@ import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.net.URLEncoder;
/** /**
* @Author: xinglei * @Author: xinglei
...@@ -81,6 +82,31 @@ public class PoiUtil { ...@@ -81,6 +82,31 @@ public class PoiUtil {
} }
/** /**
* 导出(前端导出,带文件名)
*/
public static void exportFile( HSSFWorkbook wb, String fileName, HttpServletResponse response) {
OutputStream out = null;
try {
out = response.getOutputStream();
String name = URLEncoder.encode(fileName, "UTF-8");
response.setCharacterEncoding("UTF-8");
response.setContentType("application/force-download");
response.setHeader("Content-Disposition", "attachment;filename=" + name + ".xls");
wb.write(out);
out.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (out != null) {
try {
out.close();
} catch (Exception e2) {
}
}
}
}
/**
* 导出(本地导出,测试用) * 导出(本地导出,测试用)
*/ */
public static void exportLocal(HSSFWorkbook wb, String path, String name) { public static void exportLocal(HSSFWorkbook wb, String path, String name) {
......
package com.yeejoin.amos.patrol.service.core.util; package com.yeejoin.amos.patrol.service.core.util;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
...@@ -10,155 +15,171 @@ import static com.yeejoin.amos.patrol.service.constants.XJConstant.JOINT; ...@@ -10,155 +15,171 @@ import static com.yeejoin.amos.patrol.service.constants.XJConstant.JOINT;
/** /**
* 字符串工具类 * 字符串工具类
*
* @author as-youjun
* *
* @author as-youjun
*/ */
public class StringUtil { public class StringUtil {
private static Pattern NOT_ZERO_AT_THE_END = Pattern.compile("[1-9](\\d*[1-9])?"); private static Pattern NOT_ZERO_AT_THE_END = Pattern.compile("[1-9](\\d*[1-9])?");
private static Pattern numericPattern = Pattern.compile("-?[0-9]+\\.?[0-9]*"); private static Pattern numericPattern = Pattern.compile("-?[0-9]+\\.?[0-9]*");
/** /**
* 判断对象是否为空 * 判断对象是否为空
* *
* @param str * @param str
* @return * @return
*/ */
public static boolean isNotEmpty(Object str) { public static boolean isNotEmpty(Object str) {
boolean flag = true; boolean flag = true;
if (str != null && !str.equals("")) { if (str != null && !str.equals("")) {
if (str.toString().length() > 0) { if (str.toString().length() > 0) {
flag = true; flag = true;
} }
} else { } else {
flag = false; flag = false;
} }
return flag; return flag;
} }
/*************************************************************************** /***************************************************************************
* repeat - 通过源字符串重复生成N次组成新的字符串。 * repeat - 通过源字符串重复生成N次组成新的字符串。
* *
* @param src * @param src
* - 源字符串 例如: 空格(" "), 星号("*"), "浙江" 等等... * - 源字符串 例如: 空格(" "), 星号("*"), "浙江" 等等...
* @param num * @param num
* - 重复生成次数 * - 重复生成次数
* @return 返回已生成的重复字符串 * @return 返回已生成的重复字符串
* @version 1.0 (2006.10.10) Wilson Lin * @version 1.0 (2006.10.10) Wilson Lin
**************************************************************************/ **************************************************************************/
public static String repeat(String src, int num) { public static String repeat(String src, int num) {
StringBuffer s = new StringBuffer(); StringBuffer s = new StringBuffer();
for (int i = 0; i < num; i++) for (int i = 0; i < num; i++)
s.append(src); s.append(src);
return s.toString(); return s.toString();
} }
/** /**
* 判断是否数字表示 * 判断是否数字表示
* 源字符串 * 源字符串
* @return 是否数字的标志 *
*/ * @return 是否数字的标志
public static boolean isNumeric(String str) { */
// 该正则表达式可以匹配所有的数字 包括负数 public static boolean isNumeric(String str) {
String bigStr; // 该正则表达式可以匹配所有的数字 包括负数
try { String bigStr;
bigStr = new BigDecimal(str).toString(); try {
} catch (Exception e) { bigStr = new BigDecimal(str).toString();
return false;// 异常 说明包含非数字。 } catch (Exception e) {
} return false;// 异常 说明包含非数字。
}
Matcher isNum = numericPattern.matcher(bigStr); // matcher是全匹配
if (!isNum.matches()) { Matcher isNum = numericPattern.matcher(bigStr); // matcher是全匹配
return false; if (!isNum.matches()) {
} return false;
return true; }
} return true;
}
public static int toInt(String s) {
if (s != null && !"".equals(s.trim())) { public static int toInt(String s) {
try { if (s != null && !"".equals(s.trim())) {
return Integer.parseInt(s); try {
} catch (Exception e) { return Integer.parseInt(s);
return 0; } catch (Exception e) {
} return 0;
} }
return 0; }
} return 0;
}
/**
* 截取前后都不是0的数字字符串 /**
* * 截取前后都不是0的数字字符串
* 12010102 => 12010102 12010100 => 120101 ab1201100b => 12011 * <p>
* * 12010102 => 12010102 12010100 => 120101 ab1201100b => 12011
* @param str *
* @return * @param str
*/ * @return
public static String delEndZero(String str) { */
Matcher mat = NOT_ZERO_AT_THE_END.matcher(str); public static String delEndZero(String str) {
boolean rs = mat.find(); Matcher mat = NOT_ZERO_AT_THE_END.matcher(str);
if (rs) { boolean rs = mat.find();
return mat.group(0); if (rs) {
} return mat.group(0);
}
return null;
} return null;
}
/**
* /**
* <pre> * <pre>
* 移除字符串后面的0 * 移除字符串后面的0
* </pre> * </pre>
* *
* @param s * @param s
* @return * @return
*/ */
public static String removeSufixZero(String s) { public static String removeSufixZero(String s) {
if (s == null) { if (s == null) {
return ""; return "";
} }
while (s.endsWith("0")) { while (s.endsWith("0")) {
if (s.equals("0")) { if (s.equals("0")) {
s = ""; s = "";
break; break;
} }
s = s.substring(0, s.length() - 1); s = s.substring(0, s.length() - 1);
} }
return s; return s;
} }
public static String transforCode(String code) { public static String transforCode(String code) {
if (code.endsWith("0000000")) { if (code.endsWith("0000000")) {
code = code.substring(0, 1); code = code.substring(0, 1);
} else if (code.endsWith("000000")) { } else if (code.endsWith("000000")) {
code = code.substring(0, 2); code = code.substring(0, 2);
} else if (code.endsWith("0000")) { } else if (code.endsWith("0000")) {
code = code.substring(0, 4); code = code.substring(0, 4);
} else if (code.endsWith("00")) { } else if (code.endsWith("00")) {
code = code.substring(0, 6); code = code.substring(0, 6);
} }
return code; return code;
} }
/** /**
* 获取支队orgCode * 获取支队orgCode
* *
* @param orgCode * @param orgCode
* @return * @return
*/ */
public static String getDetachmentOrgCode(String orgCode) { public static String getDetachmentOrgCode(String orgCode) {
Assert.notNull(orgCode, "组织结构orgCode不能为空!"); Assert.notNull(orgCode, "组织结构orgCode不能为空!");
String[] codes = orgCode.split("\\*"); String[] codes = orgCode.split("\\*");
if (codes.length < 2) { if (codes.length < 2) {
throw new IllegalArgumentException("组织结构orgCode为总队,不能获取支队orgCode!"); throw new IllegalArgumentException("组织结构orgCode为总队,不能获取支队orgCode!");
} else { } else {
return codes[0] + "*" + codes[1]; return codes[0] + "*" + codes[1];
} }
} }
public static String setStr(String str1, String str2) { public static String setStr(String str1, String str2) {
String str = str1 + JOINT + str2; String str = str1 + JOINT + str2;
return str; return str;
} }
/**
* List去重
*
* @param list
* @return
*/
public static List getNewList(List<String> list) {
Set set = new HashSet();
List newList = new ArrayList();
for (String cd : list) {
if (!ObjectUtils.isEmpty(cd) && set.add(cd)) {
newList.add(cd);
}
}
return newList;
}
} }
...@@ -173,6 +173,7 @@ ...@@ -173,6 +173,7 @@
ci.id checkInputId, ci.id checkInputId,
ci.input_id inputId, ci.input_id inputId,
ci.input_value AS InputValue, ci.input_value AS InputValue,
pc.order_no orderNo,
( (
CASE ci.is_ok CASE ci.is_ok
WHEN 1 THEN WHEN 1 THEN
...@@ -185,8 +186,8 @@ ...@@ -185,8 +186,8 @@
) AS IsOK, ) AS IsOK,
ii.`name` AS inputItemName, ii.`name` AS inputItemName,
ii.item_type as itemType, ii.item_type as itemType,
c.id checkId,
c.upload_time AS UploadTime, c.upload_time AS UploadTime,
u.`name` AS RealName,
ci.score AS Score, ci.score AS Score,
ci.point_classify_id classifyId, ci.point_classify_id classifyId,
ci.point_classify_name classifyName, ci.point_classify_name classifyName,
...@@ -205,21 +206,23 @@ ...@@ -205,21 +206,23 @@
p_check_input ci p_check_input ci
LEFT JOIN p_input_item ii ON ci.input_id = ii.id LEFT JOIN p_input_item ii ON ci.input_id = ii.id
LEFT JOIN p_check c ON ci.check_id = c.id LEFT JOIN p_check c ON ci.check_id = c.id
LEFT JOIN s_user u ON c.user_id = u.id
LEFT JOIN p_point p ON c.point_id = p.id LEFT JOIN p_point p ON c.point_id = p.id
LEFT JOIN p_plan_task_detail ptd ON c.plan_task_detail_id = ptd.id LEFT JOIN p_plan_task_detail ptd ON c.plan_task_detail_id = ptd.id
LEFT JOIN p_plan_task pt ON pt.id = ptd.task_no LEFT JOIN p_plan_task pt ON pt.id = ptd.task_no
LEFT JOIN p_point_classify pc on pc.id = ci.point_classify_id
<trim prefix="WHERE" prefixOverrides="AND "> <trim prefix="WHERE" prefixOverrides="AND ">
<if test="beginDate!=null and endDate!=null">and c.check_time BETWEEN #{beginDate} and #{endDate}</if> <if test="beginDate!=null and endDate!=null">and c.check_time BETWEEN #{beginDate} and #{endDate}</if>
<if test="orgCode!=null">and c.org_Code like concat(#{orgCode},"%")</if> <if test="orgCode!=null">and c.org_Code like concat(#{orgCode},"%")</if>
<if test="departmentId!=null">and c.dep_id = #{departmentId}</if> <if test="departmentId!=null">and c.dep_id = #{departmentId}</if>
</trim> </trim>
GROUP BY inputId, classifyId, beginTime GROUP BY inputId, classifyId, beginTime, checkInputId
ORDER BY ORDER BY
beginTime is null, beginTime is null,
beginTime ASC, beginTime ASC,
pointId ASC, pointId ASC,
classifyId ASC planTaskId ASC,
checkDate ASC,
orderNo ASC
</when> </when>
<otherwise> <otherwise>
select select
...@@ -234,10 +237,11 @@ ...@@ -234,10 +237,11 @@
c.upload_time AS UploadTime, c.upload_time AS UploadTime,
pt.id planTaskId, pt.id planTaskId,
pt.begin_time beginTime, pt.begin_time beginTime,
GROUP_CONCAT(DISTINCT pt.begin_time, '_', ci.is_ok) as idStateStr, GROUP_CONCAT(DISTINCT pt.begin_time, '_', IFNULL(ci.input_value,''), '_', ci.is_ok) as idStateStr,
ci.id checkInputId, ci.id checkInputId,
ci.input_id inputId, ci.input_id inputId,
ci.input_value AS InputValue, ci.input_value AS InputValue,
pc.order_no orderNo,
( (
CASE ci.is_ok CASE ci.is_ok
WHEN 1 THEN WHEN 1 THEN
...@@ -259,6 +263,7 @@ ...@@ -259,6 +263,7 @@
LEFT JOIN p_check_input ci ON c.id = ci.check_id LEFT JOIN p_check_input ci ON c.id = ci.check_id
LEFT JOIN p_input_item ii ON ci.input_id = ii.id LEFT JOIN p_input_item ii ON ci.input_id = ii.id
LEFT JOIN p_plan_task pt ON pt.id = ptd.task_no LEFT JOIN p_plan_task pt ON pt.id = ptd.task_no
LEFT JOIN p_point_classify pc on pc.id = ci.point_classify_id
<trim prefix="WHERE" prefixOverrides="AND "> <trim prefix="WHERE" prefixOverrides="AND ">
<if test="beginDate!=null and endDate!=null">and c.check_time BETWEEN #{beginDate} and #{endDate}</if> <if test="beginDate!=null and endDate!=null">and c.check_time BETWEEN #{beginDate} and #{endDate}</if>
<if test="orgCode!=null">and c.org_Code like concat(#{orgCode},"%")</if> <if test="orgCode!=null">and c.org_Code like concat(#{orgCode},"%")</if>
...@@ -266,7 +271,7 @@ ...@@ -266,7 +271,7 @@
and (pt.id is NOT NULL or pt.id = '') and (pt.id is NOT NULL or pt.id = '')
</trim> </trim>
group by pointId, inputId, classifyId group by pointId, inputId, classifyId
order BY pointId, classifyId order BY pointId, orderNo ASC, classifyId
</otherwise> </otherwise>
</choose> </choose>
</select> </select>
...@@ -981,7 +986,7 @@ ...@@ -981,7 +986,7 @@
'漏检' '漏检'
END END
) AS IsOK, ) AS IsOK,
ii.`name` AS NAME, ii.`name` AS inputItemName,
c.upload_time AS UploadTime, c.upload_time AS UploadTime,
u.`name` AS RealName, u.`name` AS RealName,
ci.score AS Score, ci.score AS Score,
...@@ -1912,8 +1917,8 @@ ...@@ -1912,8 +1917,8 @@
LEFT JOIN p_route r ON r.id = pnt.route_id LEFT JOIN p_route r ON r.id = pnt.route_id
LEFT JOIN p_check c ON c.plan_task_detail_id = ptd.id LEFT JOIN p_check c ON c.plan_task_detail_id = ptd.id
WHERE pnt.org_code LIKE CONCAT(#{orgCode}, '%') WHERE pnt.org_code LIKE CONCAT(#{orgCode}, '%')
<if test="startTime !=null and startTime!= '' "> <![CDATA[ AND pnt.check_date >= #{startTime} ]]> </if> <if test="startTime !=null and startTime!= '' "> <![CDATA[ AND pnt.begin_time >= #{startTime} ]]> </if>
<if test="endTime !=null and endTime!='' "><![CDATA[AND pnt.check_date <= #{endTime} ]]></if> <if test="endTime !=null and endTime!='' "><![CDATA[AND pnt.begin_time <= #{endTime} ]]></if>
GROUP BY ptd.id GROUP BY ptd.id
) a ) a
GROUP BY GROUP BY
...@@ -1992,8 +1997,8 @@ ...@@ -1992,8 +1997,8 @@
</when> </when>
</choose> </choose>
<if test="isOk !=null and isOk != '' ">and c.isOk = #{isOk}</if> <if test="isOk !=null and isOk != '' ">and c.isOk = #{isOk}</if>
<if test="startTime !=null and startTime!= '' "> <![CDATA[ AND pnt.check_date >= #{startTime} ]]> </if> <if test="startTime !=null and startTime!= '' "> <![CDATA[ AND pnt.begin_time >= #{startTime} ]]> </if>
<if test="endTime !=null and endTime!='' "><![CDATA[AND pnt.check_date <= #{endTime} ]]></if> <if test="endTime !=null and endTime!='' "><![CDATA[AND pnt.begin_time <= #{endTime} ]]></if>
GROUP BY GROUP BY
pnt.id pnt.id
) a ) a
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment