Commit 91f1bd119a3bf886c269771b323b4806fc5fa5ca

Authored by 房远帅
1 parent db5c391d

采购入库-化验送样单

Showing 15 changed files with 1188 additions and 0 deletions
... ... @@ -2609,3 +2609,31 @@ ALTER TABLE procurement_plan
2609 2609 -- 过磅码单:复磅功能(复磅=新增一张码单关联原单、编号为F+原编号,复磅单审核通过后原码单作废)
2610 2610 ALTER TABLE procurement_weighing_ticket
2611 2611 ADD COLUMN origin_weighing_ticket_id varchar(32) DEFAULT NULL COMMENT '原过磅码单ID(复磅单关联原单,复磅单审核通过后原单作废)' AFTER `id`;
  2612 +
  2613 +-- 化验送样单:过磅码单的下一阶段,取样员对码单过磅品种中的一个品种取样送样(一单关联一个码单、一个品种;一个过磅品种可被化验多次)
  2614 +CREATE TABLE IF NOT EXISTS `procurement_assay_apply`
  2615 +(
  2616 + `id` varchar(32) NOT NULL COMMENT 'ID',
  2617 + `weighing_ticket_id` varchar(32) NOT NULL COMMENT '过磅码单ID(单选,须为审核通过且已上传签字凭证的码单)',
  2618 + `weighing_ticket_code` varchar(50) DEFAULT NULL COMMENT '码单编号(冗余展示)',
  2619 + `workshop_id` varchar(32) DEFAULT NULL COMMENT '分厂ID(取自过磅码单,按分厂划分)',
  2620 + `workshop_name` varchar(200) DEFAULT NULL COMMENT '分厂名称(取自过磅码单)',
  2621 + `procurement_plan_id` varchar(32) DEFAULT NULL COMMENT '采购计划ID(单选,范围为码单关联计划)',
  2622 + `plan_code` varchar(50) DEFAULT NULL COMMENT '计划编号(冗余展示)',
  2623 + `product_id` varchar(32) DEFAULT NULL COMMENT '过磅品种ID(品种关系表ID,单选,范围为所选计划的过磅明细品种)',
  2624 + `product_name` varchar(200) DEFAULT NULL COMMENT '品种名称(冗余展示)',
  2625 + `department` varchar(20) DEFAULT NULL COMMENT '科室 LABORATORY-化验室 METROLOGY-计量室',
  2626 + `approval_status` varchar(50) DEFAULT NULL COMMENT '审核状态 DRAFT-草稿 AUDIT-审核中 PASS-审核通过 REFUSE-已驳回 CANCEL-已取消',
  2627 + `create_by_id` varchar(32) DEFAULT NULL COMMENT '创建人ID',
  2628 + `create_by` varchar(64) DEFAULT NULL COMMENT '创建人',
  2629 + `update_by_id` varchar(32) DEFAULT NULL COMMENT '更新人ID',
  2630 + `update_by` varchar(64) DEFAULT NULL COMMENT '更新人',
  2631 + `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  2632 + `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  2633 + PRIMARY KEY (`id`),
  2634 + KEY `idx_paa_weighing_ticket_id` (`weighing_ticket_id`),
  2635 + KEY `idx_paa_procurement_plan_id` (`procurement_plan_id`),
  2636 + KEY `idx_paa_product_id` (`product_id`),
  2637 + KEY `idx_paa_approval_status` (`approval_status`),
  2638 + KEY `idx_paa_create_time` (`create_time`)
  2639 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='化验送样单';
... ...
  1 +package com.lframework.xingyun.sc.bo.procurement;
  2 +
  3 +import com.fasterxml.jackson.annotation.JsonFormat;
  4 +import com.lframework.starter.common.constants.StringPool;
  5 +import io.swagger.annotations.ApiModelProperty;
  6 +import lombok.Data;
  7 +
  8 +import java.time.LocalDateTime;
  9 +
  10 +/**
  11 + * 化验送样:选择过磅码单弹窗行数据(审核通过且已上传签字凭证的码单)
  12 + */
  13 +@Data
  14 +public class GetAssaySelectableTicketBo {
  15 +
  16 + @ApiModelProperty("过磅码单ID")
  17 + private String id;
  18 +
  19 + @ApiModelProperty("码单编号")
  20 + private String code;
  21 +
  22 + @ApiModelProperty("供料单位名称")
  23 + private String supplierName;
  24 +
  25 + @ApiModelProperty("分厂ID")
  26 + private String workshopId;
  27 +
  28 + @ApiModelProperty("分厂名称")
  29 + private String workshopName;
  30 +
  31 + @ApiModelProperty("完成时间(第一次上传签字凭证时间)")
  32 + @JsonFormat(pattern = StringPool.DATE_TIME_PATTERN)
  33 + private LocalDateTime completeTime;
  34 +
  35 + @ApiModelProperty("创建人")
  36 + private String createBy;
  37 +}
... ...
  1 +package com.lframework.xingyun.sc.bo.procurement;
  2 +
  3 +import io.swagger.annotations.ApiModelProperty;
  4 +import lombok.Data;
  5 +
  6 +import java.util.ArrayList;
  7 +import java.util.List;
  8 +
  9 +/**
  10 + * 化验送样单新增页:根据过磅码单ID带出的计划编号下拉数据(级联第二步)
  11 + */
  12 +@Data
  13 +public class GetAssayTicketDataBo {
  14 +
  15 + @ApiModelProperty("过磅码单ID")
  16 + private String weighingTicketId;
  17 +
  18 + @ApiModelProperty("码单编号")
  19 + private String weighingTicketCode;
  20 +
  21 + @ApiModelProperty("计划编号下拉(码单关联计划)")
  22 + private List<PlanOption> planOptions = new ArrayList<>();
  23 +
  24 + @Data
  25 + public static class PlanOption {
  26 +
  27 + @ApiModelProperty("采购计划ID")
  28 + private String planId;
  29 +
  30 + @ApiModelProperty("计划编号")
  31 + private String planCode;
  32 + }
  33 +
  34 + @Data
  35 + public static class BreedOption {
  36 +
  37 + @ApiModelProperty("过磅品种ID(品种关系表ID)")
  38 + private String productId;
  39 +
  40 + @ApiModelProperty("品种名称")
  41 + private String productName;
  42 + }
  43 +}
... ...
  1 +package com.lframework.xingyun.sc.bo.procurement;
  2 +
  3 +import com.fasterxml.jackson.annotation.JsonFormat;
  4 +import com.lframework.starter.common.constants.StringPool;
  5 +import com.lframework.starter.web.core.bo.BaseBo;
  6 +import com.lframework.xingyun.sc.procurement.entity.weighing.ProcurementAssayApply;
  7 +import io.swagger.annotations.ApiModelProperty;
  8 +import lombok.Data;
  9 +
  10 +import java.time.LocalDateTime;
  11 +
  12 +@Data
  13 +public class GetProcurementAssayApplyBo extends BaseBo<ProcurementAssayApply> {
  14 +
  15 + @ApiModelProperty("ID")
  16 + private String id;
  17 +
  18 + @ApiModelProperty("过磅码单ID")
  19 + private String weighingTicketId;
  20 +
  21 + @ApiModelProperty("码单编号")
  22 + private String weighingTicketCode;
  23 +
  24 + @ApiModelProperty("分厂ID")
  25 + private String workshopId;
  26 +
  27 + @ApiModelProperty("分厂名称")
  28 + private String workshopName;
  29 +
  30 + @ApiModelProperty("分厂编码")
  31 + private String workshopCode;
  32 +
  33 + @ApiModelProperty("采购计划ID")
  34 + private String procurementPlanId;
  35 +
  36 + @ApiModelProperty("计划编号")
  37 + private String planCode;
  38 +
  39 + @ApiModelProperty("过磅品种ID(品种关系表ID)")
  40 + private String productId;
  41 +
  42 + @ApiModelProperty("品种名称")
  43 + private String productName;
  44 +
  45 + @ApiModelProperty("科室 LABORATORY-化验室 METROLOGY-计量室")
  46 + private String department;
  47 +
  48 + @ApiModelProperty("审核状态 DRAFT/AUDIT/PASS/REFUSE/CANCEL")
  49 + private String approvalStatus;
  50 +
  51 + @ApiModelProperty("是否展示审核按钮")
  52 + private Boolean showExamine;
  53 +
  54 + @ApiModelProperty("是否展示审核详情按钮")
  55 + private Boolean showExamineDetail;
  56 +
  57 + @ApiModelProperty("创建人")
  58 + private String createBy;
  59 +
  60 + @ApiModelProperty("创建人ID")
  61 + private String createById;
  62 +
  63 + @ApiModelProperty("创建时间")
  64 + @JsonFormat(pattern = StringPool.DATE_TIME_PATTERN)
  65 + private LocalDateTime createTime;
  66 +
  67 + public GetProcurementAssayApplyBo() {
  68 + super();
  69 + }
  70 +
  71 + public GetProcurementAssayApplyBo(ProcurementAssayApply dto) {
  72 + super(dto);
  73 + }
  74 +}
... ...
... ... @@ -28,6 +28,7 @@ import com.lframework.xingyun.sc.procurement.service.credit.ProcurementForeignTr
28 28 import com.lframework.xingyun.sc.procurement.service.plan.ProcurementPlanService;
29 29 import com.lframework.xingyun.sc.procurement.service.quotation.SalesmanQuotationService;
30 30 import com.lframework.xingyun.sc.procurement.service.replenish.ProcurementPlanReplenishService;
  31 +import com.lframework.xingyun.sc.procurement.service.weighing.ProcurementAssayApplyService;
31 32 import com.lframework.xingyun.sc.procurement.service.weighing.ProcurementWeighingTicketService;
32 33 import com.lframework.xingyun.sc.service.contract.ContractDistributorLineService;
33 34 import com.lframework.xingyun.sc.service.contract.ContractChangeApplicationService;
... ... @@ -174,6 +175,8 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
174 175 private ProcurementContractService procurementContractService;
175 176 @Resource
176 177 private ProcurementWeighingTicketService procurementWeighingTicketService;
  178 + @Resource
  179 + private ProcurementAssayApplyService procurementAssayApplyService;
177 180
178 181
179 182
... ... @@ -282,6 +285,9 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
282 285 case "WEIGHING_RECORD":
283 286 handleWeighingTicketData(flowStatus, businessId);
284 287 break;
  288 + case "ASSAY_APPLY":
  289 + handleAssayApplyData(flowStatus, businessId);
  290 + break;
285 291 default:
286 292 break;
287 293 }
... ... @@ -1248,4 +1254,15 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
1248 1254 procurementWeighingTicketService.updateApprovalStatus(businessId, "REFUSE");
1249 1255 }
1250 1256 }
  1257 +
  1258 + private void handleAssayApplyData(String flowStatus, String businessId) {
  1259 + if (FlowInstanceStatus.APPROVE_PASS.getCode().equals(flowStatus)
  1260 + || FlowInstanceStatus.FINISH.getCode().equals(flowStatus)) {
  1261 + procurementAssayApplyService.updateApprovalStatus(businessId, "PASS");
  1262 + } else if (FlowInstanceStatus.REVOKE.getCode().equals(flowStatus)
  1263 + || FlowInstanceStatus.REFUSE.getCode().equals(flowStatus)
  1264 + || FlowInstanceStatus.TERMINATION.getCode().equals(flowStatus)) {
  1265 + procurementAssayApplyService.updateApprovalStatus(businessId, "REFUSE");
  1266 + }
  1267 + }
