Browse Source

20241105

print/logistic/save
qiezi 1 year ago
parent
commit
534ae33cd1
  1. 5
      src/main/java/com/gaotao/common/utils/GenDate.java
  2. 3
      src/main/java/com/gaotao/modules/label/entity/PrintLabelRecord.java
  3. 2
      src/main/java/com/gaotao/modules/label/mapper/PrintLabelRecordMapper.java
  4. 23
      src/main/java/com/gaotao/modules/label/service/impl/PrintLabelRecordServiceImpl.java
  5. 17
      src/main/resources/mapper/label/PrintLabelRecordMapper.xml

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

@ -1,10 +1,11 @@
package com.gaotao.common.utils;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
public class GenDate {
public static String dateToJuLian(java.time.LocalDate currentDate) {
java.time.LocalDate excelStartDate = java.time.LocalDate.of(1904, 1, 1);
public static String dateToJuLian(LocalDate currentDate) {
LocalDate excelStartDate = LocalDate.of(1904, 1, 1);
long days = ChronoUnit.DAYS.between(excelStartDate, currentDate);
int excelDate = (int) days;
return excelDate+"09";

3
src/main/java/com/gaotao/modules/label/entity/PrintLabelRecord.java

@ -85,4 +85,7 @@ public class PrintLabelRecord {
private String tradingMark;
@TableField(exist = false)
private String weightUmName;
@TableField(exist = false)
private String dateStr;
}

2
src/main/java/com/gaotao/modules/label/mapper/PrintLabelRecordMapper.java

@ -16,4 +16,6 @@ public interface PrintLabelRecordMapper extends BaseMapper<PrintLabelRecord> {
List<PrintLabelRecord> selectPrintLabelRecordList(PrintLabelRecord printLabelRecord);
IPage<PrintLabelRecord> selectPrintLabelRecordPage(@Param("page") Page<PrintLabelRecord> page, @Param("params") PrintLabelRecord printLabelRecord);
List<PrintLabelRecord> autoCreateSerialNumber(@Param("params") PrintLabelRecord printLabelRecord,@Param("qty") int i);
}

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

@ -5,11 +5,14 @@ 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.label.entity.PrintLabelRecord;
import com.gaotao.modules.label.mapper.PrintLabelRecordMapper;
import com.gaotao.modules.label.service.PrintLabelRecordService;
import com.gaotao.modules.sys.entity.SysUserEntity;
import com.gaotao.modules.sys.service.SysMsgService;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@ -67,9 +70,19 @@ public class PrintLabelRecordServiceImpl extends ServiceImpl<PrintLabelRecordMap
int boxNoSerial = 0;
List<PrintLabelRecord> printLabelRecordList = new ArrayList<>();
// BigDecimal remainder = printLabelRecord.getCartonCount().remainder(printLabelRecord.getQtyPerCarton());
for (int j = 1; j <= cartonCount.intValue(); j++) {
boxNoSerial = boxNumber + j;
List<PrintLabelRecord> list = new ArrayList<>();
// 获得当前登录用户
SysUserEntity userEntity = (SysUserEntity) SecurityUtils.getSubject().getPrincipal();
// 判断是否需要打印SN
if ("Alpha/Hard Tag-Serials".equalsIgnoreCase(printLabelRecord.getCategory()) && "Y".equalsIgnoreCase(userEntity.getAutoSerialNumber())){
printLabelRecord.setCreateTime(new Date());
// 获取SN
list = baseMapper.autoCreateSerialNumber(printLabelRecord, cartonCount.intValue());
}
// 打印张数
for (int i = 1; i <= cartonCount.intValue(); i++) {
boxNoSerial = boxNumber + i;
printLabelRecord.setBoxNo(buNoDate+String.format("%0"+boxNum+"d", boxNoSerial));
LocalDate localDate = LocalDate.of(printLabelRecord.getManufacturerTime().getYear() + 1900,
printLabelRecord.getManufacturerTime().getMonth()+1,printLabelRecord.getManufacturerTime().getDate());
@ -77,6 +90,10 @@ public class PrintLabelRecordServiceImpl extends ServiceImpl<PrintLabelRecordMap
PrintLabelRecord target = new PrintLabelRecord();
BeanUtils.copyProperties(printLabelRecord,target);
target.setCreateTime(new Date());
if (!list.isEmpty()){
target.setSerialNumber(list.get(i-1).getSerialNumber());
target.setDateStr(list.get(i-1).getDateStr());
}
save(target);
printLabelRecordList.add(target);
}

17
src/main/resources/mapper/label/PrintLabelRecordMapper.xml

@ -1,7 +1,6 @@
<?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.gaotao.modules.label.mapper.PrintLabelRecordMapper">
<select id="getBuNo" resultType="java.lang.String">
select dbo.getBU(#{category})
</select>
@ -30,12 +29,16 @@
p.trading_mark,
p.carton_weight,
p.packing_weight,
wu.um_name as weight_um_name
wu.um_name as weight_um_name,
snl.date_str
from print_label_Record plr
left join part p on p.part_no = plr.part_no and p.site = plr.site
left join customer c on c.site = plr.site and c.customer_no = plr.customer_no
left join unit u on p.um_id = u.um_id
left join unit wu on p.weight_um_id = wu.um_id
left join serial_number_list snl on snl.part_no = plr.part_no and snl.site = plr.site and
snl.serial_number = plr.serial_number and
snl.category = plr.category
<where>
<if test="site != null and site != ''">
and plr.site = #{site}
@ -89,12 +92,16 @@
p.trading_mark,
p.carton_weight,
p.packing_weight,
wu.um_name as weight_um_name
wu.um_name as weight_um_name,
snl.date_str
from print_label_Record plr
left join part p on p.part_no = plr.part_no and p.site = plr.site
left join customer c on c.site = plr.site and c.customer_no = plr.customer_no
left join unit u on p.um_id = u.um_id
left join unit wu on p.weight_um_id = wu.um_id
left join serial_number_list snl on snl.part_no = plr.part_no and snl.site = plr.site and
snl.serial_number = plr.serial_number and
snl.category = plr.category
<where>
<if test="params.site != null and params.site != ''">
and plr.site = #{params.site}
@ -120,4 +127,8 @@
</where>
order by plr.create_time desc
</select>
<select id="autoCreateSerialNumber" resultType="com.gaotao.modules.label.entity.PrintLabelRecord">
exec dbo.AutoCreateSerialNumber #{params.site}, #{params.partNo}, #{params.createTime}, #{qty}
</select>
</mapper>
Loading…
Cancel
Save