新购验收--报告附件查询、报告附件新增API
This commit is contained in:
parent
56f09fd5c7
commit
f1a955262a
|
|
@ -21,7 +21,7 @@ public class BonusMaterialApplication
|
|||
public static void main(String[] args)
|
||||
{
|
||||
SpringApplication.run(BonusMaterialApplication.class, args);
|
||||
System.out.println("(♥◠‿◠)ノ゙ 仓储模块启动成功 ლ(´ڡ`ლ)゙ \n" +
|
||||
System.out.println("(♥◠‿◠)ノ゙ 2024机具大融合系统启动成功 ლ(´ڡ`ლ)゙ \n" +
|
||||
" .-------. ____ __ \n" +
|
||||
" | _ _ \\ \\ \\ / / \n" +
|
||||
" | ( ' ) | \\ _. / ' \n" +
|
||||
|
|
|
|||
|
|
@ -1,12 +1,16 @@
|
|||
package com.bonus.material.purchase.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import com.bonus.common.log.enums.OperaType;
|
||||
import com.bonus.material.common.annotation.PreventRepeatSubmit;
|
||||
import com.bonus.material.purchase.dto.PurchaseCheckFileDto;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
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;
|
||||
|
|
@ -26,15 +30,14 @@ import com.bonus.common.core.web.page.TableDataInfo;
|
|||
|
||||
/**
|
||||
* 新购验收任务详细Controller
|
||||
*
|
||||
* @author xsheng
|
||||
* @date 2024-10-16
|
||||
* @author syruan
|
||||
*/
|
||||
@Api(tags = "新购验收任务详细接口")
|
||||
@RestController
|
||||
@RequestMapping("/purchase_check_details")
|
||||
public class PurchaseCheckDetailsController extends BaseController {
|
||||
@Autowired
|
||||
|
||||
@Resource
|
||||
private IPurchaseCheckDetailsService purchaseCheckDetailsService;
|
||||
|
||||
/**
|
||||
|
|
@ -55,7 +58,7 @@ public class PurchaseCheckDetailsController extends BaseController {
|
|||
@ApiOperation(value = "导出新购验收任务详细列表")
|
||||
@PreventRepeatSubmit
|
||||
@RequiresPermissions("purchase:details:export")
|
||||
@SysLog(title = "新购验收任务详细", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出新购验收任务详细")
|
||||
@SysLog(title = "新购验收任务详细", businessType = OperaType.EXPORT, logType = 1,module = "物资新购->导出新购验收任务详细")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, PurchaseCheckDetails purchaseCheckDetails) {
|
||||
List<PurchaseCheckDetails> list = purchaseCheckDetailsService.selectPurchaseCheckDetailsList(purchaseCheckDetails);
|
||||
|
|
@ -79,7 +82,7 @@ public class PurchaseCheckDetailsController extends BaseController {
|
|||
@ApiOperation(value = "新增新购验收任务详细")
|
||||
@PreventRepeatSubmit
|
||||
@RequiresPermissions("purchase:details:add")
|
||||
@SysLog(title = "新购验收任务详细", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增新购验收任务详细")
|
||||
@SysLog(title = "新购验收任务详细", businessType = OperaType.INSERT, logType = 1,module = "物资新购->新增新购验收任务详细")
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody PurchaseCheckDetails purchaseCheckDetails) {
|
||||
try {
|
||||
|
|
@ -95,7 +98,7 @@ public class PurchaseCheckDetailsController extends BaseController {
|
|||
@ApiOperation(value = "修改新购验收任务详细")
|
||||
@PreventRepeatSubmit
|
||||
@RequiresPermissions("purchase:details:edit")
|
||||
@SysLog(title = "新购验收任务详细", businessType = OperaType.UPDATE, module = "仓储管理->修改新购验收任务详细")
|
||||
@SysLog(title = "新购验收任务详细", businessType = OperaType.UPDATE, module = "物资新购->修改新购验收任务详细")
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody PurchaseCheckDetails purchaseCheckDetails) {
|
||||
try {
|
||||
|
|
@ -111,9 +114,32 @@ public class PurchaseCheckDetailsController extends BaseController {
|
|||
@ApiOperation(value = "删除新购验收任务详细")
|
||||
@PreventRepeatSubmit
|
||||
@RequiresPermissions("purchase:details:remove")
|
||||
@SysLog(title = "新购验收任务详细", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除新购验收任务详细")
|
||||
@SysLog(title = "新购验收任务详细", businessType = OperaType.DELETE, logType = 1,module = "物资新购->删除新购验收任务详细")
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
return toAjax(purchaseCheckDetailsService.deletePurchaseCheckDetailsByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据任务id查询报告附件
|
||||
*/
|
||||
@ApiOperation(value = "根据任务id查询报告附件")
|
||||
@RequiresPermissions("purchase:details:query")
|
||||
@GetMapping("/fileList/{taskId}")
|
||||
@SysLog(title = "新购验收任务明细报告查询", businessType = OperaType.QUERY, module = "物资新购->根据任务id查询物资报告附件")
|
||||
public AjaxResult getFileList(@PathVariable("taskId") Long taskId) {
|
||||
return success(purchaseCheckDetailsService.selectPurchaseCheckFileListByTaskId(taskId));
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "上传文件")
|
||||
@PreventRepeatSubmit
|
||||
@RequiresPermissions("purchase:details:add")
|
||||
@SysLog(title = "上传文件", businessType = OperaType.INSERT, logType = 1,module = "物资新购->上传物资报告附件")
|
||||
@PostMapping("/uploadFile")
|
||||
public AjaxResult uploadFile(@RequestBody @NotNull @Valid PurchaseCheckFileDto purchaseCheckFileDto) {
|
||||
return purchaseCheckDetailsService.insertPurchaseCheckFile(purchaseCheckFileDto);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@ public class PurchaseCheckDetails extends BaseEntity {
|
|||
@ApiModelProperty(value = "规格名称")
|
||||
private String typeName;
|
||||
|
||||
@ApiModelProperty(value = "物资单位名称")
|
||||
private String unitName;
|
||||
|
||||
@ApiModelProperty(value = "物资名称--规格parent类型")
|
||||
private String maTypeName;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package com.bonus.material.purchase.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
import com.bonus.material.purchase.config.PurchaseModelEnum;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.bonus.common.core.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
|
@ -11,6 +11,8 @@ import lombok.EqualsAndHashCode;
|
|||
import lombok.ToString;
|
||||
import com.bonus.common.core.web.domain.BaseEntity;
|
||||
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
/**
|
||||
* 新购验收任务对象 purchase_check_info
|
||||
* @author syruan
|
||||
|
|
@ -19,7 +21,8 @@ import com.bonus.common.core.web.domain.BaseEntity;
|
|||
@Data
|
||||
@ToString
|
||||
public class PurchaseCheckInfo extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final long serialVersionUID = 1335730477657434485L;
|
||||
|
||||
/** 主键id */
|
||||
private Long id;
|
||||
|
|
@ -67,12 +70,31 @@ public class PurchaseCheckInfo extends BaseEntity {
|
|||
* 采购数量
|
||||
*/
|
||||
@ApiModelProperty(value = "采购数量--外层Table字段")
|
||||
private String purchaseMaNumber;
|
||||
private Long purchaseMaNumber;
|
||||
|
||||
/**
|
||||
* 采购含税价格
|
||||
*/
|
||||
@ApiModelProperty(value = "采购含税价格--外层Table字段")
|
||||
private BigDecimal purchaseTaxPrice;
|
||||
|
||||
/**
|
||||
* 采购不含税价格
|
||||
*/
|
||||
@ApiModelProperty(value = "采购不含税价格--外层Table字段")
|
||||
private BigDecimal purchaseNoTaxPrice;
|
||||
|
||||
/**
|
||||
* 税率
|
||||
*/
|
||||
@ApiModelProperty(value = "税率--Int整形 0~100")
|
||||
@Size(max = 100, message = "税率长度必须介于 0 和 100 之间")
|
||||
private Integer taxRate;
|
||||
|
||||
@ApiModelProperty(value = "操作人名称")
|
||||
private String createUserName;
|
||||
|
||||
@ApiModelProperty(value = "新购模块阶段名称")
|
||||
private PurchaseModelEnum modelName;
|
||||
private String modelName;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
package com.bonus.material.purchase.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
/**
|
||||
* @author : 阮世耀
|
||||
* @version : 1.0
|
||||
* @CreateTime: 2024-10-22 10:36
|
||||
* @Description: 新购验收报告附件DTO
|
||||
*/
|
||||
@Data
|
||||
public class PurchaseCheckFileDto {
|
||||
|
||||
@ApiModelProperty(value = "主键ID")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "附件名称")
|
||||
@NotBlank(message = "附件名称不能为空")
|
||||
private String fileName;
|
||||
|
||||
@ApiModelProperty(value = "附件地址url")
|
||||
@NotBlank(message = "附件地址url不能为空")
|
||||
private String fileUrl;
|
||||
|
||||
@ApiModelProperty(value = "任务ID")
|
||||
@NotBlank(message = "任务ID不能为空")
|
||||
private String taskId;
|
||||
|
||||
@ApiModelProperty(value = "字典编码")
|
||||
@NotEmpty(message = "字典编码不能为空")
|
||||
private Integer dictCode;
|
||||
|
||||
@ApiModelProperty(value = "字典标签")
|
||||
private String dictLabel;
|
||||
|
||||
@ApiModelProperty(value = "新购模块ID,无需传值,后台定义")
|
||||
private Integer modelId;
|
||||
|
||||
@ApiModelProperty(value = "创建人,无需传值,后台通过TOKEN获取")
|
||||
private String createBy;
|
||||
|
||||
}
|
||||
|
|
@ -13,7 +13,7 @@ import java.util.List;
|
|||
* @version : 1.0
|
||||
* @PackagePath: com.bonus.material.purchase.dto
|
||||
* @CreateTime: 2024-10-21 14:37
|
||||
* @Description: 描述
|
||||
* @Description: 新购验收任务通知人员Dto
|
||||
*/
|
||||
@Data
|
||||
@ToString
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
package com.bonus.material.purchase.mapper;
|
||||
|
||||
import com.bonus.material.purchase.domain.PurchaseCheckDetails;
|
||||
import com.bonus.material.purchase.dto.PurchaseCheckFileDto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 新购验收任务报告附件Mapper接口
|
||||
*
|
||||
* @author syruan
|
||||
*/
|
||||
public interface PurchaseCheckFileMapper {
|
||||
|
||||
|
||||
/**
|
||||
* 根据任务id查询新购验收任务详细报告列表--Join查询
|
||||
* @param taskId 任务id
|
||||
*/
|
||||
List<PurchaseCheckFileDto> selectPurchaseCheckFileListByTaskId(Long taskId);
|
||||
|
||||
|
||||
/**
|
||||
* 新增新购验收任务详细报告附件
|
||||
*
|
||||
* @param purchaseCheckFileDto 新购验收任务详细
|
||||
* @return 结果
|
||||
*/
|
||||
int insertPurchaseCheckFiles(PurchaseCheckFileDto purchaseCheckFileDto);
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,7 +1,10 @@
|
|||
package com.bonus.material.purchase.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.material.purchase.domain.PurchaseCheckDetails;
|
||||
import com.bonus.material.purchase.dto.PurchaseCheckFileDto;
|
||||
|
||||
/**
|
||||
* 新购验收任务详细Service接口
|
||||
|
|
@ -16,7 +19,7 @@ public interface IPurchaseCheckDetailsService {
|
|||
* @param id 新购验收任务详细主键
|
||||
* @return 新购验收任务详细
|
||||
*/
|
||||
public PurchaseCheckDetails selectPurchaseCheckDetailsById(Long id);
|
||||
PurchaseCheckDetails selectPurchaseCheckDetailsById(Long id);
|
||||
|
||||
/**
|
||||
* 查询新购验收任务详细列表
|
||||
|
|
@ -24,7 +27,19 @@ public interface IPurchaseCheckDetailsService {
|
|||
* @param purchaseCheckDetails 新购验收任务详细
|
||||
* @return 新购验收任务详细集合
|
||||
*/
|
||||
public List<PurchaseCheckDetails> selectPurchaseCheckDetailsList(PurchaseCheckDetails purchaseCheckDetails);
|
||||
List<PurchaseCheckDetails> selectPurchaseCheckDetailsList(PurchaseCheckDetails purchaseCheckDetails);
|
||||
|
||||
/**
|
||||
* 根据任务ID查询报告附件列表
|
||||
* @param taskId 任务id
|
||||
*/
|
||||
List<PurchaseCheckFileDto> selectPurchaseCheckFileListByTaskId(Long taskId);
|
||||
|
||||
/**
|
||||
* 新增报告附件
|
||||
* @param purchaseCheckFileDto 附件信息
|
||||
*/
|
||||
AjaxResult insertPurchaseCheckFile(PurchaseCheckFileDto purchaseCheckFileDto);
|
||||
|
||||
/**
|
||||
* 新增新购验收任务详细
|
||||
|
|
@ -32,7 +47,7 @@ public interface IPurchaseCheckDetailsService {
|
|||
* @param purchaseCheckDetails 新购验收任务详细
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertPurchaseCheckDetails(PurchaseCheckDetails purchaseCheckDetails);
|
||||
int insertPurchaseCheckDetails(PurchaseCheckDetails purchaseCheckDetails);
|
||||
|
||||
/**
|
||||
* 修改新购验收任务详细
|
||||
|
|
@ -40,7 +55,7 @@ public interface IPurchaseCheckDetailsService {
|
|||
* @param purchaseCheckDetails 新购验收任务详细
|
||||
* @return 结果
|
||||
*/
|
||||
public int updatePurchaseCheckDetails(PurchaseCheckDetails purchaseCheckDetails);
|
||||
int updatePurchaseCheckDetails(PurchaseCheckDetails purchaseCheckDetails);
|
||||
|
||||
/**
|
||||
* 批量删除新购验收任务详细
|
||||
|
|
@ -48,7 +63,7 @@ public interface IPurchaseCheckDetailsService {
|
|||
* @param ids 需要删除的新购验收任务详细主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePurchaseCheckDetailsByIds(Long[] ids);
|
||||
int deletePurchaseCheckDetailsByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除新购验收任务详细信息
|
||||
|
|
@ -56,5 +71,5 @@ public interface IPurchaseCheckDetailsService {
|
|||
* @param id 新购验收任务详细主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePurchaseCheckDetailsById(Long id);
|
||||
int deletePurchaseCheckDetailsById(Long id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,12 +3,19 @@ package com.bonus.material.purchase.service.impl;
|
|||
import java.util.List;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.core.utils.DateUtils;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import com.bonus.material.purchase.dto.PurchaseCheckFileDto;
|
||||
import com.bonus.material.purchase.mapper.PurchaseCheckFileMapper;
|
||||
import com.bonus.material.purchase.mapper.PurchaseCheckInfoMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.bonus.material.purchase.mapper.PurchaseCheckDetailsMapper;
|
||||
import com.bonus.material.purchase.domain.PurchaseCheckDetails;
|
||||
import com.bonus.material.purchase.service.IPurchaseCheckDetailsService;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 新购验收任务详细Service业务层处理
|
||||
*
|
||||
|
|
@ -17,9 +24,13 @@ import com.bonus.material.purchase.service.IPurchaseCheckDetailsService;
|
|||
*/
|
||||
@Service
|
||||
public class PurchaseCheckDetailsServiceImpl implements IPurchaseCheckDetailsService {
|
||||
@Autowired
|
||||
|
||||
@Resource
|
||||
private PurchaseCheckDetailsMapper purchaseCheckDetailsMapper;
|
||||
|
||||
@Resource
|
||||
private PurchaseCheckFileMapper purchaseCheckFileMapper;
|
||||
|
||||
/**
|
||||
* 查询新购验收任务详细
|
||||
*
|
||||
|
|
@ -42,6 +53,39 @@ public class PurchaseCheckDetailsServiceImpl implements IPurchaseCheckDetailsSer
|
|||
return purchaseCheckDetailsMapper.selectPurchaseCheckDetailsList(purchaseCheckDetails);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据任务ID查询报告附件列表
|
||||
*
|
||||
* @param taskId 任务id
|
||||
*/
|
||||
@Override
|
||||
public List<PurchaseCheckFileDto> selectPurchaseCheckFileListByTaskId(Long taskId) {
|
||||
try {
|
||||
return purchaseCheckFileMapper.selectPurchaseCheckFileListByTaskId(taskId);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("SQL执行错误:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增报告附件
|
||||
*
|
||||
* @param purchaseCheckFileDto 附件信息
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult insertPurchaseCheckFile(PurchaseCheckFileDto purchaseCheckFileDto) {
|
||||
try {
|
||||
if (purchaseCheckFileDto != null) {
|
||||
// TODO: 暂定魔法值,字典表为26,后续抽出定义为常量
|
||||
purchaseCheckFileDto.setModelId(26);
|
||||
purchaseCheckFileDto.setCreateBy(SecurityUtils.getLoginUser().getUsername());
|
||||
}
|
||||
return purchaseCheckFileMapper.insertPurchaseCheckFiles(purchaseCheckFileDto) > 0 ? AjaxResult.success() : AjaxResult.error("SQL插入0条");
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error("SQL执行错误:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增新购验收任务详细
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,6 +1,16 @@
|
|||
package com.bonus.material.purchase.service.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.core.utils.DateUtils;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
|
|
@ -9,6 +19,7 @@ import com.bonus.material.purchase.dto.PurchaseCheckDto;
|
|||
import com.bonus.material.purchase.mapper.PurchaseCheckDetailsMapper;
|
||||
import com.bonus.material.task.domain.TmTask;
|
||||
import com.bonus.material.task.mapper.TmTaskMapper;
|
||||
import org.apache.ibatis.reflection.ArrayUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.bonus.material.purchase.mapper.PurchaseCheckInfoMapper;
|
||||
|
|
@ -63,19 +74,74 @@ public class PurchaseCheckInfoServiceImpl implements IPurchaseCheckInfoService {
|
|||
*/
|
||||
@Override
|
||||
public List<PurchaseCheckInfo> selectPurchaseCheckInfoList(PurchaseCheckInfo purchaseCheckInfoDto) {
|
||||
// 查询新购info列表
|
||||
List<PurchaseCheckInfo> purchaseCheckInfos = purchaseCheckInfoMapper.selectPurchaseCheckInfoJoinList(purchaseCheckInfoDto);
|
||||
// 过滤info列表中空的对象
|
||||
purchaseCheckInfos.removeIf(purchaseCheckInfo -> purchaseCheckInfo.getTaskId() == null);
|
||||
// 查询新购info列表,并用stream流过滤掉info列表中空的对象 或 taskId为空的对象
|
||||
List<PurchaseCheckInfo> purchaseCheckInfos = purchaseCheckInfoMapper.selectPurchaseCheckInfoJoinList(purchaseCheckInfoDto)
|
||||
.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(purchaseCheckInfo -> purchaseCheckInfo.getTaskId() != null)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 查询details表,获取详细的采购物资名称
|
||||
// ----------- for循环开始 -------------
|
||||
for (PurchaseCheckInfo purchaseCheckInfo : purchaseCheckInfos) {
|
||||
// 查询details表,获取详细的采购物资名称
|
||||
String purchaseMaName = purchaseCheckDetailsMapper.selectMaTypeNameByTaskId(purchaseCheckInfo.getTaskId(), null);
|
||||
purchaseCheckInfo.setPurchaseMaTypeName(purchaseMaName != null ? purchaseMaName : "");
|
||||
|
||||
// 查询details表,获取详细的采购物资数量、价格
|
||||
List<PurchaseCheckDetails> purchaseCheckDetails = purchaseCheckDetailsMapper.selectPurchaseCheckDetailsListByTaskId(purchaseCheckInfo.getTaskId())
|
||||
.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 定义初始化统计变量,使用 AtomicLong 和 AtomicBigDecimal 来替代同步块,提高性能。
|
||||
// 采购物资数量
|
||||
AtomicLong purchaseMaTotalNumber = new AtomicLong(0L);
|
||||
// 采购物资不含税价格
|
||||
AtomicReference<BigDecimal> purchaseMaTotalNoTaxPrice = new AtomicReference<>(BigDecimal.ZERO);
|
||||
|
||||
// 执行for循环统计采购物资数量、价格
|
||||
for (PurchaseCheckDetails detail : purchaseCheckDetails) {
|
||||
if (detail.getPurchaseNum() == null || detail.getPurchasePrice() == null) {
|
||||
continue;
|
||||
}
|
||||
if (detail.getPurchaseNum() < 0 || detail.getPurchasePrice().compareTo(BigDecimal.ZERO) < 0) {
|
||||
throw new IllegalArgumentException("采购数量和价格必须为非负数");
|
||||
}
|
||||
// 原代码块使用sync确保线程安全,现更改为AtomicLong来替代同步块
|
||||
// 统计采购数量
|
||||
purchaseMaTotalNumber.addAndGet(detail.getPurchaseNum());
|
||||
// 采购物资数量乘以采购不含税价格
|
||||
purchaseMaTotalNoTaxPrice.updateAndGet(v -> v.add(new BigDecimal(detail.getPurchaseNum()).multiply(detail.getPurchasePrice())));
|
||||
}
|
||||
|
||||
// 赋值统计出来的采购物资数量、不含税价格
|
||||
purchaseCheckInfo.setPurchaseMaNumber(purchaseMaTotalNumber.get());
|
||||
purchaseCheckInfo.setPurchaseNoTaxPrice(purchaseMaTotalNoTaxPrice.get());
|
||||
|
||||
// 通过不含税价格及税率,计算出含税价格并赋值
|
||||
if (purchaseCheckInfo.getTaxRate() != null && purchaseCheckInfo.getPurchaseNoTaxPrice() != null) {
|
||||
purchaseCheckInfo.setPurchaseTaxPrice(
|
||||
calculateTaxPrice(purchaseMaTotalNoTaxPrice.get(), new BigDecimal(purchaseCheckInfo.getTaxRate()))
|
||||
);
|
||||
}
|
||||
}
|
||||
// ------------- for循环结束 -------------
|
||||
|
||||
return purchaseCheckInfos;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 含税价格计算
|
||||
* @param purchaseNoTaxPrice 不含税价格
|
||||
* @param taxRate 税率:0~100 例如13%税率 值应该是整形:13
|
||||
* @return 不含税价格100 税率为13%,结果为 113.00
|
||||
*/
|
||||
public static BigDecimal calculateTaxPrice(BigDecimal purchaseNoTaxPrice, BigDecimal taxRate) {
|
||||
BigDecimal one = BigDecimal.ONE;
|
||||
return purchaseNoTaxPrice.multiply(one.add(taxRate)).setScale(2, RoundingMode.HALF_UP);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增新购验收任务
|
||||
*
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="taskId" column="task_id" />
|
||||
<result property="typeId" column="type_id" />
|
||||
<result property="typeName" column="type_name" />
|
||||
<result property="unitName" column="unit_name" />
|
||||
<result property="maTypeName" column="ma_type_name" />
|
||||
<result property="purchasePrice" column="purchase_price" />
|
||||
<result property="purchaseNum" column="purchase_num" />
|
||||
|
|
@ -40,7 +41,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
select pcd.id, pcd.task_id, pcd.type_id, pcd.purchase_price, pcd.purchase_num, pcd.check_num, pcd.bind_num, pcd.check_result,
|
||||
pcd.supplier_id, pcd.status, pcd.create_by, pcd.production_time, pcd.create_time, pcd.update_by, pcd.update_time,
|
||||
pcd.remark, pcd.check_url_name, pcd.check_url, pcd.input_num, pcd.input_status, pcd.input_time, pcd.file_name,
|
||||
pcd.file_url, pcd.company_id, mt.type_name, mtp.type_name as ma_type_name
|
||||
pcd.file_url, pcd.company_id, mt.type_name, mt.unit_name, mtp.type_name as ma_type_name
|
||||
from purchase_check_details pcd
|
||||
left join ma_type mt on pcd.type_id = mt.type_id
|
||||
left join ma_type mtp on mt.parent_id = mtp.type_id
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
<?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.bonus.material.purchase.mapper.PurchaseCheckFileMapper">
|
||||
<resultMap type="com.bonus.material.purchase.dto.PurchaseCheckFileDto" id="PurchaseCheckFileResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="fileName" column="file_name" />
|
||||
<result property="fileUrl" column="file_url" />
|
||||
<result property="taskId" column="task_id" />
|
||||
<result property="dictCode" column="dict_code" />
|
||||
<result property="dictLabel" column="dict_label" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectPurchaseCheckFileJoinVo">
|
||||
SELECT
|
||||
sdd.dict_code,sdd.dict_label,
|
||||
bfi.id,bfi.file_name,bfi.file_url
|
||||
FROM
|
||||
sys_dict_data sdd
|
||||
LEFT JOIN
|
||||
bm_file_info bfi ON bfi.dic_id = sdd.dict_code
|
||||
WHERE
|
||||
sdd.dict_type = 'purchase_check_report_type'
|
||||
</sql>
|
||||
|
||||
|
||||
<select id="selectPurchaseCheckFileListByTaskId" parameterType="Long" resultMap="PurchaseCheckFileResult">
|
||||
<include refid="selectPurchaseCheckFileJoinVo"/>
|
||||
and bfi.task_id = #{taskId}
|
||||
</select>
|
||||
|
||||
<insert id="insertPurchaseCheckFiles" parameterType="com.bonus.material.purchase.dto.PurchaseCheckFileDto" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into bm_file_info
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="modelId != null">model_id,</if>
|
||||
<if test="fileName != null">file_name,</if>
|
||||
<if test="fileUrl != null">file_url,</if>
|
||||
<if test="dictCode != null">dic_id,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
create_time,
|
||||
<if test="taskId != null">task_id</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="modelId != null">#{modelId,jdbcType=INTEGER},</if>
|
||||
<if test="fileName != null">#{fileName,jdbcType=VARCHAR},</if>
|
||||
<if test="fileUrl != null">#{fileUrl,jdbcType=VARCHAR},</if>
|
||||
<if test="dictCode != null">#{dictCode},</if>
|
||||
<if test="createBy != null">#{createBy,jdbcType=VARCHAR},</if>
|
||||
now(),
|
||||
<if test="taskId != null">#{taskId}</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue