Browse Source

修正时间戳bug

master
xyiege 3 years ago
parent
commit
7aef53a585
  1. 2
      src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java
  2. 19
      src/test/java/cn/chjyj/szwh/service/impl/GoodsServiceImplTest.java

2
src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java

@ -590,7 +590,7 @@ public class GoodsServiceImpl implements GoodsService {
int fdays = festivalsMapper.countDayBetweenDays(wtStart, wtEnd, iyear);
// 节假日顺延后的日期
Date fwtEnd = DateUtils.daysAgoOrAfter(wtEnd, fdays);
cend = sdf.format(fwtEnd)+" 23:59:59";
cend = sdf.format(fwtEnd);
ncet=new Timestamp(sdf.parse(cend).getTime());
} catch (Exception ex) {
log.error("一次性委托日期转码出错:" + ex.getLocalizedMessage());

19
src/test/java/cn/chjyj/szwh/service/impl/GoodsServiceImplTest.java

@ -15,6 +15,7 @@ import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
@ -134,28 +135,31 @@ public class GoodsServiceImplTest {
// 取今年的年份数字
Calendar calendar = Calendar.getInstance();
int iyear = calendar.get(Calendar.YEAR);
//委托开始时间
Timestamp ncst=new Timestamp(0l);
//委托结束时间
Timestamp ncet=new Timestamp(0l);
if (StringUtils.isBlank(cend) && iday != null) {
//如果是一次性授权或单次授权,存在托管结束时间
if (iperiod == 2) {
try {
// 委托开始时间
// 委托开始时间 匹配时间格式,防止转码出错
Date wtStart = sdf.parse(ncstart);
// 注入当日时间,判断周几
ncst = new Timestamp(wtStart.getTime());
// 判断周几
calendar.setTime(wtStart);
// 得到处理后的时间
int wkday = calendar.get(Calendar.DAY_OF_WEEK);
//周末顺延
// notice:在节假日调休时候,会有变动
iday += wkday > 5 ? (wkday - 5 + 1) : 0;
//iday = iday+ixday;
// 委托终止时间
Date wtEnd = DateUtils.daysAgoOrAfter(wtStart, iday);
// 统计该时间段内的节假日
int fdays = festivalsMapper.countDayBetweenDays(wtStart, wtEnd, iyear);
// 节假日顺后的日期
// 节假日顺后的日期
Date fwtEnd = DateUtils.daysAgoOrAfter(wtEnd, fdays);
cend = fwtEnd.toString();
String tmpcend = sdf.format(fwtEnd);
ncet=new Timestamp(sdf.parse(tmpcend).getTime());
} catch (Exception ex) {
ex.printStackTrace();
}
@ -175,7 +179,6 @@ public class GoodsServiceImplTest {
}
}
}
String ncend = cend + "23:59:59";
}
// int icount = goodsService.manuImportGoods(jsonObject);

Loading…
Cancel
Save