Commit 48611c9335916b585d725216859e6f21abb72bfd

Authored by 房远帅
1 parent 4c41c340

采购计划:买断操作申请单 新增、查看、删除

Showing 16 changed files with 1269 additions and 0 deletions
@@ -1977,3 +1977,61 @@ CREATE TABLE `procurement_plan_line` @@ -1977,3 +1977,61 @@ CREATE TABLE `procurement_plan_line`
1977 KEY `idx_ppl_product_id` (`product_id`), 1977 KEY `idx_ppl_product_id` (`product_id`),
1978 KEY `idx_ppl_create_time` (`create_time`) 1978 KEY `idx_ppl_create_time` (`create_time`)
1979 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='采购计划明细表'; 1979 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='采购计划明细表';
  1980 +
  1981 +CREATE TABLE `procurement_buyout_apply`
  1982 +(
  1983 + `id` varchar(32) NOT NULL COMMENT 'ID',
  1984 + `procurement_plan_id` varchar(32) NOT NULL COMMENT '关联采购计划ID',
  1985 + `code` varchar(50) NOT NULL COMMENT '编号',
  1986 + `supplier_id` varchar(32) NOT NULL COMMENT '供应商ID',
  1987 + `supplier_name` varchar(200) NOT NULL COMMENT '供应商名称',
  1988 + `purchase_department` varchar(32) NOT NULL COMMENT '采购处',
  1989 + `purchase_department_name` varchar(200) DEFAULT NULL COMMENT '采购处名称',
  1990 + `region` varchar(32) NOT NULL COMMENT '区域',
  1991 + `region_name` varchar(200) DEFAULT NULL COMMENT '区域名称',
  1992 + `date` date NOT NULL COMMENT '日期',
  1993 + `shipping_cost` decimal(18, 5) DEFAULT NULL COMMENT '运费(另付运费)',
  1994 + `appearance_desc` varchar(500) NOT NULL DEFAULT '厂家生产过程中报废的一手料' COMMENT '外观描述',
  1995 + `material_condition_desc` varchar(500) NOT NULL DEFAULT '料质清爽' COMMENT '料质状况',
  1996 + `waste_material_desc` varchar(500) NOT NULL DEFAULT '含少量杂质' COMMENT '废杂物情况',
  1997 + `oil_water_desc` varchar(500) DEFAULT NULL COMMENT '油水杂情况',
  1998 + `loading_fee` decimal(18, 5) DEFAULT NULL COMMENT '装车费',
  1999 + `buyout_reason` varchar(1000) DEFAULT NULL COMMENT '买断原因',
  2000 + `paint_loss` decimal(18, 10) DEFAULT NULL COMMENT '漆损',
  2001 + `create_by_id` varchar(32) DEFAULT NULL COMMENT '创建人ID',
  2002 + `create_by` varchar(64) DEFAULT NULL COMMENT '创建人',
  2003 + `update_by_id` varchar(32) DEFAULT NULL COMMENT '更新人ID',
  2004 + `update_by` varchar(64) DEFAULT NULL COMMENT '更新人',
  2005 + `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  2006 + `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  2007 + PRIMARY KEY (`id`),
  2008 + UNIQUE KEY `uk_pba_code` (`code`),
  2009 + KEY `idx_pba_plan_id` (`procurement_plan_id`),
  2010 + KEY `idx_pba_supplier_id` (`supplier_id`),
  2011 + KEY `idx_pba_date` (`date`),
  2012 + KEY `idx_pba_create_time` (`create_time`)
  2013 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='买断操作申请单主表';
  2014 +
  2015 +CREATE TABLE `procurement_buyout_apply_line`
  2016 +(
  2017 + `id` varchar(32) NOT NULL COMMENT 'ID',
  2018 + `buyout_apply_id` varchar(32) NOT NULL COMMENT '买断操作申请单ID',
  2019 + `product_id` varchar(32) NOT NULL COMMENT '买断品种ID',
  2020 + `product_name` varchar(200) DEFAULT NULL COMMENT '买断品种名称',
  2021 + `material_type` varchar(200) DEFAULT NULL COMMENT '料型',
  2022 + `quantity` decimal(18, 5) NOT NULL COMMENT '买断数量',
  2023 + `buyout_price` decimal(18, 10) DEFAULT NULL COMMENT '买断价格(实际采购价)',
  2024 + `estimated_loss` decimal(18, 10) DEFAULT NULL COMMENT '预计吨损耗(买断料预计损耗)',
  2025 + `paint_damage_ratio` decimal(18, 10) DEFAULT NULL COMMENT '漆损率',
  2026 + `pure_copper_price` decimal(18, 10) DEFAULT NULL COMMENT '除损耗后纯铜价格',
  2027 + `item_id` varchar(32) NOT NULL COMMENT '前端行标识',
  2028 + `create_by_id` varchar(32) DEFAULT NULL COMMENT '创建人ID',
  2029 + `create_by` varchar(64) DEFAULT NULL COMMENT '创建人',
  2030 + `update_by_id` varchar(32) DEFAULT NULL COMMENT '更新人ID',
  2031 + `update_by` varchar(64) DEFAULT NULL COMMENT '更新人',
  2032 + `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  2033 + `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  2034 + PRIMARY KEY (`id`),
  2035 + KEY `idx_pbal_apply_id` (`buyout_apply_id`),
  2036 + KEY `idx_pbal_product_id` (`product_id`)
  2037 +) 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 com.lframework.starter.common.utils.CollectionUtil;
  6 +import com.lframework.starter.web.core.bo.BaseBo;
  7 +import com.lframework.xingyun.sc.procurement.entity.ProcurementBuyoutApply;
  8 +import com.lframework.xingyun.sc.procurement.entity.ProcurementBuyoutApplyLine;
  9 +import io.swagger.annotations.ApiModelProperty;
  10 +import lombok.Data;
  11 +import java.math.BigDecimal;
  12 +import java.time.LocalDate;
  13 +import java.time.LocalDateTime;
  14 +import java.util.List;
  15 +import java.util.stream.Collectors;
  16 +
  17 +@Data
  18 +public class GetProcurementBuyoutApplyBo extends BaseBo<ProcurementBuyoutApply> {
  19 +
  20 + /**
  21 + * ID
  22 + */
  23 + @ApiModelProperty("ID")
  24 + private String id;
  25 +
  26 + /**
  27 + * 采购计划ID
  28 + */
  29 + @ApiModelProperty("采购计划ID")
  30 + private String procurementPlanId;
  31 +
  32 + /**
  33 + * 编号
  34 + */
  35 + @ApiModelProperty("编号")
  36 + private String code;
  37 +
  38 + /**
  39 + * 供应商ID
  40 + */
  41 + @ApiModelProperty("供应商ID")
  42 + private String supplierId;
  43 +
  44 + /**
  45 + * 供应商名称
  46 + */
  47 + @ApiModelProperty("供应商名称")
  48 + private String supplierName;
  49 +
  50 + /**
  51 + * 采购处
  52 + */
  53 + @ApiModelProperty("采购处")
  54 + private String purchaseDepartment;
  55 +
  56 + /**
  57 + * 采购处名称
  58 + */
  59 + @ApiModelProperty("采购处名称")
  60 + private String purchaseDepartmentName;
  61 +
  62 + /**
  63 + * 区域
  64 + */
  65 + @ApiModelProperty("区域")
  66 + private String region;
  67 +
  68 + /**
  69 + * 区域名称
  70 + */
  71 + @ApiModelProperty("区域名称")
  72 + private String regionName;
  73 +
  74 + /**
  75 + * 日期
  76 + */
  77 + @ApiModelProperty("日期")
  78 + @JsonFormat(pattern = StringPool.DATE_PATTERN)
  79 + private LocalDate date;
  80 +
  81 + /**
  82 + * 另付运费
  83 + */
  84 + @ApiModelProperty("另付运费")
  85 + private BigDecimal shippingCost;
  86 +
  87 + /**
  88 + * 装车费
  89 + */
  90 + @ApiModelProperty("装车费")
  91 + private BigDecimal loadingFee;
  92 +
  93 + /**
  94 + * 漆损
  95 + */
  96 + @ApiModelProperty("漆损")
  97 + private BigDecimal paintLoss;
  98 +
  99 + /**
  100 + * 外观描述
  101 + */
  102 + @ApiModelProperty("外观描述")
  103 + private String appearanceDesc;
  104 +
  105 + /**
  106 + * 料质状况描述
  107 + */
  108 + @ApiModelProperty("料质状况描述")
  109 + private String materialConditionDesc;
  110 +
  111 + /**
  112 + * 废料描述
  113 + */
  114 + @ApiModelProperty("废料描述")
  115 + private String wasteMaterialDesc;
  116 +
  117 + /**
  118 + * 油水描述
  119 + */
  120 + @ApiModelProperty("油水描述")
  121 + private String oilWaterDesc;
  122 +
  123 + /**
  124 + * 买断原因
  125 + */
  126 + @ApiModelProperty("买断原因")
  127 + private String buyoutReason;
  128 +
  129 + /**
  130 + * 创建人ID
  131 + */
  132 + @ApiModelProperty("创建人ID")
  133 + private String createById;
  134 +
  135 + /**
  136 + * 创建人
  137 + */
  138 + @ApiModelProperty("创建人")
  139 + private String createBy;
  140 +
  141 + /**
  142 + * 更新人ID
  143 + */
  144 + @ApiModelProperty("更新人ID")
  145 + private String updateById;
  146 +
  147 + /**
  148 + * 更新人
  149 + */
  150 + @ApiModelProperty("更新人")
  151 + private String updateBy;
  152 +
  153 + /**
  154 + * 创建时间
  155 + */
  156 + @ApiModelProperty("创建时间")
  157 + @JsonFormat(pattern = StringPool.DATE_TIME_PATTERN)
  158 + private LocalDateTime createTime;
  159 +
  160 + /**
  161 + * 更新时间
  162 + */
  163 + @ApiModelProperty("更新时间")
  164 + @JsonFormat(pattern = StringPool.DATE_TIME_PATTERN)
  165 + private LocalDateTime updateTime;
  166 +
  167 + /**
  168 + * 明细信息
  169 + */
  170 + @ApiModelProperty("明细信息")
  171 + private List<ProcurementBuyoutApplyLineBo> lineList;
  172 +
  173 + public GetProcurementBuyoutApplyBo() {
  174 + }
  175 +
  176 + public GetProcurementBuyoutApplyBo(ProcurementBuyoutApply dto, List<ProcurementBuyoutApplyLine> lines) {
  177 + super(dto);
  178 + if (!CollectionUtil.isEmpty(lines)) {
  179 + this.lineList = lines.stream().map(ProcurementBuyoutApplyLineBo::new).collect(Collectors.toList());
  180 + }
  181 + }
  182 +
  183 + public GetProcurementBuyoutApplyBo(ProcurementBuyoutApply dto) {
  184 + super(dto);
  185 + }
  186 +
  187 + @Override
  188 + public BaseBo<ProcurementBuyoutApply> convert(ProcurementBuyoutApply dto) {
  189 + return super.convert(dto);
  190 + }
  191 +
  192 + @Override
  193 + protected void afterInit(ProcurementBuyoutApply dto) {
  194 +
  195 + }
  196 +}
  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.ProcurementBuyoutApplyLine;
  7 +import io.swagger.annotations.ApiModelProperty;
  8 +import lombok.Data;
  9 +import java.math.BigDecimal;
  10 +import java.time.LocalDateTime;
  11 +
  12 +@Data
  13 +public class ProcurementBuyoutApplyLineBo extends BaseBo<ProcurementBuyoutApplyLine> {
  14 +
  15 + /**
  16 + * ID
  17 + */
  18 + @ApiModelProperty("ID")
  19 + private String id;
  20 +
  21 + /**
  22 + * 买断操作申请单ID
  23 + */
  24 + @ApiModelProperty("买断操作申请单ID")
  25 + private String buyoutApplyId;
  26 +
  27 + /**
  28 + * 品种ID
  29 + */
  30 + @ApiModelProperty("品种ID")
  31 + private String productId;
  32 +
  33 + /**
  34 + * 品种名称
  35 + */
  36 + @ApiModelProperty("品种名称")
  37 + private String productName;
  38 +
  39 + /**
  40 + * 料型
  41 + */
  42 + @ApiModelProperty("料型")
  43 + private String materialType;
  44 +
  45 + /**
  46 + * 数量
  47 + */
  48 + @ApiModelProperty("数量")
  49 + private BigDecimal quantity;
  50 +
  51 + /**
  52 + * 买断价
  53 + */
  54 + @ApiModelProperty("买断价")
  55 + private BigDecimal buyoutPrice;
  56 +
  57 + /**
  58 + * 买断料预计损耗
  59 + */
  60 + @ApiModelProperty("买断料预计损耗")
  61 + private BigDecimal estimatedLoss;
  62 +
  63 + /**
  64 + * 漆损率
  65 + */
  66 + @ApiModelProperty("漆损率")
  67 + private BigDecimal paintDamageRatio;
  68 +
  69 + /**
  70 + * 除损耗后纯铜价
  71 + */
  72 + @ApiModelProperty("除损耗后纯铜价")
  73 + private BigDecimal pureCopperPrice;
  74 +
  75 + /**
  76 + * 前端行标识
  77 + */
  78 + @ApiModelProperty("前端行标识")
  79 + private String itemId;
  80 +
  81 + /**
  82 + * 创建人ID
  83 + */
  84 + @ApiModelProperty("创建人ID")
  85 + private String createById;
  86 +
  87 + /**
  88 + * 创建人
  89 + */
  90 + @ApiModelProperty("创建人")
  91 + private String createBy;
  92 +
  93 + /**
  94 + * 更新人ID
  95 + */
  96 + @ApiModelProperty("更新人ID")
  97 + private String updateById;
  98 +
  99 + /**
  100 + * 更新人
  101 + */
  102 + @ApiModelProperty("更新人")
  103 + private String updateBy;
  104 +
  105 + /**
  106 + * 创建时间
  107 + */
  108 + @ApiModelProperty("创建时间")
  109 + @JsonFormat(pattern = StringPool.DATE_TIME_PATTERN)
  110 + private LocalDateTime createTime;
  111 +
  112 + /**
  113 + * 更新时间
  114 + */
  115 + @ApiModelProperty("更新时间")
  116 + @JsonFormat(pattern = StringPool.DATE_TIME_PATTERN)
  117 + private LocalDateTime updateTime;
  118 +
  119 + public ProcurementBuyoutApplyLineBo(ProcurementBuyoutApplyLine dto) {
  120 + super(dto);
  121 + }
  122 +
  123 + @Override
  124 + public BaseBo<ProcurementBuyoutApplyLine> convert(ProcurementBuyoutApplyLine dto) {
  125 + return super.convert(dto);
  126 + }
  127 +}
  1 +package com.lframework.xingyun.sc.procurement.controller.buyout;
  2 +
  3 +import com.lframework.starter.web.core.annotations.security.HasPermission;
  4 +import com.lframework.starter.web.core.controller.DefaultBaseController;
  5 +import com.lframework.starter.web.core.components.resp.InvokeResult;
  6 +import com.lframework.starter.web.core.components.resp.InvokeResultBuilder;
  7 +import com.lframework.xingyun.sc.bo.procurement.GetProcurementBuyoutApplyBo;
  8 +import com.lframework.xingyun.sc.procurement.service.buyout.ProcurementBuyoutApplyService;
  9 +import com.lframework.xingyun.sc.procurement.vo.buyout.CreateProcurementBuyoutApplyVo;
  10 +import io.swagger.annotations.Api;
  11 +import io.swagger.annotations.ApiImplicitParam;
  12 +import io.swagger.annotations.ApiOperation;
  13 +import org.springframework.beans.factory.annotation.Autowired;
  14 +import org.springframework.validation.annotation.Validated;
  15 +import org.springframework.web.bind.annotation.*;
  16 +import javax.validation.Valid;
  17 +import javax.validation.constraints.NotBlank;
  18 +
  19 +@Api(tags = "买断操作申请单管理")
  20 +@Validated
  21 +@RestController
  22 +@RequestMapping("/procurement/buyout/apply")
  23 +public class ProcurementBuyoutApplyController extends DefaultBaseController {
  24 +
  25 + @Autowired
  26 + private ProcurementBuyoutApplyService procurementBuyoutApplyService;
  27 +
  28 + /**
  29 + * 新增买断操作申请单
  30 + */
  31 + @ApiOperation("新增买断操作申请单")
  32 + @HasPermission({"plan-manage:buy‑out:create", "plan-manage:domestic-plan:generate"})
  33 + @PostMapping("/create")
  34 + public InvokeResult<String> create(@RequestBody @Valid CreateProcurementBuyoutApplyVo vo) {
  35 + String id = procurementBuyoutApplyService.create(vo);
  36 + return InvokeResultBuilder.success(id);
  37 + }
  38 +
  39 + /**
  40 + * 删除
  41 + */
  42 + @ApiOperation("删除")
  43 + @ApiImplicitParam(value = "ID", name = "id", paramType = "query", required = true)
  44 + @HasPermission({"plan-manage:buy‑out:delete"})
  45 + @PostMapping("/delete")
  46 + public InvokeResult<Void> delete(@NotBlank(message = "ID不能为空!") String id) {
  47 + procurementBuyoutApplyService.deleteById(id);
  48 + return InvokeResultBuilder.success();
  49 + }
  50 +
  51 + /**
  52 + * 废除
  53 + */
  54 + @ApiOperation("废除")
  55 + @ApiImplicitParam(value = "PlanId", name = "planId", paramType = "query", required = true)
  56 + @HasPermission({"plan-manage:domestic-plan:cancel"})
  57 + @PostMapping("/deleteByPlanId")
  58 + public InvokeResult<Void> deleteByPlanId(@NotBlank(message = "计划ID不能为空!") String planId) {
  59 +
  60 + procurementBuyoutApplyService.deleteByPlanId(planId);
  61 + return InvokeResultBuilder.success();
  62 + }
  63 +
  64 + /**
  65 + * 查询详情
  66 + */
  67 + @ApiOperation("查询详情")
  68 + @ApiImplicitParam(value = "ID", name = "id", paramType = "query", required = true)
  69 + @HasPermission({"plan-manage:buy‑out:query"})
  70 + @GetMapping("/detail")
  71 + public InvokeResult<GetProcurementBuyoutApplyBo> detail(@NotBlank(message = "ID不能为空!") String id) {
  72 + GetProcurementBuyoutApplyBo result = procurementBuyoutApplyService.findById(id);
  73 + return InvokeResultBuilder.success(result);
  74 + }
  75 +
  76 +
  77 + /**
  78 + * 查询详情
  79 + */
  80 + @ApiOperation("查询详情")
  81 + @ApiImplicitParam(value = "PlanId", name = "planId", paramType = "query", required = true)
  82 + @HasPermission({"plan-manage:domestic-plan:look"})
  83 + @GetMapping("/detailByPlanId")
  84 + public InvokeResult<GetProcurementBuyoutApplyBo> detailByPlanId(@NotBlank(message = "计划ID不能为空!") String planId) {
  85 + GetProcurementBuyoutApplyBo result = procurementBuyoutApplyService.findByPlanId(planId);
  86 + return InvokeResultBuilder.success(result);
  87 + }
  88 +}
  1 +package com.lframework.xingyun.sc.procurement.entity;
  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 +import java.math.BigDecimal;
  10 +import java.time.LocalDate;
  11 +import java.time.LocalDateTime;
  12 +
  13 +@Data
  14 +@TableName("procurement_buyout_apply")
  15 +public class ProcurementBuyoutApply extends BaseEntity implements BaseDto {
  16 +
  17 + private static final long serialVersionUID = 1L;
  18 +
  19 + /**
  20 + * ID
  21 + */
  22 + private String id;
  23 +
  24 + /**
  25 + * 采购计划ID
  26 + */
  27 + private String procurementPlanId;
  28 +
  29 + /**
  30 + * 编号
  31 + */
  32 + private String code;
  33 +
  34 + /**
  35 + * 供应商ID
  36 + */
  37 + private String supplierId;
  38 +
  39 + /**
  40 + * 供应商名称
  41 + */
  42 + private String supplierName;
  43 +
  44 + /**
  45 + * 采购处
  46 + */
  47 + private String purchaseDepartment;
  48 +
  49 + /**
  50 + * 采购处名称
  51 + */
  52 + private String purchaseDepartmentName;
  53 +
  54 + /**
  55 + * 区域
  56 + */
  57 + private String region;
  58 +
  59 + /**
  60 + * 区域名称
  61 + */
  62 + private String regionName;
  63 +
  64 + /**
  65 + * 日期
  66 + */
  67 + private LocalDate date;
  68 +
  69 + /**
  70 + * 运费
  71 + */
  72 + private BigDecimal shippingCost;
  73 +
  74 + /**
  75 + * 装车费
  76 + */
  77 + private BigDecimal loadingFee;
  78 +
  79 + /**
  80 + * 漆损
  81 + */
  82 + private BigDecimal paintLoss;
  83 +
  84 + /**
  85 + * 外观描述
  86 + */
  87 + private String appearanceDesc;
  88 +
  89 + /**
  90 + * 料质状况描述
  91 + */
  92 + private String materialConditionDesc;
  93 +
  94 + /**
  95 + * 废料描述
  96 + */
  97 + private String wasteMaterialDesc;
  98 +
  99 + /**
  100 + * 油水杂情况
  101 + */
  102 + private String oilWaterDesc;
  103 +
  104 + /**
  105 + * 买断原因
  106 + */
  107 + private String buyoutReason;
  108 +
  109 + /**
  110 + * 创建人ID
  111 + */
  112 + @TableField(fill = FieldFill.INSERT)
  113 + private String createById;
  114 +
  115 + /**
  116 + * 创建人
  117 + */
  118 + @TableField(fill = FieldFill.INSERT)
  119 + private String createBy;
  120 +
  121 + /**
  122 + * 更新人ID
  123 + */
  124 + @TableField(fill = FieldFill.INSERT_UPDATE)
  125 + private String updateById;
  126 +
  127 + /**
  128 + * 更新人
  129 + */
  130 + @TableField(fill = FieldFill.INSERT_UPDATE)
  131 + private String updateBy;
  132 +
  133 + /**
  134 + * 创建时间
  135 + */
  136 + @TableField(fill = FieldFill.INSERT)
  137 + private LocalDateTime createTime;
  138 +
  139 + /**
  140 + * 更新时间
  141 + */
  142 + @TableField(fill = FieldFill.INSERT_UPDATE)
  143 + private LocalDateTime updateTime;
  144 +}
  1 +package com.lframework.xingyun.sc.procurement.entity;
  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 +import java.math.BigDecimal;
  10 +import java.time.LocalDateTime;
  11 +
  12 +@Data
  13 +@TableName("procurement_buyout_apply_line")
  14 +public class ProcurementBuyoutApplyLine extends BaseEntity implements BaseDto {
  15 +
  16 + private static final long serialVersionUID = 1L;
  17 +
  18 + /**
  19 + * ID
  20 + */
  21 + private String id;
  22 +
  23 + /**
  24 + * 买断操作申请单ID
  25 + */
  26 + private String buyoutApplyId;
  27 +
  28 + /**
  29 + * 品种ID
  30 + */
  31 + private String productId;
  32 +
  33 + /**
  34 + * 品种名称
  35 + */
  36 + private String productName;
  37 +
  38 + /**
  39 + * 料型
  40 + */
  41 + private String materialType;
  42 +
  43 + /**
  44 + * 数量
  45 + */
  46 + private BigDecimal quantity;
  47 +
  48 + /**
  49 + * 买断价
  50 + */
  51 + private BigDecimal buyoutPrice;
  52 +
  53 + /**
  54 + * 买断料预计损耗
  55 + */
  56 + private BigDecimal estimatedLoss;
  57 +
  58 + /**
  59 + * 漆损率
  60 + */
  61 + private BigDecimal paintDamageRatio;
  62 +
  63 + /**
  64 + * 除损耗后纯铜价
  65 + */
  66 + private BigDecimal pureCopperPrice;
  67 +
  68 + /**
  69 + * 前端行标识
  70 + */
  71 + private String itemId;
  72 +
  73 + /**
  74 + * 创建人ID
  75 + */
  76 + @TableField(fill = FieldFill.INSERT)
  77 + private String createById;
  78 +
  79 + /**
  80 + * 创建人
  81 + */
  82 + @TableField(fill = FieldFill.INSERT)
  83 + private String createBy;
  84 +
  85 + /**
  86 + * 更新人ID
  87 + */
  88 + @TableField(fill = FieldFill.INSERT_UPDATE)
  89 + private String updateById;
  90 +
  91 + /**
  92 + * 更新人
  93 + */
  94 + @TableField(fill = FieldFill.INSERT_UPDATE)
  95 + private String updateBy;
  96 +
  97 + /**
  98 + * 创建时间
  99 + */
  100 + @TableField(fill = FieldFill.INSERT)
  101 + private LocalDateTime createTime;
  102 +
  103 + /**
  104 + * 更新时间
  105 + */
  106 + @TableField(fill = FieldFill.INSERT_UPDATE)
  107 + private LocalDateTime updateTime;
  108 +}
  1 +package com.lframework.xingyun.sc.procurement.impl.buyout;
  2 +
  3 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  4 +import com.lframework.xingyun.sc.procurement.entity.ProcurementBuyoutApplyLine;
  5 +import com.lframework.xingyun.sc.procurement.mappers.buyout.ProcurementBuyoutApplyLineMapper;
  6 +import com.lframework.xingyun.sc.procurement.service.buyout.ProcurementBuyoutApplyLineService;
  7 +import org.springframework.stereotype.Service;
  8 +import java.util.List;
  9 +
  10 +@Service
  11 +public class ProcurementBuyoutApplyLineServiceImpl extends
  12 + ServiceImpl<ProcurementBuyoutApplyLineMapper, ProcurementBuyoutApplyLine> implements
  13 + ProcurementBuyoutApplyLineService {
  14 +
  15 + @Override
  16 + public List<ProcurementBuyoutApplyLine> getByApplyId(String applyId) {
  17 + return getBaseMapper().getByApplyId(applyId);
  18 + }
  19 +}
  1 +package com.lframework.xingyun.sc.procurement.impl.buyout;
  2 +
  3 +import com.baomidou.mybatisplus.core.conditions.Wrapper;
  4 +import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  5 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  6 +import com.lframework.starter.common.exceptions.impl.DefaultClientException;
  7 +import com.lframework.starter.common.exceptions.impl.InputErrorException;
  8 +import com.lframework.starter.common.utils.CollectionUtil;
  9 +import com.lframework.starter.common.utils.StringUtil;
  10 +import com.lframework.starter.web.core.annotations.oplog.OpLog;
  11 +import com.lframework.starter.web.core.utils.IdUtil;
  12 +import com.lframework.starter.web.inner.components.oplog.OtherOpLogType;
  13 +import com.lframework.xingyun.basedata.entity.BreedRelationship;
  14 +import com.lframework.xingyun.basedata.service.breed.BreedRelationshipService;
  15 +import com.lframework.xingyun.sc.bo.procurement.GetProcurementBuyoutApplyBo;
  16 +import com.lframework.xingyun.sc.bo.procurement.GetProcurementPlanBo;
  17 +import com.lframework.xingyun.sc.procurement.entity.ProcurementBuyoutApply;
  18 +import com.lframework.xingyun.sc.procurement.entity.ProcurementBuyoutApplyLine;
  19 +import com.lframework.xingyun.sc.procurement.entity.ProcurementPlan;
  20 +import com.lframework.xingyun.sc.procurement.entity.ProcurementPlanLine;
  21 +import com.lframework.xingyun.sc.procurement.mappers.buyout.ProcurementBuyoutApplyMapper;
  22 +import com.lframework.xingyun.sc.procurement.service.buyout.ProcurementBuyoutApplyLineService;
  23 +import com.lframework.xingyun.sc.procurement.service.buyout.ProcurementBuyoutApplyService;
  24 +import com.lframework.xingyun.sc.procurement.service.plan.ProcurementPlanLineService;
  25 +import com.lframework.xingyun.sc.procurement.service.plan.ProcurementPlanService;
  26 +import com.lframework.xingyun.sc.procurement.vo.buyout.CreateProcurementBuyoutApplyVo;
  27 +import org.springframework.stereotype.Service;
  28 +import org.springframework.transaction.annotation.Transactional;
  29 +import javax.annotation.Resource;
  30 +import java.math.BigDecimal;
  31 +import java.math.RoundingMode;
  32 +import java.util.ArrayList;
  33 +import java.util.List;
  34 +
  35 +@Service
  36 +public class ProcurementBuyoutApplyServiceImpl extends
  37 + ServiceImpl<ProcurementBuyoutApplyMapper, ProcurementBuyoutApply> implements
  38 + ProcurementBuyoutApplyService {
  39 + @Resource
  40 + private ProcurementPlanService procurementPlanService;
  41 + @Resource
  42 + private ProcurementPlanLineService procurementPlanLineService;
  43 + @Resource
  44 + private ProcurementBuyoutApplyLineService buyoutApplyLineService;
  45 + @Resource
  46 + private BreedRelationshipService breedRelationshipService;
  47 +
  48 + @Override
  49 + @Transactional(rollbackFor = Exception.class)
  50 + @OpLog(type = OtherOpLogType.class, name = "生成买断操作申请单,ID:{}", params = {"#vo.procurementPlanId"})
  51 + public String create(CreateProcurementBuyoutApplyVo vo) {
  52 + if (StringUtil.isBlank(vo.getProcurementPlanId())) {
  53 + throw new InputErrorException("采购计划ID不能为空!");
  54 + }
  55 +
  56 + GetProcurementPlanBo plan = procurementPlanService.getDetail(vo.getProcurementPlanId());
  57 + if (plan == null) {
  58 + throw new DefaultClientException("采购计划不存在!");
  59 + }
  60 +
  61 + List<ProcurementPlanLine> planLines = procurementPlanLineService.getByProcurementPlanId(plan.getId());
  62 + if (CollectionUtil.isEmpty(planLines)) {
  63 + throw new DefaultClientException("采购计划明细为空!");
  64 + }
  65 +
  66 + ProcurementBuyoutApply apply = new ProcurementBuyoutApply();
  67 + apply.setId(IdUtil.getId());
  68 + apply.setProcurementPlanId(plan.getId());
  69 + apply.setCode(plan.getCode());
  70 + apply.setSupplierId(plan.getSupplierId());
  71 + apply.setSupplierName(plan.getSupplierName());
  72 + apply.setPurchaseDepartment(plan.getPurchaseDepartment());
  73 + apply.setPurchaseDepartmentName(plan.getPurchaseDepartmentName());
  74 + apply.setRegion(plan.getRegion());
  75 + apply.setRegionName(plan.getRegionName());
  76 + apply.setDate(plan.getDate());
  77 + apply.setShippingCost(plan.getShippingCost());
  78 + apply.setLoadingFee(plan.getLoadingFee());
  79 + apply.setAppearanceDesc("厂家生产过程中报废的一手料");
  80 + apply.setMaterialConditionDesc("料质清爽");
  81 + apply.setWasteMaterialDesc("含少量杂质");
  82 + apply.setOilWaterDesc(null);
  83 + apply.setBuyoutReason(null);
  84 +
  85 + this.save(apply);
  86 +
  87 + List<ProcurementBuyoutApplyLine> lines = new ArrayList<>();
  88 + BigDecimal shippingCost = plan.getShippingCost() == null ? BigDecimal.ZERO : plan.getShippingCost();
  89 + BigDecimal loadingFee = plan.getLoadingFee() == null ? BigDecimal.ZERO : plan.getLoadingFee();
  90 +
  91 + for (ProcurementPlanLine planLine : planLines) {
  92 + ProcurementBuyoutApplyLine line = new ProcurementBuyoutApplyLine();
  93 + line.setId(IdUtil.getId());
  94 + line.setBuyoutApplyId(apply.getId());
  95 + line.setProductId(planLine.getProductId());
  96 + line.setMaterialType(planLine.getMaterialType());
  97 + line.setQuantity(planLine.getQuantity());
  98 + line.setBuyoutPrice(planLine.getActualPurchasePrice());
  99 + line.setEstimatedLoss(planLine.getEstimatedLoss());
  100 + line.setItemId(planLine.getItemId());
  101 +
  102 + BreedRelationship breed = breedRelationshipService.getById(planLine.getProductId());
  103 + String productName = breed != null ? breed.getProductName() : null;
  104 + line.setProductName(productName);
  105 +
  106 + // 漆损率(%值存储到DB,计算时 ÷100)
  107 + // 优先级1:采购计划明细 paint_damage_ratio
  108 + BigDecimal paintDamageRatioPercent = planLine.getPaintDamageRatio();
  109 + if (paintDamageRatioPercent == null) {
  110 + // 优先级2:品种关系表("品种关系对应表中的漆损率",这里使用 attritionRate 作为漆损率%字段)
  111 + if (breed != null && breed.getAttritionRate() != null) {
  112 + paintDamageRatioPercent = breed.getAttritionRate();
  113 + }
  114 + }
  115 + line.setPaintDamageRatio(paintDamageRatioPercent);
  116 +
  117 + // 参与计算用的小数漆损率 = %值 / 100
  118 + BigDecimal ratioDecimal = paintDamageRatioPercent != null
  119 + ? paintDamageRatioPercent.divide(new BigDecimal("100"), 10, RoundingMode.HALF_UP)
  120 + : BigDecimal.ZERO;
  121 +
  122 + BigDecimal denominator = BigDecimal.ONE.subtract(ratioDecimal);
  123 + BigDecimal buyoutPrice = line.getBuyoutPrice() != null ? line.getBuyoutPrice() : BigDecimal.ZERO;
  124 + BigDecimal pureCopperPrice;
  125 + if (denominator.compareTo(BigDecimal.ZERO) > 0) {
  126 + pureCopperPrice = buyoutPrice.divide(denominator, 10, RoundingMode.HALF_UP);
  127 + } else {
  128 + pureCopperPrice = buyoutPrice;
  129 + }
  130 + BigDecimal estimatedLoss = line.getEstimatedLoss() == null ? BigDecimal.ZERO : line.getEstimatedLoss();
  131 + pureCopperPrice = pureCopperPrice.add(shippingCost).add(estimatedLoss).add(loadingFee);
  132 + line.setPureCopperPrice(pureCopperPrice);
  133 +
  134 + lines.add(line);
  135 + }
  136 +
  137 + if (!CollectionUtil.isEmpty(lines)) {
  138 + buyoutApplyLineService.saveBatch(lines);
  139 + }
  140 +
  141 + // 主表漆损:只有品种名含"漆"字的品种才参与加权平均
  142 + // 公式:Σ(带漆qty * (1 - ratioDecimal)) / Σ(带漆qty)
  143 + BigDecimal paintTotalQty = BigDecimal.ZERO;
  144 + BigDecimal paintLossNumerator = BigDecimal.ZERO;
  145 + for (ProcurementBuyoutApplyLine line : lines) {
  146 + String pName = line.getProductName();
  147 + if (StringUtil.isBlank(pName) || !pName.contains("漆")) {
  148 + continue;
  149 + }
  150 + BigDecimal qty = line.getQuantity() == null ? BigDecimal.ZERO : line.getQuantity();
  151 + if (qty.compareTo(BigDecimal.ZERO) <= 0) {
  152 + continue;
  153 + }
  154 + BigDecimal ratioPercent = line.getPaintDamageRatio();
  155 + BigDecimal ratioDecimal = ratioPercent != null
  156 + ? ratioPercent.divide(new BigDecimal("100"), 10, RoundingMode.HALF_UP)
  157 + : BigDecimal.ZERO;
  158 +
  159 + paintTotalQty = paintTotalQty.add(qty);
  160 + paintLossNumerator = paintLossNumerator.add(qty.multiply(BigDecimal.ONE.subtract(ratioDecimal)));
  161 + }
  162 + BigDecimal paintLoss = paintTotalQty.compareTo(BigDecimal.ZERO) > 0
  163 + ? paintLossNumerator.divide(paintTotalQty, 10, RoundingMode.HALF_UP)
  164 + : BigDecimal.ZERO;
  165 + apply.setPaintLoss(paintLoss);
  166 + this.updateById(apply);
  167 +
  168 + return apply.getId();
  169 + }
  170 +
  171 + @Override
  172 + @Transactional(rollbackFor = Exception.class)
  173 + @OpLog(type = OtherOpLogType.class, name = "删除买断操作申请单,ID:{}", params = {"#id"})
  174 + public void deleteById(String id) {
  175 + if (StringUtil.isBlank(id)) {
  176 + throw new InputErrorException("ID不能为空!");
  177 + }
  178 + ProcurementBuyoutApply apply = this.getById(id);
  179 + if (apply == null) {
  180 + throw new DefaultClientException("买断操作申请单不存在!");
  181 + }
  182 +
  183 + buyoutApplyLineService.remove(Wrappers.lambdaQuery(ProcurementBuyoutApplyLine.class)
  184 + .eq(ProcurementBuyoutApplyLine::getBuyoutApplyId, id));
  185 +
  186 + this.removeById(id);
  187 + }
  188 +
  189 + @Override
  190 + @Transactional(rollbackFor = Exception.class)
  191 + @OpLog(type = OtherOpLogType.class, name = "删除买断操作申请单,计划ID:{}", params = {"#planId"})
  192 + public void deleteByPlanId(String planId) {
  193 + if (StringUtil.isBlank(planId)) {
  194 + throw new InputErrorException("计划ID不能为空!");
  195 + }
  196 + Wrapper<ProcurementBuyoutApply> queryWrapper = Wrappers.lambdaQuery(ProcurementBuyoutApply.class)
  197 + .eq(ProcurementBuyoutApply::getProcurementPlanId, planId);
  198 + ProcurementBuyoutApply apply = this.getOne(queryWrapper);
  199 + if (apply == null) {
  200 + throw new DefaultClientException("买断操作申请单不存在!");
  201 + }
  202 +
  203 + buyoutApplyLineService.remove(Wrappers.lambdaQuery(ProcurementBuyoutApplyLine.class)
  204 + .eq(ProcurementBuyoutApplyLine::getBuyoutApplyId, apply.getId()));
  205 +
  206 + this.removeById(apply.getId());
  207 + }
  208 +
  209 + @Override
  210 + public GetProcurementBuyoutApplyBo findById(String id) {
  211 + if (StringUtil.isBlank(id)) {
  212 + throw new InputErrorException("ID不能为空!");
  213 + }
  214 +
  215 + ProcurementBuyoutApply apply = getBaseMapper().findById(id);
  216 + if (apply == null) {
  217 + throw new DefaultClientException("买断操作申请单不存在!");
  218 + }
  219 +
  220 + List<ProcurementBuyoutApplyLine> lineList = buyoutApplyLineService.getByApplyId(id);
  221 +
  222 + return new GetProcurementBuyoutApplyBo(apply, lineList);
  223 + }
  224 +
  225 + @Override
  226 + public GetProcurementBuyoutApplyBo findByPlanId(String planId) {
  227 + if (StringUtil.isBlank(planId)) {
  228 + throw new InputErrorException("计划ID不能为空!");
  229 + }
  230 + Wrapper<ProcurementBuyoutApply> queryWrapper = Wrappers.lambdaQuery(ProcurementBuyoutApply.class)
  231 + .eq(ProcurementBuyoutApply::getProcurementPlanId, planId);
  232 + ProcurementBuyoutApply apply = this.getOne(queryWrapper);
  233 + if (apply == null) {
  234 + throw new DefaultClientException("买断操作申请单不存在!");
  235 + }
  236 +
  237 + List<ProcurementBuyoutApplyLine> lineList = buyoutApplyLineService.getByApplyId(apply.getId());
  238 +
  239 + return new GetProcurementBuyoutApplyBo(apply, lineList);
  240 + }
  241 +}
  1 +package com.lframework.xingyun.sc.procurement.mappers.buyout;
  2 +
  3 +import com.lframework.starter.web.core.mapper.BaseMapper;
  4 +import com.lframework.xingyun.sc.procurement.entity.ProcurementBuyoutApplyLine;
  5 +import org.apache.ibatis.annotations.Param;
  6 +import java.util.List;
  7 +
  8 +public interface ProcurementBuyoutApplyLineMapper extends BaseMapper<ProcurementBuyoutApplyLine> {
  9 +
  10 + /**
  11 + * 根据申请单ID查询
  12 + *
  13 + * @param applyId
  14 + * @return
  15 + */
  16 + List<ProcurementBuyoutApplyLine> getByApplyId(@Param("applyId") String applyId);
  17 +}
  1 +package com.lframework.xingyun.sc.procurement.mappers.buyout;
  2 +
  3 +import com.lframework.starter.web.core.mapper.BaseMapper;
  4 +import com.lframework.xingyun.sc.procurement.entity.ProcurementBuyoutApply;
  5 +import org.apache.ibatis.annotations.Param;
  6 +
  7 +public interface ProcurementBuyoutApplyMapper extends BaseMapper<ProcurementBuyoutApply> {
  8 +
  9 + /**
  10 + * 根据ID查询
  11 + *
  12 + * @param id
  13 + * @return
  14 + */
  15 + ProcurementBuyoutApply findById(@Param("id") String id);
  16 +}
  1 +package com.lframework.xingyun.sc.procurement.service.buyout;
  2 +
  3 +import com.baomidou.mybatisplus.extension.service.IService;
  4 +import com.lframework.xingyun.sc.procurement.entity.ProcurementBuyoutApplyLine;
  5 +import java.util.List;
  6 +
  7 +public interface ProcurementBuyoutApplyLineService extends IService<ProcurementBuyoutApplyLine> {
  8 +
  9 + /**
  10 + * 根据申请单ID查询
  11 + *
  12 + * @param applyId
  13 + * @return
  14 + */
  15 + List<ProcurementBuyoutApplyLine> getByApplyId(String applyId);
  16 +}
  1 +package com.lframework.xingyun.sc.procurement.service.buyout;
  2 +
  3 +import com.baomidou.mybatisplus.extension.service.IService;
  4 +import com.lframework.xingyun.sc.bo.procurement.GetProcurementBuyoutApplyBo;
  5 +import com.lframework.xingyun.sc.procurement.entity.ProcurementBuyoutApply;
  6 +import com.lframework.xingyun.sc.procurement.vo.buyout.CreateProcurementBuyoutApplyVo;
  7 +
  8 +public interface ProcurementBuyoutApplyService extends IService<ProcurementBuyoutApply> {
  9 +
  10 + /**
  11 + * 创建
  12 + *
  13 + * @param vo
  14 + * @return
  15 + */
  16 + String create(CreateProcurementBuyoutApplyVo vo);
  17 +
  18 + /**
  19 + * 根据ID删除
  20 + *
  21 + * @param id
  22 + */
  23 + void deleteById(String id);
  24 +
  25 +
  26 + /**
  27 + * 根据计划ID删除
  28 + *
  29 + * @param planId 计划ID
  30 + */
  31 + void deleteByPlanId(String planId);
  32 +
  33 + /**
  34 + * 根据ID查询详情
  35 + *
  36 + * @param id
  37 + * @return
  38 + */
  39 + GetProcurementBuyoutApplyBo findById(String id);
  40 +
  41 + /**
  42 + * 根据计划ID查询详情
  43 + *
  44 + * @param planId 计划ID
  45 + * @return
  46 + */
  47 + GetProcurementBuyoutApplyBo findByPlanId(String planId);
  48 +}
  1 +package com.lframework.xingyun.sc.procurement.vo.buyout;
  2 +
  3 +import com.lframework.starter.web.core.vo.BaseVo;
  4 +import io.swagger.annotations.ApiModelProperty;
  5 +import lombok.Data;
  6 +import javax.validation.constraints.NotBlank;
  7 +import java.io.Serializable;
  8 +
  9 +@Data
  10 +public class CreateProcurementBuyoutApplyVo implements BaseVo, Serializable {
  11 +
  12 + private static final long serialVersionUID = 1L;
  13 +
  14 + /**
  15 + * 采购计划ID
  16 + */
  17 + @ApiModelProperty(value = "采购计划ID", required = true)
  18 + @NotBlank(message = "采购计划ID不能为空!")
  19 + private String procurementPlanId;
  20 +}
  1 +package com.lframework.xingyun.sc.procurement.vo.buyout;
  2 +
  3 +import io.swagger.annotations.ApiModelProperty;
  4 +import lombok.Data;
  5 +
  6 +import java.time.LocalDate;
  7 +
  8 +@Data
  9 +public class QueryProcurementBuyoutApplyVo {
  10 +
  11 + private static final long serialVersionUID = 1L;
  12 +
  13 + /**
  14 + * 编号
  15 + */
  16 + @ApiModelProperty("编号")
  17 + private String code;
  18 +
  19 + /**
  20 + * 供应商ID
  21 + */
  22 + @ApiModelProperty("供应商ID")
  23 + private String supplierId;
  24 +
  25 + /**
  26 + * 供应商名称
  27 + */
  28 + @ApiModelProperty("供应商名称")
  29 + private String supplierName;
  30 +
  31 + /**
  32 + * 采购处
  33 + */
  34 + @ApiModelProperty("采购处")
  35 + private String purchaseDepartment;
  36 +
  37 + /**
  38 + * 区域
  39 + */
  40 + @ApiModelProperty("区域")
  41 + private String region;
  42 +
  43 + /**
  44 + * 日期起始
  45 + */
  46 + @ApiModelProperty("日期起始")
  47 + private LocalDate startDate;
  48 +
  49 + /**
  50 + * 日期截止
  51 + */
  52 + @ApiModelProperty("日期截止")
  53 + private LocalDate endDate;
  54 +}
  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.buyout.ProcurementBuyoutApplyLineMapper">
  4 +
  5 + <resultMap id="ProcurementBuyoutApplyLine" type="com.lframework.xingyun.sc.procurement.entity.ProcurementBuyoutApplyLine">
  6 + <id column="id" property="id"/>
  7 + <result column="buyout_apply_id" property="buyoutApplyId"/>
  8 + <result column="product_id" property="productId"/>
  9 + <result column="product_name" property="productName"/>
  10 + <result column="material_type" property="materialType"/>
  11 + <result column="item_id" property="itemId"/>
  12 + <result column="quantity" property="quantity"/>
  13 + <result column="buyout_price" property="buyoutPrice"/>
  14 + <result column="estimated_loss" property="estimatedLoss"/>
  15 + <result column="paint_damage_ratio" property="paintDamageRatio"/>
  16 + <result column="pure_copper_price" property="pureCopperPrice"/>
  17 + <result column="create_by_id" property="createById"/>
  18 + <result column="create_by" property="createBy"/>
  19 + <result column="update_by_id" property="updateById"/>
  20 + <result column="update_by" property="updateBy"/>
  21 + <result column="create_time" property="createTime"/>
  22 + <result column="update_time" property="updateTime"/>
  23 + </resultMap>
  24 +
  25 + <sql id="ProcurementBuyoutApplyLine_sql">
  26 + SELECT
  27 + pbal.id,
  28 + pbal.buyout_apply_id,
  29 + pbal.product_id,
  30 + pbal.product_name,
  31 + pbal.material_type,
  32 + pbal.item_id,
  33 + pbal.quantity,
  34 + pbal.buyout_price,
  35 + pbal.estimated_loss,
  36 + pbal.paint_damage_ratio,
  37 + pbal.pure_copper_price,
  38 + pbal.create_by_id,
  39 + pbal.create_by,
  40 + pbal.update_by_id,
  41 + pbal.update_by,
  42 + pbal.create_time,
  43 + pbal.update_time
  44 + FROM procurement_buyout_apply_line AS pbal
  45 + </sql>
  46 +
  47 + <select id="getByApplyId" resultMap="ProcurementBuyoutApplyLine">
  48 + <include refid="ProcurementBuyoutApplyLine_sql"/>
  49 + WHERE pbal.buyout_apply_id = #{applyId}
  50 + ORDER BY pbal.create_time ASC
  51 + </select>
  52 +</mapper>
  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.buyout.ProcurementBuyoutApplyMapper">
  4 +
  5 + <resultMap id="ProcurementBuyoutApply" type="com.lframework.xingyun.sc.procurement.entity.ProcurementBuyoutApply">
  6 + <id column="id" property="id"/>
  7 + <result column="procurement_plan_id" property="procurementPlanId"/>
  8 + <result column="code" property="code"/>
  9 + <result column="supplier_id" property="supplierId"/>
  10 + <result column="supplier_name" property="supplierName"/>
  11 + <result column="purchase_department" property="purchaseDepartment"/>
  12 + <result column="purchase_department_name" property="purchaseDepartmentName"/>
  13 + <result column="region" property="region"/>
  14 + <result column="region_name" property="regionName"/>
  15 + <result column="date" property="date"/>
  16 + <result column="shipping_cost" property="shippingCost"/>
  17 + <result column="loading_fee" property="loadingFee"/>
  18 + <result column="paint_loss" property="paintLoss"/>
  19 + <result column="appearance_desc" property="appearanceDesc"/>
  20 + <result column="material_condition_desc" property="materialConditionDesc"/>
  21 + <result column="waste_material_desc" property="wasteMaterialDesc"/>
  22 + <result column="oil_water_desc" property="oilWaterDesc"/>
  23 + <result column="buyout_reason" property="buyoutReason"/>
  24 + <result column="create_by_id" property="createById"/>
  25 + <result column="create_by" property="createBy"/>
  26 + <result column="update_by_id" property="updateById"/>
  27 + <result column="update_by" property="updateBy"/>
  28 + <result column="create_time" property="createTime"/>
  29 + <result column="update_time" property="updateTime"/>
  30 + </resultMap>
  31 +
  32 + <sql id="ProcurementBuyoutApply_sql">
  33 + SELECT
  34 + pba.id,
  35 + pba.procurement_plan_id,
  36 + pba.code,
  37 + pba.supplier_id,
  38 + pba.supplier_name,
  39 + pba.purchase_department,
  40 + pba.purchase_department_name,
  41 + pba.region,
  42 + pba.region_name,
  43 + pba.date,
  44 + pba.shipping_cost,
  45 + pba.loading_fee,
  46 + pba.paint_loss,
  47 + pba.appearance_desc,
  48 + pba.material_condition_desc,
  49 + pba.waste_material_desc,
  50 + pba.oil_water_desc,
  51 + pba.buyout_reason,
  52 + pba.create_by_id,
  53 + pba.create_by,
  54 + pba.update_by_id,
  55 + pba.update_by,
  56 + pba.create_time,
  57 + pba.update_time
  58 + FROM procurement_buyout_apply AS pba
  59 + </sql>
  60 +
  61 + <select id="findById" resultMap="ProcurementBuyoutApply">
  62 + <include refid="ProcurementBuyoutApply_sql"/>
  63 + WHERE pba.id = #{id}
  64 + </select>
  65 +</mapper>