java后端把毫秒數轉化成日期的方法:
date.setTime(Long.valueOf(map.get("hfsj").toString()));
map.put("hfsj",DateFormatUtils.format(date,"yyyy-MM-dd")); //commons-lang3 3.7
java中實現日期的加減:
String oneHoursAgoTime="";
Date dt = new Date();
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd-HH");
Calendar rightNow = Calendar.getInstance();
rightNow.setTime(dt);
//rightNow.add(Calendar.DATE, -1);
rightNow.add(Calendar.HOUR, -1);
Date dt1=rightNow.getTime();
oneHoursAgoTime = sdf.format(dt1);
return oneHoursAgoTime;
public List<WpSsgc> getByBmmbId(String bmmbId) { List<WpSsgc> ssgcsList = ssgcMapper.selectByBmmbId(bmmbId); for (WpSsgc ssgc:ssgcsList){ Date date = new Date(); date.setTime(ssgc.getSsrj()); ssgc.setSsrjStr(DateFormatUtils.format(date,"yyyy-MM-dd")); } return ssgcsList; }
毫秒數轉字符串 :select FROM_UNIXTIME(1593322599965/1000, "%Y-%m-%d")
SELECT DATE_FORMAT(NOW(),'%Y-%m-%d %H:%i:%s')
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.hainei.mapper.wp.fxypgg.WpFxcnsMapper">
<resultMap id="BaseResultMap" type="com.hainei.pojo.model.wp.fxypgg.WpFxcns">
<id column="id" property="id" jdbcType="VARCHAR"/>
<result column="jhcj" property="jhcj" jdbcType="VARCHAR"/>
<result column="jmcj" property="jmcj" jdbcType="VARCHAR"/>
<result column="zhcj" property="zhcj" jdbcType="VARCHAR"/>
<result column="ccwl" property="ccwl" jdbcType="VARCHAR"/>
<result column="tzsb" property="tzsb" jdbcType="VARCHAR"/>
<result column="bjss" property="bjss" jdbcType="VARCHAR"/>
<result column="xcwx" property="xcwx" jdbcType="VARCHAR"/>
<result column="pcyh" property="pcyh" jdbcType="VARCHAR"/>
<result column="gwfx" property="gwfx" jdbcType="VARCHAR"/>
<result column="tcj" property="tcj" jdbcType="VARCHAR"/>
<result column="tszysl" property="tszysl" jdbcType="VARCHAR"/>
<result column="gsm" property="gsm" jdbcType="VARCHAR"/>
<result column="tszynr" property="tszynr" jdbcType="VARCHAR"/>
<result column="zjl" property="zjl" jdbcType="VARCHAR"/>
<result column="tbr" property="tbr" jdbcType="VARCHAR"/>
<result column="ggrq" property="ggrq" jdbcType="BIGINT"/>
<result column="status" property="status" jdbcType="VARCHAR"/>
<result column="cjr" property="cjr" jdbcType="VARCHAR"/>
<result column="cjsj" property="cjsj" jdbcType="TIMESTAMP"/>
<result column="xgsj" property="xgsj" jdbcType="TIMESTAMP"/>
<result column="xgr" property="xgr" jdbcType="VARCHAR"/>
<result column="delete_status" property="deleteStatus" jdbcType="INTEGER"/>
<result column="zx" property="zx" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
id, jhcj, jmcj, zhcj, ccwl, tzsb, bjss, xcwx, pcyh, gwfx, tcj, tszysl, gsm, tszynr,
zjl, tbr, ggrq, status, cjr, cjsj, xgsj, xgr, delete_status,zx
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from wp_fxcns
where id = #{id,jdbcType=VARCHAR}
</select>
<select id="getById" resultType="java.util.Map">
SELECT DISTINCT f.id, jhcj, jmcj, zhcj, ccwl, tzsb, bjss, xcwx, pcyh, gwfx, tcj, tszysl, gsm, tszynr,
zjl, tbr, ggrq, d.`name` gsmc, d1.`name` gwfxmc,d2.name tcjmc, u.`name` tbrmc, FROM_UNIXTIME(f.ggrq/1000, "%Y-%m-%d") ggrqStr, w.`status` status,
w.id AS processinstId,f.cjsj
from wp_fxcns f
-- join base_data_table bdt on bdt.tableid=f.id
LEFT JOIN base_data_dictionary d on f.gsm = d.id
LEFT JOIN base_data_dictionary d1 on f.gwfx = d1.id
LEFT JOIN base_data_dictionary d2 on f.tcj = d2.id
LEFT JOIN base_user u on f.tbr = u.id
INNER JOIN wf_processinst w on f.id = w.business_Id
where f.id = #{id,jdbcType=VARCHAR}
AND judgeDataPermission(f.id,#{id},f.cjr)=1
</select>
<select id="selectBySelective" resultType="java.util.Map">
SELECT DISTINCT f.id, jhcj, jmcj, zhcj, ccwl, tzsb, bjss, xcwx, pcyh, gwfx, tcj, tszysl, gsm, tszynr,
zjl, tbr, ggrq, d.`name` gsmc, d1.`name` gwfxmc,d2.name tcjmc, u.`name` tbrmc, FROM_UNIXTIME(f.ggrq/1000, "%Y-%m-%d") ggrqStr, w.`status` status,
w.id AS processinstId,f.cjsj
from wp_fxcns f
-- join base_data_table bdt on bdt.tableid=f.id
LEFT JOIN base_data_dictionary d on f.gsm = d.id
LEFT JOIN base_data_dictionary d1 on f.gwfx = d1.id
LEFT JOIN base_data_dictionary d2 on f.tcj = d2.id
LEFT JOIN base_user u on f.tbr = u.id
INNER JOIN wf_processinst w on f.id = w.business_Id
where 1=1
<if test="jhcj != null and jhcj != ''">
AND f.jhcj LIKE CONCAT(CONCAT('%',#{jhcj,jdbcType=VARCHAR},'%'))
</if>
<if test="jmcj != null and jmcj != '' ">
AND f.jmcj LIKE CONCAT(CONCAT('%',#{jmcj,jdbcType=VARCHAR},'%'))
</if>
<if test="zhcj != null and zhcj != ''">
AND f.zhcj LIKE CONCAT(CONCAT('%',#{zhcj,jdbcType=VARCHAR},'%'))
</if>
<if test="ccwl != null and ccwl != ''">
AND f.ccwl LIKE CONCAT(CONCAT('%',#{ccwl,jdbcType=VARCHAR},'%'))
</if>
<if test="tzsb != null and tzsb != ''">
AND f.tzsb LIKE CONCAT(CONCAT('%',#{tzsb,jdbcType=VARCHAR},'%'))
</if>
<if test="bjss != null and bjss != ''">
AND f.bjss LIKE CONCAT(CONCAT('%',#{bjss,jdbcType=VARCHAR},'%'))
</if>
<if test="xcwx != null and xcwx != ''">
AND f.xcwx LIKE CONCAT(CONCAT('%',#{xcwx,jdbcType=VARCHAR},'%'))
</if>
<if test="pcyh != null and pcyh != ''">
AND f.pcyh LIKE CONCAT(CONCAT('%',#{pcyh,jdbcType=VARCHAR},'%'))
</if>
<if test="gwfx != null and gwfx != ''">
AND f.gwfx = #{gwfx,jdbcType=VARCHAR}
</if>
<if test="tcj != null and tcj != ''">
AND f.tcj = #{tcj,jdbcType=VARCHAR}
</if>
<if test="tszysl != null and tszysl != ''">
AND f.tszysl LIKE CONCAT(CONCAT('%',#{tszysl,jdbcType=VARCHAR},'%'))
</if>
<if test="gsm != null and gsm != ''">
AND f.gsm = #{gsm,jdbcType=VARCHAR}
</if>
<if test="tszynr != null and tszynr != ''">
AND f.tszynr LIKE CONCAT(CONCAT('%',#{tszynr,jdbcType=VARCHAR},'%'))
</if>
<if test="zjl != null and zjl != ''">
AND f.zjl LIKE CONCAT(CONCAT('%',#{zjl,jdbcType=VARCHAR},'%'))
</if>
<if test="tbr != null and tbr != ''">
AND u.name LIKE CONCAT(CONCAT('%',#{tbr,jdbcType=VARCHAR},'%'))
</if>
<if test="ggrqStart != null and ggrqEnd != null">
AND #{ggrqStart,jdbcType=BIGINT} <= f.ggrq
AND f.ggrq <= #{ggrqEnd,jdbcType=BIGINT}
</if>
<if test="status != null ">
AND w.status = #{status,jdbcType=VARCHAR}
</if>
<if test="deleteStatus != null">
AND f.delete_status = #{deleteStatus,jdbcType=INTEGER}
</if>
<!--<if test="oidStr != null">-->
<!--AND bdt.oid in (${oidStr})-->
<!--</if>-->
<if test="all != null and all != ''">
AND CONCAT(f.jhcj, f.jmcj, f.zhcj, f.ccwl, f.tzsb, f.bjss, f.xcwx, f.pcyh, f.tszysl, f.gsm, f.tszynr,
f.zjl, u.name) LIKE CONCAT(CONCAT('%',#{all},'%'))
</if>
AND judgeDataPermission(f.id,#{cjr},f.cjr)=1
order by f.cjsj desc
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from wp_fxcns
where id = #{id,jdbcType=VARCHAR}
</delete>
<insert id="insertSelective" parameterType="com.hainei.pojo.model.wp.fxypgg.WpFxcns">
insert into wp_fxcns
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="jhcj != null">
jhcj,
</if>
<if test="jmcj != null">
jmcj,
</if>
<if test="zhcj != null">
zhcj,
</if>
<if test="ccwl != null">
ccwl,
</if>
<if test="tzsb != null">
tzsb,
</if>
<if test="bjss != null">
bjss,
</if>
<if test="xcwx != null">
xcwx,
</if>
<if test="pcyh != null">
pcyh,
</if>
<if test="gwfx != null">
gwfx,
</if>
<if test="tcj != null">
tcj,
</if>
<if test="tszysl != null">
tszysl,
</if>
<if test="gsm != null">
gsm,
</if>
<if test="tszynr != null">
tszynr,
</if>
<if test="zjl != null">
zjl,
</if>
<if test="tbr != null">
tbr,
</if>
<if test="ggrq != null">
ggrq,
</if>
<if test="status != null">
status,
</if>
<if test="cjr != null">
cjr,
</if>
<if test="cjsj != null">
cjsj,
</if>
<if test="xgsj != null">
xgsj,
</if>
<if test="xgr != null">
xgr,
</if>
<if test="deleteStatus != null">
delete_status,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="jhcj != null">
#{jhcj,jdbcType=VARCHAR},
</if>
<if test="jmcj != null">
#{jmcj,jdbcType=VARCHAR},
</if>
<if test="zhcj != null">
#{zhcj,jdbcType=VARCHAR},
</if>
<if test="ccwl != null">
#{ccwl,jdbcType=VARCHAR},
</if>
<if test="tzsb != null">
#{tzsb,jdbcType=VARCHAR},
</if>
<if test="bjss != null">
#{bjss,jdbcType=VARCHAR},
</if>
<if test="xcwx != null">
#{xcwx,jdbcType=VARCHAR},
</if>
<if test="pcyh != null">
#{pcyh,jdbcType=VARCHAR},
</if>
<if test="gwfx != null">
#{gwfx,jdbcType=VARCHAR},
</if>
<if test="tcj != null">
#{tcj,jdbcType=VARCHAR},
</if>
<if test="tszysl != null">
#{tszysl,jdbcType=VARCHAR},
</if>
<if test="gsm != null">
#{gsm,jdbcType=VARCHAR},
</if>
<if test="tszynr != null">
#{tszynr,jdbcType=VARCHAR},
</if>
<if test="zjl != null">
#{zjl,jdbcType=VARCHAR},
</if>
<if test="tbr != null">
#{tbr,jdbcType=VARCHAR},
</if>
<if test="ggrq != null">
#{ggrq,jdbcType=BIGINT},
</if>
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
<if test="cjr != null">
#{cjr,jdbcType=VARCHAR},
</if>
<if test="cjsj != null">
#{cjsj,jdbcType=TIMESTAMP},
</if>
<if test="xgsj != null">
#{xgsj,jdbcType=TIMESTAMP},
</if>
<if test="xgr != null">
#{xgr,jdbcType=VARCHAR},
</if>
<if test="deleteStatus != null">
#{deleteStatus,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.hainei.pojo.model.wp.fxypgg.WpFxcns">
update wp_fxcns
<set>
<if test="jhcj != null">
jhcj = #{jhcj,jdbcType=VARCHAR},
</if>
<if test="jmcj != null">
jmcj = #{jmcj,jdbcType=VARCHAR},
</if>
<if test="zhcj != null">
zhcj = #{zhcj,jdbcType=VARCHAR},
</if>
<if test="ccwl != null">
ccwl = #{ccwl,jdbcType=VARCHAR},
</if>
<if test="tzsb != null">
tzsb = #{tzsb,jdbcType=VARCHAR},
</if>
<if test="bjss != null">
bjss = #{bjss,jdbcType=VARCHAR},
</if>
<if test="xcwx != null">
xcwx = #{xcwx,jdbcType=VARCHAR},
</if>
<if test="pcyh != null">
pcyh = #{pcyh,jdbcType=VARCHAR},
</if>
<if test="gwfx != null">
gwfx = #{gwfx,jdbcType=VARCHAR},
</if>
<if test="tcj != null">
tcj = #{tcj,jdbcType=VARCHAR},
</if>
<if test="tszysl != null">
tszysl = #{tszysl,jdbcType=VARCHAR},
</if>
<if test="gsm != null">
gsm = #{gsm,jdbcType=VARCHAR},
</if>
<if test="tszynr != null">
tszynr = #{tszynr,jdbcType=VARCHAR},
</if>
<if test="zjl != null">
zjl = #{zjl,jdbcType=VARCHAR},
</if>
<if test="tbr != null">
tbr = #{tbr,jdbcType=VARCHAR},
</if>
<if test="ggrq != null">
ggrq = #{ggrq,jdbcType=BIGINT},
</if>
<if test="status != null">
status = #{status,jdbcType=VARCHAR},
</if>
<if test="cjr != null">
cjr = #{cjr,jdbcType=VARCHAR},
</if>
<if test="cjsj != null">
cjsj = #{cjsj,jdbcType=TIMESTAMP},
</if>
<if test="xgsj != null">
xgsj = #{xgsj,jdbcType=TIMESTAMP},
</if>
<if test="xgr != null">
xgr = #{xgr,jdbcType=VARCHAR},
</if>
<if test="deleteStatus != null">
delete_status = #{deleteStatus,jdbcType=INTEGER},
</if>
<if test="zx != null">
zx = #{zx,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<select id="getBooleanById" resultType="boolean">
SELECT #{id,jdbcType=VARCHAR} in (
SELECT distinct wp.business_Id as docId
FROM
wf_processinst wp
LEFT JOIN act_ru_task art ON wp.id = art.PROC_INST_ID_
left JOIN act_re_model arm on arm.KEY_=wp.processDefinationKey
left join base_user u1 on u1.id=wp.origiator
LEFT JOIN base_user u2 on u2.id=art.ASSIGNEE_
-- inner join base_data_table bdt on bdt.tableid=wp.business_Id
WHERE
1=1
and wp.`status` in
<foreach item="wpStatus" collection="wpStatusList" open="(" separator="," close=")">
#{wpStatus}
</foreach>
and art.ID_ in
<foreach item="taskId" collection="taskIdList" open="(" separator="," close=")">
#{taskId}
</foreach>
<!--<if test="oidStr!=null">-->
<!--AND bdt.oid in (${oidStr})-->
<!--</if>-->
AND judgeDataPermission(wp.id,#{userId},wp.gmt_created_by)=1
)
</select>
<update id="updateZx" >
update wp_fxcns
set zx = 0
where zx = 1
</update>
<update id="resetZx" >
update wp_fxcns
set zx = 1
where id = #{id,jdbcType=VARCHAR}
</update>
<select id="getByZx" resultType="java.util.Map">
SELECT f.id, jhcj, jmcj, zhcj, ccwl, tzsb, bjss, xcwx, pcyh, gwfx, tcj, tszysl, gsm, tszynr,
zjl, tbr, ggrq, d.`name` gsmc, d1.`name` gwfxmc,d2.name tcjmc, u.`name` tbrmc, FROM_UNIXTIME(f.ggrq/1000, "%Y-%m-%d") ggrqStr
from wp_fxcns f
LEFT JOIN base_data_dictionary d on f.gsm = d.id
LEFT JOIN base_data_dictionary d1 on f.gwfx = d1.id
LEFT JOIN base_data_dictionary d2 on f.tcj = d2.id
LEFT JOIN base_user u on f.tbr = u.id
where f.zx = 1 and f.delete_status = 0
</select>
<select id="getBestZx" resultType="java.util.Map">
SELECT DISTINCT f.id, jhcj, jmcj, zhcj, ccwl, tzsb, bjss, xcwx, pcyh, gwfx, tcj, tszysl, gsm, tszynr,
zjl, tbr, ggrq, d.`name` gsmc, d1.`name` gwfxmc,d2.name tcjmc, u.`name` tbrmc, FROM_UNIXTIME(f.ggrq/1000, "%Y-%m-%d") ggrqStr, w.`status` status,
w.id AS processinstId,f.cjsj
from wp_fxcns f
-- join base_data_table bdt on bdt.tableid=f.id
LEFT JOIN base_data_dictionary d on f.gsm = d.id
LEFT JOIN base_data_dictionary d1 on f.gwfx = d1.id
LEFT JOIN base_data_dictionary d2 on f.tcj = d2.id
LEFT JOIN base_user u on f.tbr = u.id
INNER JOIN wf_processinst w on f.id = w.business_Id
where 1=1 AND w.status = "Finished" and f.delete_status = 0
AND judgeDataPermission(f.id,u.id,f.gmt_created_by)=1
order by f.cjsj desc
LIMIT 1
</select>
</mapper>
<select id="getByZx" resultType="java.util.Map"> SELECT f.id, jhcj, jmcj, zhcj, ccwl, tzsb, bjss, xcwx, pcyh, gwfx, tcj, tszysl, gsm, tszynr, zjl, tbr, ggrq, d.`name` gsmc, d1.`name` gwfxmc,d2.name tcjmc, u.`name` tbrmc, FROM_UNIXTIME(f.ggrq/1000, "%Y-%m-%d") ggrqStr from wp_fxcns f LEFT JOIN base_data_dictionary d on f.gsm = d.id LEFT JOIN base_data_dictionary d1 on f.gwfx = d1.id LEFT JOIN base_data_dictionary d2 on f.tcj = d2.id LEFT JOIN base_user u on f.tbr = u.id where f.zx = 1 and f.delete_status = 0 </select>


基於 中國標准時間 的字符串格式轉換
時間格式轉換不太熟,記錄一下
private static String parseTime( String dateStr ) { // 轉換時間格式 ==> "Wed Nov 21 2018 00:00:00 GMT+0800 (中國標准時間)" String parseDate; // 定義一個用於返回的變量 // 字符串轉Date // 定義一個 用於格式化字符串的變量 SimpleDateFormat sdf = new SimpleDateFormat( "EEE MMM dd yyyy HH:mm:ss 'GMT+0800 (中國標准時間)'", Locale.US ); Date date = new Date(); // 創建 Date 對象 try { date = sdf.parse( dateStr ); // 將目標字符串按指定格式解析 } catch (ParseException e) { log.info( "時間格式轉換錯誤" + date.toString() ); // 打印錯誤日志,也可以用 "System.out.println()" } //Date轉字符串 sdf = new SimpleDateFormat( "yyyy-MM-dd" ); // 再次指定轉換的格式 parseDate = sdf.format( date ); // 按指定日期格式轉換 //parseDate: 2018-11-21 return parseDate; // 返回處理后的結果 }