1251 1268 }
... ...
  1 +package com.lframework.xingyun.sc.procurement.controller.weighing;
  2 +
  3 +import com.lframework.starter.web.core.annotations.security.HasPermission;
  4 +import com.lframework.starter.web.core.components.resp.InvokeResult;
  5 +import com.lframework.starter.web.core.components.resp.InvokeResultBuilder;
  6 +import com.lframework.starter.web.core.components.resp.PageResult;
  7 +import com.lframework.starter.web.core.controller.DefaultBaseController;
  8 +import com.lframework.starter.web.core.utils.PageResultUtil;
  9 +import com.lframework.xingyun.sc.bo.procurement.GetAssaySelectableTicketBo;
  10 +import com.lframework.xingyun.sc.bo.procurement.GetAssayTicketDataBo;
  11 +import com.lframework.xingyun.sc.bo.procurement.GetProcurementAssayApplyBo;
  12 +import com.lframework.xingyun.sc.procurement.entity.weighing.ProcurementAssayApply;
  13 +import com.lframework.xingyun.sc.procurement.service.weighing.ProcurementAssayApplyService;
  14 +import com.lframework.xingyun.sc.procurement.vo.weighing.CreateProcurementAssayApplyVo;
  15 +import com.lframework.xingyun.sc.procurement.vo.weighing.QueryAssaySelectableTicketVo;
  16 +import com.lframework.xingyun.sc.procurement.vo.weighing.QueryProcurementAssayApplyVo;
  17 +import com.lframework.xingyun.sc.procurement.vo.weighing.UpdateProcurementAssayApplyVo;
  18 +import io.swagger.annotations.Api;
  19 +import io.swagger.annotations.ApiImplicitParam;
  20 +import io.swagger.annotations.ApiImplicitParams;
  21 +import io.swagger.annotations.ApiOperation;
  22 +import java.util.List;
  23 +import java.util.stream.Collectors;
  24 +import javax.annotation.Resource;
  25 +import javax.validation.Valid;
  26 +import javax.validation.constraints.NotBlank;
  27 +import lombok.extern.slf4j.Slf4j;
  28 +import org.springframework.util.CollectionUtils;
  29 +import org.springframework.validation.annotation.Validated;
  30 +import org.springframework.web.bind.annotation.GetMapping;
  31 +import org.springframework.web.bind.annotation.PostMapping;
  32 +import org.springframework.web.bind.annotation.PutMapping;
  33 +import org.springframework.web.bind.annotation.RequestBody;
  34 +import org.springframework.web.bind.annotation.RequestMapping;
  35 +import org.springframework.web.bind.annotation.RestController;
  36 +
  37 +/**
  38 + * 化验送样单
  39 + */
  40 +@Api(tags = "化验送样单管理")
  41 +@Slf4j
  42 +@Validated
  43 +@RestController
  44 +@RequestMapping("/procurement/assay/apply")
  45 +public class ProcurementAssayApplyController extends DefaultBaseController {
  46 +
  47 + @Resource
  48 + private ProcurementAssayApplyService procurementAssayApplyService;
  49 +
  50 + @ApiOperation("分页查询化验送样单")
  51 + @HasPermission({"warehouse-manage:sample-submission:query"})
  52 + @GetMapping("/query")
  53 + public InvokeResult<PageResult<GetProcurementAssayApplyBo>> query(
  54 + @Valid QueryProcurementAssayApplyVo vo) {
  55 + PageResult<ProcurementAssayApply> result = procurementAssayApplyService.query(
  56 + getPageIndex(vo), getPageSize(vo), vo);
  57 +
  58 + List<GetProcurementAssayApplyBo> results = null;
  59 + if (!CollectionUtils.isEmpty(result.getDatas())) {
  60 + results = result.getDatas().stream().map(GetProcurementAssayApplyBo::new)
  61 + .collect(Collectors.toList());
  62 + }
  63 + return InvokeResultBuilder.success(PageResultUtil.rebuild(result, results));
  64 + }
  65 +
  66 + @ApiOperation("查询化验送样单详情")
  67 + @ApiImplicitParam(value = "ID", name = "id", paramType = "query", required = true)
  68 + @HasPermission({"warehouse-manage:sample-submission:query", "warehouse-manage:sample-submission:review"})
  69 + @GetMapping("")
  70 + public InvokeResult<GetProcurementAssayApplyBo> findById(
  71 + @NotBlank(message = "ID不能为空!") String id) {
  72 + return InvokeResultBuilder.success(procurementAssayApplyService.findDetail(id));
  73 + }
  74 +
  75 + @ApiOperation("选择码单弹窗:分页查询可送样化验的过磅码单(审核通过且已上传签字凭证,级联第一步)")
  76 + @GetMapping("/ticketPage")
  77 + public InvokeResult<PageResult<GetAssaySelectableTicketBo>> querySelectableTickets(
  78 + @Valid QueryAssaySelectableTicketVo vo) {
  79 + return InvokeResultBuilder.success(procurementAssayApplyService.querySelectableTickets(
  80 + getPageIndex(vo), getPageSize(vo), vo));
  81 + }
  82 +
  83 + @ApiOperation("新增页根据过磅码单带出计划编号下拉(码单须为审核通过且已上传签字凭证,级联第二步)")
  84 + @ApiImplicitParam(value = "过磅码单ID", name = "ticketId", paramType = "query", required = true)
  85 + @GetMapping("/ticketData")
  86 + public InvokeResult<GetAssayTicketDataBo> getTicketData(
  87 + @NotBlank(message = "过磅码单ID不能为空!") String ticketId) {
  88 + return InvokeResultBuilder.success(procurementAssayApplyService.getTicketData(ticketId));
  89 + }
  90 +
  91 + @ApiOperation("新增页根据所选计划带出过磅品种下拉(级联第三步)")
  92 + @ApiImplicitParams({
  93 + @ApiImplicitParam(value = "过磅码单ID", name = "ticketId", paramType = "query", required = true),
  94 + @ApiImplicitParam(value = "采购计划ID", name = "planId", paramType = "query", required = true)
  95 + })
  96 + @GetMapping("/breedOptions")
  97 + public InvokeResult<List<GetAssayTicketDataBo.BreedOption>> getBreedOptions(
  98 + @NotBlank(message = "过磅码单ID不能为空!") String ticketId,
  99 + @NotBlank(message = "采购计划ID不能为空!") String planId) {
  100 + return InvokeResultBuilder.success(procurementAssayApplyService.getBreedOptions(ticketId, planId));
  101 + }
  102 +
  103 + @ApiOperation("新增化验送样单(草稿,取样员)")
  104 + @HasPermission({"warehouse-manage:sample-submission:add"})
  105 + @PostMapping("")
  106 + public InvokeResult<String> create(@RequestBody @Valid CreateProcurementAssayApplyVo vo) {
  107 + return InvokeResultBuilder.success(procurementAssayApplyService.create(vo));
  108 + }
  109 +
  110 + @ApiOperation("修改化验送样单")
  111 + @HasPermission({"warehouse-manage:sample-submission:modify","warehouse-manage:sample-submission:approve"})
  112 + @PutMapping("")
  113 + public InvokeResult<Void> update(@RequestBody @Valid UpdateProcurementAssayApplyVo vo) {
  114 + procurementAssayApplyService.update(vo);
  115 + return InvokeResultBuilder.success();
  116 + }
  117 +
  118 + @ApiOperation("提交化验送样单审核")
  119 + @ApiImplicitParam(value = "ID", name = "id", paramType = "query", required = true)
  120 + @HasPermission({"warehouse-manage:sample-submission:submit"})
  121 + @PutMapping("/submit")
  122 + public InvokeResult<Void> submit(@NotBlank(message = "ID不能为空!") String id) {
  123 + procurementAssayApplyService.submit(id);
  124 + return InvokeResultBuilder.success();
  125 + }
  126 +
  127 + @ApiOperation("取消化验送样单(已驳回状态可取消)")
  128 + @ApiImplicitParam(value = "ID", name = "id", paramType = "query", required = true)
  129 + @HasPermission({"warehouse-manage:sample-submission:cancel"})
  130 + @PutMapping("/cancel")
  131 + public InvokeResult<Void> cancel(@NotBlank(message = "ID不能为空!") String id) {
  132 + procurementAssayApplyService.cancel(id);
  133 + return InvokeResultBuilder.success();
  134 + }
  135 +}
