Browse Source

开票导出功能优化

user5 3 years ago
parent
commit
a4a4c9e01b

+ 2 - 0
src/main/java/com/jeeplus/modules/workinvoice/dao/WorkInvoiceDao.java

@@ -87,6 +87,8 @@ public interface WorkInvoiceDao extends CrudDao<WorkInvoice> {
 	 */
 	List<WorkInvoice> findListOnExport(WorkInvoice workInvoice);
 
+	List<WorkInvoice> findListExport(WorkInvoice workInvoice);
+
 	List<WorkInvoice> findMapList(WorkInvoice workInvoice);
 	Integer queryMapCount(WorkInvoice workInvoice);
 

+ 18 - 2
src/main/java/com/jeeplus/modules/workinvoice/service/WorkInvoiceAllService.java

@@ -227,6 +227,22 @@ public class WorkInvoiceAllService extends CrudService<WorkInvoiceDao, WorkInvoi
 		return page;
 
 	}
+	public Page<WorkInvoice> findListExport(Page<WorkInvoice> page, WorkInvoice workInvoice) {
+//		workInvoice.getSqlMap().put("dsf", dataScopeFilter(workInvoice.getCurrentUser(), "o", "u","s", MenuStatusEnum.WORK_INVOICE.getValue()));
+		if(StringUtils.isNotBlank(workInvoice.getOfficeId())){
+			//查询该选择节点下所有的部门Id
+			List<String> officeIdList = officeService.getChildrenOffice(workInvoice.getOfficeId());
+			officeIdList.add(workInvoice.getOfficeId());
+			workInvoice.setOfficeIdList(officeIdList);
+		}
+		int count = dao.queryCount(workInvoice);
+		page.setCount(count);
+		page.setCountFlag(false);
+		workInvoice.setPage(page);
+		page.setList(dao.findListExport(workInvoice));
+		return page;
+
+	}
 	public Page<WorkInvoice> findMapPage(Page<WorkInvoice> page, WorkInvoice workInvoice) {
 		if(StringUtils.isNotBlank(workInvoice.getOfficeId())){
 			//查询该选择节点下所有的部门Id
@@ -2236,7 +2252,7 @@ public class WorkInvoiceAllService extends CrudService<WorkInvoiceDao, WorkInvoi
 				if ( projectRelation.getIsProject() == 2) {
 					projectRelation.setProjectName(projectRelation.getDetails());
 					//判断是否选择合同,选择合同则将合同信息以及委托方查询并放入
-					if(StringUtils.isNotBlank(projectRelation.getContractId())){
+					/*if(StringUtils.isNotBlank(projectRelation.getContractId())){
 						WorkContractInfo workContractInfo = contractInfoService.get(projectRelation.getContractId());
 						projectRelation.setWorkContractName(workContractInfo.getName());
 						if(null != workContractInfo.getClient() && StringUtils.isNotBlank(workContractInfo.getClient().getName())){
@@ -2245,7 +2261,7 @@ public class WorkInvoiceAllService extends CrudService<WorkInvoiceDao, WorkInvoi
 					}else{
 						projectRelation.setWorkContractName("");
 						projectRelation.setClientName("");
-					}
+					}*/
 				}
 			}
 		}

+ 3 - 3
src/main/java/com/jeeplus/modules/workinvoice/web/WorkInvoiceAllTwoController.java

@@ -675,14 +675,14 @@ public class WorkInvoiceAllTwoController extends BaseController {
 	public String exportFile(WorkInvoice workInvoice, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) {
 		try {
 			String fileName = "发票一览表"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
-			Page<WorkInvoice> page = workInvoiceService.findPage(new Page<WorkInvoice>(request, response, -1), workInvoice);
+			Page<WorkInvoice> page = workInvoiceService.findListExport(new Page<WorkInvoice>(request, response, -1), workInvoice);
 			List<WorkInvoice> workInvoiceList = page.getList();
-			for (WorkInvoice invoice: workInvoiceList) {
+			/*for (WorkInvoice invoice: workInvoiceList) {
 				invoice.setWorkInvoiceProjectRelationList(workInvoiceService.getProjectRelation(invoice));
 				List<String> projectNameList = workInvoiceService.getProjectNameList(invoice);
 				String projectNameStr = String.join(",", projectNameList);
 				invoice.setProjectName(projectNameStr);
-			}
+			}*/
 			new ExportExcel("发票一览表", WorkInvoiceExport.class).setDataList(page.getList()).write(response, fileName).dispose();
 			return null;
 		} catch (Exception e) {

+ 221 - 0
src/main/resources/mappings/modules/workinvoice/WorkInvoiceDao.xml

@@ -529,6 +529,227 @@
 			</otherwise>
 		</choose>
 	</select>
+
+	<select id="findListExport" resultType="WorkInvoice" >
+		SELECT
+		a.id AS "id",
+		a.number AS "number",
+		a.process_instance_id AS "processInstanceId",
+		a.client_id AS "client.id",
+		a.project_id AS "project.id",
+		a.money AS "money",
+		a.money AS "moneyStr",
+		a.invoice_type AS "invoiceType",
+		(case when a.invoice_type = '1' then '专票' when a.invoice_type = '2' then '普票' else '' end) as invoiceTypeStr,
+		a.charge_type AS "chargeType",
+		a.content AS "content",
+		a.drawer_id AS "drawer.id",
+		a.office_id AS "office.id",
+		a.invoice_number AS "invoiceNumber",
+		a.invoice_date AS "invoiceDate",
+		a.drawer_name AS "drawerName",
+		a.take_date AS "takeDate",
+		a.invoice_remarks AS "invoiceRemarks",
+		a.is_invoice AS "isInvoice",
+		a.is_charge AS "isCharge",
+		a.is_invalid AS "isInvalid",
+		a.create_by AS "createBy.id",
+		a.create_date AS "createDate",
+		a.update_by AS "updateBy.id",
+		a.update_date AS "updateDate",
+		a.remarks AS "remarks",
+		a.del_flag AS "delFlag",
+		a.orUnicode AS "orUnicode",
+		a.address AS "address",
+		a.telephone AS "telephone",
+		a.bank AS "bank",
+		a.bank_number AS "bankNumber",
+		a.cancle_reason AS "cancaleReason",
+		u.name AS "drawer.name",
+		su.name AS "createBy.name",
+		so.top_company AS "office.name",
+		w.name AS "client.name",
+		p.project_name AS "project.projectName",
+		p.id AS "project.id",
+		a.invoice_state AS "invoiceState",
+		p.project_id AS "project.projectId",
+		ci.name AS "project.workContractInfo.name",
+		w.usc_code AS "client.uscCode",
+		w.fax AS "client.fax",
+		w.or_unicode AS "client.orUnicode",
+		w.telephone AS "client.telephone",
+		a.company_id AS "companyId",
+		a.cancle_reason AS "cancleReason",
+		w.address AS "client.address",
+		a.officee_id AS "officeId",
+		a.province AS "province",
+		a.ext AS "ext",
+		a.billing_content as "billingContent",
+		prd.number as "project.reportData.number",
+		p.area_name as "project.county",
+		a.receipt_money_date as "receiptMoneyDate",
+		(case when a.receipt_money = '0' then '否' when a.receipt_money = '1' then '是' else '否' end) as receiptMoney,
+		a.cancellation_remark as "cancellationRemark",
+		a.account_checking_user_id as "accountCheckingUserId",
+		a.area_id as "area.id",
+		acu.name as "accountCheckingUserName"
+		,wid.number as "widNumber"
+		,wid.total_money as "widTotalMoney"
+		,(select
+		CASE
+		WHEN RIGHT( GROUP_CONCAT(is_project),1) =2 THEN GROUP_CONCAT(concat('其他:',wipr1.details))
+		WHEN RIGHT( GROUP_CONCAT(is_project),1) =1 THEN GROUP_CONCAT(rpr1.project_name)
+		ELSE '' END
+		FROM work_invoice_project_relation wipr1
+		LEFT JOIN rural_project_records rpr1 ON wipr1.project_id = rpr1.id
+		LEFT JOIN project_report_data prd1 ON prd1.project_id = wipr1.project_id
+		WHERE wipr1.invoice_id = a.id) as projectName
+		,(select
+		GROUP_CONCAT(prd1.number)
+		FROM work_invoice_project_relation wipr1
+		LEFT JOIN rural_project_records rpr1 ON wipr1.project_id = rpr1.id
+		LEFT JOIN project_report_data prd1 ON prd1.project_id = wipr1.project_id
+		WHERE wipr1.invoice_id = a.id) as reportNumber
+		FROM work_invoice a
+		<include refid="workInvoiceJoins"/>
+		left join work_invoice_detail wid on a.id = wid.invoice_id
+		LEFT JOIN sys_user sua ON sua.id = a.account_checking_user_id
+		<where>
+			a.del_flag = #{DEL_FLAG_NORMAL}
+			<if test="number != null and number != ''">
+				AND a.number LIKE
+				<if test="dbName == 'oracle'">'%'||#{number}||'%'</if>
+				<if test="dbName == 'mssql'">'%'+#{number}+'%'</if>
+				<if test="dbName == 'mysql'">concat('%',#{number},'%')</if>
+			</if>
+			<if test="invoiceState != null and invoiceState != ''">
+				AND a.invoice_state = #{invoiceState}
+			</if>
+			<if test="beginContractDate != null and endContractDate != null and beginContractDate != '' and endContractDate != ''">
+				AND a.create_date BETWEEN #{beginContractDate} AND #{endContractDate}
+			</if>
+
+			<if test="receiptBeginDate != null and receiptBeginDate != ''">
+				AND date_format(a.receipt_money_date,'%Y-%m-%d') &gt;= date_format(#{receiptBeginDate},'%Y-%m-%d')
+			</if>
+			<if test="receiptEndDate != null and receiptEndDate != ''">
+				AND date_format(a.receipt_money_date,'%Y-%m-%d') &lt;= date_format(#{receiptEndDate},'%Y-%m-%d')
+			</if>
+
+			<if test="client != null and client.id != null and client.id != ''">
+				AND a.client_id = #{client.id}
+			</if>
+			<if test="project != null and project.id != null and project.id != ''">
+				AND a.project_id = #{project.id}
+			</if>
+			<if test="project != null and project.projectId != null and project.projectId != ''">
+				AND p.project_id LIKE
+				<if test="dbName == 'oracle'">'%'||#{project.projectId}||'%'</if>
+				<if test="dbName == 'mssql'">'%'+#{project.projectId}+'%'</if>
+				<if test="dbName == 'mysql'">concat('%',#{project.projectId},'%')</if>
+			</if>
+			<if test="project != null and project.projectName != null and project.projectName != ''">
+				AND p.project_name LIKE
+				<if test="dbName == 'oracle'">'%'||#{project.projectName}||'%'</if>
+				<if test="dbName == 'mssql'">'%'+#{project.projectName}+'%'</if>
+				<if test="dbName == 'mysql'">concat('%',#{project.projectName},'%')</if>
+			</if>
+			<if test="project != null and project.reportData != null and project.reportData.number != null and project.reportData.number != ''">
+				AND prd.number LIKE
+				<if test="dbName == 'oracle'">'%'||#{project.reportData.number}||'%'</if>
+				<if test="dbName == 'mssql'">'%'+#{project.reportData.number}+'%'</if>
+				<if test="dbName == 'mysql'">concat('%',#{project.reportData.number},'%')</if>
+			</if>
+			<if test="client != null and client.name != null and client.name != ''">
+				AND w.name LIKE
+				<if test="dbName == 'oracle'">'%'||#{client.name}||'%'</if>
+				<if test="dbName == 'mssql'">'%'+#{client.name}+'%'</if>
+				<if test="dbName == 'mysql'">concat('%',#{client.name},'%')</if>
+			</if>
+			<!--<if test="officeId != null and officeId != ''">
+				AND so.id  = #{officeId}
+			</if>-->
+			<if test="money != null and money != ''">
+				AND a.money = #{money}
+			</if>
+			<!--<if test="submitterId != null and submitterId != ''">
+				AND a.create_by = #{submitterId}
+			</if>-->
+			<if test="(submitterId != null and submitterId != '') or (submitterName != null and submitterName != '')">
+				AND (a.create_by = #{submitterId} or su.name like concat('%',#{submitterName},'%'))
+			</if>
+			<if test="receiptMoney != null and receiptMoney != ''">
+				AND a.receipt_money = #{receiptMoney}
+			</if>
+			<if test="invoiceType != null and invoiceType != ''">
+				AND a.invoice_type = #{invoiceType}
+			</if>
+			<if test="chargeType != null and chargeType != ''">
+				AND a.charge_type = #{chargeType}
+			</if>
+			<if test="content != null and content != ''">
+				AND a.content = #{content}
+			</if>
+			<if test="drawer != null and drawer.id != null and drawer.id != ''">
+				AND a.drawer_id = #{drawer.id}
+			</if>
+			<if test="companyId != null and companyId != ''">
+				AND a.company_id = #{companyId}
+			</if>
+			<!--<if test="office != null and office.id != null and office.id != ''">
+				AND a.office_id = #{office.id}
+			</if>-->
+			<if test="officeIdList!=null and officeIdList.size!=0">
+				and a.office_id in
+				<foreach collection="officeIdList" item="officeId" separator="," open="(" close=")">
+					#{officeId}
+				</foreach>
+			</if>
+			<if test="invoiceNumber != null and invoiceNumber != ''">
+				AND a.invoice_number LIKE
+				<if test="dbName == 'oracle'">'%'||#{invoiceNumber}||'%'</if>
+				<if test="dbName == 'mssql'">'%'+#{invoiceNumber}+'%'</if>
+				<if test="dbName == 'mysql'">concat('%',#{invoiceNumber},'%')</if>
+			</if>
+			<if test="invoiceDate != null and invoiceDate != ''">
+				AND a.invoice_date = #{invoiceDate}
+			</if>
+			<if test="isInvoice != null and isInvoice != ''">
+				AND a.is_invoice = #{isInvoice}
+			</if>
+			<if test="isCharge != null and isCharge != ''">
+				AND a.is_charge = #{isCharge}
+			</if>
+			<if test="isInvalid != null and isInvalid != ''">
+				AND a.is_invalid = #{isInvalid}
+			</if>
+			<if test="area != null and area.id != null and area.id != ''">
+				AND a.area_parent_id LIKE
+				<if test="dbName == 'oracle'">'%'||#{area.id}||'%'</if>
+				<if test="dbName == 'mssql'">'%'+#{area.id}+'%'</if>
+				<if test="dbName == 'mysql'">concat('%',#{area.id},'%')</if>
+			</if>
+			<if test="(accountCheckingUserId != null and accountCheckingUserId != '') or (accountCheckingUserName != null and accountCheckingUserName != '')">
+				AND (a.account_checking_user_id = #{accountCheckingUserId} or sua.name like concat('%',#{accountCheckingUserName},'%'))
+			</if>
+			<if test="widNumber != null and widNumber != ''">
+				AND wid.number LIKE
+				<if test="dbName == 'oracle'">'%'||#{widNumber}||'%'</if>
+				<if test="dbName == 'mssql'">'%'+#{widNumber}+'%'</if>
+				<if test="dbName == 'mysql'">concat('%',#{widNumber},'%')</if>
+			</if>
+			${sqlMap.dsf}
+		</where>
+		<choose>
+			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
+				ORDER BY ${page.orderBy}
+			</when>
+			<otherwise>
+				ORDER BY a.create_date DESC
+			</otherwise>
+		</choose>
+	</select>
+
 <select id="getSumMoney" resultType="java.lang.String" >
 	select format(sum(x.money),2) as sumMoney
 	FROM (