代码调整,二维码下载

This commit is contained in:
mashuai 2024-08-23 16:31:42 +08:00
parent e2f4b4e2ff
commit 9c58719e1a
14 changed files with 481 additions and 68 deletions

View File

@ -92,6 +92,22 @@
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
<version>3.3.0</version>
</dependency>
<!-- Apache Commons Compress library for ZIP handling -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.22</version>
</dependency>
</dependencies>

View File

@ -4,22 +4,16 @@ import com.bonus.common.core.domain.ResultBean;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.page.TableDataInfo;
import com.bonus.common.security.annotation.RequiresPermissions;
import com.bonus.purchase.domain.BpmPurchaseInfo;
import com.bonus.purchase.dto.PurchaseBindDto;
import com.bonus.purchase.dto.PurchaseDto;
import com.bonus.purchase.dto.PurchaseTaskDto;
import com.bonus.purchase.service.BpmPurchaseBindService;
import com.bonus.purchase.service.impl.BpmPurchaseInfoService;
import com.bonus.purchase.vo.PurchaseAcceptVo;
import com.bonus.purchase.vo.PurchaseVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Positive;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
* 新购到货验收表(bpm_purchase_info)控制层
@ -73,4 +67,13 @@ public class BpmPurchaseBindController extends BaseController {
return ResultBean.toIsSuccess(1,"急急急");
}
/**
* 二维码生成下载
*/
@PostMapping(value = "/downloadQrCode")
@RequiresPermissions("purchase:bpmPurchaseInfo:query")
public void downloadQrCode(HttpServletResponse response, PurchaseDto purchaseDto) {
bpmPurchaseBindService.downloadQrCode(response, purchaseDto);
}
}

View File