... ...
  1 +package com.lframework.xingyun.sc.procurement.entity.weighing;
  2 +
  3 +import com.baomidou.mybatisplus.annotation.FieldFill;
  4 +import com.baomidou.mybatisplus.annotation.TableField;
  5 +import com.baomidou.mybatisplus.annotation.TableName;
  6 +import com.lframework.starter.web.core.dto.BaseDto;
  7 +import com.lframework.starter.web.core.entity.BaseEntity;
  8 +import lombok.Data;
  9 +
  10 +import java.time.LocalDateTime;
  11 +
  12 +/**
  13 + * 化验送样单
  14 + */
  15 +@Data
  16 +@TableName("procurement_assay_apply")
  17 +public class ProcurementAssayApply extends BaseEntity implements BaseDto {
  18 +
  19 + private static final long serialVersionUID = 1L;
  20 +
  21 + /**
  22 + * 主键ID
  23 + */
  24 + private String id;
  25 +
  26 + /**
  27 + * 过磅码单ID(单选,须为审核通过且已上传签字凭证的码单)
  28 + */
  29 + private String weighingTicketId;
  30 +
  31 + /**
  32 + * 码单编号(冗余展示)
  33 + */
  34 + private String weighingTicketCode;
  35 +
  36 + /**
  37 + * 分厂ID(取自过磅码单,按分厂划分)
  38 + */
  39 + private String workshopId;
  40 +
  41 + /**
  42 + * 分厂名称(取自过磅码单)
  43 + */
  44 + private String workshopName;
  45 +
  46 + /**
  47 + * 分厂编码
  48 + */
  49 + @TableField(exist = false)
  50 + private String workshopCode;
  51 +
  52 + /**
  53 + * 采购计划ID(单选,范围为码单关联计划)
  54 + */
  55 + private String procurementPlanId;
  56 +
  57 + /**
  58 + * 计划编号(冗余展示)
  59 + */
  60 + private String planCode;
  61 +
  62 + /**
  63 + * 过磅品种ID(品种关系表ID,单选,范围为所选计划的过磅明细品种)
  64 + */
  65 + private String productId;
  66 +
  67 + /**
  68 + * 品种名称(冗余展示)
  69 + */
  70 + private String productName;
  71 +
  72 + /**
  73 + * 科室 LABORATORY-化验室 METROLOGY-计量室(计量室即测试室)
  74 + */
  75 + private String department;
  76 +
  77 + /**
  78 + * 审核状态 DRAFT-草稿 AUDIT-审核中 PASS-审核通过 REFUSE-已驳回 CANCEL-已取消
  79 + */
  80 + private String approvalStatus;
  81 +
  82 + /**
  83 + * 创建人ID
  84 + */
  85 + @TableField(fill = FieldFill.INSERT)
  86 + private String createById;
  87 +
  88 + /**
  89 + * 创建人
  90 + */
  91 + @TableField(fill = FieldFill.INSERT)
  92 + private String createBy;
  93 +
  94 + /**
  95 + * 更新人ID
  96 + */
  97 + @TableField(fill = FieldFill.INSERT_UPDATE)
  98 + private String updateById;
  99 +
  100 + /**
  101 + * 更新人
  102 + */
  103 + @TableField(fill = FieldFill.INSERT_UPDATE)
  104 + private String updateBy;
  105 +
  106 + /**
  107 + * 创建时间
  108 + */
  109 + @TableField(fill = FieldFill.INSERT)
  110 + private LocalDateTime createTime;
  111 +
  112 + /**
  113 + * 更新时间
  114 + */
  115 + @TableField(fill = FieldFill.INSERT_UPDATE)
  116 + private LocalDateTime updateTime;
  117 +
  118 + /**
  119 + * 是否展示审核按钮(非持久化)
  120 + */
  121 + @TableField(exist = false)
  122 + private Boolean showExamine = false;
  123 +
  124 + /**
  125 + * 是否展示审核详情按钮(非持久化)
  126 + */
  127 + @TableField(exist = false)
  128 + private Boolean showExamineDetail = false;
  129 +}
... ...
  1 +package com.lframework.xingyun.sc.procurement.impl.weighing;
  2 +
  3 +import com.github.pagehelper.PageInfo;
  4 +import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  5 +import com.lframework.starter.bpm.dto.FlowTaskDto;
  6 +import com.lframework.starter.bpm.entity.FlowInstanceWrapper;
  7 +import com.lframework.starter.bpm.mappers.FlowTaskWrapperMapper;
  8 +import com.lframework.starter.bpm.service.FlowInstanceWrapperService;
  9 +import com.lframework.starter.bpm.vo.flow.task.QueryTodoTaskListVo;
  10 +import com.lframework.starter.common.exceptions.impl.DefaultClientException;
  11 +import com.lframework.starter.common.exceptions.impl.InputErrorException;
  12 +import com.lframework.starter.common.utils.Assert;
  13 +import com.lframework.starter.common.utils.CollectionUtil;
  14 +import com.lframework.starter.common.utils.StringUtil;
  15 +import com.lframework.starter.web.core.annotations.oplog.OpLog;
  16 +import com.lframework.starter.web.core.components.resp.PageResult;
  17 +import com.lframework.starter.web.core.components.security.SecurityUtil;
  18 +import com.lframework.starter.web.core.impl.BaseMpServiceImpl;
  19 +import com.lframework.starter.web.core.utils.IdUtil;
  20 +import com.lframework.starter.web.core.utils.OpLogUtil;
  21 +import com.lframework.starter.web.core.utils.PageHelperUtil;
  22 +import com.lframework.starter.web.core.utils.PageResultUtil;
  23 +import com.lframework.starter.web.inner.components.oplog.OtherOpLogType;
  24 +import com.lframework.xingyun.sc.bo.procurement.GetAssaySelectableTicketBo;
  25 +import com.lframework.xingyun.sc.bo.procurement.GetAssayTicketDataBo;
  26 +import com.lframework.xingyun.sc.bo.procurement.GetProcurementAssayApplyBo;
  27 +import com.lframework.xingyun.sc.procurement.entity.weighing.ProcurementAssayApply;
  28 +import com.lframework.xingyun.sc.procurement.entity.weighing.ProcurementWeighingTicket;
  29 +import com.lframework.xingyun.sc.procurement.entity.weighing.ProcurementWeighingTicketLine;
  30 +import com.lframework.xingyun.sc.procurement.entity.weighing.ProcurementWeighingTicketPlan;
  31 +import com.lframework.xingyun.sc.procurement.mappers.weighing.ProcurementAssayApplyMapper;
  32 +import com.lframework.xingyun.sc.procurement.mappers.weighing.ProcurementWeighingTicketMapper;
  33 +import com.lframework.xingyun.sc.procurement.service.weighing.ProcurementAssayApplyService;
  34 +import com.lframework.xingyun.sc.procurement.service.weighing.ProcurementWeighingTicketLineService;
  35 +import com.lframework.xingyun.sc.procurement.service.weighing.ProcurementWeighingTicketPlanService;
  36 +import com.lframework.xingyun.sc.procurement.vo.weighing.CreateProcurementAssayApplyVo;
  37 +import com.lframework.xingyun.sc.procurement.vo.weighing.QueryAssaySelectableTicketVo;
  38 +import com.lframework.xingyun.sc.procurement.vo.weighing.QueryProcurementAssayApplyVo;
  39 +import com.lframework.xingyun.sc.procurement.vo.weighing.UpdateProcurementAssayApplyVo;
  40 +import java.util.ArrayList;
  41 +import java.util.Collections;
  42 +import java.util.HashSet;
  43 +import java.util.List;
  44 +import java.util.Map;
  45 +import java.util.Objects;
  46 +import java.util.Set;
  47 +import java.util.stream.Collectors;
  48 +import javax.annotation.Resource;
  49 +import lombok.extern.slf4j.Slf4j;
  50 +import org.springframework.stereotype.Service;
  51 +import org.springframework.transaction.annotation.Transactional;
  52 +
  53 +/**
  54 + * 化验送样单
  55 + */
  56 +@Slf4j
  57 +@Service
  58 +public class ProcurementAssayApplyServiceImpl
  59 + extends BaseMpServiceImpl<ProcurementAssayApplyMapper, ProcurementAssayApply>
  60 + implements ProcurementAssayApplyService {
  61 +
  62 + /** 审核状态-草稿 */
  63 + private static final String STATUS_DRAFT = "DRAFT";
  64 + /** 审核状态-审核中 */
  65 + private static final String STATUS_AUDIT = "AUDIT";
  66 + /** 审核状态-审核通过 */
  67 + private static final String STATUS_PASS = "PASS";
  68 + /** 审核状态-已驳回 */
  69 + private static final String STATUS_REFUSE = "REFUSE";
  70 + /** 审核状态-已取消 */
  71 + private static final String STATUS_CANCEL = "CANCEL";
  72 + /** 科室-化验室 */
  73 + private static final String DEPT_LABORATORY = "LABORATORY";
  74 + /** 科室-计量室(测试室) */
  75 + private static final String DEPT_METROLOGY = "METROLOGY";
  76 + /** 流程编号(需与流程设计器中的流程编号一致:测试室审核 -> 化验室审核) */
  77 + private static final String BPM_FLAG = "ASSAY_APPLY";
  78 +
  79 + @Resource
  80 + private ProcurementAssayApplyMapper assayApplyMapper;
  81 +
  82 + @Resource
  83 + private ProcurementWeighingTicketMapper weighingTicketMapper;
  84 +
  85 + @Resource
  86 + private ProcurementWeighingTicketPlanService planLineService;
  87 +
  88 + @Resource
  89 + private ProcurementWeighingTicketLineService weighLineService;
  90 +
  91 + @Resource
  92 + private FlowInstanceWrapperService flowInstanceWrapperService;
  93 +
  94 + @Resource
  95 + private FlowTaskWrapperMapper flowTaskWrapperMapper;
  96 +
  97 + @Override
  98 + public PageResult<ProcurementAssayApply> query(Integer pageIndex, Integer pageSize,
  99 + QueryProcurementAssayApplyVo vo) {
  100 + PageHelperUtil.startPage(pageIndex, pageSize);
  101 + List<ProcurementAssayApply> datas = assayApplyMapper.query(vo);
  102 + PageResult<ProcurementAssayApply> pageResult = PageResultUtil.convert(new PageInfo<>(datas));
  103 +
  104 + fillOperateFlags(pageResult.getDatas());
  105 +
  106 + return pageResult;
  107 + }
  108 +
  109 + @Override
  110 + public GetProcurementAssayApplyBo findDetail(String id) {
  111 + if (StringUtil.isBlank(id)) {
  112 + throw new InputErrorException("ID不能为空!");
  113 + }
  114 +
  115 + ProcurementAssayApply entity = assayApplyMapper.findById(id);
  116 + if (entity == null) {
  117 + throw new DefaultClientException("化验送样单不存在!");
  118 + }
  119 + fillOperateFlags(Collections.singletonList(entity));
  120 +
  121 + GetProcurementAssayApplyBo bo = new GetProcurementAssayApplyBo(entity);
  122 + bo.convert(entity);
  123 +
  124 + return bo;
  125 + }
  126 +
  127 + @Override
  128 + public PageResult<GetAssaySelectableTicketBo> querySelectableTickets(Integer pageIndex,
  129 + Integer pageSize, QueryAssaySelectableTicketVo vo) {
  130 + PageHelperUtil.startPage(pageIndex, pageSize);
  131 + List<GetAssaySelectableTicketBo> datas = assayApplyMapper.querySelectableTickets(vo);
  132 + return PageResultUtil.convert(new PageInfo<>(datas));
  133 + }
  134 +
  135 + @Override
  136 + public GetAssayTicketDataBo getTicketData(String ticketId) {
  137 + ProcurementWeighingTicket ticket = assertTicketUsable(ticketId);
  138 +
  139 + GetAssayTicketDataBo bo = new GetAssayTicketDataBo();
  140 + bo.setWeighingTicketId(ticket.getId());
  141 + bo.setWeighingTicketCode(ticket.getCode());
  142 +
  143 + // 计划下拉:码单关联计划(同一计划多明细行会重复,按计划ID去重,保持原排序)
  144 + List<ProcurementWeighingTicketPlan> plans = planLineService.getByWeighingTicketId(ticket.getId());
  145 + if (CollectionUtil.isNotEmpty(plans)) {
  146 + Set<String> planIdSet = new HashSet<>();
  147 + for (ProcurementWeighingTicketPlan plan : plans) {
  148 + if (StringUtil.isBlank(plan.getProcurementPlanId()) || !planIdSet.add(plan.getProcurementPlanId())) {
  149 + continue;
  150 + }
  151 + GetAssayTicketDataBo.PlanOption option = new GetAssayTicketDataBo.PlanOption();
  152 + option.setPlanId(plan.getProcurementPlanId());
  153 + option.setPlanCode(plan.getPlanCode());
  154 + bo.getPlanOptions().add(option);
  155 + }
  156 + }
  157 +
  158 + return bo;
  159 + }
  160 +
  161 + @Override
  162 + public List<GetAssayTicketDataBo.BreedOption> getBreedOptions(String ticketId, String planId) {
  163 + if (StringUtil.isBlank(ticketId)) {
  164 + throw new DefaultClientException("过磅码单不能为空!");
  165 + }
  166 + if (StringUtil.isBlank(planId)) {
  167 + throw new DefaultClientException("采购计划不能为空!");
  168 + }
  169 +
  170 + // 品种下拉:所选计划下的过磅明细品种(按品种ID去重,保持原排序)
  171 + List<ProcurementWeighingTicketLine> weighs = weighLineService.getByWeighingTicketId(ticketId);
  172 + List<GetAssayTicketDataBo.BreedOption> options = new ArrayList<>();
  173 + if (CollectionUtil.isEmpty(weighs)) {
  174 + return options;
  175 + }
  176 + Set<String> breedIdSet = new HashSet<>();
  177 + for (ProcurementWeighingTicketLine line : weighs) {
  178 + if (!planId.equals(line.getProcurementPlanId())) {
  179 + continue;
  180 + }
  181 + if (StringUtil.isBlank(line.getProductId()) || !breedIdSet.add(line.getProductId())) {
  182 + continue;
  183 + }
  184 + GetAssayTicketDataBo.BreedOption option = new GetAssayTicketDataBo.BreedOption();
  185 + option.setProductId(line.getProductId());
  186 + option.setProductName(line.getProductName());
  187 + options.add(option);
  188 + }
  189 + return options;
  190 + }
  191 +
  192 + @Override
  193 + @Transactional(rollbackFor = Exception.class)
  194 + @OpLog(type = OtherOpLogType.class, name = "新增化验送样单,ID:{}", params = {"#result"})
  195 + public String create(CreateProcurementAssayApplyVo vo) {
  196 + ProcurementAssayApply entity = new ProcurementAssayApply();
  197 + entity.setId(IdUtil.getId());
  198 + applyFields(entity, vo);
  199 +
  200 + entity.setApprovalStatus(STATUS_DRAFT);
  201 +
  202 + this.save(entity);
  203 +
  204 + OpLogUtil.setVariable("id", entity.getId());
  205 + OpLogUtil.setExtra(entity);
  206 +
  207 + return entity.getId();
  208 + }
  209 +
  210 + @Override
  211 + @Transactional(rollbackFor = Exception.class)
  212 + @OpLog(type = OtherOpLogType.class, name = "修改化验送样单,ID:{}", params = {"#vo.id"})
  213 + public void update(UpdateProcurementAssayApplyVo vo) {
  214 + Assert.notBlank(vo.getId(), "ID不能为空!");
  215 +
  216 + ProcurementAssayApply oldEntity = this.getById(vo.getId());
  217 + if (oldEntity == null) {
  218 + throw new DefaultClientException("化验送样单不存在!");
  219 + }
  220 + // 仅草稿、已驳回可修改;审核中、审核通过、已取消不可修改
  221 + assertEditable(oldEntity);
  222 +
  223 + ProcurementAssayApply entity = new ProcurementAssayApply();
  224 + entity.setId(vo.getId());
  225 + applyFields(entity, vo);
  226 +
  227 + this.updateById(entity);
  228 +
  229 + OpLogUtil.setVariable("id", entity.getId());
  230 + OpLogUtil.setExtra(entity);
  231 + }
  232 +
  233 + @Override
  234 + @Transactional(rollbackFor = Exception.class)
  235 + @OpLog(type = OtherOpLogType.class, name = "提交化验送样单审核,ID:{}", params = {"#id"})
  236 + public void submit(String id) {
  237 + Assert.notBlank(id);
  238 +
  239 + ProcurementAssayApply entity = assayApplyMapper.findById(id);
  240 + if (entity == null) {
  241 + throw new DefaultClientException("化验送样单不存在!");
  242 + }
  243 + if (!STATUS_DRAFT.equals(entity.getApprovalStatus()) && !STATUS_REFUSE.equals(entity.getApprovalStatus())) {
  244 + throw new DefaultClientException("当前单据状态不允许提交审核!");
  245 + }
  246 +
  247 + // 提交前完整性校验(字段在新增时已校验,防历史数据变更后失效)
  248 + assertTicketUsable(entity.getWeighingTicketId());
  249 +
  250 + this.update(Wrappers.lambdaUpdate(ProcurementAssayApply.class)
  251 + .set(ProcurementAssayApply::getApprovalStatus, STATUS_AUDIT)
  252 + .eq(ProcurementAssayApply::getId, id));
  253 +
  254 + flowInstanceWrapperService.startInstance(BPM_FLAG, entity.getId(), BPM_FLAG, entity);
  255 +
  256 + OpLogUtil.setVariable("id", id);
  257 + OpLogUtil.setExtra(entity);
  258 + }
  259 +
  260 + @Override
  261 + @Transactional(rollbackFor = Exception.class)
  262 + @OpLog(type = OtherOpLogType.class, name = "取消化验送样单,ID:{}", params = {"#id"})
  263 + public void cancel(String id) {
  264 + Assert.notBlank(id);
  265 +
  266 + ProcurementAssayApply entity = assayApplyMapper.findById(id);
  267 + if (entity == null) {
  268 + throw new DefaultClientException("化验送样单不存在!");
  269 + }
  270 + if (!STATUS_REFUSE.equals(entity.getApprovalStatus())) {
  271 + throw new DefaultClientException("只有已驳回的化验送样单可以取消!");
  272 + }
  273 +
  274 + this.update(Wrappers.lambdaUpdate(ProcurementAssayApply.class)
  275 + .set(ProcurementAssayApply::getApprovalStatus, STATUS_CANCEL)
  276 + .eq(ProcurementAssayApply::getId, id));
  277 +
  278 + OpLogUtil.setVariable("id", id);
  279 + OpLogUtil.setExtra(entity);
  280 + }
  281 +
  282 + @Override
  283 + @Transactional(rollbackFor = Exception.class)
  284 + public void updateApprovalStatus(String id, String approvalStatus) {
  285 + if (StringUtil.isBlank(id) || StringUtil.isBlank(approvalStatus)) {
  286 + throw new DefaultClientException("化验送样单ID、审核状态不能为空!");
  287 + }
  288 +
  289 + ProcurementAssayApply entity = this.getById(id);
  290 + if (entity == null) {
  291 + throw new DefaultClientException("化验送样单不存在!");
  292 + }
  293 +
  294 + this.update(Wrappers.lambdaUpdate(ProcurementAssayApply.class)
  295 + .set(ProcurementAssayApply::getApprovalStatus, approvalStatus)
  296 + .eq(ProcurementAssayApply::getId, id));
  297 + }
  298 +
  299 + /**
  300 + * 组装单据字段(新增/修改共用):校验码单、计划、品种合法后回填冗余字段
  301 + */
  302 + private void applyFields(ProcurementAssayApply entity, CreateProcurementAssayApplyVo vo) {
  303 +
  304 + // 2. 校验码单:必须审核通过且已上传签字凭证
  305 + ProcurementWeighingTicket ticket = assertTicketUsable(vo.getWeighingTicketId());
  306 +
  307 + // 3. 校验计划:必须属于码单关联计划
  308 + List<ProcurementWeighingTicketPlan> plans = planLineService.getByWeighingTicketId(ticket.getId());
  309 + ProcurementWeighingTicketPlan matchedPlan = plans == null ? null : plans.stream()
  310 + .filter(p -> vo.getProcurementPlanId().equals(p.getProcurementPlanId()))
  311 + .findFirst().orElse(null);
  312 + if (matchedPlan == null) {
  313 + throw new DefaultClientException("所选计划不属于该过磅码单关联的计划!");
  314 + }
  315 +
  316 + // 4. 校验品种:必须属于所选计划的过磅明细品种
  317 + List<ProcurementWeighingTicketLine> weighs = weighLineService.getByWeighingTicketId(ticket.getId());
  318 + ProcurementWeighingTicketLine matchedLine = weighs == null ? null : weighs.stream()
  319 + .filter(w -> vo.getProcurementPlanId().equals(w.getProcurementPlanId())
  320 + && vo.getProductId().equals(w.getProductId()))
  321 + .findFirst().orElse(null);
  322 + if (matchedLine == null) {
  323 + throw new DefaultClientException("所选品种不属于所选计划的过磅品种!");
  324 + }
  325 +
  326 + // 5. 回填字段与冗余信息
  327 + entity.setWeighingTicketId(ticket.getId());
  328 + entity.setWeighingTicketCode(ticket.getCode());
  329 + entity.setWorkshopId(ticket.getWorkshopId());
  330 + entity.setWorkshopName(ticket.getWorkshopName());
  331 + entity.setProcurementPlanId(matchedPlan.getProcurementPlanId());
  332 + entity.setPlanCode(matchedPlan.getPlanCode());
  333 + entity.setProductId(matchedLine.getProductId());
  334 + entity.setProductName(matchedLine.getProductName());
  335 + entity.setDepartment(vo.getDepartment());
  336 + }
  337 +
  338 + /**
  339 + * 码单可用校验:审核通过且已上传签字凭证(完成时间不为空)
  340 + */
  341 + private ProcurementWeighingTicket assertTicketUsable(String ticketId) {
  342 + if (StringUtil.isBlank(ticketId)) {
  343 + throw new DefaultClientException("过磅码单不能为空!");
  344 + }
  345 + ProcurementWeighingTicket ticket = weighingTicketMapper.findById(ticketId);
  346 + if (ticket == null) {
  347 + throw new DefaultClientException("过磅码单不存在!");
  348 + }
  349 + if (!STATUS_PASS.equals(ticket.getApprovalStatus())) {
  350 + throw new DefaultClientException("过磅码单必须为审核通过状态,才能化验送样!");
  351 + }
  352 + if (ticket.getCompleteTime() == null) {
  353 + throw new DefaultClientException("过磅码单未上传签字凭证,不能化验送样!");
  354 + }
  355 + return ticket;
  356 + }
  357 +
  358 + /**
  359 + * 编辑校验:仅草稿、已驳回可修改
  360 + */
  361 + private void assertEditable(ProcurementAssayApply entity) {
  362 + if (!STATUS_DRAFT.equals(entity.getApprovalStatus()) && !STATUS_REFUSE.equals(entity.getApprovalStatus())) {
  363 + throw new DefaultClientException("当前单据状态不允许修改!");
  364 + }
  365 + }
  366 +
  367 + /**
  368 + * 审核按钮标记:待办驱动(列表 + 详情两条返回路径都要调用)
  369 + */
  370 + private void fillOperateFlags(List<ProcurementAssayApply> datas) {
  371 + if (CollectionUtil.isEmpty(datas)) {
  372 + return;
  373 + }
  374 +
  375 + List<String> businessIds = datas.stream()
  376 + .filter(Objects::nonNull)
  377 + .map(ProcurementAssayApply::getId)
  378 + .collect(Collectors.toList());
  379 +
  380 + List<FlowInstanceWrapper> flowList = flowInstanceWrapperService.getFlowByBusinessIdList(businessIds);
  381 + Set<String> flowBusinessIdSet = CollectionUtil.isNotEmpty(flowList)
  382 + ? flowList.stream().map(FlowInstanceWrapper::getBusinessId).collect(Collectors.toSet())
  383 + : new HashSet<>();
  384 +
  385 + List<FlowTaskDto> todoFlowTaskList = flowTaskWrapperMapper.queryTodoList(
  386 + new QueryTodoTaskListVo(), SecurityUtil.getCurrentUser().getId());
  387 + Set<String> todoBusinessIdSet = CollectionUtil.isNotEmpty(todoFlowTaskList)
  388 + ? todoFlowTaskList.stream().map(FlowTaskDto::getBusinessId).collect(Collectors.toSet())
  389 + : new HashSet<>();
  390 +
  391 + for (ProcurementAssayApply data : datas) {
  392 + if (data == null) {
  393 + continue;
  394 + }
  395 + boolean hasFlow = flowBusinessIdSet.contains(data.getId());
  396 + boolean hasTodo = todoBusinessIdSet.contains(data.getId());
  397 + data.setShowExamine(hasTodo && STATUS_AUDIT.equals(data.getApprovalStatus()));
  398 + data.setShowExamineDetail(hasFlow && StringUtil.isNotBlank(data.getApprovalStatus()));
  399 + }
  400 + }
  401 +}
... ...
  1 +package com.lframework.xingyun.sc.procurement.mappers.weighing;
  2 +
  3 +import com.lframework.starter.web.core.mapper.BaseMapper;
  4 +import com.lframework.xingyun.sc.bo.procurement.GetAssaySelectableTicketBo;
  5 +import com.lframework.xingyun.sc.procurement.entity.weighing.ProcurementAssayApply;
  6 +import com.lframework.xingyun.sc.procurement.vo.weighing.QueryAssaySelectableTicketVo;
  7 +import com.lframework.xingyun.sc.procurement.vo.weighing.QueryProcurementAssayApplyVo;
  8 +import java.util.List;
  9 +import org.apache.ibatis.annotations.Param;
  10 +
  11 +public interface ProcurementAssayApplyMapper extends BaseMapper<ProcurementAssayApply> {
  12 +
  13 + List<ProcurementAssayApply> query(@Param("vo") QueryProcurementAssayApplyVo vo);
  14 +
  15 + ProcurementAssayApply findById(@Param("id") String id);
  16 +
  17 + /**
  18 + * 分页查询可送样化验的过磅码单(审核通过且已上传签字凭证,选择码单弹窗)
  19 + */
  20 + List<GetAssaySelectableTicketBo> querySelectableTickets(
  21 + @Param("vo") QueryAssaySelectableTicketVo vo);
  22 +}
