|
|
|
@ -6,11 +6,14 @@ import cn.hutool.json.JSONString;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.foreverwin.mesnac.common.constant.Constants;
|
|
|
|
|
import com.foreverwin.mesnac.common.dto.LabelPrintDto;
|
|
|
|
|
import com.foreverwin.mesnac.common.model.PrintLog;
|
|
|
|
|
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.stereotype.Service;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
@ -39,6 +42,9 @@ public class PrintLogServiceImpl extends ServiceImpl<PrintLogMapper, PrintLog> i
|
|
|
|
|
@Autowired
|
|
|
|
|
private PrintLogMapper printLogMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private PrintLogService printLogService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
|
|
|
|
public void savePrintLog(String site, String user, PrintLog printLog) {
|
|
|
|
@ -54,10 +60,6 @@ public class PrintLogServiceImpl extends ServiceImpl<PrintLogMapper, PrintLog> i
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void labelPrint(String site, String user, List<PrintLog> printList) {
|
|
|
|
|
if (printList == null || printList.size() <= 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<LabelPrintDto> labelPrintDtoList = new ArrayList<>();
|
|
|
|
|
for (PrintLog printLog : printList) {
|
|
|
|
|
LabelPrintDto labelPrintDto = new LabelPrintDto();
|
|
|
|
@ -67,7 +69,32 @@ public class PrintLogServiceImpl extends ServiceImpl<PrintLogMapper, PrintLog> i
|
|
|
|
|
labelPrintDto.setItemDescription(printLog.getItemDescription());
|
|
|
|
|
labelPrintDtoList.add(labelPrintDto);
|
|
|
|
|
}
|
|
|
|
|
String post = HttpUtil.post(printServer, JSON.toJSONString(labelPrintDtoList), 30000);
|
|
|
|
|
/**
|
|
|
|
|
* {"msg":"打印成功","code":0}
|
|
|
|
|
* {"msg":"打印失败","code":500}
|
|
|
|
|
* 根据返回值,更新打印机信息-printName及打印是否成功信息isPrint
|
|
|
|
|
*/
|
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(post);
|
|
|
|
|
String code = jsonObject.getString("code");
|
|
|
|
|
if (code == null){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
List<PrintLog> printLogList = new ArrayList<>();
|
|
|
|
|
if (post.indexOf("500") != -1){
|
|
|
|
|
throw BusinessException.build("打印失败!");
|
|
|
|
|
}
|
|
|
|
|
for (PrintLog printLog : printList) {
|
|
|
|
|
PrintLog printLogOne = new PrintLog();
|
|
|
|
|
printLogOne.setHandle(printLog.getHandle());
|
|
|
|
|
printLogOne.setIsPrint("true");
|
|
|
|
|
// 更新日志
|
|
|
|
|
if (printLog.getCategory().equals(Constants.PRINT_TYPE_INV)){
|
|
|
|
|
printLogOne.setPrintName(printLog.getPrintName());
|
|
|
|
|
}
|
|
|
|
|
printLogList.add(printLogOne);
|
|
|
|
|
}
|
|
|
|
|
printLogService.updateBatchById(printLogList);
|
|
|
|
|
|
|
|
|
|
HttpUtil.post(printServer, JSON.toJSONString(labelPrintDtoList), 30000);
|
|
|
|
|
}
|
|
|
|
|
}
|