Commit 27db5714994b98ab29973870dead315dde35793a

Authored by 房远帅
1 parent cb2efb83

采购:过磅码单-打印

@@ -2504,6 +2504,11 @@ CREATE TABLE IF NOT EXISTS `procurement_weighing_ticket` @@ -2504,6 +2504,11 @@ CREATE TABLE IF NOT EXISTS `procurement_weighing_ticket`
2504 `delay_attachment_file_names` text COMMENT '延期说明附件文件名称集合(多文件,逗号分隔)', 2504 `delay_attachment_file_names` text COMMENT '延期说明附件文件名称集合(多文件,逗号分隔)',
2505 `reweigh_attachment_file_ids` text COMMENT '复磅附件文件ID集合(多文件,逗号分隔)', 2505 `reweigh_attachment_file_ids` text COMMENT '复磅附件文件ID集合(多文件,逗号分隔)',
2506 `reweigh_attachment_file_names` text COMMENT '复磅附件文件名称集合(多文件,逗号分隔)', 2506 `reweigh_attachment_file_names` text COMMENT '复磅附件文件名称集合(多文件,逗号分隔)',
  2507 + `weigher_id` varchar(32) DEFAULT NULL COMMENT '供应科计量员ID',
  2508 + `weigher_name` varchar(64) DEFAULT NULL COMMENT '供应科计量员姓名',
  2509 + `quality_inspector_id` varchar(32) DEFAULT NULL COMMENT '分厂质检员ID',
  2510 + `quality_inspector_name` varchar(64) DEFAULT NULL COMMENT '分厂质检员姓名',
  2511 + `driver` varchar(64) DEFAULT NULL COMMENT '驾驶员姓名(上传签字凭证时手动输入)',
2507 `deleted` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否作废/删除 0-有效单 1-作废单(作废单只能查看)', 2512 `deleted` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否作废/删除 0-有效单 1-作废单(作废单只能查看)',
2508 `create_by_id` varchar(32) DEFAULT NULL COMMENT '创建人ID', 2513 `create_by_id` varchar(32) DEFAULT NULL COMMENT '创建人ID',
2509 `create_by` varchar(64) DEFAULT NULL COMMENT '创建人', 2514 `create_by` varchar(64) DEFAULT NULL COMMENT '创建人',
@@ -121,6 +121,21 @@ public class GetProcurementWeighingTicketBo extends BaseBo<ProcurementWeighingTi @@ -121,6 +121,21 @@ public class GetProcurementWeighingTicketBo extends BaseBo<ProcurementWeighingTi
121 @ApiModelProperty("复磅附件文件名称集合") 121 @ApiModelProperty("复磅附件文件名称集合")
122 private String reweighAttachmentFileNames; 122 private String reweighAttachmentFileNames;
123 123
  124 + @ApiModelProperty("供应科计量员ID")
  125 + private String weigherId;
  126 +
  127 + @ApiModelProperty("供应科计量员姓名")
  128 + private String weigherName;
  129 +
  130 + @ApiModelProperty("分厂质检员ID")
  131 + private String qualityInspectorId;
  132 +
  133 + @ApiModelProperty("分厂质检员姓名")
  134 + private String qualityInspectorName;
  135 +
  136 + @ApiModelProperty("驾驶员姓名(上传签字凭证时手动输入)")
  137 + private String driver;
  138 +
124 @ApiModelProperty("是否作废单") 139 @ApiModelProperty("是否作废单")
125 private Boolean deleted; 140 private Boolean deleted;
126 141
@@ -22,6 +22,7 @@ import com.lframework.xingyun.sc.procurement.service.change.ProcurementPlanChang @@ -22,6 +22,7 @@ import com.lframework.xingyun.sc.procurement.service.change.ProcurementPlanChang
22 import com.lframework.xingyun.sc.procurement.service.coordination.CoordinationSummaryApprovalService; 22 import com.lframework.xingyun.sc.procurement.service.coordination.CoordinationSummaryApprovalService;
23 import com.lframework.xingyun.sc.procurement.service.plan.ProcurementPlanService; 23 import com.lframework.xingyun.sc.procurement.service.plan.ProcurementPlanService;
24 import com.lframework.xingyun.sc.procurement.service.replenish.ProcurementPlanReplenishService; 24 import com.lframework.xingyun.sc.procurement.service.replenish.ProcurementPlanReplenishService;
  25 +import com.lframework.xingyun.sc.procurement.service.weighing.ProcurementWeighingTicketService;