@ -13,6 +13,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Positive;
@ -27,7 +28,8 @@ import java.util.List;
@RequestMapping("/purchase/store")
public class BpmPurchaseStorageController extends BaseController {
@Autowired
@Resource
private BpmPurchaseStorageService purchaseStorageService;
@Autowired

View File

@ -1,6 +1,7 @@
package com.bonus.purchase.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import javax.validation.constraints.NotNull;
@ -12,6 +13,7 @@ import java.util.List;
* @create 2024/8/19 17:50
*/
@Data
@Builder
public class PurchaseDto {
@ApiModelProperty(value = "id")
@ -47,4 +49,13 @@ public class PurchaseDto {
@ApiModelProperty(value = "二级明细id")
private String purchaseId;
@ApiModelProperty(value = "采购数量")
private Integer num;
@ApiModelProperty(value = "二维码code")
private String qrCode;
@ApiModelProperty(value = "二维码curl")
private String qrUrl;
}

View File

@ -1,12 +1,10 @@
package com.bonus.purchase.mapper;
import com.bonus.base.api.domain.MaType;
import com.bonus.purchase.domain.BpmPurchaseInfo;
import com.bonus.purchase.dto.PurchaseBindDto;
import com.bonus.purchase.dto.PurchaseDto;
import com.bonus.purchase.vo.PurchaseAcceptVo;
import com.bonus.purchase.vo.PurchaseVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -24,4 +22,30 @@ public interface BpmPurchaseBindMapper {
List<PurchaseVo> selectManageList(PurchaseDto purchaseDto);
List<PurchaseAcceptVo> getDetailsList(PurchaseDto record);
/**
* 根据月份查找code
* @param genMonth
* @return
*/
List<PurchaseBindDto> select(String genMonth);
/**
* 插入数据
* @param dto
*/
void insert(PurchaseDto dto);
/**
* 更新状态
* @param id
*/
void updateStatus(String id);
/**
* 查询状态
* @param purchaseDto
* @return
*/
List<Integer> selectStatus(PurchaseDto purchaseDto);
}

View File

@ -1,12 +1,11 @@
package com.bonus.purchase.service;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.purchase.domain.BpmPurchaseInfo;
import com.bonus.purchase.dto.PurchaseBindDto;
import com.bonus.purchase.dto.PurchaseDto;
import com.bonus.purchase.vo.PurchaseAcceptVo;
import com.bonus.purchase.vo.PurchaseVo;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
@ -20,4 +19,12 @@ public interface BpmPurchaseBindService {
List<PurchaseAcceptVo> getDetailsList(PurchaseDto record);
int addBind(PurchaseBindDto bindDto);
/**
* 下载二维码
* @param purchaseDto
* @param response
* @return
*/
void downloadQrCode(HttpServletResponse response, PurchaseDto purchaseDto);
}

View File

@ -104,16 +104,7 @@ public class BpmPurchaseAcceptServiceImpl implements BpmPurchaseAcceptService {
PurchaseAcceptVo::getId,
Collectors.mapping(PurchaseAcceptVo::getStatus, Collectors.toList())
));
for (Map.Entry<Integer, List<Integer>> entry : groupedByIdStatus.entrySet()) {
Integer id = entry.getKey();
List<Integer> statusList1 = entry.getValue();
if (statusList1.contains(Constants.PENDING_BINDING)) {
//如果详情状态包含待绑定则外部任务状态为待绑定
result += bpmTaskMapper.updateStatusById(Constants.PENDING_BINDING, id);
} else if (!statusList1.contains(Constants.PENDING_BINDING) && statusList1.contains(Constants.PENDING_INVENTORY)) {
result += bpmTaskMapper.updateStatusById(Constants.PENDING_INVENTORY, id);
}
}
result = getResult(result, groupedByIdStatus);
if (result > 0) {
return AjaxResult.success("批量验收合格成功");
}
@ -147,16 +138,7 @@ public class BpmPurchaseAcceptServiceImpl implements BpmPurchaseAcceptService {
PurchaseAcceptVo::getId,
Collectors.mapping(PurchaseAcceptVo::getStatus, Collectors.toList())
));
for (Map.Entry<Integer, List<Integer>> entry : groupedByIdStatus.entrySet()) {
Integer id = entry.getKey();
List<Integer> statusList1 = entry.getValue();
if (statusList1.contains(Constants.PENDING_BINDING)) {
//如果详情状态包含待绑定则外部任务状态为待绑定
result += bpmTaskMapper.updateStatusById(Constants.PENDING_BINDING, id);
} else if (!statusList1.contains(Constants.PENDING_BINDING) && statusList1.contains(Constants.PENDING_INVENTORY)) {
result += bpmTaskMapper.updateStatusById(Constants.PENDING_INVENTORY, id);
}
}
result = getResult(result, groupedByIdStatus);
if (result > 0) {
return AjaxResult.success("批量验收合格成功");
}
@ -167,6 +149,26 @@ public class BpmPurchaseAcceptServiceImpl implements BpmPurchaseAcceptService {
return AjaxResult.error("操作失败");
}
/**
* 批量合格方法抽取
* @param result
* @param groupedByIdStatus
* @return
*/
private int getResult(int result, Map<Integer, List<Integer>> groupedByIdStatus) {
for (Map.Entry<Integer, List<Integer>> entry : groupedByIdStatus.entrySet()) {
Integer id = entry.getKey();
List<Integer> statusList1 = entry.getValue();
if (statusList1.contains(Constants.PENDING_BINDING)) {
//如果详情状态包含待绑定则外部任务状态为待绑定
result += bpmTaskMapper.updateStatusById(Constants.PENDING_BINDING, id);
} else if (!statusList1.contains(Constants.PENDING_BINDING) && statusList1.contains(Constants.PENDING_INVENTORY)) {
result += bpmTaskMapper.updateStatusById(Constants.PENDING_INVENTORY, id);
}
}
return result;
}
/**
* 二级批量审批不合格
* @param purchaseDto
@ -190,17 +192,7 @@ public class BpmPurchaseAcceptServiceImpl implements BpmPurchaseAcceptService {
PurchaseAcceptVo::getId,
Collectors.mapping(PurchaseAcceptVo::getStatus, Collectors.toList())
));
for (Map.Entry<Integer, List<Integer>> entry : groupedByIdStatus.entrySet()) {
Integer id = entry.getKey();
List<Integer> statusList1 = entry.getValue();
if (!statusList1.contains(Constants.PENDING_ACCEPTANCE) && statusList1.contains(Constants.PURCHASE_ACCEPTED)
&& !statusList1.contains(Constants.PURCHASE_NO_PASSED)) {
//如果不包含47和49则更新任务状态为48 全部通过
result += bpmTaskMapper.updateStatusById(Constants.PURCHASE_ACCEPTED, id);
} else if (!statusList1.contains(Constants.PENDING_ACCEPTANCE) && statusList1.contains(Constants.PURCHASE_NO_PASSED)) {
result += bpmTaskMapper.updateStatusById(Constants.PURCHASE_NO_PASSED, id);
}
}
result = getAnInt(result, groupedByIdStatus);
if (result > 0) {
return AjaxResult.success("操作成功");
}
@ -210,4 +202,25 @@ public class BpmPurchaseAcceptServiceImpl implements BpmPurchaseAcceptService {
}
return AjaxResult.error("操作失败");
}
/**
* 批量不合格方法抽取
* @param result
* @param groupedByIdStatus
* @return
*/
private int getAnInt(int result, Map<Integer, List<Integer>> groupedByIdStatus) {
for (Map.Entry<Integer, List<Integer>> entry : groupedByIdStatus.entrySet()) {
Integer id = entry.getKey();
List<Integer> statusList1 = entry.getValue();
if (!statusList1.contains(Constants.PENDING_ACCEPTANCE) && statusList1.contains(Constants.PURCHASE_ACCEPTED)
&& !statusList1.contains(Constants.PURCHASE_NO_PASSED)) {
//如果不包含47和49则更新任务状态为48 全部通过
result += bpmTaskMapper.updateStatusById(Constants.PURCHASE_ACCEPTED, id);
} else if (!statusList1.contains(Constants.PENDING_ACCEPTANCE) && statusList1.contains(Constants.PURCHASE_NO_PASSED)) {
result += bpmTaskMapper.updateStatusById(Constants.PURCHASE_NO_PASSED, id);
}
}
return result;
}
}

