List<Long> userIdList =attendMapper.selectTodayAbsence();
if(CollectionUtils.isNotEmpty(userIdList)){ //判断是否为空方法
ava获取取得Timestamp类型的当前系统时间
java获取取得Timestamp类型的当前系统时间 格式:2010-11-04 16:19:42
方法1:
Timestamp d = new Timestamp(System.currentTimeMillis());
方法2:
Timestamp nousedate = new Timestamp(new Date().getTime());
获取时间天数的方法
事务处理
在service层 TMS_back_handover_doc_makeServiceImpl
@Transactional(propagation=Propagation.REQUIRED)
后台做判断是否重复处理数据和字符串转义
线路名称、用户名称等转换
public String getOp_user_id() {
if(this.op_user_id!=null){
return UserCache.getUserName(this.op_user_id)!=null?UserCache.getUserName(this.op_user_id):"";
}
return "";
}
上一站,下一站等下拉框信息公用
true:显示/不显示
查询条件修改
//如没有时间而显示1970/1/1,就让它不显示
Grid++打印运单信息
xml解析
public static void main(String[] args) {
Document document;
Map<String, Object> map = new HashMap<String, Object>();
String table_name = "";
String column_name = "";
try {
SAXReader reader = new SAXReader();
document = reader.read(new File("src/test/java/autoTest/result.xml"));//解析xml文件(相对路径)/绝对路径:e:/result.xml 或者 e:\result.xml
// document = DocumentHelper.parseText(infoXML);//解析String类型的xml文件
Element root = document.getRootElement();
Iterator it = root.elements().iterator();
System.out.println("root="+root.getName());//值为ROWDATA
while (it.hasNext()) {
Element info = (Element) it.next();
System.out.println("info="+info.getName());//值为ROW
Iterator itc = info.elements().iterator();
while (itc.hasNext()) {
Element infoc = (Element) itc.next();
System.out.println("infoc="+infoc.getName());
if("TABLE_NAME".equals(infoc.getName())){
table_name = infoc.getText();
}else if ("COLUMN_NAME".equals(infoc.getName())) {
column_name = infoc.getText();
}
}
map.put(table_name, column_name);
}
} catch (DocumentException e) {
e.printStackTrace();
}
System.out.println("完成map"+map);
}
解析xml
xml叫可扩展标记语言 和html的区别在于 显示层和 数据层分离 。
显示可以用css或者 xsl设置数据的显示格式
利用Java对xml文件进行解析 用到的类 DocumentBuilderFactory xml解析器工具 DocumentBuilder文档解析器 Document文档类 NodeList节点类
package me.dom.test;
import javax.xml.parsers.*; //导入相关类
import org.w3c.dom.*;
import org.w3c.dom.NodeList; //导入DOM节点类
import java.io.*; //io包
public class DomTest
{
public static void main(String []args) throws Exception
{
DocumentBuilderFactory buf=DocumentBuilderFactory.newInstance() ; //xm解析器生成工具 的静态方法 直接生成xml解析器
DocumentBuilder db=buf.newDocumentBuilder() ; //xml解析器工具来生成一个xml解析器对象 因为 DocumentBuilder没有提供共有构造方法
Document dom= db.parse(new File("C:\Users\xiaowei\Desktop\idnex.xml")) ; //将一个xml文件转换成一个DOM对象 也就是Document
NodeList list=dom.getElementsByTagName("name") ;//返回节点对象
for(int i=0;i<list.getLength();i++)
{
System.out.println(list.item(i).getTextContent()); //循环输出 节点文本
}
}
}
public static void main(String[] args) {
Map<String, String> map = new HashMap<String, String>();
map.put("1", "value1");
map.put("2", "value2");
map.put("3", "value3");
//第一种:普遍使用,二次取值
System.out.println("通过Map.keySet遍历key和value:");
for (String key : map.keySet()) {
System.out.println("key= "+ key + " and value= " + map.get(key));
}
//第二种
System.out.println("通过Map.entrySet使用iterator遍历key和value:");
Iterator<Map.Entry<String, String>> it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, String> entry = it.next();
System.out.println("key= " + entry.getKey() + " and value= " + entry.getValue());
}
//第三种:推荐,尤其是容量大时
System.out.println("通过Map.entrySet遍历key和value");
for (Map.Entry<String, String> entry : map.entrySet()) {
System.out.println("key= " + entry.getKey() + " and value= " + entry.getValue());
}
//第四种
System.out.println("通过Map.values()遍历所有的value,但不能遍历key");
for (String v : map.values()) {
System.out.println("value= " + v);
}
}
json解析
如下原因会造成JSON校验失败,而且会让你不知道为什么失败
- JSON字符串里的非数字型键值没有双引号
- JSON中存在 这样的制表符,看起来和空格一样,但是就是因为它的存在校验不通过。去掉就能过了。
- 编辑器有bom头也会造成