9 changed files with 519 additions and 2 deletions
-
1src/main/java/com/xujie/sys/modules/pms/service/Impl/EamObjectServiceImpl.java
-
66src/main/java/com/xujie/sys/modules/quote/controller/QuoteController.java
-
115src/main/java/com/xujie/sys/modules/quote/entity/Quote.java
-
25src/main/java/com/xujie/sys/modules/quote/mapper/QuoteMapper.java
-
23src/main/java/com/xujie/sys/modules/quote/service/QuoteService.java
-
90src/main/java/com/xujie/sys/modules/quote/service/impl/QuoteServiceImpl.java
-
1src/main/resources/application-dev.yml
-
1src/main/resources/mapper/pms/EamMapper.xml
-
199src/main/resources/mapper/quote/QuoteMapper.xml
@ -0,0 +1,66 @@ |
|||||
|
package com.xujie.sys.modules.quote.controller; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.xujie.sys.common.utils.R; |
||||
|
import com.xujie.sys.modules.quote.entity.Quote; |
||||
|
import com.xujie.sys.modules.quote.service.QuoteService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@RestController |
||||
|
@RequestMapping("/quote") |
||||
|
public class QuoteController { |
||||
|
|
||||
|
@Autowired |
||||
|
private QuoteService quoteService; |
||||
|
|
||||
|
@PostMapping("/{no}/{size}") |
||||
|
public R queryQuotePage(@PathVariable Integer no, |
||||
|
@PathVariable Integer size, |
||||
|
@RequestBody Quote quote){ |
||||
|
IPage<Quote> page = quoteService.queryQuotePage(no, size, quote); |
||||
|
return R.ok().put("rows", page.getRecords()).put("total", page.getTotal()); |
||||
|
} |
||||
|
|
||||
|
@PostMapping |
||||
|
public R queryQuoteList(@RequestBody Quote quote){ |
||||
|
return R.ok().put("rows", quoteService.queryQuoteList(quote)); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/{id}") |
||||
|
public R queryQuoteById(@PathVariable Long id) { |
||||
|
return R.ok().put("row", quoteService.queryQuoteById(id)); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/save") |
||||
|
public R saveQuote(@RequestBody Quote quote) { |
||||
|
quoteService.saveQuote(quote); |
||||
|
return R.ok("操作成功"); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/update") |
||||
|
public R updateQuote(@RequestBody Quote quote) { |
||||
|
quoteService.updateQuote(quote); |
||||
|
return R.ok("操作成功"); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/remove/{id}") |
||||
|
public R removeQuote(@PathVariable Long id) { |
||||
|
quoteService.removeById(id); |
||||
|
return R.ok("操作成功"); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/again") |
||||
|
public R againQuote(@RequestBody Quote quote) { |
||||
|
quoteService.againQuote(quote); |
||||
|
return R.ok("操作成功"); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/batch/save") |
||||
|
public R batchSaveQuote(@RequestBody List<Quote> quotes) { |
||||
|
quoteService.batchSaveQuote(quotes); |
||||
|
return R.ok("操作成功"); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,115 @@ |
|||||
|
package com.xujie.sys.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("plm_quote") |
||||
|
@Data |
||||
|
public class Quote { |
||||
|
|
||||
|
@TableId |
||||
|
private Long id; |
||||
|
|
||||
|
private String quoteNo; |
||||
|
|
||||
|
private String site; |
||||
|
|
||||
|
private String buNo; |
||||
|
|
||||
|
private String versionNo; |
||||
|
|
||||
|
@JsonFormat(pattern = "yyyy-MM-dd") |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd") |
||||
|
private Date quoteDate; |
||||
|
|
||||
|
private String quoteVersionNo; |
||||
|
|
||||
|
private String customerNo; |
||||
|
|
||||
|
private String projectNo; |
||||
|
|
||||
|
/** |
||||
|
* 采购专员 |
||||
|
*/ |
||||
|
private String purchase; |
||||
|
|
||||
|
/** |
||||
|
* 报价专员 |
||||
|
*/ |
||||
|
private String quoter; |
||||
|
|
||||
|
/** |
||||
|
* 币种 |
||||
|
*/ |
||||
|
private String currency; |
||||
|
|
||||
|
private String status; |
||||
|
|
||||
|
private String customerInquiryNo; |
||||
|
|
||||
|
private String insideInquiryNo; |
||||
|
|
||||
|
/** |
||||
|
* 是否需要审批 |
||||
|
*/ |
||||
|
private String requireApproval; |
||||
|
|
||||
|
/** |
||||
|
* 审批状态 |
||||
|
*/ |
||||
|
private String approvalStatus; |
||||
|
|
||||
|
/** |
||||
|
* 是否需要tool |
||||
|
*/ |
||||
|
private String requireToolFlag; |
||||
|
|
||||
|
private String active; |
||||
|
|
||||
|
private String createBy; |
||||
|
|
||||
|
@JsonFormat(pattern = "yyyy-MM-dd") |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd") |
||||
|
private Date createDate; |
||||
|
|
||||
|
private String updateBy; |
||||
|
|
||||
|
@JsonFormat(pattern = "yyyy-MM-dd") |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd") |
||||
|
private Date updateDate; |
||||
|
|
||||
|
private String remark; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* ------------------(额外字段)---------------------- |
||||
|
*/ |
||||
|
@TableField(exist = false) |
||||
|
private String customerDesc; |
||||
|
|
||||
|
@TableField(exist = false) |
||||
|
private String projectDesc; |
||||
|
|
||||
|
@TableField(exist = false) |
||||
|
private String buDesc; |
||||
|
|
||||
|
@TableField(exist = false) |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd") |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd") |
||||
|
private Date startDate; |
||||
|
|
||||
|
@TableField(exist = false) |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd") |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd") |
||||
|
private Date endDate; |
||||
|
|
||||
|
@TableField(exist = false) |
||||
|
private Integer buId; |
||||
|
} |
||||
@ -0,0 +1,25 @@ |
|||||
|
package com.xujie.sys.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.xujie.sys.modules.base.entity.Bu; |
||||
|
import com.xujie.sys.modules.quote.entity.Quote; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
|
||||
|
@Mapper |
||||
|
public interface QuoteMapper extends BaseMapper<Quote> { |
||||
|
|
||||
|
IPage<Quote> queryQuotePage(@Param("page") Page<Quote> page,@Param("params") Quote quote); |
||||
|
List<Quote> queryQuoteList(Quote quote); |
||||
|
|
||||
|
int batchSaveQuote(List<Quote> quotes); |
||||
|
|
||||
|
Bu queryBuSiteById(Integer id); |
||||
|
|
||||
|
String queryQuoteNo(Quote quote); |
||||
|
} |
||||
@ -0,0 +1,23 @@ |
|||||
|
package com.xujie.sys.modules.quote.service; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
import com.xujie.sys.modules.quote.entity.Quote; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
public interface QuoteService extends IService<Quote> { |
||||
|
IPage<Quote> queryQuotePage(Integer no, Integer size, Quote quote); |
||||
|
|
||||
|
List<Quote> queryQuoteList(Quote quote); |
||||
|
|
||||
|
Quote queryQuoteById(Long id); |
||||
|
|
||||
|
void saveQuote(Quote quote); |
||||
|
|
||||
|
void updateQuote(Quote quote); |
||||
|
|
||||
|
void againQuote(Quote quote); |
||||
|
|
||||
|
void batchSaveQuote(List<Quote> quotes); |
||||
|
} |
||||
@ -0,0 +1,90 @@ |
|||||
|
package com.xujie.sys.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.xujie.sys.modules.base.entity.Bu; |
||||
|
import com.xujie.sys.modules.quote.entity.Quote; |
||||
|
import com.xujie.sys.modules.quote.mapper.QuoteMapper; |
||||
|
import com.xujie.sys.modules.quote.service.QuoteService; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
import org.springframework.util.StringUtils; |
||||
|
|
||||
|
import java.time.LocalDate; |
||||
|
import java.time.format.DateTimeFormatter; |
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
|
||||
|
@Service |
||||
|
@Slf4j |
||||
|
public class QuoteServiceImpl extends ServiceImpl<QuoteMapper, Quote> implements QuoteService { |
||||
|
|
||||
|
@Override |
||||
|
public IPage<Quote> queryQuotePage(Integer no, Integer size, Quote quote) { |
||||
|
Page<Quote> page = new Page<>(no, size); |
||||
|
return baseMapper.queryQuotePage(page, quote); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<Quote> queryQuoteList(Quote quote) { |
||||
|
return baseMapper.queryQuoteList(quote); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Quote queryQuoteById(Long id) { |
||||
|
Quote quote = new Quote(); |
||||
|
quote.setId(id); |
||||
|
List<Quote> quotes = baseMapper.queryQuoteList(quote); |
||||
|
if (!quotes.isEmpty()){ |
||||
|
return quotes.get(0); |
||||
|
} |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional |
||||
|
public void saveQuote(Quote quote) { |
||||
|
if (StringUtils.isEmpty(quote.getBuId())){ |
||||
|
throw new RuntimeException("BU不能为空"); |
||||
|
} |
||||
|
// 1、获取BU对应Site |
||||
|
Bu bu = baseMapper.queryBuSiteById(quote.getBuId()); |
||||
|
quote.setSite(bu.getSite()); |
||||
|
quote.setBuNo(bu.getBuNo()); |
||||
|
// 2、获取报价单号 |
||||
|
String quoteNo = baseMapper.queryQuoteNo(quote); |
||||
|
quote.setQuoteNo("BJ"+genDateStr("yyyyMMdd")+quoteNo); |
||||
|
quote.setVersionNo("A001"); |
||||
|
quote.setQuoteVersionNo(quote.getQuoteNo() + "-" + quote.getVersionNo()); |
||||
|
quote.setCreateDate(new Date()); |
||||
|
save(quote); |
||||
|
} |
||||
|
|
||||
|
private String genDateStr(String format){ |
||||
|
LocalDate date = LocalDate.now(); |
||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format); |
||||
|
return date.format(formatter); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional |
||||
|
public void updateQuote(Quote quote) { |
||||
|
quote.setUpdateDate(new Date()); |
||||
|
updateById(quote); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional |
||||
|
public void againQuote(Quote quote) { |
||||
|
// todo 校验参数,再次报价逻辑 |
||||
|
save(quote); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional |
||||
|
public void batchSaveQuote(List<Quote> quotes) { |
||||
|
baseMapper.batchSaveQuote(quotes); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,199 @@ |
|||||
|
<?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.xujie.sys.modules.quote.mapper.QuoteMapper"> |
||||
|
|
||||
|
<select id="queryQuotePage" resultType="com.xujie.sys.modules.quote.entity.Quote"> |
||||
|
select q.id, |
||||
|
q.quote_no, |
||||
|
q.site, |
||||
|
q.bu_no, |
||||
|
q.version_no, |
||||
|
q.quote_date, |
||||
|
q.quote_version_no, |
||||
|
q.customer_no, |
||||
|
q.project_no, |
||||
|
q.purchase, |
||||
|
q.quoter, |
||||
|
q.currency, |
||||
|
q.status, |
||||
|
q.customer_inquiry_no, |
||||
|
q.inside_inquiry_no, |
||||
|
q.require_approval, |
||||
|
q.approval_status, |
||||
|
q.require_tool_flag, |
||||
|
q.active, |
||||
|
q.create_by, |
||||
|
q.create_date, |
||||
|
q.update_by, |
||||
|
q.update_date, |
||||
|
q.remark, |
||||
|
c.customer_desc, |
||||
|
p.project_desc, |
||||
|
b.bu_desc, |
||||
|
b.id as buId |
||||
|
from plm_quote q |
||||
|
left join plm_customer_information c on q.customer_no = c.customer_no and q.site = c.site |
||||
|
left join plm_project_info p on q.project_no = p.project_no and q.site = p.site |
||||
|
left join BU b on q.bu_no = b.bu_no and b.site = q.site |
||||
|
<where> |
||||
|
q.site in (select site from eam_access_site where username = #{params.createBy}) |
||||
|
and (q.site + '-' + q.bu_no) in (select * from dbo.query_bu(#{params.createBy})) |
||||
|
<if test="params.id != null"> |
||||
|
and q.id = #{params.id} |
||||
|
</if> |
||||
|
<if test="params.quoteNo != null and params.quoteNo != ''"> |
||||
|
and q.quote_no = #{params.quoteNo} |
||||
|
</if> |
||||
|
<if test="params.buNo != null and params.buNo != ''"> |
||||
|
and q.bu_no = #{params.buNo} |
||||
|
</if> |
||||
|
<if test="params.customerNo != null and params.customerNo != ''"> |
||||
|
and q.customer_no = #{params.customerNo} |
||||
|
</if> |
||||
|
<if test="params.projectNo != null and params.projectNo != ''"> |
||||
|
and q.project_no = #{params.projectNo} |
||||
|
</if> |
||||
|
<if test="params.status != null and params.status != ''"> |
||||
|
and q.status = #{params.status} |
||||
|
</if> |
||||
|
<if test="params.quoteVersionNo != null and params.quoteVersionNo != ''"> |
||||
|
and q.quote_version_no = #{params.quoteVersionNo} |
||||
|
</if> |
||||
|
<if test="params.customerDesc != null and params.customerDesc != ''"> |
||||
|
and c.customer_desc like #{params.customerDesc} |
||||
|
</if> |
||||
|
<if test="params.projectDesc != null and params.projectDesc != ''"> |
||||
|
and p.project_desc like #{params.projectDesc} |
||||
|
</if> |
||||
|
<if test="params.purchase != null and params.purchase != ''"> |
||||
|
and q.purchase like #{params.purchase} |
||||
|
</if> |
||||
|
<if test="params.quoter != null and params.quoter != ''"> |
||||
|
and q.quoter like #{params.quoter} |
||||
|
</if> |
||||
|
<if test="params.customerInquiryNo != null and params.customerInquiryNo != ''"> |
||||
|
and q.customer_inquiry_no like #{params.customerInquiryNo} |
||||
|
</if> |
||||
|
<if test="params.insideInquiryNo != null and params.insideInquiryNo != ''"> |
||||
|
and q.customer_inquiry_no like #{params.insideInquiryNo} |
||||
|
</if> |
||||
|
<if test="params.startDate != null"> |
||||
|
and q.quote_date >= #{params.startDate} |
||||
|
</if> |
||||
|
<if test="params.endDate != null"> |
||||
|
and q.quote_date <= #{params.endDate} |
||||
|
</if> |
||||
|
</where> |
||||
|
order by q.id desc |
||||
|
</select> |
||||
|
|
||||
|
<select id="queryQuoteList" resultType="com.xujie.sys.modules.quote.entity.Quote"> |
||||
|
select q.id, |
||||
|
q.quote_no, |
||||
|
q.site, |
||||
|
q.bu_no, |
||||
|
q.version_no, |
||||
|
q.quote_date, |
||||
|
q.quote_version_no, |
||||
|
q.customer_no, |
||||
|
q.project_no, |
||||
|
q.purchase, |
||||
|
q.quoter, |
||||
|
q.currency, |
||||
|
q.status, |
||||
|
q.customer_inquiry_no, |
||||
|
q.inside_inquiry_no, |
||||
|
q.require_approval, |
||||
|
q.approval_status, |
||||
|
q.require_tool_flag, |
||||
|
q.active, |
||||
|
q.create_by, |
||||
|
q.create_date, |
||||
|
q.update_by, |
||||
|
q.update_date, |
||||
|
q.remark, |
||||
|
c.customer_desc, |
||||
|
p.project_desc, |
||||
|
b.bu_desc, |
||||
|
b.id as buId |
||||
|
from plm_quote q |
||||
|
left join plm_customer_information c on q.customer_no = c.customer_no and q.site = c.site |
||||
|
left join plm_project_info p on q.project_no = p.project_no and q.site = p.site |
||||
|
left join BU b on q.bu_no = b.bu_no and b.site = q.site |
||||
|
<where> |
||||
|
q.site in (select site from eam_access_site where username = #{createBy}) |
||||
|
and (q.site + '-' + q.bu_no) in (select * from dbo.query_bu(#{createBy})) |
||||
|
<if test="id != null"> |
||||
|
and q.id = #{id} |
||||
|
</if> |
||||
|
<if test="quoteNo != null and quoteNo != ''"> |
||||
|
and q.quote_no = #{quoteNo} |
||||
|
</if> |
||||
|
<if test="buNo != null and buNo != ''"> |
||||
|
and q.bu_no = #{buNo} |
||||
|
</if> |
||||
|
<if test="customerNo != null and customerNo != ''"> |
||||
|
and q.customer_no = #{customerNo} |
||||
|
</if> |
||||
|
<if test="projectNo != null and projectNo != ''"> |
||||
|
and q.project_no = #{ projectNo} |
||||
|
</if> |
||||
|
<if test="status != null and status != ''"> |
||||
|
and q.status = #{ status} |
||||
|
</if> |
||||
|
<if test="quoteVersionNo != null and quoteVersionNo != ''"> |
||||
|
and q.quote_version_no = #{ quoteVersionNo} |
||||
|
</if> |
||||
|
<if test=" customerDesc != null and customerDesc != ''"> |
||||
|
and c.customer_desc like #{ customerDesc} |
||||
|
</if> |
||||
|
<if test="projectDesc != null and projectDesc != ''"> |
||||
|
and p.project_desc like #{ projectDesc} |
||||
|
</if> |
||||
|
<if test="purchase != null and purchase != ''"> |
||||
|
and q.purchase like #{ purchase} |
||||
|
</if> |
||||
|
<if test=" quoter != null and quoter != ''"> |
||||
|
and q.quoter like #{ quoter} |
||||
|
</if> |
||||
|
<if test=" customerInquiryNo != null and customerInquiryNo != ''"> |
||||
|
and q.customer_inquiry_no like #{ customerInquiryNo} |
||||
|
</if> |
||||
|
<if test=" insideInquiryNo != null and insideInquiryNo != ''"> |
||||
|
and q.customer_inquiry_no like #{ insideInquiryNo} |
||||
|
</if> |
||||
|
<if test="startDate != null"> |
||||
|
and q.quote_date >= #{ startDate} |
||||
|
</if> |
||||
|
<if test="endDate != null"> |
||||
|
and q.quote_date <= #{ endDate} |
||||
|
</if> |
||||
|
</where> |
||||
|
order by q.id desc |
||||
|
</select> |
||||
|
|
||||
|
<insert id="batchSaveQuote"> |
||||
|
insert into plm_quote (quote_no, site, bu_no, version_no, quote_date, quote_version_no, customer_no, project_no, |
||||
|
purchase, quoter, currency, status, customer_inquiry_no, inside_inquiry_no, |
||||
|
require_approval, approval_status, require_tool_flag, active, create_by, create_date, remark) |
||||
|
values |
||||
|
<foreach collection="list" separator="," item="item"> |
||||
|
(#{item.quoteNo},#{item.site},#{item.buNo},#{item.versionNo},#{item.quoteDate},#{item.quoteVersionNo},#{item.customerNo},#{item.projectNo}, |
||||
|
#{item.purchase},#{item.quoter},#{item.currency},#{item.status},#{item.customerInquiryNo},#{item.insideInquiryNo}, |
||||
|
#{item.requireApproval},#{item.approvalStatus},#{item.requireToolFlag},#{item.active},#{item.createBy},#{item.createDate},#{item.remark}) |
||||
|
</foreach> |
||||
|
</insert> |
||||
|
|
||||
|
<select id="queryBuSiteById" resultType="com.xujie.sys.modules.base.entity.Bu"> |
||||
|
select id, site, bu_no, bu_desc, remark, active |
||||
|
from BU |
||||
|
where id = #{id} |
||||
|
</select> |
||||
|
|
||||
|
<select id="queryQuoteNo" resultType="java.lang.String"> |
||||
|
SELECT |
||||
|
Right('0000000000' + convert(VARCHAR(10), isnull(max(convert(INT, SUBSTRING(quote_no, 4, 10))), 0) + 1), 4) |
||||
|
FROM plm_quote |
||||
|
WHERE site = #{site} and bu_no = #{buNo} |
||||
|
</select> |
||||
|
</mapper> |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue