feat(载具):修改

This commit is contained in:
chengzhaofeng 2024-12-02 17:09:18 +08:00
parent 2bcd2c7422
commit 1a9cfd95dd

View File

@ -29,7 +29,6 @@ import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@ -160,6 +159,7 @@ public class WmsCarrierController {
@ApiOperation(value = "托盘码创建")
public R trayNumberCreate(String printName, String count) {
String site = TenantContextHolder.getTenantId();
String userName = SecurityUtils.getUserName();
List<JSONObject> jsonObjects = new ArrayList<>();
if (StrUtil.isBlank(printName)) {
throw BusinessException.build("打印机名称名称不能为空!");
@ -184,35 +184,32 @@ public class WmsCarrierController {
List<Carrier> carrierByNo = wmsCarrierMapper.findCarrierByNo(String.valueOf(nextNumberResponseId), site);
if (carrierByNo.isEmpty()) {
Carrier carrier = new Carrier();
carrier.setHandle(Carrier.genHandle(site, nextNumberResponseId));
carrier.setCarrier(nextNumberResponseId);
carrier.setDescription("托盘码");
carrier.setStatus("Y");
carrier.setCreator(SecurityUtils.getUserName());
carrier.setCreateTime(LocalDateTime.now());
carrier.setSite(site);
carrier.setCarrierTypeBo(CarrierType.genHandle(site, "TP"));
wmsCarrierService.save(carrier);
}
// 组装打印数据
JSONObject param = new JSONObject();
JSONObject printRequestObj = new JSONObject();
printRequestObj.put("PRINT_SERVER", null);
printRequestObj.put("PRINT_NAME", printName);
printRequestObj.put("LABEL_QTY", Math.toIntExact(1));
printRequestObj.put("TEMPLATE", "TPBatcuNumber01.lab");
printRequestObj.put("batchNumber", nextNumberResponseId);
jsonObjects.add(printRequestObj);
printRequestObj.put("TRANSACTION_ID", UUID.randomUUID().toString());
JSONObject paramMap = new JSONObject();
paramMap.put("batchNumber",nextNumberResponseId);
printRequestObj.put("PRINT_DATA", JSONObject.toJSON(paramMap));
param.put("PRINT_REQUEST", printRequestObj);
jsonObjects.add(param);
}
// 生成托盘码
if (!nextNumberResponseIds.isEmpty()) {
for (JSONObject pintData : jsonObjects) {
// 开个独立的线程,避免阻塞
try {
ThreadPoolUtil.execute(() -> {
remotePrintService.remotePrintSaveLog(pintData);
} catch (Exception e) {
throw BusinessException.build("调用打印失败:" + e.getMessage());
}
});
}
return R.ok(nextNumberResponseIds);
} else {