... ...
  1 +package com.lframework.xingyun.sc.procurement.service.weighing;
  2 +
  3 +import com.lframework.starter.web.core.components.resp.PageResult;
  4 +import com.lframework.starter.web.core.service.BaseMpService;
  5 +import com.lframework.xingyun.sc.bo.procurement.GetAssaySelectableTicketBo;
  6 +import com.lframework.xingyun.sc.bo.procurement.GetAssayTicketDataBo;
  7 +import com.lframework.xingyun.sc.bo.procurement.GetProcurementAssayApplyBo;
  8 +import com.lframework.xingyun.sc.procurement.entity.weighing.ProcurementAssayApply;
  9 +import com.lframework.xingyun.sc.procurement.vo.weighing.CreateProcurementAssayApplyVo;
  10 +import com.lframework.xingyun.sc.procurement.vo.weighing.QueryAssaySelectableTicketVo;
  11 +import com.lframework.xingyun.sc.procurement.vo.weighing.QueryProcurementAssayApplyVo;
  12 +import com.lframework.xingyun.sc.procurement.vo.weighing.UpdateProcurementAssayApplyVo;
  13 +
  14 +import java.util.List;
  15 +import java.util.Map;
  16 +
  17 +/**
  18 + * 化验送样单
  19 + */
  20 +public interface ProcurementAssayApplyService extends BaseMpService<ProcurementAssayApply> {
  21 +
  22 + /**
  23 + * 分页查询化验送样单列表
  24 + */
  25 + PageResult<ProcurementAssayApply> query(Integer pageIndex, Integer pageSize,
  26 + QueryProcurementAssayApplyVo vo);
  27 +
  28 + /**
  29 + * 分页查询可送样化验的过磅码单(审核通过且已上传签字凭证,选择码单弹窗第一步)
  30 + */
  31 + PageResult<GetAssaySelectableTicketBo> querySelectableTickets(Integer pageIndex, Integer pageSize,
  32 + QueryAssaySelectableTicketVo vo);
  33 +
  34 + /**
  35 + * 查询化验送样单详情
  36 + */
  37 + GetProcurementAssayApplyBo findDetail(String id);
  38 +
  39 + /**
  40 + * 化验送样单新增页:根据过磅码单ID带出计划编号下拉(码单须为审核通过且已上传签字凭证)
  41 + */
  42 + GetAssayTicketDataBo getTicketData(String ticketId);
  43 +
  44 + /**
  45 + * 化验送样单新增页:所选计划下的过磅品种下拉(级联第三步)
  46 + */
  47 + List<GetAssayTicketDataBo.BreedOption> getBreedOptions(String ticketId, String planId);
  48 +
  49 + /**
  50 + * 新增化验送样单(草稿):一单关联一个过磅码单并化验其中一个过磅品种
  51 + */
  52 + String create(CreateProcurementAssayApplyVo vo);
  53 +
  54 + /**
  55 + * 修改化验送样单(仅草稿、已驳回可修改)
  56 + */
  57 + void update(UpdateProcurementAssayApplyVo vo);
  58 +
  59 + /**
  60 + * 提交审核(草稿、已驳回可提交;流程:测试室审核 -> 化验室审核)
  61 + */
  62 + void submit(String id);
  63 +
  64 + /**
  65 + * 取消化验送样单(已驳回状态可取消,取消后只能查看)
  66 + */
  67 + void cancel(String id);
  68 +
  69 + /**
  70 + * 审核流程回调更新审核状态(流程结束时由 BusinessDataHandlerService 调用)
  71 + *
  72 + * @param id 化验送样单ID
  73 + * @param approvalStatus 审核结果 PASS/REFUSE
  74 + */
  75 + void updateApprovalStatus(String id, String approvalStatus);
  76 +}
