From 5ae4af6c44bd679d71bdeb877c2c56679f17c87e Mon Sep 17 00:00:00 2001 From: HashMap Date: Mon, 1 Dec 2025 20:24:30 +0800 Subject: [PATCH] =?UTF-8?q?feat(Frozen/Sale=20[New]):=20=E9=94=80=E5=94=AE?= =?UTF-8?q?=E4=B8=BB=E8=A1=A8=20|=20=E6=98=8E=E7=BB=86=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 销售主子表管理功能 [skip ci] --- .../frozen/controller/DdSaleController.java | 104 ++++++++++ .../com/zhyc/module/frozen/domain/DdSale.java | 194 ++++++++++++++++++ .../zhyc/module/frozen/domain/DdSaleItem.java | 151 ++++++++++++++ .../module/frozen/mapper/DdSaleMapper.java | 87 ++++++++ .../module/frozen/service/IDdSaleService.java | 61 ++++++ .../service/impl/DdSaleServiceImpl.java | 133 ++++++++++++ .../mapper/frozen/sale/DdSaleMapper.xml | 150 ++++++++++++++ 7 files changed, 880 insertions(+) create mode 100644 zhyc-module/src/main/java/com/zhyc/module/frozen/controller/DdSaleController.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/frozen/domain/DdSale.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/frozen/domain/DdSaleItem.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/frozen/mapper/DdSaleMapper.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/frozen/service/IDdSaleService.java create mode 100644 zhyc-module/src/main/java/com/zhyc/module/frozen/service/impl/DdSaleServiceImpl.java create mode 100644 zhyc-module/src/main/resources/mapper/frozen/sale/DdSaleMapper.xml diff --git a/zhyc-module/src/main/java/com/zhyc/module/frozen/controller/DdSaleController.java b/zhyc-module/src/main/java/com/zhyc/module/frozen/controller/DdSaleController.java new file mode 100644 index 0000000..d78b11f --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/frozen/controller/DdSaleController.java @@ -0,0 +1,104 @@ +package com.zhyc.module.frozen.controller; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.zhyc.common.annotation.Log; +import com.zhyc.common.core.controller.BaseController; +import com.zhyc.common.core.domain.AjaxResult; +import com.zhyc.common.enums.BusinessType; +import com.zhyc.module.frozen.domain.DdSale; +import com.zhyc.module.frozen.service.IDdSaleService; +import com.zhyc.common.utils.poi.ExcelUtil; +import com.zhyc.common.core.page.TableDataInfo; + +/** + * 销售主单Controller + * + * @author HashMap + * @date 2025-12-01 + */ +@RestController +@RequestMapping("/sale/sale") +public class DdSaleController extends BaseController +{ + @Autowired + private IDdSaleService ddSaleService; + + /** + * 查询销售主单列表 + */ + @PreAuthorize("@ss.hasPermi('sale:sale:list')") + @GetMapping("/list") + public TableDataInfo list(DdSale ddSale) + { + startPage(); + List list = ddSaleService.selectDdSaleList(ddSale); + return getDataTable(list); + } + + /** + * 导出销售主单列表 + */ + @PreAuthorize("@ss.hasPermi('sale:sale:export')") + @Log(title = "销售主单", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, DdSale ddSale) + { + List list = ddSaleService.selectDdSaleList(ddSale); + ExcelUtil util = new ExcelUtil(DdSale.class); + util.exportExcel(response, list, "销售主单数据"); + } + + /** + * 获取销售主单详细信息 + */ + @PreAuthorize("@ss.hasPermi('sale:sale:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(ddSaleService.selectDdSaleById(id)); + } + + /** + * 新增销售主单 + */ + @PreAuthorize("@ss.hasPermi('sale:sale:add')") + @Log(title = "销售主单", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody DdSale ddSale) + { + return toAjax(ddSaleService.insertDdSale(ddSale)); + } + + /** + * 修改销售主单 + */ + @PreAuthorize("@ss.hasPermi('sale:sale:edit')") + @Log(title = "销售主单", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody DdSale ddSale) + { + return toAjax(ddSaleService.updateDdSale(ddSale)); + } + + /** + * 删除销售主单 + */ + @PreAuthorize("@ss.hasPermi('sale:sale:remove')") + @Log(title = "销售主单", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(ddSaleService.deleteDdSaleByIds(ids)); + } +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/frozen/domain/DdSale.java b/zhyc-module/src/main/java/com/zhyc/module/frozen/domain/DdSale.java new file mode 100644 index 0000000..dc112c6 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/frozen/domain/DdSale.java @@ -0,0 +1,194 @@ +package com.zhyc.module.frozen.domain; + +import java.math.BigDecimal; +import java.util.List; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.zhyc.common.annotation.Excel; +import com.zhyc.common.core.domain.BaseEntity; + +/** + * 销售主单对象 dd_sl + * + * @author HashMap + * @date 2025-12-01 + */ +public class DdSale extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键 */ + private Long id; + + /** 销售日期 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "销售日期", width = 30, dateFormat = "yyyy-MM-dd") + private Date saleDate; + + /** 客户名称 */ + @Excel(name = "客户名称") + private String custName; + + /** 客户电话 */ + @Excel(name = "客户电话") + private String custPhone; + + /** 客户地址 */ + @Excel(name = "客户地址") + private String custAddr; + + /** 销售人员 */ + @Excel(name = "销售人员") + private String salesper; + + /** 检疫证号(可选) */ + @Excel(name = "检疫证号", readConverterExp = "可=选") + private String quaranNo; + + /** 审批编号(可选) */ + @Excel(name = "审批编号", readConverterExp = "可=选") + private String apprNo; + + /** 总价 */ + @Excel(name = "总价") + private BigDecimal price; + + /** 技术员 */ + @Excel(name = "技术员") + private String tech; + + /** 销售明细信息 */ + private List ddSaleItemList; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setSaleDate(Date saleDate) + { + this.saleDate = saleDate; + } + + public Date getSaleDate() + { + return saleDate; + } + + public void setCustName(String custName) + { + this.custName = custName; + } + + public String getCustName() + { + return custName; + } + + public void setCustPhone(String custPhone) + { + this.custPhone = custPhone; + } + + public String getCustPhone() + { + return custPhone; + } + + public void setCustAddr(String custAddr) + { + this.custAddr = custAddr; + } + + public String getCustAddr() + { + return custAddr; + } + + public void setSalesper(String salesper) + { + this.salesper = salesper; + } + + public String getSalesper() + { + return salesper; + } + + public void setQuaranNo(String quaranNo) + { + this.quaranNo = quaranNo; + } + + public String getQuaranNo() + { + return quaranNo; + } + + public void setApprNo(String apprNo) + { + this.apprNo = apprNo; + } + + public String getApprNo() + { + return apprNo; + } + + public void setPrice(BigDecimal price) + { + this.price = price; + } + + public BigDecimal getPrice() + { + return price; + } + + public void setTech(String tech) + { + this.tech = tech; + } + + public String getTech() + { + return tech; + } + + public List getDdSaleItemList() + { + return ddSaleItemList; + } + + public void setDdSaleItemList(List ddSaleItemList) + { + this.ddSaleItemList = ddSaleItemList; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("saleDate", getSaleDate()) + .append("custName", getCustName()) + .append("custPhone", getCustPhone()) + .append("custAddr", getCustAddr()) + .append("salesper", getSalesper()) + .append("quaranNo", getQuaranNo()) + .append("apprNo", getApprNo()) + .append("price", getPrice()) + .append("tech", getTech()) + .append("remark", getRemark()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("ddSaleItemList", getDdSaleItemList()) + .toString(); + } +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/frozen/domain/DdSaleItem.java b/zhyc-module/src/main/java/com/zhyc/module/frozen/domain/DdSaleItem.java new file mode 100644 index 0000000..99a1a2c --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/frozen/domain/DdSaleItem.java @@ -0,0 +1,151 @@ +package com.zhyc.module.frozen.domain; + +import java.math.BigDecimal; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.zhyc.common.annotation.Excel; +import com.zhyc.common.core.domain.BaseEntity; + +/** + * 销售明细对象 dd_sl_item + * + * @author HashMap + * @date 2025-12-01 + */ +public class DdSaleItem extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键 */ + private Long id; + + /** 销售主单ID */ + @Excel(name = "销售主单ID") + private Long saleId; + + /** 明细类型(冻胚embryo冻精semen) */ + @Excel(name = "明细类型", readConverterExp = "冻=胚embryo冻精semen") + private String itemType; + + /** 胚胎编号或冻精号 */ + @Excel(name = "胚胎编号或冻精号") + private String itemCode; + + /** 数量 */ + @Excel(name = "数量") + private Long qty; + + /** 单价(元) */ + @Excel(name = "单价", readConverterExp = "元=") + private BigDecimal unitPrice; + + /** 所在液氮罐ID */ + @Excel(name = "所在液氮罐ID") + private Long tankId; + + /** 所在提桶ID */ + @Excel(name = "所在提桶ID") + private Long bucketId; + + /** 所在冷冻架ID */ + @Excel(name = "所在冷冻架ID") + private Long rackId; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + public void setSaleId(Long saleId) + { + this.saleId = saleId; + } + + public Long getSaleId() + { + return saleId; + } + public void setItemType(String itemType) + { + this.itemType = itemType; + } + + public String getItemType() + { + return itemType; + } + public void setItemCode(String itemCode) + { + this.itemCode = itemCode; + } + + public String getItemCode() + { + return itemCode; + } + public void setQty(Long qty) + { + this.qty = qty; + } + + public Long getQty() + { + return qty; + } + public void setUnitPrice(BigDecimal unitPrice) + { + this.unitPrice = unitPrice; + } + + public BigDecimal getUnitPrice() + { + return unitPrice; + } + public void setTankId(Long tankId) + { + this.tankId = tankId; + } + + public Long getTankId() + { + return tankId; + } + public void setBucketId(Long bucketId) + { + this.bucketId = bucketId; + } + + public Long getBucketId() + { + return bucketId; + } + public void setRackId(Long rackId) + { + this.rackId = rackId; + } + + public Long getRackId() + { + return rackId; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("saleId", getSaleId()) + .append("itemType", getItemType()) + .append("itemCode", getItemCode()) + .append("qty", getQty()) + .append("unitPrice", getUnitPrice()) + .append("tankId", getTankId()) + .append("bucketId", getBucketId()) + .append("rackId", getRackId()) + .append("createTime", getCreateTime()) + .toString(); + } +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/frozen/mapper/DdSaleMapper.java b/zhyc-module/src/main/java/com/zhyc/module/frozen/mapper/DdSaleMapper.java new file mode 100644 index 0000000..0094fd3 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/frozen/mapper/DdSaleMapper.java @@ -0,0 +1,87 @@ +package com.zhyc.module.frozen.mapper; + +import java.util.List; +import com.zhyc.module.frozen.domain.DdSale; +import com.zhyc.module.frozen.domain.DdSaleItem; + +/** + * 销售主单Mapper接口 + * + * @author HashMap + * @date 2025-12-01 + */ +public interface DdSaleMapper +{ + /** + * 查询销售主单 + * + * @param id 销售主单主键 + * @return 销售主单 + */ + public DdSale selectDdSaleById(Long id); + + /** + * 查询销售主单列表 + * + * @param ddSale 销售主单 + * @return 销售主单集合 + */ + public List selectDdSaleList(DdSale ddSale); + + /** + * 新增销售主单 + * + * @param ddSale 销售主单 + * @return 结果 + */ + public int insertDdSale(DdSale ddSale); + + /** + * 修改销售主单 + * + * @param ddSale 销售主单 + * @return 结果 + */ + public int updateDdSale(DdSale ddSale); + + /** + * 删除销售主单 + * + * @param id 销售主单主键 + * @return 结果 + */ + public int deleteDdSaleById(Long id); + + /** + * 批量删除销售主单 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteDdSaleByIds(Long[] ids); + + /** + * 批量删除销售明细 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteDdSaleItemBySaleIds(Long[] ids); + + /** + * 批量新增销售明细 + * + * @param ddSaleItemList 销售明细列表 + * @return 结果 + */ + public int batchDdSaleItem(List ddSaleItemList); + + + /** + * 通过销售主单主键删除销售明细信息 + * + * @param id 销售主单ID + * @return 结果 + */ + public int deleteDdSaleItemBySaleId(Long id); +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/frozen/service/IDdSaleService.java b/zhyc-module/src/main/java/com/zhyc/module/frozen/service/IDdSaleService.java new file mode 100644 index 0000000..75340d8 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/frozen/service/IDdSaleService.java @@ -0,0 +1,61 @@ +package com.zhyc.module.frozen.service; + +import java.util.List; +import com.zhyc.module.frozen.domain.DdSale; + +/** + * 销售主单Service接口 + * + * @author HashMap + * @date 2025-12-01 + */ +public interface IDdSaleService +{ + /** + * 查询销售主单 + * + * @param id 销售主单主键 + * @return 销售主单 + */ + public DdSale selectDdSaleById(Long id); + + /** + * 查询销售主单列表 + * + * @param ddSale 销售主单 + * @return 销售主单集合 + */ + public List selectDdSaleList(DdSale ddSale); + + /** + * 新增销售主单 + * + * @param ddSale 销售主单 + * @return 结果 + */ + public int insertDdSale(DdSale ddSale); + + /** + * 修改销售主单 + * + * @param ddSale 销售主单 + * @return 结果 + */ + public int updateDdSale(DdSale ddSale); + + /** + * 批量删除销售主单 + * + * @param ids 需要删除的销售主单主键集合 + * @return 结果 + */ + public int deleteDdSaleByIds(Long[] ids); + + /** + * 删除销售主单信息 + * + * @param id 销售主单主键 + * @return 结果 + */ + public int deleteDdSaleById(Long id); +} diff --git a/zhyc-module/src/main/java/com/zhyc/module/frozen/service/impl/DdSaleServiceImpl.java b/zhyc-module/src/main/java/com/zhyc/module/frozen/service/impl/DdSaleServiceImpl.java new file mode 100644 index 0000000..d2827f5 --- /dev/null +++ b/zhyc-module/src/main/java/com/zhyc/module/frozen/service/impl/DdSaleServiceImpl.java @@ -0,0 +1,133 @@ +package com.zhyc.module.frozen.service.impl; + +import java.util.List; +import com.zhyc.common.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import java.util.ArrayList; +import com.zhyc.common.utils.StringUtils; +import org.springframework.transaction.annotation.Transactional; +import com.zhyc.module.frozen.domain.DdSaleItem; +import com.zhyc.module.frozen.mapper.DdSaleMapper; +import com.zhyc.module.frozen.domain.DdSale; +import com.zhyc.module.frozen.service.IDdSaleService; + +/** + * 销售主单Service业务层处理 + * + * @author HashMap + * @date 2025-12-01 + */ +@Service +public class DdSaleServiceImpl implements IDdSaleService +{ + @Autowired + private DdSaleMapper ddSaleMapper; + + /** + * 查询销售主单 + * + * @param id 销售主单主键 + * @return 销售主单 + */ + @Override + public DdSale selectDdSaleById(Long id) + { + return ddSaleMapper.selectDdSaleById(id); + } + + /** + * 查询销售主单列表 + * + * @param ddSale 销售主单 + * @return 销售主单 + */ + @Override + public List selectDdSaleList(DdSale ddSale) + { + return ddSaleMapper.selectDdSaleList(ddSale); + } + + /** + * 新增销售主单 + * + * @param ddSale 销售主单 + * @return 结果 + */ + @Transactional + @Override + public int insertDdSale(DdSale ddSale) + { + ddSale.setCreateTime(DateUtils.getNowDate()); + int rows = ddSaleMapper.insertDdSale(ddSale); + insertDdSaleItem(ddSale); + return rows; + } + + /** + * 修改销售主单 + * + * @param ddSale 销售主单 + * @return 结果 + */ + @Transactional + @Override + public int updateDdSale(DdSale ddSale) + { + ddSaleMapper.deleteDdSaleItemBySaleId(ddSale.getId()); + insertDdSaleItem(ddSale); + return ddSaleMapper.updateDdSale(ddSale); + } + + /** + * 批量删除销售主单 + * + * @param ids 需要删除的销售主单主键 + * @return 结果 + */ + @Transactional + @Override + public int deleteDdSaleByIds(Long[] ids) + { + ddSaleMapper.deleteDdSaleItemBySaleIds(ids); + return ddSaleMapper.deleteDdSaleByIds(ids); + } + + /** + * 删除销售主单信息 + * + * @param id 销售主单主键 + * @return 结果 + */ + @Transactional + @Override + public int deleteDdSaleById(Long id) + { + ddSaleMapper.deleteDdSaleItemBySaleId(id); + return ddSaleMapper.deleteDdSaleById(id); + } + + /** + * 新增销售明细信息 + * + * @param ddSale 销售主单对象 + */ + public void insertDdSaleItem(DdSale ddSale) + { + List ddSaleItemList = ddSale.getDdSaleItemList(); + Long id = ddSale.getId(); + if (StringUtils.isNotNull(ddSaleItemList)) + { + List list = new ArrayList(); + for (DdSaleItem ddSaleItem : ddSaleItemList) + { + ddSaleItem.setSaleId(id); + list.add(ddSaleItem); + } + if (list.size() > 0) + { + ddSaleMapper.batchDdSaleItem(list); + } + } + } +} diff --git a/zhyc-module/src/main/resources/mapper/frozen/sale/DdSaleMapper.xml b/zhyc-module/src/main/resources/mapper/frozen/sale/DdSaleMapper.xml new file mode 100644 index 0000000..7011ee2 --- /dev/null +++ b/zhyc-module/src/main/resources/mapper/frozen/sale/DdSaleMapper.xml @@ -0,0 +1,150 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select id, sale_date, cust_name, cust_phone, cust_addr, salesper, quaran_no, appr_no, price, tech, remark, create_by, create_time from dd_sl + + + + + + + + + + insert into dd_sl + + sale_date, + cust_name, + cust_phone, + cust_addr, + salesper, + quaran_no, + appr_no, + price, + tech, + remark, + create_by, + create_time, + + + #{saleDate}, + #{custName}, + #{custPhone}, + #{custAddr}, + #{salesper}, + #{quaranNo}, + #{apprNo}, + #{price}, + #{tech}, + #{remark}, + #{createBy}, + #{createTime}, + + + + + update dd_sl + + sale_date = #{saleDate}, + cust_name = #{custName}, + cust_phone = #{custPhone}, + cust_addr = #{custAddr}, + salesper = #{salesper}, + quaran_no = #{quaranNo}, + appr_no = #{apprNo}, + price = #{price}, + tech = #{tech}, + remark = #{remark}, + create_by = #{createBy}, + create_time = #{createTime}, + + where id = #{id} + + + + delete from dd_sl where id = #{id} + + + + delete from dd_sl where id in + + #{id} + + + + + delete from dd_sl_item where sale_id in + + #{saleId} + + + + + delete from dd_sl_item where sale_id = #{saleId} + + + + insert into dd_sl_item( id, sale_id, item_type, item_code, qty, unit_price, tank_id, bucket_id, rack_id, create_time) values + + ( #{item.id}, #{item.saleId}, #{item.itemType}, #{item.itemCode}, #{item.qty}, #{item.unitPrice}, #{item.tankId}, #{item.bucketId}, #{item.rackId}, #{item.createTime}) + + + \ No newline at end of file