88 lines
2.9 KiB
Java
88 lines
2.9 KiB
Java
|
|
package com.czlis.interfaceCommon.utils;
|
||
|
|
|
||
|
|
import cn.hutool.core.date.DateUtil;
|
||
|
|
import com.czlis.common.core.domain.Result;
|
||
|
|
import com.czlis.common.core.domain.entity.lis.LabReqmain;
|
||
|
|
import com.czlis.common.core.domain.entity.lis.LabReqpack;
|
||
|
|
import com.czlis.common.utils.DateUtils;
|
||
|
|
import com.czlis.interfaceCommon.pojo.entity.BarCodeParam;
|
||
|
|
import lombok.extern.slf4j.Slf4j;
|
||
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
|
import org.springframework.stereotype.Component;
|
||
|
|
|
||
|
|
import java.util.List;
|
||
|
|
import java.util.Map;
|
||
|
|
|
||
|
|
@Component
|
||
|
|
@Slf4j
|
||
|
|
public class PackBarcodeUtil {
|
||
|
|
@Autowired
|
||
|
|
CommonUtil commonUtil;
|
||
|
|
@Autowired
|
||
|
|
private ReportUtil reportUtil;
|
||
|
|
/**
|
||
|
|
* 获取下一个箱码
|
||
|
|
* @return
|
||
|
|
*/
|
||
|
|
public String getNextPackID(){
|
||
|
|
String seqid="PACK";
|
||
|
|
String head="88"+ DateUtils.dateTimeNow("yyMMdd");
|
||
|
|
Long PackID=10000+commonUtil.getNextSeq(seqid);
|
||
|
|
String seqno=PackID.toString();
|
||
|
|
if (seqno.length ()<4) return"9999";
|
||
|
|
seqno.substring (seqno.length () - 4);
|
||
|
|
return head+seqno;
|
||
|
|
}
|
||
|
|
public Boolean checkPackID(String packID){
|
||
|
|
int sl=commonUtil.getLabReqpackConut(packID);
|
||
|
|
if (sl>0) return true;
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
public Result checkpackid(String packid) {
|
||
|
|
if (packid.length() < 12) {
|
||
|
|
return new Result("1", "箱码非法,请输入正确的箱码!");
|
||
|
|
}
|
||
|
|
if (!"88".equals(packid.substring(0, 2))) {
|
||
|
|
return new Result("1", "箱码非法,请输入正确的箱码!");
|
||
|
|
}
|
||
|
|
boolean checked =checkPackID(packid);
|
||
|
|
if (checked) {
|
||
|
|
return new Result("1", "此箱码已使用过,不能重复使用,请换一个新的!");
|
||
|
|
}
|
||
|
|
return new Result("0", "");
|
||
|
|
}
|
||
|
|
public Result getpackreq(String sqh){
|
||
|
|
LabReqmain labReqmain=commonUtil.getLabReqmainOne(sqh);
|
||
|
|
String zt=labReqmain.getZt();
|
||
|
|
if(zt==null)return new Result("-1", "条码号错误");
|
||
|
|
zt=zt.trim();
|
||
|
|
switch (zt){
|
||
|
|
case "1":
|
||
|
|
case "0":
|
||
|
|
return new Result("-1", "条码未打印");
|
||
|
|
case "13":
|
||
|
|
return new Result("-1", "标本已送出");
|
||
|
|
case "9":
|
||
|
|
return new Result("-1", "条码已作废");
|
||
|
|
case "2":
|
||
|
|
case "3":
|
||
|
|
case "4":
|
||
|
|
return new Result("-1", "标本已接收");
|
||
|
|
}
|
||
|
|
return new Result("0", "",labReqmain);
|
||
|
|
}
|
||
|
|
public Result printpackid(String ksmc){
|
||
|
|
String packid=getNextPackID();
|
||
|
|
BarCodeParam barCodeParam = new BarCodeParam();
|
||
|
|
barCodeParam.setSqh(packid);
|
||
|
|
barCodeParam.setBrxm("检验样本");
|
||
|
|
barCodeParam.setSfxmmc("样本数量____");
|
||
|
|
barCodeParam.setKsmc(ksmc);
|
||
|
|
return reportUtil.printToPdf(barCodeParam, packid);
|
||
|
|
}
|
||
|
|
public Result packup(List<LabReqpack> labReqpacks){
|
||
|
|
commonUtil.batchInsertLabReqpack(labReqpacks);
|
||
|
|
return new Result("0", "");
|
||
|
|
}
|
||
|
|
}
|