... ...
  1 +package com.lframework.xingyun.sc.procurement.vo.weighing;
  2 +
  3 +import io.swagger.annotations.ApiModelProperty;
  4 +import javax.validation.constraints.NotBlank;
  5 +import lombok.Data;
  6 +
  7 +@Data
  8 +public class CreateProcurementAssayApplyVo {
  9 +
  10 + @ApiModelProperty(value = "过磅码单ID(单选,须为审核通过且已上传签字凭证的码单)", required = true)
  11 + @NotBlank(message = "过磅码单不能为空!")
  12 + private String weighingTicketId;
  13 +
  14 + @ApiModelProperty(value = "采购计划ID(单选,范围为码单关联计划)", required = true)
  15 + @NotBlank(message = "计划编号不能为空!")
  16 + private String procurementPlanId;
  17 +
  18 + @ApiModelProperty(value = "过磅品种ID(品种关系表ID,单选,范围为所选计划的过磅明细品种)", required = true)
  19 + @NotBlank(message = "品种不能为空!")
  20 + private String productId;
  21 +
  22 + @ApiModelProperty("科室 LABORATORY-化验室 METROLOGY-计量室")
  23 + private String department;
  24 +}
... ...
  1 +package com.lframework.xingyun.sc.procurement.vo.weighing;
  2 +
  3 +import com.lframework.starter.web.core.vo.SortPageVo;
  4 +import io.swagger.annotations.ApiModel;
  5 +import io.swagger.annotations.ApiModelProperty;
  6 +import lombok.Data;
  7 +
  8 +import java.io.Serializable;
  9 +
  10 +@Data
  11 +@ApiModel("化验送样:选择过磅码单(审核通过且已上传签字凭证)")
  12 +public class QueryAssaySelectableTicketVo extends SortPageVo implements Serializable {
  13 +
  14 + private static final long serialVersionUID = 1L;
  15 +
  16 + @ApiModelProperty("码单编号(模糊匹配)")
  17 + private String code;
  18 +
  19 + @ApiModelProperty("分厂ID(按分厂划分,可选)")
  20 + private String workshopId;
  21 +}
