Browse Source

日期格式调整

master
Yangzz 3 months ago
parent
commit
622cb4fad7
  1. 15
      src/main/java/com/gaotao/common/utils/GenDate.java
  2. 5
      src/main/java/com/gaotao/modules/label/service/impl/PrintLabelRecordServiceImpl.java
  3. 5
      src/main/java/com/gaotao/modules/label/service/impl/PrintRollLabelRecordServiceImpl.java

15
src/main/java/com/gaotao/common/utils/GenDate.java

@ -1,6 +1,7 @@
package com.gaotao.common.utils;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
public class GenDate {
@ -10,4 +11,18 @@ public class GenDate {
int excelDate = (int) days;
return excelDate+siteCode;
}
/**
* 将LocalDate转换为指定格式的日期字符串
* @param currentDate 要转换的日期
* @param dateFormat 日期格式例如"yyyy-MM-dd", "yyyyMMdd", "yyyy/MM/dd"
* @return 格式化后的日期字符串
*/
public static String formatDate(LocalDate currentDate, String dateFormat) {
if (currentDate == null || dateFormat == null || dateFormat.trim().isEmpty()) {
return "";
}
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(dateFormat);
return currentDate.format(formatter);
}
}

5
src/main/java/com/gaotao/modules/label/service/impl/PrintLabelRecordServiceImpl.java

@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gaotao.common.constant.SysMsgConstant;
import com.gaotao.common.utils.GenDate;
import com.gaotao.modules.app.entity.UserEntity;
import com.gaotao.modules.factory.entity.Site;
import com.gaotao.modules.factory.service.SiteService;
import com.gaotao.modules.label.entity.LabelFormatUserDefault;
@ -170,7 +169,9 @@ public class PrintLabelRecordServiceImpl extends ServiceImpl<PrintLabelRecordMap
printLabelRecord.setBoxNo(buNoDate+String.format("%0"+boxNum+"d", boxNoSerial));
LocalDate localDate = LocalDate.of(printLabelRecord.getManufacturerTime().getYear() + 1900,
printLabelRecord.getManufacturerTime().getMonth()+1,printLabelRecord.getManufacturerTime().getDate());
printLabelRecord.setManufacturerDate(GenDate.dateToJuLian(localDate,str));
printLabelRecord.setManufacturerDate(
"Alpha/Hard Tag-No Serials".equalsIgnoreCase(printLabelRecord.getCategory())|| "Alpha/Hard Tag-Serials".equalsIgnoreCase(printLabelRecord.getCategory())?
GenDate.formatDate(localDate,"MM/dd/yyyy") : GenDate.dateToJuLian(localDate,str));
// printLabelRecord.setManufacturerDate(GenDate.dateToJuLian(localDate,manufacturer.getManufacturerCode()));
PrintLabelRecord target = new PrintLabelRecord();
BeanUtils.copyProperties(printLabelRecord,target);

5
src/main/java/com/gaotao/modules/label/service/impl/PrintRollLabelRecordServiceImpl.java

@ -7,7 +7,6 @@ import com.gaotao.common.constant.SysMsgConstant;
import com.gaotao.common.utils.GenDate;
import com.gaotao.modules.factory.entity.Site;
import com.gaotao.modules.factory.service.SiteService;
import com.gaotao.modules.label.entity.PrintLabelRecord;
import com.gaotao.modules.label.entity.PrintRollLabelRecord;
import com.gaotao.modules.label.entity.Seq;
import com.gaotao.modules.label.mapper.PrintRollLabelRecordMapper;
@ -132,7 +131,9 @@ public class PrintRollLabelRecordServiceImpl extends ServiceImpl<PrintRollLabelR
.toLocalDate();
// LocalDate localDate = LocalDate.of(printRollLabelRecord.getManufacturerTime().getYear() + 1900,
// printRollLabelRecord.getManufacturerTime().getMonth()+1,printRollLabelRecord.getManufacturerTime().getDate());
printRollLabelRecord.setManufacturerDate(GenDate.dateToJuLian(localDate,str));
printRollLabelRecord.setManufacturerDate(
"Alpha/Hard Tag-No Serials".equalsIgnoreCase(printRollLabelRecord.getCategory())|| "Alpha/Hard Tag-Serials".equalsIgnoreCase(printRollLabelRecord.getCategory())?
GenDate.formatDate(localDate,"MM/dd/yyyy") : GenDate.dateToJuLian(localDate,str));
PrintRollLabelRecord target = new PrintRollLabelRecord();
BeanUtils.copyProperties(printRollLabelRecord,target);
target.setCreateTime(new Date());

Loading…
Cancel
Save