|
|
|
@ -8,10 +8,14 @@ import com.gaotao.modules.finishedProduct.entity.ReportfileSeqinfo; |
|
|
|
import com.gaotao.modules.finishedProduct.service.ReportcontentitemSeqruleService; |
|
|
|
import com.gaotao.modules.finishedProduct.service.ReportcontentitemService; |
|
|
|
import com.gaotao.modules.finishedProduct.service.ReportfileSeqinfoService; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
@ -33,6 +37,67 @@ public class ReportfileSeqinfoServiceImpl extends ServiceImpl<ReportfileSeqinfoD |
|
|
|
@Autowired |
|
|
|
private ReportcontentitemSeqruleService reportcontentitemSeqruleService; |
|
|
|
|
|
|
|
private Logger logger = LoggerFactory.getLogger(getClass()); |
|
|
|
|
|
|
|
|
|
|
|
//LR 20245-01-18 后来修改的方法 |
|
|
|
@Override |
|
|
|
public String getSeqNumber(String reportId, String seq, Map<String, String> itemMap) { |
|
|
|
Reportcontentitem reportcontentitem = reportcontentitemService.getReportcontentitem(reportId, seq); |
|
|
|
Integer serialNumber = null; |
|
|
|
if (reportcontentitem != null) { |
|
|
|
// 获取规则 |
|
|
|
List<ReportcontentitemSeqrule> reportcontentitemSeqrules = reportcontentitemSeqruleService.lambdaQuery() |
|
|
|
.eq(ReportcontentitemSeqrule::getReportid, reportcontentitem.getReportid()) |
|
|
|
.orderByAsc(ReportcontentitemSeqrule::getSeqno).list(); |
|
|
|
if (reportcontentitemSeqrules.size() > 0) { |
|
|
|
String keyInfo = reportcontentitemSeqrules.stream().map(ReportcontentitemSeqrule::getObjectname).collect(Collectors.joining("+")); |
|
|
|
logger.info("流水号规则的key:"+keyInfo); |
|
|
|
//根据值获取value信息 |
|
|
|
String keyValueInfo = Arrays.stream(keyInfo.split("\\+")) |
|
|
|
.map(key -> itemMap.get(key)) |
|
|
|
.filter(value-> value!= null) |
|
|
|
.collect(Collectors.joining("+")); |
|
|
|
logger.info("流水号规则的值:"+keyValueInfo); |
|
|
|
// 获取流水号规则 |
|
|
|
ReportfileSeqinfo reportfileSeqinfo = reportfileSeqinfoService.lambdaQuery() |
|
|
|
.eq(ReportfileSeqinfo::getReportid, reportcontentitem.getReportid()) |
|
|
|
.eq(ReportfileSeqinfo::getItemno, reportcontentitem.getItemno()) |
|
|
|
.eq(ReportfileSeqinfo::getKeyinfo, keyValueInfo).one(); |
|
|
|
// 获取流水号 |
|
|
|
if (reportfileSeqinfo == null) { |
|
|
|
serialNumber = reportcontentitem.getInterval(); |
|
|
|
// 没有打印过 则是初始值加 |
|
|
|
reportfileSeqinfo = new ReportfileSeqinfo(); |
|
|
|
reportfileSeqinfo.setItemno(reportcontentitem.getItemno()); |
|
|
|
reportfileSeqinfo.setLastseqno(serialNumber); |
|
|
|
reportfileSeqinfo.setReportid(reportcontentitem.getReportid()); |
|
|
|
reportfileSeqinfo.setKeyinfo(keyValueInfo); |
|
|
|
// 保存流水号 |
|
|
|
reportfileSeqinfoService.save(reportfileSeqinfo); |
|
|
|
} else { |
|
|
|
// 打印过该流水规则 |
|
|
|
serialNumber = reportfileSeqinfo.getLastseqno() + reportcontentitem.getInterval(); |
|
|
|
// 获取流水号之后 修改流水号 |
|
|
|
this.baseMapper.updateSerialNumber(reportcontentitem.getReportid(), reportcontentitem.getItemno(), keyValueInfo, serialNumber); |
|
|
|
// reportfileSeqinfoService.lambdaUpdate().set(ReportfileSeqinfo::getLastseqno, serialNumber) |
|
|
|
// .eq(ReportfileSeqinfo::getReportid, reportcontentitem.getReportid()) |
|
|
|
// .eq(ReportfileSeqinfo::getKeyinfo, keyInfo) |
|
|
|
// .eq(ReportfileSeqinfo::getItemno, reportcontentitem.getItemno()).update(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (serialNumber != null) { |
|
|
|
Integer sequencebits = reportcontentitem.getSequencebits(); |
|
|
|
String number = "00000000000000000000000000"; |
|
|
|
number += serialNumber; |
|
|
|
return number.substring(number.length() - sequencebits); |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
//原佘莉写得方法 |
|
|
|
@Override |
|
|
|
public String getSeqNumber(String reportId, String seq) { |
|
|
|
Reportcontentitem reportcontentitem = reportcontentitemService.getReportcontentitem(reportId, seq); |
|
|
|
|