10 changed files with 424 additions and 2 deletions
-
1src/main/java/com/spring/modules/quotation/service/impl/QuotationHeaderServiceImpl.java
-
50src/main/java/com/spring/modules/quote/controller/SalesQuoteController.java
-
92src/main/java/com/spring/modules/quote/entity/SalesQuote.java
-
78src/main/java/com/spring/modules/quote/entity/SalesQuoteDetail.java
-
16src/main/java/com/spring/modules/quote/mapper/SalesQuoteMapper.java
-
17src/main/java/com/spring/modules/quote/service/SalesQuoteService.java
-
74src/main/java/com/spring/modules/quote/service/impl/SalesQuoteServiceImpl.java
-
2src/main/resources/application-dev.yml
-
2src/main/resources/mapper/quotation/QuotationHeaderMapper.xml
-
94src/main/resources/mapper/quote/SalesQuoteMapper.xml
@ -0,0 +1,50 @@ |
|||||
|
package com.spring.modules.quote.controller; |
||||
|
|
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.spring.common.utils.R; |
||||
|
import com.spring.modules.quote.entity.SalesQuote; |
||||
|
import com.spring.modules.quote.service.SalesQuoteService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@RestController |
||||
|
@RequestMapping("/sales/quote") |
||||
|
public class SalesQuoteController { |
||||
|
@Autowired |
||||
|
private SalesQuoteService salesQuoteService; |
||||
|
|
||||
|
@PostMapping("/{no}/{size}") |
||||
|
public R querySalesQuote(@RequestBody SalesQuote quote, |
||||
|
@PathVariable int no, |
||||
|
@PathVariable int size){ |
||||
|
IPage<SalesQuote> page = salesQuoteService.querySalesQuoteByPage(no, size, quote); |
||||
|
return R.ok().put("rows", page.getRecords()).put("total", page.getTotal()); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/save") |
||||
|
public R saveSalesQuote(@RequestBody SalesQuote quote){ |
||||
|
salesQuoteService.saveSalesQuote(quote); |
||||
|
return R.ok("操作成功"); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/update") |
||||
|
public R updateSalesQuote(@RequestBody SalesQuote quote){ |
||||
|
salesQuoteService.updateSalesQuote(quote); |
||||
|
return R.ok("操作成功"); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/remove") |
||||
|
public R removeSalesQuote(@RequestBody SalesQuote quote){ |
||||
|
salesQuoteService.removeSalesQuote(quote); |
||||
|
return R.ok("操作成功"); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/update/status") |
||||
|
public R updateSalesQuoteStatus(@RequestBody SalesQuote quote){ |
||||
|
salesQuoteService.updateSalesQuoteStatus(quote); |
||||
|
return R.ok("操作成功"); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,92 @@ |
|||||
|
package com.spring.modules.quote.entity; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.TableField; |
||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import lombok.Data; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
@TableName("quotation_header") |
||||
|
@Data |
||||
|
public class SalesQuote { |
||||
|
|
||||
|
@TableField(exist = false) |
||||
|
public static final String PREFIX = "BJ"; |
||||
|
@TableField(exist = false) |
||||
|
public static final String VERSION_PREFIX = "A"; |
||||
|
@TableField(exist = false) |
||||
|
public static final String DEFAULT_STATUS = "草稿"; |
||||
|
|
||||
|
@TableId("quotation_header_id") |
||||
|
private Long id; |
||||
|
|
||||
|
private String site; |
||||
|
|
||||
|
private String quotationNo; |
||||
|
|
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
||||
|
private Date quotationDate; |
||||
|
|
||||
|
private String customerNo; |
||||
|
|
||||
|
private String versionCode; |
||||
|
|
||||
|
private String projectId; |
||||
|
|
||||
|
private String quoter; |
||||
|
|
||||
|
private String tracker; |
||||
|
|
||||
|
private String currency; |
||||
|
|
||||
|
@TableField("quotation_status") |
||||
|
private String status; |
||||
|
|
||||
|
private String remark; |
||||
|
|
||||
|
private String customerInquiryNo; |
||||
|
|
||||
|
private String internalInquiryNo; |
||||
|
|
||||
|
private String requireApproval; |
||||
|
|
||||
|
private String approvalStatus; |
||||
|
|
||||
|
private String createBy; |
||||
|
|
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
|
private Date createTime; |
||||
|
|
||||
|
private String active; |
||||
|
|
||||
|
private String toolRequireFlag; |
||||
|
|
||||
|
@TableField(exist = false) |
||||
|
private String customerDesc; |
||||
|
|
||||
|
@TableField(exist = false) |
||||
|
private String projectDesc; |
||||
|
|
||||
|
@TableField(exist = false) |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
||||
|
private Date startDate; |
||||
|
|
||||
|
@TableField(exist = false) |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
||||
|
private Date endDate; |
||||
|
|
||||
|
@TableField(exist = false) |
||||
|
private String quoterName; |
||||
|
|
||||
|
@TableField(exist = false) |
||||
|
private String trackerName; |
||||
|
@TableField(exist = false) |
||||
|
private String quoteVersionNo; |
||||
|
} |
||||
@ -0,0 +1,78 @@ |
|||||
|
package com.spring.modules.quote.entity; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.TableField; |
||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.math.BigDecimal; |
||||
|
|
||||
|
@TableName("quotation_detail") |
||||
|
@Data |
||||
|
public class SalesQuoteDetail { |
||||
|
|
||||
|
@TableId("quotation_detail_id") |
||||
|
private Long id; |
||||
|
|
||||
|
private Long quotation_header_id; |
||||
|
|
||||
|
private String site; |
||||
|
|
||||
|
private String product_no; |
||||
|
|
||||
|
private String product_desc; |
||||
|
|
||||
|
private String internal_inquiry_no; |
||||
|
|
||||
|
@TableField("quotation_detail_quantity") |
||||
|
private BigDecimal qty; |
||||
|
|
||||
|
private Integer quotation_detail_count; |
||||
|
|
||||
|
@TableField("quotation_detail_status") |
||||
|
private String status; |
||||
|
|
||||
|
private BigDecimal compute_part_cost; |
||||
|
|
||||
|
private BigDecimal compute_labour_cost; |
||||
|
|
||||
|
private BigDecimal compute_fabricate_cost; |
||||
|
|
||||
|
private BigDecimal compute_tool_cost; |
||||
|
|
||||
|
private BigDecimal adjust_part_cost; |
||||
|
|
||||
|
private BigDecimal adjust_labour_cost; |
||||
|
|
||||
|
private BigDecimal adjust_fabricate_cost; |
||||
|
|
||||
|
private BigDecimal adjust_tool_cost; |
||||
|
|
||||
|
private BigDecimal detail_other_cost; |
||||
|
|
||||
|
private BigDecimal detail_manage_cost; |
||||
|
|
||||
|
private BigDecimal detail_total_cost; |
||||
|
|
||||
|
private BigDecimal detail_profit_rate; |
||||
|
|
||||
|
private BigDecimal detail_profit_amount; |
||||
|
|
||||
|
private BigDecimal system_compute_amount; |
||||
|
|
||||
|
private BigDecimal system_compute_price; |
||||
|
|
||||
|
private BigDecimal final_untaxed_price; |
||||
|
|
||||
|
private BigDecimal final_taxed_price; |
||||
|
|
||||
|
private BigDecimal compute_machine_cost; |
||||
|
|
||||
|
private BigDecimal adjust_machine_cost; |
||||
|
|
||||
|
private BigDecimal tax_rate; |
||||
|
|
||||
|
private String remark; |
||||
|
|
||||
|
private String active; |
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
package com.spring.modules.quote.mapper; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
import com.spring.modules.quote.entity.SalesQuote; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
|
||||
|
@Mapper |
||||
|
public interface SalesQuoteMapper extends BaseMapper<SalesQuote> { |
||||
|
IPage<SalesQuote> querySalesQuoteByPage(@Param("page") Page<SalesQuote> page,@Param("quote") SalesQuote quote); |
||||
|
|
||||
|
Integer getSalesQuoteNo(SalesQuote quote); |
||||
|
Integer getSalesVersionCode(SalesQuote quote); |
||||
|
} |
||||
@ -0,0 +1,17 @@ |
|||||
|
package com.spring.modules.quote.service; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
import com.spring.modules.quote.entity.SalesQuote; |
||||
|
|
||||
|
public interface SalesQuoteService extends IService <SalesQuote> { |
||||
|
IPage<SalesQuote> querySalesQuoteByPage(int no, int size, SalesQuote quote); |
||||
|
|
||||
|
void saveSalesQuote(SalesQuote quote); |
||||
|
|
||||
|
void updateSalesQuote(SalesQuote quote); |
||||
|
|
||||
|
void removeSalesQuote(SalesQuote quote); |
||||
|
|
||||
|
void updateSalesQuoteStatus(SalesQuote quote); |
||||
|
} |
||||
@ -0,0 +1,74 @@ |
|||||
|
package com.spring.modules.quote.service.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
|
import com.spring.modules.quote.entity.SalesQuote; |
||||
|
import com.spring.modules.quote.mapper.SalesQuoteMapper; |
||||
|
import com.spring.modules.quote.service.SalesQuoteService; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
@Service |
||||
|
public class SalesQuoteServiceImpl extends ServiceImpl<SalesQuoteMapper, SalesQuote> implements SalesQuoteService { |
||||
|
@Override |
||||
|
public IPage<SalesQuote> querySalesQuoteByPage(int no, int size, SalesQuote quote) { |
||||
|
Page<SalesQuote> page = new Page<>(no, size); |
||||
|
return baseMapper.querySalesQuoteByPage(page,quote); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional |
||||
|
public void saveSalesQuote(SalesQuote quote) { |
||||
|
// 获取报价单号 |
||||
|
Integer code = baseMapper.getSalesQuoteNo(quote); |
||||
|
String quoteNo = String.format("%08d", code); |
||||
|
quote.setQuotationNo(SalesQuote.PREFIX + quoteNo); |
||||
|
// 获取版本号 |
||||
|
Integer version = baseMapper.getSalesVersionCode(quote); |
||||
|
String versionCode = String.format("%03d", version); |
||||
|
quote.setVersionCode(SalesQuote.VERSION_PREFIX+versionCode); |
||||
|
// 设置默认状态 |
||||
|
quote.setStatus(SalesQuote.DEFAULT_STATUS); |
||||
|
// 设置创建时间 |
||||
|
quote.setCreateTime(new Date()); |
||||
|
|
||||
|
|
||||
|
save(quote); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional |
||||
|
public void updateSalesQuote(SalesQuote quote) { |
||||
|
updateById(quote); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional |
||||
|
public void removeSalesQuote(SalesQuote quote) { |
||||
|
// 校验明细 |
||||
|
|
||||
|
|
||||
|
removeById(quote.getId()); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional |
||||
|
public void updateSalesQuoteStatus(SalesQuote quote) { |
||||
|
String status = quote.getStatus(); |
||||
|
if("下达".equals(quote.getStatus())){ |
||||
|
status = "草稿"; |
||||
|
}else if ("草稿".equals(quote.getStatus())){ |
||||
|
status = "下达"; |
||||
|
} |
||||
|
// 改变明细状态 |
||||
|
|
||||
|
// 改变报价单状态 |
||||
|
lambdaUpdate() |
||||
|
.eq(SalesQuote::getId,quote.getId()) |
||||
|
.set(SalesQuote::getStatus,status) |
||||
|
.update(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,94 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
<mapper namespace="com.spring.modules.quote.mapper.SalesQuoteMapper"> |
||||
|
|
||||
|
<select id="querySalesQuoteByPage" resultType="com.spring.modules.quote.entity.SalesQuote"> |
||||
|
select qh.quotation_header_id as id, |
||||
|
qh.site, |
||||
|
qh.quotation_no, |
||||
|
qh.quotation_date, |
||||
|
qh.customer_no, |
||||
|
qh.version_code, |
||||
|
qh.project_id, |
||||
|
qh.tracker, |
||||
|
qh.quoter, |
||||
|
qh.currency, |
||||
|
qh.quotation_status as status, |
||||
|
qh.remark, |
||||
|
qh.customer_inquiry_no, |
||||
|
qh.internal_inquiry_no, |
||||
|
qh.require_approval, |
||||
|
qh.approval_status, |
||||
|
qh.create_by, |
||||
|
qh.create_time, |
||||
|
qh.active, |
||||
|
qh.tool_require_flag, |
||||
|
c.customer_desc, |
||||
|
p.project_name as project_desc, |
||||
|
concat(qh.quotation_no, '-', qh.version_code) as quote_version_no, |
||||
|
dbo.get_userDisPlay(qh.quoter) as quoter_name, |
||||
|
dbo.get_userDisPlay(qh.tracker) as tracker_name |
||||
|
from quotation_header qh |
||||
|
left join plm_customer_information c on qh.customer_no = c.customer_no and c.site = qh.site |
||||
|
left join plm_project_info p on qh.project_id = p.project_id and p.site = qh.site |
||||
|
<where> |
||||
|
<if test="quote.site != null and quote.site != ''"> |
||||
|
and qh.site = #{quote.site} |
||||
|
</if> |
||||
|
<if test="quote.quotationNo != null and quote.quotationNo != ''"> |
||||
|
and concat(qh.quotation_no, '-', qh.version_code) like #{quote.quotationNo} |
||||
|
</if> |
||||
|
<if test="quote.status != null and quote.status != ''"> |
||||
|
and qh.quotation_status = #{quote.status} |
||||
|
</if> |
||||
|
<if test="quote.customerInquiryNo != null and quote.customerInquiryNo != ''"> |
||||
|
and qh.customer_inquiry_no like #{quote.customerInquiryNo} |
||||
|
</if> |
||||
|
<if test="quote.internalInquiryNo != null and quote.internalInquiryNo != ''"> |
||||
|
and qh.internal_inquiry_no like #{quote.internalInquiryNo} |
||||
|
</if> |
||||
|
<if test="quote.customerNo != null and quote.customerNo != ''"> |
||||
|
and qh.customer_no like #{quote.customerNo} |
||||
|
</if> |
||||
|
<if test="quote.customerDesc != null and quote.customerDesc != ''"> |
||||
|
and c.customer_desc like #{quote.customerDesc} |
||||
|
</if> |
||||
|
<if test="quote.projectId != null and quote.projectId != ''"> |
||||
|
and qh.project_id = #{quote.projectId} |
||||
|
</if> |
||||
|
<if test="quote.projectDesc != null and quote.projectDesc != ''"> |
||||
|
and p.project_desc like #{quote.projectDesc} |
||||
|
</if> |
||||
|
<if test="quote.startDate != null"> |
||||
|
and qh.quotation_date >= #{quote.startDate} |
||||
|
</if> |
||||
|
<if test="quote.endDate != null"> |
||||
|
and qh.quotation_date <= #{quote.endDate} |
||||
|
</if> |
||||
|
<if test="quote.quoterName != null and quote.quoterName != ''"> |
||||
|
and dbo.get_userDisPlay(qh.quoter) like #{quote.quoterName} |
||||
|
</if> |
||||
|
<if test="quote.trackerName != null and quote.trackerName != ''"> |
||||
|
and dbo.get_userDisPlay(qh.tracker) like #{quote.trackerName} |
||||
|
</if> |
||||
|
order by CAST(RIGHT(qh.quotation_no, 8) AS int) desc, CAST(RIGHT(qh.version_code, 3) AS int) desc |
||||
|
</where> |
||||
|
</select> |
||||
|
|
||||
|
<select id="getSalesQuoteNo" resultType="java.lang.Integer"> |
||||
|
SELECT |
||||
|
isnull(max(CAST(RIGHT(quotation_no, 8) AS int)), 0) + 1 AS next_quotationNo |
||||
|
FROM |
||||
|
quotation_header |
||||
|
where site = #{site} |
||||
|
</select> |
||||
|
|
||||
|
<select id="getSalesVersionCode" resultType="java.lang.Integer"> |
||||
|
SELECT |
||||
|
isnull(max(CAST(RIGHT(version_code, 3) AS int)), 0) + 1 AS next_versionCode |
||||
|
FROM |
||||
|
quotation_header |
||||
|
where site = #{site} and quotation_no = #{quotationNo} |
||||
|
</select> |
||||
|
</mapper> |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue