业务单据打印相关
parent
ac4774981d
commit
8677fb7fdc
@ -0,0 +1,128 @@
|
||||
package com.glxp.api.controller.purchase;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.json.JSONConfig;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.glxp.api.annotation.AuthRuleAnnotation;
|
||||
import com.glxp.api.common.enums.ResultEnum;
|
||||
import com.glxp.api.common.util.ResultVOUtils;
|
||||
import com.glxp.api.entity.system.SysPdfTemplateRelevanceBizEntity;
|
||||
import com.glxp.api.entity.system.SystemPDFTemplateEntity;
|
||||
import com.glxp.api.exception.JsonException;
|
||||
import com.glxp.api.req.inout.FilterReceiveDetailRequest;
|
||||
import com.glxp.api.req.inout.FilterReceiveRequest;
|
||||
import com.glxp.api.req.inout.PurOrderPrintRequest;
|
||||
import com.glxp.api.res.inout.ReceiveDetailResponse;
|
||||
import com.glxp.api.res.inout.ReceiveResponse;
|
||||
import com.glxp.api.service.inout.impl.ReceiveDetailService;
|
||||
import com.glxp.api.service.inout.impl.ReceiveService;
|
||||
import com.glxp.api.service.system.SystemPDFTemplateRelevanceBizService;
|
||||
import com.glxp.api.service.system.SystemPDFTemplateService;
|
||||
import com.glxp.api.util.IntUtil;
|
||||
import com.glxp.api.util.JasperUtils;
|
||||
import com.glxp.api.util.MsDateUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 业务管理打印
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
public class PurOrderPrintController {
|
||||
@Value("${file_path}")
|
||||
private String filePath;
|
||||
|
||||
@Resource
|
||||
SystemPDFTemplateRelevanceBizService systemPDFTemplateRelevanceBizService;
|
||||
@Resource
|
||||
private SystemPDFTemplateService systemPDFTemplateService;
|
||||
@Resource
|
||||
ReceiveService receiveService;
|
||||
@Resource
|
||||
ReceiveDetailService receivedetailService;
|
||||
|
||||
/**
|
||||
* 领用单单据打印
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @throws Exception
|
||||
*/
|
||||
@AuthRuleAnnotation("")
|
||||
@PostMapping("/pur/receive/order/printOrder")
|
||||
public void printOrder(@RequestBody PurOrderPrintRequest purOrderPrintRequest, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
FilterReceiveRequest filterReceiveRequest = new FilterReceiveRequest();
|
||||
filterReceiveRequest.setBillNo(purOrderPrintRequest.getBillNo());
|
||||
List<ReceiveResponse> receiveResponses = receiveService.filterList(filterReceiveRequest);
|
||||
ReceiveResponse purReceiveEntity = receiveResponses.get(0);
|
||||
if (purReceiveEntity == null) {
|
||||
throw new JsonException(500, "单据未找到!");
|
||||
}
|
||||
SysPdfTemplateRelevanceBizEntity sysPdfTemplateRelevanceBizEntity;
|
||||
if (IntUtil.value(purReceiveEntity.getStatus()) == 3) {
|
||||
sysPdfTemplateRelevanceBizEntity = systemPDFTemplateRelevanceBizService.findByModuleKey("bizAlready", "HCLY");
|
||||
} else {
|
||||
sysPdfTemplateRelevanceBizEntity = systemPDFTemplateRelevanceBizService.findByModuleKey("bizlWait", "HCLY");
|
||||
}
|
||||
SystemPDFTemplateEntity systemPDFTemplateEntity = systemPDFTemplateService.selectById(sysPdfTemplateRelevanceBizEntity.getTemplateId() + "");
|
||||
if (systemPDFTemplateEntity == null)
|
||||
throw new JsonException(500, "未设置模板!");
|
||||
//打印单号标签
|
||||
Map<String, Object> data = new HashMap<>(1);
|
||||
List<Object> list = new ArrayList<>();
|
||||
FilterReceiveDetailRequest filterReceiveDetailRequest = new FilterReceiveDetailRequest();
|
||||
filterReceiveDetailRequest.setOrderIdFk(purReceiveEntity.getBillNo());
|
||||
List<ReceiveDetailResponse> responseList = receivedetailService.filterList(filterReceiveDetailRequest);
|
||||
int i = 1;
|
||||
if (CollUtil.isNotEmpty(responseList)) {
|
||||
for (ReceiveDetailResponse obj : responseList) {
|
||||
Map<String, Object> supData = new HashMap<>();
|
||||
supData.put("billNo", purReceiveEntity.getBillNo());
|
||||
supData.put("deptName", purReceiveEntity.getDeptName());
|
||||
supData.put("deptCode", purReceiveEntity.getDeptCode());
|
||||
supData.put("invName", purReceiveEntity.getInvName());
|
||||
supData.put("invCode", purReceiveEntity.getInvCode());
|
||||
supData.put("targetDeptName", purReceiveEntity.getTargetDeptName());
|
||||
supData.put("targetDeptCode", purReceiveEntity.getTargetInvCode());
|
||||
supData.put("targetInvName", purReceiveEntity.getTargetInvName());
|
||||
supData.put("targetInvCode", purReceiveEntity.getTargetInvCode());
|
||||
supData.put("createUserName", purReceiveEntity.getCreateUserName());
|
||||
supData.put("auditUserName", purReceiveEntity.getAuditUserName());
|
||||
supData.put("billDate", MsDateUtil.formatDate(purReceiveEntity.getBillDate(), "yyyy-MM-dd"));
|
||||
supData.put("auditTime", MsDateUtil.formatDate(purReceiveEntity.getAuditTime(), "yyyy-MM-dd"));
|
||||
|
||||
supData.put("cpmctymc", obj.getCpmctymc());
|
||||
supData.put("ggxh", obj.getGgxh());
|
||||
supData.put("manufactory", obj.getManufactory());
|
||||
supData.put("measname", obj.getMeasname());
|
||||
supData.put("nameCode", obj.getNameCode());
|
||||
supData.put("price", obj.getPrice());
|
||||
supData.put("supName", obj.getSupName());
|
||||
supData.put("ylqxzcrbarmc", obj.getYlqxzcrbarmc());
|
||||
supData.put("zczbhhzbapzbh", obj.getZczbhhzbapzbh());
|
||||
list.add(supData);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
data.put("data", list);
|
||||
String param = JSONObject.toJSONString(data, SerializerFeature.WriteNullStringAsEmpty);
|
||||
JasperUtils.jasperReport(request, response, param, filePath + "pdf/template/" + systemPDFTemplateEntity.getPath(), "pdf");
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.glxp.api.req.inout;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PurOrderPrintRequest {
|
||||
private String billNo;
|
||||
}
|
@ -1,79 +1,76 @@
|
||||
<?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.glxp.api.dao.system.SysPdfTemplateRelevanceBizDao">
|
||||
<resultMap id="BaseResultMap" autoMapping="true" type="com.glxp.api.entity.system.SysPdfTemplateRelevanceBizEntity">
|
||||
<!--@mbg.generated-->
|
||||
<!--@Table sys_pdf_template_relevance_biz-->
|
||||
<!-- <id column="id" jdbcType="INTEGER" property="id" />-->
|
||||
<result column="templateId" jdbcType="INTEGER" property="templateId" />
|
||||
<result column="customerId" jdbcType="BIGINT" property="customerId" />
|
||||
<result column="adminId" jdbcType="INTEGER" property="adminId" />
|
||||
<result column="moduleId" jdbcType="INTEGER" property="moduleId" />
|
||||
<result column="localAction" jdbcType="VARCHAR" property="localAction" />
|
||||
<result column="remark1" jdbcType="VARCHAR" property="remark1" />
|
||||
<result column="remark2" jdbcType="VARCHAR" property="remark2" />
|
||||
<result column="remark3" jdbcType="VARCHAR" property="remark3" />
|
||||
<result column="printType" jdbcType="TINYINT" property="printType" />
|
||||
<result column="modelKey" jdbcType="VARCHAR" property="modelKey" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
<!--@mbg.generated-->
|
||||
id, templateId, customerId, adminId, moduleId, localAction, remark1, remark2, remark3,
|
||||
printType, modelKey
|
||||
</sql>
|
||||
<resultMap id="BaseResultMap" autoMapping="true" type="com.glxp.api.entity.system.SysPdfTemplateRelevanceBizEntity">
|
||||
<!--@mbg.generated-->
|
||||
<!--@Table sys_pdf_template_relevance_biz-->
|
||||
<!-- <id column="id" jdbcType="INTEGER" property="id" />-->
|
||||
<result column="templateId" jdbcType="INTEGER" property="templateId"/>
|
||||
<result column="customerId" jdbcType="BIGINT" property="customerId"/>
|
||||
<result column="adminId" jdbcType="INTEGER" property="adminId"/>
|
||||
<result column="moduleId" jdbcType="INTEGER" property="moduleId"/>
|
||||
<result column="localAction" jdbcType="VARCHAR" property="localAction"/>
|
||||
<result column="remark1" jdbcType="VARCHAR" property="remark1"/>
|
||||
<result column="remark2" jdbcType="VARCHAR" property="remark2"/>
|
||||
<result column="remark3" jdbcType="VARCHAR" property="remark3"/>
|
||||
<result column="printType" jdbcType="TINYINT" property="printType"/>
|
||||
<result column="modelKey" jdbcType="VARCHAR" property="modelKey"/>
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
<!--@mbg.generated-->
|
||||
id, templateId, customerId, adminId, moduleId, localAction, remark1, remark2, remark3,
|
||||
printType, modelKey
|
||||
</sql>
|
||||
|
||||
|
||||
<select id="filterList" parameterType="com.glxp.api.req.system.FilterPdfTemplateRelevanceRequest"
|
||||
resultType="com.glxp.api.res.system.SystemPDFTemplateRelevanceResponse">
|
||||
SELECT
|
||||
basic_bustype_change.`originName` localActionName,
|
||||
sys_pdf_template_relevance_biz.id,
|
||||
basic_bustype_change.originAction localAction,
|
||||
templateId,
|
||||
moduleId,
|
||||
sys_pdf_template.NAME templateName,
|
||||
sys_pdf_template_relevance_biz.remark1,
|
||||
sys_pdf_template_relevance_biz.remark2,
|
||||
sys_pdf_template_relevance_biz.remark3,
|
||||
printType
|
||||
FROM
|
||||
basic_bustype_change
|
||||
LEFT JOIN sys_pdf_template_relevance_biz ON basic_bustype_change.originAction = sys_pdf_template_relevance_biz.localAction
|
||||
LEFT JOIN sys_pdf_template ON sys_pdf_template_relevance_biz.templateId = sys_pdf_template.id
|
||||
<where>
|
||||
<if test="moduleId != null">
|
||||
AND `moduleId` = #{moduleId}
|
||||
</if>
|
||||
<if test="localAction != null">
|
||||
AND sys_pdf_template_relevance_biz.`localAction` = #{localAction}
|
||||
</if>
|
||||
<if test="templateType != null">
|
||||
AND sys_pdf_template_relevance_biz.`templateType` = #{templateType}
|
||||
</if>
|
||||
<if test="modelKey != null">
|
||||
AND sys_pdf_template_relevance_biz.`modelKey` = #{modelKey}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="filterList" parameterType="com.glxp.api.req.system.FilterPdfTemplateRelevanceRequest"
|
||||
resultType="com.glxp.api.res.system.SystemPDFTemplateRelevanceResponse">
|
||||
SELECT basic_bustype_change.`originName` localActionName,
|
||||
sys_pdf_template_relevance_biz.id,
|
||||
basic_bustype_change.originAction localAction,
|
||||
templateId,
|
||||
moduleId,
|
||||
sys_pdf_template.NAME templateName,
|
||||
sys_pdf_template_relevance_biz.remark1,
|
||||
sys_pdf_template_relevance_biz.remark2,
|
||||
sys_pdf_template_relevance_biz.remark3,
|
||||
printType
|
||||
FROM basic_bustype_change
|
||||
LEFT JOIN sys_pdf_template_relevance_biz
|
||||
ON basic_bustype_change.originAction = sys_pdf_template_relevance_biz.localAction
|
||||
LEFT JOIN sys_pdf_template ON sys_pdf_template_relevance_biz.templateId = sys_pdf_template.id
|
||||
<where>
|
||||
<if test="moduleId != null">
|
||||
AND `moduleId` = #{moduleId}
|
||||
</if>
|
||||
<if test="localAction != null">
|
||||
AND sys_pdf_template_relevance_biz.`localAction` = #{localAction}
|
||||
</if>
|
||||
<if test="templateType != null">
|
||||
AND sys_pdf_template_relevance_biz.`templateType` = #{templateType}
|
||||
</if>
|
||||
<if test="modelKey != null">
|
||||
AND sys_pdf_template_relevance_biz.`modelKey` = #{modelKey}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<insert id="upInsert" parameterType="com.glxp.api.entity.system.SysPdfTemplateRelevanceBizEntity">
|
||||
insert
|
||||
ignore
|
||||
INTO sys_pdf_template_relevance_biz
|
||||
(templateId, customerId, adminId, moduleId, localAction, remark1, remark2, remark3, printType, modelKey,
|
||||
updateTime)
|
||||
values (#{templateId},
|
||||
#{customerId},
|
||||
#{adminId},
|
||||
#{moduleId},
|
||||
#{localAction},
|
||||
#{remark1},
|
||||
#{remark2},
|
||||
#{remark3},
|
||||
#{printType},
|
||||
#{modelKey},
|
||||
#{updateTime})
|
||||
</insert>
|
||||
|
||||
|
||||
</mapper>
|
||||
<insert id="upInsert" parameterType="com.glxp.api.entity.system.SysPdfTemplateRelevanceBizEntity">
|
||||
insert
|
||||
ignore
|
||||
INTO sys_pdf_template_relevance_biz
|
||||
(templateId, customerId, adminId, moduleId, localAction, remark1, remark2, remark3, printType, modelKey,
|
||||
updateTime)
|
||||
values (#{templateId},
|
||||
#{customerId},
|
||||
#{adminId},
|
||||
#{moduleId},
|
||||
#{localAction},
|
||||
#{remark1},
|
||||
#{remark2},
|
||||
#{remark3},
|
||||
#{printType},
|
||||
#{modelKey},
|
||||
#{updateTime})
|
||||
</insert>
|
||||
</mapper>
|
||||
|
Loading…
Reference in New Issue