... ...
  1 +package com.lframework.xingyun.sc.procurement.vo.weighing;
  2 +
  3 +import com.fasterxml.jackson.annotation.JsonFormat;
  4 +import com.lframework.starter.common.constants.StringPool;
  5 +import com.lframework.starter.web.core.vo.SortPageVo;
  6 +import io.swagger.annotations.ApiModel;
  7 +import io.swagger.annotations.ApiModelProperty;
  8 +import lombok.Data;
  9 +
  10 +import java.io.Serializable;
  11 +import java.time.LocalDateTime;
  12 +import java.util.List;
  13 +
  14 +@Data
  15 +@ApiModel("查询化验送样单")
  16 +public class QueryProcurementAssayApplyVo extends SortPageVo implements Serializable {
  17 +
  18 + private static final long serialVersionUID = 1L;
  19 +
  20 + @ApiModelProperty("码单编号(模糊匹配)")
  21 + private String weighingTicketCode;
  22 +
  23 + @ApiModelProperty("品种名称(模糊匹配)")
  24 + private String productName;
  25 +
  26 + @ApiModelProperty("计划编号(模糊匹配)")
  27 + private String planCode;
  28 +
  29 + @ApiModelProperty("审核状态 DRAFT/AUDIT/PASS/REFUSE/CANCEL")
  30 + private String approvalStatus;
  31 +
  32 + @ApiModelProperty("创建人(模糊匹配)")
  33 + private String createBy;
  34 +
  35 + @ApiModelProperty("创建时间-开始")
  36 + @JsonFormat(pattern = StringPool.DATE_TIME_PATTERN)
  37 + private LocalDateTime startTime;
  38 +
  39 + @ApiModelProperty("创建时间-结束")
  40 + @JsonFormat(pattern = StringPool.DATE_TIME_PATTERN)
  41 + private LocalDateTime endTime;
  42 +
  43 + @ApiModelProperty("创建人ID集合(数据权限用,后端注入)")
  44 + private List<String> createByIdList;
  45 +}
... ...
  1 +package com.lframework.xingyun.sc.procurement.vo.weighing;
  2 +
  3 +import io.swagger.annotations.ApiModelProperty;
  4 +import javax.validation.constraints.NotBlank;
  5 +import lombok.Data;
  6 +import lombok.EqualsAndHashCode;
  7 +
  8 +@Data
  9 +@EqualsAndHashCode(callSuper = true)
  10 +public class UpdateProcurementAssayApplyVo extends CreateProcurementAssayApplyVo {
  11 +
  12 + @ApiModelProperty(value = "化验送样单ID", required = true)
  13 + @NotBlank(message = "ID不能为空!")
  14 + private String id;
  15 +}
... ...
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3 +<mapper namespace="com.lframework.xingyun.sc.procurement.mappers.weighing.ProcurementAssayApplyMapper">
  4 +
  5 + <resultMap id="ProcurementAssayApplyResult" type="com.lframework.xingyun.sc.procurement.entity.weighing.ProcurementAssayApply">
  6 + <id column="id" property="id"/>
  7 + <result column="weighing_ticket_id" property="weighingTicketId"/>
  8 + <result column="weighing_ticket_code" property="weighingTicketCode"/>
  9 + <result column="workshop_id" property="workshopId"/>
  10 + <result column="workshop_name" property="workshopName"/>
  11 + <result column="workshop_code" property="workshopCode"/>
  12 + <result column="procurement_plan_id" property="procurementPlanId"/>
  13 + <result column="plan_code" property="planCode"/>
  14 + <result column="product_id" property="productId"/>
  15 + <result column="product_name" property="productName"/>
  16 + <result column="department" property="department"/>
  17 + <result column="approval_status" property="approvalStatus"/>
  18 + <result column="create_by_id" property="createById"/>
  19 + <result column="create_by" property="createBy"/>
  20 + <result column="update_by_id" property="updateById"/>
  21 + <result column="update_by" property="updateBy"/>
  22 + <result column="create_time" property="createTime"/>
  23 + <result column="update_time" property="updateTime"/>
  24 + </resultMap>
  25 +
  26 + <sql id="PAA_sql">
  27 + SELECT
  28 + paa.id,
  29 + paa.weighing_ticket_id,
  30 + paa.weighing_ticket_code,
  31 + paa.workshop_id,
  32 + paa.workshop_name,
  33 + ws.code AS workshop_code,
  34 + paa.procurement_plan_id,
  35 + paa.plan_code,
  36 + paa.product_id,
  37 + paa.product_name,
  38 + paa.department,
  39 + paa.approval_status,
  40 + paa.create_by_id,
  41 + paa.create_by,
  42 + paa.update_by_id,
  43 + paa.update_by,
  44 + paa.create_time,
  45 + paa.update_time
  46 + FROM procurement_assay_apply AS paa
  47 + LEFT JOIN base_data_workshop AS ws ON ws.id = paa.workshop_id
  48 + </sql>
  49 +
  50 + <select id="query" resultMap="ProcurementAssayApplyResult">
  51 + <include refid="PAA_sql"/>
  52 + <where>
  53 + <if test="vo.weighingTicketCode != null and vo.weighingTicketCode != ''">
  54 + AND paa.weighing_ticket_code LIKE CONCAT('%', #{vo.weighingTicketCode}, '%')
  55 + </if>
  56 + <if test="vo.productName != null and vo.productName != ''">
  57 + AND paa.product_name LIKE CONCAT('%', #{vo.productName}, '%')
  58 + </if>
  59 + <if test="vo.planCode != null and vo.planCode != ''">
  60 + AND paa.plan_code LIKE CONCAT('%', #{vo.planCode}, '%')
  61 + </if>
  62 + <if test="vo.approvalStatus != null and vo.approvalStatus != ''">
  63 + AND paa.approval_status = #{vo.approvalStatus}
  64 + </if>
  65 + <if test="vo.createBy != null and vo.createBy != ''">
  66 + AND paa.create_by LIKE CONCAT('%', #{vo.createBy}, '%')
  67 + </if>
  68 + <if test="vo.startTime != null">
  69 + AND paa.create_time &gt;= #{vo.startTime}
  70 + </if>
  71 + <if test="vo.endTime != null">
  72 + AND paa.create_time &lt;= #{vo.endTime}
  73 + </if>
  74 + <if test="vo.createByIdList != null and vo.createByIdList.size() > 0">
  75 + AND paa.create_by_id IN
  76 + <foreach collection="vo.createByIdList" item="item" open="(" separator="," close=")">
  77 + #{item}
  78 + </foreach>
  79 + </if>
  80 + </where>
  81 + ORDER BY paa.create_time DESC
  82 + </select>
  83 +
  84 + <select id="findById" resultMap="ProcurementAssayApplyResult">
  85 + <include refid="PAA_sql"/>
  86 + WHERE paa.id = #{id}
  87 + </select>
  88 +
  89 + <resultMap id="AssaySelectableTicketResult" type="com.lframework.xingyun.sc.bo.procurement.GetAssaySelectableTicketBo">
  90 + <id column="id" property="id"/>
  91 + <result column="code" property="code"/>
  92 + <result column="supplier_name" property="supplierName"/>
  93 + <result column="workshop_id" property="workshopId"/>
  94 + <result column="workshop_name" property="workshopName"/>
  95 + <result column="complete_time" property="completeTime"/>
  96 + <result column="create_by" property="createBy"/>
  97 + </resultMap>
  98 +
  99 + <!-- 化验送样选择码单弹窗:审核通过 + 已上传签字凭证(完成时间非空)+ 未作废 -->
  100 + <select id="querySelectableTickets" resultMap="AssaySelectableTicketResult">
  101 + SELECT
  102 + pwt.id,
  103 + pwt.code,
  104 + pwt.supplier_name,
  105 + pwt.workshop_id,
  106 + pwt.workshop_name,
  107 + pwt.complete_time,
  108 + pwt.create_by
  109 + FROM procurement_weighing_ticket AS pwt
  110 + WHERE pwt.deleted = 0
  111 + AND pwt.approval_status = 'PASS'
  112 + AND pwt.complete_time IS NOT NULL
  113 + <if test="vo.code != null and vo.code != ''">
  114 + AND pwt.code LIKE CONCAT('%', #{vo.code}, '%')
  115 + </if>
  116 + <if test="vo.workshopId != null and vo.workshopId != ''">
  117 + AND pwt.workshop_id = #{vo.workshopId}
  118 + </if>
  119 + ORDER BY pwt.complete_time DESC, pwt.create_time DESC
  120 + </select>
  121 +</mapper>
... ...