View File

@ -1,25 +1,32 @@
package com.bonus.purchase.service.impl;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.purchase.domain.BpmPurchaseInfo;
import com.bonus.common.core.utils.DateTimeHelper;
import com.bonus.purchase.dto.PurchaseBindDto;
import com.bonus.purchase.dto.PurchaseDto;
import com.bonus.purchase.mapper.BpmPurchaseAcceptMapper;
import com.bonus.purchase.mapper.BpmPurchaseBindMapper;
import com.bonus.purchase.service.BpmPurchaseAcceptService;
import com.bonus.purchase.service.BpmPurchaseBindService;
import com.bonus.purchase.utils.Constants;
import com.bonus.purchase.utils.QrCodeUtils;
import com.bonus.purchase.vo.PurchaseAcceptVo;
import com.bonus.purchase.vo.PurchaseVo;
import com.google.zxing.WriterException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/**
* @Author bonus
@ -31,6 +38,9 @@ public class BpmPurchaseBindServiceImpl implements BpmPurchaseBindService {
@Resource
private BpmPurchaseBindMapper mapper;
@Resource
private BpmPurchaseAcceptMapper acceptMapper;
@Override
public List<PurchaseVo> selectManageList(PurchaseDto purchaseDto) {
@ -58,4 +68,144 @@ public class BpmPurchaseBindServiceImpl implements BpmPurchaseBindService {
return res;
}
/**
* 二维码下载
* @param purchaseDto
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void downloadQrCode(HttpServletResponse response, PurchaseDto purchaseDto) {
//生成二维码
if (purchaseDto.getId() != null) {
isDownLoad(purchaseDto);
String genMonth = DateTimeHelper.getNowMonth();
//根据月份查找code
List<PurchaseBindDto> codeList = mapper.select(genMonth);
int num = 0;
if (CollectionUtils.isNotEmpty(codeList)) {
PurchaseBindDto purchaseBindDto = codeList.get(0);
num = Integer.parseInt(purchaseBindDto.getMaCode().split("-")[1]);
}
List<PurchaseAcceptVo> details = acceptMapper.getDetails(purchaseDto);
try {
Path downloadDir = Paths.get("qr_codes");
Files.createDirectories(downloadDir);
ZipOutputStream zos = new ZipOutputStream(response.getOutputStream());
if (CollectionUtils.isNotEmpty(details)) {
for (int i = 0; i < details.size(); i++) {
String materialModel = details.get(i).getMaterialModel();
String materialName = details.get(i).getMaterialName();
Integer typeId = details.get(i).getTypeId();
Integer checkNum = details.get(i).getCheckNum();
getString(purchaseDto, genMonth, num, downloadDir, zos, materialModel, materialName, typeId, checkNum);
num = num + checkNum;
}
zos.flush();
zos.close();
}
} catch (WriterException | IOException e) {
e.printStackTrace();
}
}else if (purchaseDto.getPurchaseId() != null) {
isDownLoad(purchaseDto);
String genMonth = DateTimeHelper.getNowMonth();
//根据月份查找code
List<PurchaseBindDto> codeList = mapper.select(genMonth);
int num = 0;
if (CollectionUtils.isNotEmpty(codeList)) {
PurchaseBindDto purchaseBindDto = codeList.get(0);
num = Integer.parseInt(purchaseBindDto.getMaCode().split("-")[1]);
}
List<PurchaseAcceptVo> details = acceptMapper.getDetails(purchaseDto);
try {
Path downloadDir = Paths.get("qr_codes");
Files.createDirectories(downloadDir);
ZipOutputStream zos = new ZipOutputStream(response.getOutputStream());
if(CollectionUtils.isNotEmpty(details)) {
String materialModel = details.get(0).getMaterialModel();
String materialName = details.get(0).getMaterialName();
Integer typeId = details.get(0).getTypeId();
Integer checkNum = details.get(0).getCheckNum();
purchaseDto.setId(details.get(0).getTaskId());
getString(purchaseDto, genMonth, num, downloadDir, zos, materialModel, materialName, typeId, checkNum);
zos.flush();
zos.close();
}
} catch (WriterException | IOException e) {
e.printStackTrace();
}
}
}
/**
* 方法抽取
* @param purchaseDto
* @param genMonth
* @param num
* @param downloadDir
* @param zos
* @param materialModel
* @param materialName
* @param typeId
* @param checkNum
* @throws WriterException
* @throws IOException
*/
private void getString(PurchaseDto purchaseDto, String genMonth, int num, Path downloadDir, ZipOutputStream zos, String materialModel, String materialName, Integer typeId, Integer checkNum) throws WriterException, IOException {
for (int j = 1; j <= checkNum / 1000; j++) {
genMonth = genMonth.replace("-", "");
String code = genMonth + "-" + String.format("%5d", num + j).replace(" ", "0");
// 新购管理-二维码打印-新增
String qrUrl = "D://files/" + "images" + "/" + code + ".jpg";
String Path = "[" + materialModel + "-" + materialName + "]" + code + ".jpg";
String baseText = "QR Code " + j;
BufferedImage qrCodeImage = QrCodeUtils.generateQRCodeImage(baseText, 300, 300);
java.nio.file.Path filePath = downloadDir.resolve(Path);
QrCodeUtils.saveQRCodeImage(qrCodeImage, filePath);
PurchaseDto dto = PurchaseDto.builder().id(purchaseDto.getId()).typeId(typeId).qrCode(code).qrUrl(qrUrl).build();
mapper.insert(dto);
//修改任务表的是否下载状态
mapper.updateStatus(purchaseDto.getId());
extracted(zos, materialModel, materialName, code, qrUrl);
}
}
/**
* 是否下载方法抽取
* @param purchaseDto
*/
private void isDownLoad(PurchaseDto purchaseDto) {
List<Integer> statusList =mapper.selectStatus(purchaseDto);
if (CollectionUtils.isNotEmpty(statusList) && statusList.contains(1)) {
throw new RuntimeException("该采购单二维码已生成,无法再次生成!");
}
}
/**
* 二维码下载方法抽取
* @param zos
* @param materialModel
* @param materialName
* @param code
* @param qrUrl
* @throws IOException
*/
private void extracted(ZipOutputStream zos, String materialModel, String materialName, String code, String qrUrl) throws IOException {
// 判断路径是否存在
File imageFile = new File(qrUrl);
if (!imageFile.exists()) {
return;
}
zos.setLevel(0);
zos.putNextEntry(new ZipEntry("[" + materialModel + "-" + materialName + "]" + code + ".jpg"));
InputStream fis = new FileInputStream(imageFile);
byte[] buffer = new byte[1024];
int r = 0;
while ((r = fis.read(buffer)) != -1) {
zos.write(buffer, 0, r);
}
fis.close();
}
}

