|
|
|
@ -12,16 +12,19 @@ import com.foreverwin.mesnac.common.mapper.PrintLogMapper;
|
|
|
|
|
import com.foreverwin.mesnac.common.service.PrintLogService;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import com.foreverwin.modular.core.exception.BusinessException;
|
|
|
|
|
import com.foreverwin.modular.core.util.CommonMethods;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <p>
|
|
|
|
@ -73,19 +76,9 @@ public class PrintLogServiceImpl extends ServiceImpl<PrintLogMapper, PrintLog> i
|
|
|
|
|
list.get(i).setPrintTemplate(printList.get(i).getPrintTemplate());
|
|
|
|
|
list.get(i).setPrintNum(printList.get(i).getPrintNum());
|
|
|
|
|
}
|
|
|
|
|
String post = HttpUtil.post(printServer, JSON.toJSONString(list), 60000);
|
|
|
|
|
/**
|
|
|
|
|
* {"msg":"打印成功","code":0}
|
|
|
|
|
* {"msg":"打印失败","code":500}
|
|
|
|
|
* 根据返回值,更新打印机信息-printName及打印是否成功信息isPrint
|
|
|
|
|
* */
|
|
|
|
|
|
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(post);
|
|
|
|
|
Integer code = jsonObject.getInteger("code");
|
|
|
|
|
String msg = jsonObject.getString("msg");
|
|
|
|
|
if (code != 0){
|
|
|
|
|
throw BusinessException.build(msg);
|
|
|
|
|
}
|
|
|
|
|
printServer(list);
|
|
|
|
|
|
|
|
|
|
// 更新打印记录:是否已打印、使用的打印机、打印次数
|
|
|
|
|
List<PrintLog> printLogList = new ArrayList<>();
|
|
|
|
|
for (PrintLog printLog : printList) {
|
|
|
|
@ -113,4 +106,66 @@ public class PrintLogServiceImpl extends ServiceImpl<PrintLogMapper, PrintLog> i
|
|
|
|
|
return printLogMapper.getPrintLogListByCondition(printLog);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public LabelPrintDto findSfcPrintInfoBySfc(String sfc) {
|
|
|
|
|
return printLogMapper.findSfcPrintInfoBySfc(sfc,CommonMethods.getSite());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void sfcLabelPrint(Map<String,Object> map) {
|
|
|
|
|
Integer qty = (Integer) map.get("qty");
|
|
|
|
|
List<LabelPrintDto> labelPrintDtoList = (List<LabelPrintDto>) map.get("labelPrintDtoList");
|
|
|
|
|
printServer(labelPrintDtoList);
|
|
|
|
|
// 解决无法获取list中对象的问题
|
|
|
|
|
String parse = JSON.toJSONString(labelPrintDtoList);
|
|
|
|
|
List<LabelPrintDto> labelPrintDtos = JSONObject.parseArray(parse, LabelPrintDto.class);
|
|
|
|
|
// 打印张数
|
|
|
|
|
Integer printNum = 0;
|
|
|
|
|
for (LabelPrintDto labelP:labelPrintDtos) {
|
|
|
|
|
printNum += labelP.getPrintNum();
|
|
|
|
|
}
|
|
|
|
|
LabelPrintDto labelPrintDto = labelPrintDtos.get(0);
|
|
|
|
|
PrintLog printLog = new PrintLog();
|
|
|
|
|
printLog.setCategory(Constants.PRINT_TYPE_SFC_SPE);
|
|
|
|
|
printLog.setSfc(labelPrintDto.getSfc());
|
|
|
|
|
printLog.setSite(CommonMethods.getSite());
|
|
|
|
|
List<PrintLog> printLogListByCondition = printLogService.getPrintLogListByCondition(printLog);
|
|
|
|
|
if (printLogListByCondition.size() == 1){
|
|
|
|
|
PrintLog printLog1 = printLogListByCondition.get(0);
|
|
|
|
|
printLog1.setPrintNum(printNum);
|
|
|
|
|
printLog1.setModifiedDateTime(LocalDateTime.now());
|
|
|
|
|
printLog1.setModifyUser(CommonMethods.getUser());
|
|
|
|
|
printLogService.updateById(printLog1);
|
|
|
|
|
}else{
|
|
|
|
|
labelPrintDto.setQty(BigDecimal.valueOf(qty));
|
|
|
|
|
printLog.setCreateUser(labelPrintDto.getPrintTemplate());
|
|
|
|
|
printLog.setPrintParam(JSON.toJSONString(labelPrintDto));
|
|
|
|
|
printLog.setItem(labelPrintDto.getItem());
|
|
|
|
|
printLog.setPrintName(labelPrintDto.getPrinter());
|
|
|
|
|
printLog.setPrintTemplate(labelPrintDto.getPrintTemplate());
|
|
|
|
|
printLog.setIsPrint("true");
|
|
|
|
|
printLog.setPrintNum(printNum);
|
|
|
|
|
printLog.setHandle(UUID.randomUUID().toString());
|
|
|
|
|
printLog.setCreatedDateTime(LocalDateTime.now());
|
|
|
|
|
printLog.setCreateUser(CommonMethods.getUser());
|
|
|
|
|
printLogService.save(printLog);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void printServer(List<LabelPrintDto> list){
|
|
|
|
|
/*String post = HttpUtil.post(printServer, JSON.toJSONString(list), 60000);
|
|
|
|
|
*//**
|
|
|
|
|
* {"msg":"打印成功","code":0}
|
|
|
|
|
* {"msg":"打印失败","code":500}
|
|
|
|
|
* 根据返回值,更新打印机信息-printName及打印是否成功信息isPrint
|
|
|
|
|
*//*
|
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(post);
|
|
|
|
|
Integer code = jsonObject.getInteger("code");
|
|
|
|
|
String msg = jsonObject.getString("msg");
|
|
|
|
|
if (code != 0){
|
|
|
|
|
throw BusinessException.build(msg);
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|