25 import com.lframework.xingyun.sc.procurement.vo.change.UpdateProcurementPlanChangeVo; 26 import com.lframework.xingyun.sc.procurement.vo.change.UpdateProcurementPlanChangeVo;
26 import com.lframework.xingyun.sc.service.contract.ContractDistributorStandardService; 27 import com.lframework.xingyun.sc.service.contract.ContractDistributorStandardService;
27 import com.lframework.xingyun.sc.service.customer.CustomerCreditService; 28 import com.lframework.xingyun.sc.service.customer.CustomerCreditService;
@@ -73,6 +74,8 @@ public class FlowTaskServiceImpl implements FlowTaskService { @@ -73,6 +74,8 @@ public class FlowTaskServiceImpl implements FlowTaskService {
73 private ProcurementPlanReplenishService procurementPlanReplenishService; 74 private ProcurementPlanReplenishService procurementPlanReplenishService;
74 @Resource 75 @Resource
75 private CoordinationSummaryApprovalService coordinationSummaryApprovalService; 76 private CoordinationSummaryApprovalService coordinationSummaryApprovalService;
  77 + @Resource
  78 + private ProcurementWeighingTicketService procurementWeighingTicketService;
76 79
77 80
78 @OpLog(type = OtherOpLogType.class, name = "修改客户资信,ID:{}", params = {"#id"}) 81 @OpLog(type = OtherOpLogType.class, name = "修改客户资信,ID:{}", params = {"#id"})
@@ -478,6 +481,12 @@ public class FlowTaskServiceImpl implements FlowTaskService { @@ -478,6 +481,12 @@ public class FlowTaskServiceImpl implements FlowTaskService {
478 coordinationSummaryApprovalService.updateNoFlowInstance(map); 481 coordinationSummaryApprovalService.updateNoFlowInstance(map);
479 } 482 }
480 483
  484 + @Transactional(rollbackFor = Exception.class)
  485 + @Override
  486 + public void updateWeighingTicketApprovalMap(Map<String, Object> map) {
  487 + procurementWeighingTicketService.updateNoFlowInstance(map);
  488 + }
  489 +
481 @Override 490 @Override
482 public Map<String, Object> findById(String s) { 491 public Map<String, Object> findById(String s) {
483 ProductSampleConfirmationSlip slip = productSampleConfirmationSlipService.findById(s); 492 ProductSampleConfirmationSlip slip = productSampleConfirmationSlipService.findById(s);
1 package com.lframework.xingyun.sc.procurement.controller.weighing; 1 package com.lframework.xingyun.sc.procurement.controller.weighing;
2 2
  3 +import cn.hutool.core.convert.NumberChineseFormatter;
  4 +import cn.hutool.core.io.resource.ClassPathResource;
3 import com.lframework.starter.web.core.annotations.security.HasPermission; 5 import com.lframework.starter.web.core.annotations.security.HasPermission;
4 import com.lframework.starter.web.core.components.resp.InvokeResult; 6 import com.lframework.starter.web.core.components.resp.InvokeResult;
5 import com.lframework.starter.web.core.components.resp.InvokeResultBuilder; 7 import com.lframework.starter.web.core.components.resp.InvokeResultBuilder;
6 import com.lframework.starter.web.core.components.resp.PageResult; 8 import com.lframework.starter.web.core.components.resp.PageResult;
7 import com.lframework.starter.web.core.controller.DefaultBaseController; 9 import com.lframework.starter.web.core.controller.DefaultBaseController;
  10 +import com.lframework.xingyun.sc.bo.procurement.GetProcurementWeighingTicketApplyLineBo;
8 import com.lframework.xingyun.sc.bo.procurement.GetProcurementWeighingTicketBo; 11 import com.lframework.xingyun.sc.bo.procurement.GetProcurementWeighingTicketBo;
9 import com.lframework.xingyun.sc.bo.procurement.WeighingTicketPlanBo; 12 import com.lframework.xingyun.sc.bo.procurement.WeighingTicketPlanBo;
10 import com.lframework.xingyun.sc.procurement.entity.ProcurementPlanLine; 13 import com.lframework.xingyun.sc.procurement.entity.ProcurementPlanLine;
@@ -15,14 +18,38 @@ import com.lframework.xingyun.sc.procurement.vo.weighing.QueryProcurementWeighin @@ -15,14 +18,38 @@ import com.lframework.xingyun.sc.procurement.vo.weighing.QueryProcurementWeighin
15 import com.lframework.xingyun.sc.procurement.vo.weighing.QueryWeighingTicketPlanVo; 18 import com.lframework.xingyun.sc.procurement.vo.weighing.QueryWeighingTicketPlanVo;
16 import com.lframework.xingyun.sc.procurement.vo.weighing.UpdateProcurementWeighingTicketVo; 19 import com.lframework.xingyun.sc.procurement.vo.weighing.UpdateProcurementWeighingTicketVo;
17 import com.lframework.xingyun.sc.procurement.vo.weighing.WeighingTicketAttachmentVo; 20 import com.lframework.xingyun.sc.procurement.vo.weighing.WeighingTicketAttachmentVo;
  21 +import com.lframework.xingyun.sc.utils.ExcelUtil;
  22 +import com.lframework.xingyun.sc.utils.ResponseUtil;
18 import io.swagger.annotations.Api; 23 import io.swagger.annotations.Api;
19 import io.swagger.annotations.ApiImplicitParam; 24 import io.swagger.annotations.ApiImplicitParam;
20 import io.swagger.annotations.ApiOperation; 25 import io.swagger.annotations.ApiOperation;
  26 +import java.io.File;
  27 +import java.io.FileInputStream;
  28 +import java.io.FileNotFoundException;
  29 +import java.io.FileOutputStream;
  30 +import java.io.IOException;
  31 +import java.io.InputStream;
  32 +import java.math.BigDecimal;
  33 +import java.nio.file.Files;
  34 +import java.time.format.DateTimeFormatter;
  35 +import java.util.HashMap;
21 import java.util.List; 36 import java.util.List;
  37 +import java.util.Map;
  38 +import javax.servlet.http.HttpServletResponse;
22 import javax.annotation.Resource; 39 import javax.annotation.Resource;
23 import javax.validation.Valid; 40 import javax.validation.Valid;
24 import javax.validation.constraints.NotBlank; 41 import javax.validation.constraints.NotBlank;
25 import lombok.extern.slf4j.Slf4j; 42 import lombok.extern.slf4j.Slf4j;
  43 +import org.apache.poi.ss.usermodel.Cell;
  44 +import org.apache.poi.ss.usermodel.CellStyle;
  45 +import org.apache.poi.ss.usermodel.CellType;
  46 +import org.apache.poi.ss.usermodel.HorizontalAlignment;
  47 +import org.apache.poi.ss.usermodel.Row;
  48 +import org.apache.poi.ss.usermodel.Sheet;
  49 +import org.apache.poi.ss.usermodel.VerticalAlignment;
  50 +import org.apache.poi.ss.usermodel.Workbook;
  51 +import org.apache.poi.ss.util.CellRangeAddress;
  52 +import org.apache.poi.xssf.usermodel.XSSFWorkbook;
26 import org.springframework.validation.annotation.Validated; 53 import org.springframework.validation.annotation.Validated;
27 import org.springframework.web.bind.annotation.GetMapping; 54 import org.springframework.web.bind.annotation.GetMapping;
28 import org.springframework.web.bind.annotation.PostMapping; 55 import org.springframework.web.bind.annotation.PostMapping;
@@ -113,7 +140,7 @@ public class ProcurementWeighingTicketController extends DefaultBaseController { @@ -113,7 +140,7 @@ public class ProcurementWeighingTicketController extends DefaultBaseController {
113 @HasPermission({"warehouse-manage:weight-ticket:uploadSigned"}) 140 @HasPermission({"warehouse-manage:weight-ticket:uploadSigned"})
114 @PutMapping("/attachment/sign") 141 @PutMapping("/attachment/sign")
115 public InvokeResult<Void> uploadSignAttachment(@RequestBody @Valid WeighingTicketAttachmentVo vo) { 142 public InvokeResult<Void> uploadSignAttachment(@RequestBody @Valid WeighingTicketAttachmentVo vo) {
116 - procurementWeighingTicketService.uploadSignAttachment(vo.getId(), vo.getFileIds(), vo.getFileNames()); 143 + procurementWeighingTicketService.uploadSignAttachment(vo.getId(), vo.getFileIds(), vo.getFileNames(), vo.getDriver());
117 return InvokeResultBuilder.success(); 144 return InvokeResultBuilder.success();
118 } 145 }
119 146
@@ -141,4 +168,226 @@ public class ProcurementWeighingTicketController extends DefaultBaseController { @@ -141,4 +168,226 @@ public class ProcurementWeighingTicketController extends DefaultBaseController {
141 procurementWeighingTicketService.delete(id); 168 procurementWeighingTicketService.delete(id);
142 return InvokeResultBuilder.success(); 169 return InvokeResultBuilder.success();
143 } 170 }
  171 +
  172 + /**
  173 + * 打印过磅码单
  174 + *
  175 + * @param exportType 导出类型 PDF-导出PDF文件,其他/默认-导出Excel文件
  176 + * @param templateType 模板类型 NO_REMARK-无备注,其他/默认-有备注
  177 + */
  178 + @ApiOperation("打印过磅码单(exportType=PDF导出PDF文件,默认Excel;templateType=NO_REMARK无备注模板,默认有备注)")
  179 + @HasPermission({"warehouse-manage:weight-ticket:print"})
  180 + @GetMapping("/export")
  181 + public void export(@NotBlank(message = "ID不能为空!") String id, String exportType, String templateType,
  182 + HttpServletResponse response) throws IOException {
  183 +
  184 + GetProcurementWeighingTicketBo data = procurementWeighingTicketService.findDetail(id);
  185 +
  186 + // 模板类型:NO_REMARK-无备注(procurementWeighingTicket2.xlsx),默认有备注(procurementWeighingTicket.xlsx)
  187 + String templateFile = "NO_REMARK".equals(templateType)
  188 + ? "templates/procurementWeighingTicket2.xlsx" : "templates/procurementWeighingTicket.xlsx";
  189 +
  190 + try {
  191 + try (InputStream inputStream = new ClassPathResource(templateFile).getStream();
  192 + Workbook workbook = new XSSFWorkbook(inputStream)) {
  193 + Sheet sheet = workbook.getSheetAt(0);
  194 +
  195 + // 申请数量:一行两条(品种代号、数量),不足两条保留一行,超出向下叠加
  196 + List<GetProcurementWeighingTicketApplyLineBo> applyLines = data.getApplyLines();
  197 + final int APPLY_START_ROW = 4; // 第5行(Excel) = 索引4,模板预留1行
  198 + int dataSize = applyLines == null ? 0 : applyLines.size();
  199 + int needRows = Math.max(1, (dataSize + 1) / 2);
  200 + int needInsert = needRows - 1;
  201 + if (needInsert > 0) {
  202 + int shiftStart = APPLY_START_ROW + 1;
  203 + int shiftEnd = sheet.getLastRowNum();
  204 + if (shiftEnd >= shiftStart) {
  205 + sheet.shiftRows(shiftStart, shiftEnd, needInsert, true, true);
  206 + }
  207 + // 复制模板申请数量行样式到新插入的每一行
  208 + Row templateRow = sheet.getRow(APPLY_START_ROW);
  209 + for (int k = 1; k <= needInsert; k++) {
  210 + int newRowIdx = APPLY_START_ROW + k;
  211 + Row newRow = sheet.getRow(newRowIdx);
  212 + if (newRow == null) {
  213 + newRow = sheet.createRow(newRowIdx);
  214 + }
  215 + if (templateRow != null) {
  216 + newRow.setHeight(templateRow.getHeight());
  217 + for (int c = 0; c < 8; c++) {
  218 + Cell tc = templateRow.getCell(c);
  219 + Cell nc = newRow.getCell(c);
  220 + if (nc == null) {
  221 + nc = newRow.createCell(c);
  222 + }
  223 + if (tc != null) {
  224 + nc.setCellStyle(tc.getCellStyle());
  225 + }
  226 + }
  227 + // 新行补充合并单元格,与模板申请数量行一致:C:D(数量1)、E:F(品种代号2)、G:H(数量2)
  228 + sheet.addMergedRegion(new CellRangeAddress(newRowIdx, newRowIdx, 2, 3));
  229 + sheet.addMergedRegion(new CellRangeAddress(newRowIdx, newRowIdx, 4, 5));
  230 + sheet.addMergedRegion(new CellRangeAddress(newRowIdx, newRowIdx, 6, 7));
  231 + }
  232 + }
  233 + // "申请数量"标签(A列)纵向合并到最后一行申请行
  234 + sheet.addMergedRegion(new CellRangeAddress(APPLY_START_ROW, APPLY_START_ROW + needRows - 1, 0, 0));
  235 + // 合并后"申请数量"标签设置水平/垂直居中(克隆原样式避免破坏边框)
  236 + Cell aCell = sheet.getRow(APPLY_START_ROW).getCell(0);
  237 + if (aCell != null) {
  238 + CellStyle centerStyle = workbook.createCellStyle();
  239 + centerStyle.cloneStyleFrom(aCell.getCellStyle());
  240 + centerStyle.setAlignment(HorizontalAlignment.CENTER);
  241 + centerStyle.setVerticalAlignment(VerticalAlignment.CENTER);
  242 + for (int r = APPLY_START_ROW; r <= APPLY_START_ROW + needRows - 1; r++) {
  243 + Cell ac = sheet.getRow(r).getCell(0);
  244 + if (ac != null) {
  245 + ac.setCellStyle(centerStyle);
  246 + }
  247 + }
  248 + }
  249 + }
  250 +
  251 + for (int i = 0; i < dataSize; i++) {
  252 + GetProcurementWeighingTicketApplyLineBo line = applyLines.get(i);
  253 + int rowIdx = APPLY_START_ROW + i / 2;
  254 + if (i % 2 == 0) {
  255 + // 第1条:B列品种代号、C列数量(C:D合并)
  256 + ExcelUtil.setCellValue(sheet, rowIdx, 1, nvl(line.getCategory()));
  257 + ExcelUtil.setCellValue(sheet, rowIdx, 2, line.getQuantity());
  258 + } else {
  259 + // 第2条:E列品种代号(E:F合并)、G列数量(G:H合并)
  260 + ExcelUtil.setCellValue(sheet, rowIdx, 4, nvl(line.getCategory()));
  261 + ExcelUtil.setCellValue(sheet, rowIdx, 6, line.getQuantity());
  262 + }
  263 + }
  264 +
  265 + // 占位符替换
  266 + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
  267 + Map<String, Object> dataMap = new HashMap<>();
  268 + // 日期只取年月日
  269 + dataMap.put("firstGrossWeightTime",
  270 + data.getFirstGrossWeightTime() == null ? "" : data.getFirstGrossWeightTime().format(dateFormatter));
  271 + dataMap.put("supplierName", nvl(data.getSupplierName()));
  272 + dataMap.put("code", nvl(data.getCode()));
  273 + dataMap.put("receiveUnitName", nvl(data.getReceiveUnitName()));
  274 + dataMap.put("materialName", nvl(data.getMaterialName()));
  275 + dataMap.put("totalGrossWeight", formatDecimal(data.getTotalGrossWeight()));
  276 + dataMap.put("actualImpurityWeight", formatDecimal(data.getActualImpurityWeight()));
  277 + dataMap.put("netWeight", formatDecimal(data.getNetWeight()));
  278 + dataMap.put("netWeightUpper", buildNetWeightUpper(data.getNetWeight()));
  279 + dataMap.put("documentRemark", nvl(data.getDocumentRemark()));
  280 + // 审核人:供料复核=驾驶员,收料复核=分厂质检员,监磅=供应科计量员
  281 + dataMap.put("driver", nvl(data.getDriver()));
  282 + dataMap.put("qualityInspectorName", nvl(data.getQualityInspectorName()));
  283 + dataMap.put("weigherName", nvl(data.getWeigherName()));
  284 + dataMap.put("createBy", nvl(data.getCreateBy()));
  285 + processTemplateSheet(sheet, dataMap);
  286 +
  287 + if ("PDF".equals(exportType)) {
  288 + // 导出 PDF:先写临时 .xlsx 文件,再调 LibreOffice 转换输出
  289 + ResponseUtil.setPDFResponseHead(response, nvl(data.getCode()) + "-过磅码单.pdf");
  290 +
  291 + File tempExcel = File.createTempFile("weighing_ticket_" + nvl(data.getCode()), ".xlsx");
  292 + try {
  293 + try (FileOutputStream fos = new FileOutputStream(tempExcel)) {
  294 + workbook.write(fos);
  295 + }
  296 + // 调用 LibreOffice 转 PDF
  297 + File pdfFile = ExcelUtil.convertExcelToPdf(tempExcel,
  298 + "/usr/bin/libreoffice --headless --convert-to pdf --outdir %s %s");
  299 + try (InputStream pdfIn = new FileInputStream(pdfFile)) {
  300 + byte[] buffer = new byte[8192];
  301 + int len;
  302 + while ((len = pdfIn.read(buffer)) != -1) {
  303 + response.getOutputStream().write(buffer, 0, len);
  304 + }
  305 + response.getOutputStream().flush();
  306 + } finally {
  307 + if (pdfFile != null && pdfFile.exists()) {
  308 + Files.delete(pdfFile.toPath());
  309 + }
  310 + }
  311 + } finally {
  312 + if (tempExcel != null && tempExcel.exists()) {
  313 + Files.delete(tempExcel.toPath());
  314 + }
  315 + }
  316 + } else {
  317 + // 默认导出 Excel
  318 + ResponseUtil.setExcelResponseHead(response, nvl(data.getCode()) + "-过磅码单.xlsx");
  319 + workbook.write(response.getOutputStream());
  320 + response.getOutputStream().flush();
  321 + }
  322 + } catch (FileNotFoundException e) {
  323 + throw new RuntimeException("模板文件不存在: " + templateFile, e);
  324 + } catch (IOException e) {
  325 + throw new RuntimeException("无法读取模板文件: " + templateFile, e);
  326 + }
  327 + } catch (Exception e) {
  328 + log.error("打印过磅码单失败, id={}, {}", id, e.getMessage(), e);
  329 + }
  330 + }
  331 +
  332 + /**
  333 + * 按单 Sheet 替换模板占位符(${...} / #{...})
  334 + */
  335 + private void processTemplateSheet(Sheet sheet, Map<String, Object> dataMap) {
  336 + for (Row row : sheet) {
  337 + for (Cell cell : row) {
  338 + if (cell.getCellTypeEnum() == CellType.STRING) {
  339 + String cellValue = cell.getStringCellValue();
  340 + String newValue = replacePlaceholders(cellValue, dataMap);
  341 + if (!cellValue.equals(newValue)) {
  342 + cell.setCellValue(newValue);
  343 + }
  344 + }
  345 + }
  346 + }
  347 + }
  348 +
  349 + private String replacePlaceholders(String text, Map<String, Object> dataMap) {
  350 + if (text == null || text.isEmpty()) {
  351 + return text;
  352 + }
  353 +
  354 + String result = text;
  355 + for (Map.Entry<String, Object> entry : dataMap.entrySet()) {
  356 + String placeholder = "${" + entry.getKey() + "}";
  357 + String value = entry.getValue() != null ? entry.getValue().toString() : "";
  358 + value = value.replace("\\n", "\n");
  359 + result = result.replace(placeholder, value);
  360 + }
  361 +
  362 + for (Map.Entry<String, Object> entry : dataMap.entrySet()) {
  363 + String placeholder = "#{" + entry.getKey() + "}";
  364 + String value = entry.getValue() != null ? entry.getValue().toString() : "";
  365 + value = value.replace("\\n", "\n");
  366 + result = result.replace(placeholder, value);
  367 + }
  368 +
  369 + return result;
  370 + }
  371 +
  372 + /**
  373 + * 净重大写:按模板"X万X仟X佰X拾X点X公斤"格式由净重自动生成(壹贰叁大写、位名万仟佰拾、小数读"点"、单位公斤)
  374 + */
  375 + private String buildNetWeightUpper(BigDecimal netWeight) {
  376 + if (netWeight == null) {
  377 + return "";
  378 + }
  379 + // isUseTraditional=true 输出大写(壹贰叁…),位名与模板一致(万仟佰拾),小数读"点"
  380 + return NumberChineseFormatter.format(netWeight.doubleValue(), true) + "公斤";
  381 + }
  382 +
  383 + private String nvl(Object o) {
  384 + return o == null ? "" : o.toString();
  385 + }
  386 +
  387 + private String formatDecimal(BigDecimal bd) {
  388 + if (bd == null) {
  389 + return "";
  390 + }
  391 + return bd.stripTrailingZeros().toPlainString();
  392 + }
144 } 393 }
@@ -191,6 +191,31 @@ public class ProcurementWeighingTicket extends BaseEntity implements BaseDto { @@ -191,6 +191,31 @@ public class ProcurementWeighingTicket extends BaseEntity implements BaseDto {
191 private String reweighAttachmentFileNames; 191 private String reweighAttachmentFileNames;
192 192
193 /** 193 /**
  194 + * 供应科计量员ID
  195 + */
  196 + private String weigherId;
  197 +
  198 + /**
  199 + * 供应科计量员姓名
  200 + */
  201 + private String weigherName;
  202 +
  203 + /**
  204 + * 分厂质检员ID
  205 + */
  206 + private String qualityInspectorId;
  207 +
  208 + /**
  209 + * 分厂质检员姓名
  210 + */
  211 + private String qualityInspectorName;
  212 +
  213 + /**
  214 + * 驾驶员姓名(上传签字凭证时手动输入)
  215 + */
  216 + private String driver;
  217 +
  218 + /**
194 * 是否作废/删除 0-有效单 1-作废单(作废单只能查看) 219 * 是否作废/删除 0-有效单 1-作废单(作废单只能查看)
195 */ 220 */
196 private Boolean deleted; 221 private Boolean deleted;
@@ -29,6 +29,7 @@ import com.lframework.xingyun.sc.bo.procurement.GetProcurementWeighingTicketLine @@ -29,6 +29,7 @@ import com.lframework.xingyun.sc.bo.procurement.GetProcurementWeighingTicketLine
29 import com.lframework.xingyun.sc.bo.procurement.GetProcurementWeighingTicketPlanBo; 29 import com.lframework.xingyun.sc.bo.procurement.GetProcurementWeighingTicketPlanBo;
30 import com.lframework.xingyun.sc.bo.procurement.WeighingTicketPlanBo; 30 import com.lframework.xingyun.sc.bo.procurement.WeighingTicketPlanBo;
31 import com.lframework.xingyun.sc.procurement.entity.ProcurementPlan; 31 import com.lframework.xingyun.sc.procurement.entity.ProcurementPlan;
  32 +import com.lframework.xingyun.sc.procurement.entity.ProcurementPlanChange;
32 import com.lframework.xingyun.sc.procurement.entity.ProcurementPlanLine; 33 import com.lframework.xingyun.sc.procurement.entity.ProcurementPlanLine;
33 import com.lframework.xingyun.sc.procurement.entity.weighing.ProcurementWeighingTicket; 34 import com.lframework.xingyun.sc.procurement.entity.weighing.ProcurementWeighingTicket;
34 import com.lframework.xingyun.sc.procurement.entity.weighing.ProcurementWeighingTicketApplyLine; 35 import com.lframework.xingyun.sc.procurement.entity.weighing.ProcurementWeighingTicketApplyLine;
@@ -360,6 +361,62 @@ public class ProcurementWeighingTicketServiceImpl @@ -360,6 +361,62 @@ public class ProcurementWeighingTicketServiceImpl
360 361
361 @Override 362 @Override
362 @Transactional(rollbackFor = Exception.class) 363 @Transactional(rollbackFor = Exception.class)
  364 + public void updateNoFlowInstance(Map<String, Object> map) {
  365 + try {
  366 + //流程编码
  367 + Object n = map.get("nodeCode");
  368 + String nodeCode = n == null ? null : String.valueOf(n);
  369 +
  370 + // 审核状态
  371 + Object examStatusObj = map.get("examStatus");
  372 + String examStatus = examStatusObj == null ? null : String.valueOf(examStatusObj);
  373 +
  374 + // 业务ID(过磅码单ID),兼容前端流程回调 variables 子 map 包裹
  375 + String bizId = null;
  376 + Object bizIdObj = map.get("bizId");
  377 + if (bizIdObj != null) {
  378 + bizId = String.valueOf(bizIdObj);
  379 + } else {
  380 + Object varsObj = map.get("variables");
  381 + if (varsObj instanceof Map) {
  382 + Object bizIdInVar = ((Map<?, ?>) varsObj).get("bizId");
  383 + if (bizIdInVar != null) {
  384 + bizId = String.valueOf(bizIdInVar);
  385 + }
  386 + }
  387 + }
  388 +
  389 + if (StringUtil.isBlank(bizId)) {
  390 + throw new DefaultClientException("过磅码单审核回调缺少业务ID!");
  391 + }
  392 + if ("PASS".equals(examStatus)) {
  393 + // 司磅员节点(供应科计量员审批):回填司磅员
  394 + boolean weigherNode = "weighing_ticket_gykjly".equals(nodeCode);
  395 + // 质检科主任节点(一/二/三分厂及总部质检科主任审批):回填质检员
  396 + boolean inspectorNode = "weighing_ticket_yfcckzjy".equals(nodeCode)
  397 + || "weighing_ticket_efcckzjy".equals(nodeCode)
  398 + || "weighing_ticket_sfcckzjy".equals(nodeCode)
  399 + || "weighing_ticket_ztfcckzjy".equals(nodeCode);
  400 +
  401 + if (weigherNode || inspectorNode) {
  402 + this.update(Wrappers.lambdaUpdate(ProcurementWeighingTicket.class)
  403 + .set(weigherNode, ProcurementWeighingTicket::getWeigherName, SecurityUtil.getCurrentUser().getName())
  404 + .set(weigherNode, ProcurementWeighingTicket::getWeigherId, SecurityUtil.getCurrentUser().getId())
  405 + .set(inspectorNode, ProcurementWeighingTicket::getQualityInspectorName, SecurityUtil.getCurrentUser().getName())
  406 + .set(inspectorNode, ProcurementWeighingTicket::getQualityInspectorId, SecurityUtil.getCurrentUser().getId())
  407 + .eq(ProcurementWeighingTicket::getId, bizId));
  408 +
  409 + // 回填操作日志
  410 + OpLogUtil.setVariable("id", bizId);
  411 + }
  412 + }
  413 + } catch (Exception ex) {
  414 + ex.printStackTrace();
  415 + }
  416 + }
  417 +
  418 + @Override
  419 + @Transactional(rollbackFor = Exception.class)
363 public void recalcPlanDiffFlags(List<String> planIds) { 420 public void recalcPlanDiffFlags(List<String> planIds) {
364 // 计算逻辑统一收敛在采购计划侧(避免多处维护口径) 421 // 计算逻辑统一收敛在采购计划侧(避免多处维护口径)
365 procurementPlanService.recalcDiffFlags(planIds); 422 procurementPlanService.recalcDiffFlags(planIds);
@@ -380,7 +437,7 @@ public class ProcurementWeighingTicketServiceImpl @@ -380,7 +437,7 @@ public class ProcurementWeighingTicketServiceImpl
380 @Override 437 @Override
381 @Transactional(rollbackFor = Exception.class) 438 @Transactional(rollbackFor = Exception.class)
382 @OpLog(type = OtherOpLogType.class, name = "上传过磅码单签字凭证,ID:{}", params = {"#id"}) 439 @OpLog(type = OtherOpLogType.class, name = "上传过磅码单签字凭证,ID:{}", params = {"#id"})
383 - public void uploadSignAttachment(String id, String fileIds, String fileNames) { 440 + public void uploadSignAttachment(String id, String fileIds, String fileNames, String driver) {
384 Assert.notBlank(id); 441 Assert.notBlank(id);
385 442
386 ProcurementWeighingTicket entity = this.getById(id); 443 ProcurementWeighingTicket entity = this.getById(id);
@@ -397,6 +454,7 @@ public class ProcurementWeighingTicketServiceImpl @@ -397,6 +454,7 @@ public class ProcurementWeighingTicketServiceImpl
397 appendFiles(entity.getSignAttachmentFileIds(), fileIds)) 454 appendFiles(entity.getSignAttachmentFileIds(), fileIds))
398 .set(ProcurementWeighingTicket::getSignAttachmentFileNames, 455 .set(ProcurementWeighingTicket::getSignAttachmentFileNames,
399 appendFiles(entity.getSignAttachmentFileNames(), fileNames)) 456 appendFiles(entity.getSignAttachmentFileNames(), fileNames))
  457 + .set(ProcurementWeighingTicket::getDriver, driver)
400 .eq(ProcurementWeighingTicket::getId, id); 458 .eq(ProcurementWeighingTicket::getId, id);
401 459
402 // 完成时间:以第一次上传签字凭证的时间为准 460 // 完成时间:以第一次上传签字凭证的时间为准
@@ -11,6 +11,7 @@ import com.lframework.xingyun.sc.procurement.vo.weighing.QueryProcurementWeighin @@ -11,6 +11,7 @@ import com.lframework.xingyun.sc.procurement.vo.weighing.QueryProcurementWeighin
11 import com.lframework.xingyun.sc.procurement.vo.weighing.QueryWeighingTicketPlanVo; 11 import com.lframework.xingyun.sc.procurement.vo.weighing.QueryWeighingTicketPlanVo;
12 import com.lframework.xingyun.sc.procurement.vo.weighing.UpdateProcurementWeighingTicketVo; 12 import com.lframework.xingyun.sc.procurement.vo.weighing.UpdateProcurementWeighingTicketVo;
13 import java.util.List; 13 import java.util.List;
  14 +import java.util.Map;
14 15
15 public interface ProcurementWeighingTicketService extends BaseMpService<ProcurementWeighingTicket> { 16 public interface ProcurementWeighingTicketService extends BaseMpService<ProcurementWeighingTicket> {
16 17
@@ -59,6 +60,13 @@ public interface ProcurementWeighingTicketService extends BaseMpService<Procurem @@ -59,6 +60,13 @@ public interface ProcurementWeighingTicketService extends BaseMpService<Procurem
59 void updateApprovalStatus(String id, String approvalStatus); 60 void updateApprovalStatus(String id, String approvalStatus);
60 61
61 /** 62 /**
  63 + * BPM 流程审批回调(无流程实例模式,由 FlowTaskService 分发)
  64 + *
  65 + * @param map 回调参数:bizId-过磅码单ID,examStatus-审核状态(PASS/REFUSE),兼容 variables 子 map 包裹
  66 + */
  67 + void updateNoFlowInstance(Map<String, Object> map);
  68 +
  69 + /**
62 * 重算采购计划差值标识(多x吨/少x吨) 70 * 重算采购计划差值标识(多x吨/少x吨)
63 * 口径:已过磅数量 = 关联该计划的、未作废且已完成(完成时间不为空)的过磅码单的过磅明细数量合计(公斤转吨) 71 * 口径:已过磅数量 = 关联该计划的、未作废且已完成(完成时间不为空)的过磅码单的过磅明细数量合计(公斤转吨)
64 * 差值 = 计划总数量 - 已过磅数量;计划总数量10吨以内容差1吨、10吨以上容差2吨,差值绝对值在容差内不显示 72 * 差值 = 计划总数量 - 已过磅数量;计划总数量10吨以内容差1吨、10吨以上容差2吨,差值绝对值在容差内不显示
@@ -69,8 +77,10 @@ public interface ProcurementWeighingTicketService extends BaseMpService<Procurem @@ -69,8 +77,10 @@ public interface ProcurementWeighingTicketService extends BaseMpService<Procurem
69 77
70 /** 78 /**
71 * 上传签字凭证(可多次,首次上传时锁定过磅重量) 79 * 上传签字凭证(可多次,首次上传时锁定过磅重量)
  80 + *
  81 + * @param driver 驾驶员姓名(上传人手动输入,可空)
72 */ 82 */
73 - void uploadSignAttachment(String id, String fileIds, String fileNames); 83 + void uploadSignAttachment(String id, String fileIds, String fileNames, String driver);
74 84
75 /** 85 /**
76 * 上传延期说明附件 86 * 上传延期说明附件
@@ -23,4 +23,7 @@ public class WeighingTicketAttachmentVo implements BaseVo, Serializable { @@ -23,4 +23,7 @@ public class WeighingTicketAttachmentVo implements BaseVo, Serializable {
23 23
24 @ApiModelProperty("附件文件名称集合(多文件,逗号分隔)") 24 @ApiModelProperty("附件文件名称集合(多文件,逗号分隔)")
25 private String fileNames; 25 private String fileNames;
  26 +
  27 + @ApiModelProperty("驾驶员姓名(仅上传签字凭证时手动输入)")
  28 + private String driver;
26 } 29 }
@@ -37,6 +37,11 @@ @@ -37,6 +37,11 @@
37 <result column="delay_attachment_file_names" property="delayAttachmentFileNames"/> 37 <result column="delay_attachment_file_names" property="delayAttachmentFileNames"/>
38 <result column="reweigh_attachment_file_ids" property="reweighAttachmentFileIds"/> 38 <result column="reweigh_attachment_file_ids" property="reweighAttachmentFileIds"/>
39 <result column="reweigh_attachment_file_names" property="reweighAttachmentFileNames"/> 39 <result column="reweigh_attachment_file_names" property="reweighAttachmentFileNames"/>
  40 + <result column="weigher_id" property="weigherId"/>
  41 + <result column="weigher_name" property="weigherName"/>
  42 + <result column="quality_inspector_id" property="qualityInspectorId"/>
  43 + <result column="quality_inspector_name" property="qualityInspectorName"/>
  44 + <result column="driver" property="driver"/>
40 <result column="deleted" property="deleted"/> 45 <result column="deleted" property="deleted"/>
41 <result column="create_by_id" property="createById"/> 46 <result column="create_by_id" property="createById"/>
42 <result column="create_by" property="createBy"/> 47 <result column="create_by" property="createBy"/>
@@ -84,6 +89,11 @@ @@ -84,6 +89,11 @@
84 pwt.delay_attachment_file_names, 89 pwt.delay_attachment_file_names,
85 pwt.reweigh_attachment_file_ids, 90 pwt.reweigh_attachment_file_ids,
86 pwt.reweigh_attachment_file_names, 91 pwt.reweigh_attachment_file_names,
  92 + pwt.weigher_id,
  93 + pwt.weigher_name,
  94 + pwt.quality_inspector_id,
  95 + pwt.quality_inspector_name,
  96 + pwt.driver,
87 pwt.deleted, 97 pwt.deleted,
88 pwt.create_by_id, 98 pwt.create_by_id,
89 pwt.create_by, 99 pwt.create_by,