View File

@ -0,0 +1,110 @@
package com.bonus.purchase.utils;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.WriterException;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
/**
* 二维码生成保存压缩包工具类
* @Author ma_sh
* @create 2024/8/23 11:37
*/
public class QrCodeUtils {
/**
* 生成二维码图片
* @param text 二维码内容
* @param width 图片宽度
* @param height 图片高度
* @return 生成的二维码图片
* @throws WriterException 如果二维码生成失败
*/
public static BufferedImage generateQRCodeImage(String text, int width, int height) throws WriterException {
QRCodeWriter qrCodeWriter = new QRCodeWriter();
BitMatrix bitMatrix = qrCodeWriter.encode(text, BarcodeFormat.QR_CODE, width, height);
return MatrixToImageWriter.toBufferedImage(bitMatrix);
}
/**
* 将二维码图片保存到文件
* @param qrCodeImage 二维码图片
* @param filePath 文件路径
* @throws IOException 如果保存文件失败
*/
public static void saveQRCodeImage(BufferedImage qrCodeImage, Path filePath) throws IOException {
File outputFile = filePath.toFile();
ImageIO.write(qrCodeImage, "jpg", outputFile);
}
/**
* 压缩目录中的图片到ZIP文件
* @param sourceDir 源目录
* @param zipFilePath ZIP文件路径
* @throws IOException 如果压缩过程失败
*/
public static void zipImages(Path sourceDir, Path zipFilePath) throws IOException {
try (FileOutputStream fos = new FileOutputStream(zipFilePath.toFile());
ZipArchiveOutputStream zos = new ZipArchiveOutputStream(fos)) {
Files.walk(sourceDir)
.filter(Files::isRegularFile)
.forEach(file -> {
try {
ZipArchiveEntry zipEntry = new ZipArchiveEntry(file.toFile(), sourceDir.relativize(file).toString());
zos.putArchiveEntry(zipEntry);
Files.copy(file, zos);
zos.closeArchiveEntry();
} catch (IOException e) {
e.printStackTrace();
}
});
}
}
/*public static void main(String[] args) {
try {
Path downloadDir = Paths.get("qr_codes");
Files.createDirectories(downloadDir);
int width = 300;
int height = 300;
String baseText = "QR Code ";
// 生成二维码
for (int i = 1; i <= 2; i++) {
String text = baseText + i;
BufferedImage qrCodeImage = QRCodeUtils.generateQRCodeImage(text, width, height);
Path filePath = downloadDir.resolve("QRCode_" + i + ".jpg");
QRCodeUtils.saveQRCodeImage(qrCodeImage, filePath);
System.out.println("Generated: " + filePath);
}
// 压缩二维码图片
Path zipFilePath = Paths.get("qr_codes.zip");
zipImages(downloadDir, zipFilePath);
System.out.println("Images zipped to: " + zipFilePath);
// 清理
Files.walk(downloadDir)
.map(Path::toFile)
.forEach(File::delete);
Files.deleteIfExists(downloadDir);
} catch (WriterException | IOException e) {
e.printStackTrace();
}
}*/
}

View File

@ -25,7 +25,7 @@ public class PurchaseAcceptVo {
private String materialName;
@ApiModelProperty("规格型号")
private String specificationCode;
private String materialModel;
@ApiModelProperty(value="单位")
private String unitName;
@ -92,4 +92,13 @@ public class PurchaseAcceptVo {
@ApiModelProperty(value="备注")
@Excel(name = "备注")
private String remark;
@ApiModelProperty(value = "二级明细id")
private String purchaseId;
@ApiModelProperty(value = "管理类型0是编码1计数")
private String manageType;
@ApiModelProperty(value = "任务id")
private String taskId;
}

View File

@ -81,4 +81,7 @@ public class PurchaseVo {
@ApiModelProperty(value="备注")
@Excel(name = "备注")
private String remark;
@ApiModelProperty(value = "管理类型0是编码1计数")
private String manageType;
}

View File

@ -40,7 +40,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND (
bt.`code` LIKE CONCAT('%',#{keyWord},'%')
OR GROUP_CONCAT( mt.`name` ) LIKE CONCAT('%',#{keyWord},'%')
OR bp.tax_rate = #{keyWord}
OR su.nick_name LIKE CONCAT('%',#{keyWord},'%')
OR bt.remark LIKE CONCAT('%',#{keyWord},'%')
)
@ -57,6 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getDetails" resultType="com.bonus.purchase.vo.PurchaseAcceptVo">
SELECT
bp.id AS purchaseId,
bp.task_id AS taskId,
mt1.`name` AS materialName,
mt.`name` AS materialModel,
mt.manage_type AS manageType,
@ -64,8 +64,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bp.purchase_price AS purchasePrice,
bp.notax_price AS notaxPrice,
bp.purchase_num AS purchaseNum,
bp.check_num AS checkNum,
bp.type_id as typeId,
bs.`name` AS supplierName,
CONCAT(bp.tax_rate, '%') AS taxRate,
bp.product_date AS productDate,
bp.`status` AS STATUS,
sda1.dict_label AS statusName

View File

@ -51,8 +51,46 @@
supplier_id, product_date, `status`, bind_num, input_num, updater, update_time, auditor,
audit_time, is_active, remark, file_url
</sql>
<insert id="insert">
INSERT INTO bm_qrcode
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="qrCode != null">
code,
</if>
<if test="typeId != null">
type_id,
</if>
<if test="qrUrl != null">
qr_url,
</if>
<if test="id != null">
task_id,
</if>
gen_time,
is_active
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="qrCode != null">
#{qrCode},
</if>
<if test="typeId != null">
#{typeId},
</if>
<if test="qrUrl != null">
#{qrUrl},
</if>
<if test="id != null">
#{id},
</if>
NOW(),
1
</trim>
</insert>
<update id="updateStatus">
UPDATE bpm_purchase_info
SET is_download = '1'
WHERE task_id = #{id}
</update>
<select id="selectManageList" resultType="com.bonus.purchase.vo.PurchaseVo">
@ -125,4 +163,28 @@
AND bp.task_id = #{taskId,jdbcType=INTEGER}
</select>
<select id="select" resultType="com.bonus.purchase.dto.PurchaseBindDto">
SELECT
`code` as maCode
FROM
bm_qrcode
WHERE
DATE_FORMAT(gen_time, '%Y-%m') = #{genMonth}
ORDER BY
`code` DESC
</select>
<select id="selectStatus" resultType="java.lang.Integer">
SELECT
is_download
FROM
bpm_purchase_info
WHERE
is_active = '1'
<if test="id != null and id != ''">
and task_id = #{id}
</if>
<if test="purchaseId != null and purchaseId != ''">
and id = #{purchaseId}
</if>
</select>
</mapper>

View File

@ -38,7 +38,7 @@
SUM( bp.purchase_num ) AS purchaseNum,
SUM( bp.purchase_price ) AS purchasePrice,
SUM( bp.notax_price ) AS notaxPrice,
bt.creator AS createBy,
su.nick_name AS createBy,
bt.create_time AS createTime,
bt.`status` AS STATUS,
sda.dict_label AS statusName,
@ -48,17 +48,17 @@
LEFT JOIN bpm_task bt ON bp.task_id = bt.id
LEFT JOIN ma_type mt ON bp.type_id = mt.id
LEFT JOIN sys_dict_data sda ON sda.dict_code = bt.`status`
LEFT JOIN sys_user su ON bt.creator = su.user_id
WHERE
bp.is_active = '1'
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND bt.arrival_time BETWEEN #{startTime} AND #{endTime}
<![CDATA[ AND DATE_FORMAT( bt.arrival_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime} ]]>
</if>
<if test="keyWord != null and keyWord != ''">
AND (
bt.`code` LIKE CONCAT('%',#{keyWord},'%')
OR mt1.`name` LIKE CONCAT('%',#{keyWord},'%')
OR bp.tax_rate = #{keyWord}
OR bt.creator LIKE CONCAT('%',#{keyWord},'%')
OR su.nick_name LIKE CONCAT('%',#{keyWord},'%')
OR bt.remark LIKE CONCAT('%',#{keyWord},'%')
)
</if>
@ -79,11 +79,12 @@
sda.dict_label AS unitName,
bp.purchase_price AS purchasePrice,
bp.notax_price AS notaxPrice,
bp.purchase_num AS purchaseNum,
bp.bind_num AS purchaseNum,
bs.`name` AS supplierName,
bp.product_date AS productDate,
bp.`status` AS STATUS,
sda1.dict_label AS statusName
sda1.dict_label AS statusName,
mt.manage_type AS manageType
FROM
bpm_purchase_info bp
LEFT JOIN bpm_task bt ON bp.task_id = bt.id
@ -93,18 +94,18 @@
LEFT JOIN bm_supplier bs ON bp.supplier_id = bs.id
LEFT JOIN sys_dict_data sda1 ON sda1.dict_code = bp.`status`
WHERE
bp.is_acvtive = '1'
bp.is_active = '1'
<if test="typeId != null and typeId != ''">
AND (
mt1.id = #{typeId}
OR mt.id = #{typeId}
)
AND mt.id = #{typeId}
</if>
<if test="supplierId != null and supplierId != ''">
AND bs.id = #{supplierId}
</if>
<if test="productDate != null and productDate != ''">
AND bp.product_date = #{productDate}
<![CDATA[ AND DATE_FORMAT( bp.product_date, '%Y-%m-%d' ) = #{productDate} ]]>
</if>
<if test="id != null and id != ''">
AND bp.task_id = #{id}
</if>
</select>
<select id="selectByPrimaryKey" resultType="com.bonus.purchase.domain.PurchaseStorageDto"