Quellcode durchsuchen

feat: 企业当日结算数据发送邮件通知2

lixuesong vor 1 Jahr
Ursprung
Commit
3acfc5efa9

+ 9 - 6
hnqz-upms/hnqz-upms-api/src/main/java/com/qunzhixinxi/hnqz/admin/api/feign/RemoteScorePackageService.java

@@ -6,9 +6,12 @@ import com.qunzhixinxi.hnqz.common.core.constant.ServiceNameConstants;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestHeader;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 积分包feign服务
@@ -22,18 +25,18 @@ public interface RemoteScorePackageService {
 	/**
 	 * 结算包结算导出-内部
 	 *
-	 * @param deptId 企业id
+	 * @param params 参数
 	 * @return excel模型
 	 */
-	@GetMapping("/settle/exportPackageSettleForInner/{deptId}")
-	List<WmScorePackageSettleExcelModel> exportPackageSettle(@PathVariable("deptId") Integer deptId, @RequestHeader(SecurityConstants.FROM) String from);
+	@PostMapping("/settle/exportPackageSettleForInner")
+	List<WmScorePackageSettleExcelModel> exportPackageSettle(@RequestBody Map<String, Object> params, @RequestHeader(SecurityConstants.FROM) String from);
 
 	/**
 	 * MAH结算包结算导出-内部
 	 *
-	 * @param deptId 企业id
+	 * @param params 参数
 	 * @return excel模型
 	 */
-	@GetMapping("/settle/exportPackageSettleByMAHForInner/{deptId}")
-	List<WmScorePackageSettleExcelModel> exportPackageSettleByMAH(@PathVariable("deptId") Integer deptId, @RequestHeader(SecurityConstants.FROM) String from);
+	@PostMapping("/settle/exportPackageSettleByMAHForInner")
+	List<WmScorePackageSettleExcelModel> exportPackageSettleByMAH(@RequestBody Map<String, Object> params, @RequestHeader(SecurityConstants.FROM) String from);
 }

+ 7 - 12
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/controller/WmPayOffController.java

@@ -438,7 +438,7 @@ public class WmPayOffController {
 	 */
 	@ResponseExcel(name = "exportPackageSettle", sheet = "积分包结算数据")
 	@SysLog("积分包结算导出")
-	@GetMapping("/exportPackageSettleByMAH")
+	@PostMapping("/exportPackageSettleByMAH")
 	public List<WmScorePackageSettleExcelModel> exportPackageSettleByMAH(WmScorePackageSettleInput input) {
 
 		input.setMahSettleDeptId(SecurityUtils.getUser().getDeptId());
@@ -449,31 +449,26 @@ public class WmPayOffController {
 	/**
 	 * 结算包结算导出-内部
 	 *
-	 * @param deptId 企业id
+	 * @param input 参数
 	 * @return excel模型
 	 */
 	@Inner
 	@SysLog("积分包结算导出-内部")
-	@GetMapping("/exportPackageSettleForInner/{deptId}")
-	public List<WmScorePackageSettleExcelModel> exportPackageSettle(@PathVariable("deptId") Integer deptId) {
-		WmScorePackageSettleInput input = new WmScorePackageSettleInput();
-		input.setSendPackageDeptId(String.valueOf(deptId));
+	@PostMapping("/exportPackageSettleForInner")
+	public List<WmScorePackageSettleExcelModel> exportPackageSettleForInner(@RequestBody WmScorePackageSettleInput input) {
 
-		// TODO 添加查询条件 查指定日期
 		return wmPayOffService.exportPackageSettle(input);
 	}
 
 	/**
 	 * MAH结算包结算导出-内部
 	 *
-	 * @param deptId 企业id
+	 * @param input 参数
 	 * @return excel模型
 	 */
 	@SysLog("积分包结算导出")
-	@GetMapping("/exportPackageSettleByMAHForInner/{deptId}")
-	public List<WmScorePackageSettleExcelModel> exportPackageSettleByMAH(@PathVariable("deptId") Integer deptId) {
-		WmScorePackageSettleInput input = new WmScorePackageSettleInput();
-		input.setMahSettleDeptId(deptId);
+	@GetMapping("/exportPackageSettleByMAHForInner")
+	public List<WmScorePackageSettleExcelModel> exportPackageSettleByMAHForInner(@RequestBody WmScorePackageSettleInput input) {
 
 		return wmPayOffService.exportPackageSettleByMAH(input);
 	}

+ 5 - 0
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/entity/input/WmScorePackageSettleInput.java

@@ -124,4 +124,9 @@ public class WmScorePackageSettleInput implements Serializable {
 	 */
 	private UpmsState.SettleFinancialReviewStatus reviewStatus;
 
+	/**
+	 * 结算回调时间
+	 */
+	private LocalDateTime[] notifyTime;
+
 }

+ 14 - 2
hnqz-upms/hnqz-upms-biz/src/main/resources/mapper/WmScorePackageMapper.xml

@@ -1589,8 +1589,11 @@
 			p.package_type2,
 			p.sub_type,
 			p.sub_location AS subject_location
-		FROM wm_score_package p,
-		sys_dept d
+		FROM wm_score_package p
+		left join sys_dept d on p.send_package_dept_id = d.dept_id
+		<if test="query.notifyTime != null and query.notifyTime.length == 2">
+			left join wm_score_package_settle_note sn on p.id = sn.package_id
+		</if>
 		WHERE
 		p.send_package_dept_id = d.dept_id
 		<if test="query.sendPackageDeptId != null and query.sendPackageDeptId != ''">
@@ -1620,6 +1623,9 @@
 		<if test="query.settlementDate != null and query.settlementDate.length == 2">
 			AND p.settlement_date between #{query.settlementDate[0]} and #{query.settlementDate[1]}
 		</if>
+		<if test="query.notifyTime != null and query.notifyTime.length == 2">
+			AND sn.notify_time between #{query.notifyTime[0]} and #{query.notifyTime[1]}
+		</if>
 		ORDER BY
 		p.create_time DESC
 	</select>
@@ -1647,6 +1653,9 @@
 		FROM wm_score_package p left join sys_dept d on p.send_package_dept_id = d.dept_id
 		left join wm_score_package_status ps on p.id = ps.package_id
 		left join sys_user su on ps.user_id = su.user_id
+		<if test="query.notifyTime != null and query.notifyTime.length == 2">
+			left join wm_score_package_settle_note sn on p.id = sn.package_id
+		</if>
 		<where>
 			<if test="query.sendPackageDeptId != null and query.sendPackageDeptId != ''">
 				AND p.send_package_dept_id= #{query.sendPackageDeptId}
@@ -1681,6 +1690,9 @@
 			<if test="query.settlementDate != null and query.settlementDate.length == 2">
 				AND p.settlement_date between #{query.settlementDate[0]} and #{query.settlementDate[1]}
 			</if>
+			<if test="query.notifyTime != null and query.notifyTime.length == 2">
+				AND sn.notify_time between #{query.notifyTime[0]} and #{query.notifyTime[1]}
+			</if>
 		</where>
 		ORDER BY
 		p.create_time DESC

+ 19 - 10
hnqz-visual/hnqz-daemon-quartz/src/main/java/com/qunzhixinxi/hnqz/daemon/quartz/task/SpringBeanTaskDemo.java

@@ -63,6 +63,7 @@ import java.time.format.DateTimeFormatter;
 import java.time.temporal.TemporalAdjusters;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
@@ -475,24 +476,26 @@ public class SpringBeanTaskDemo {
 		}
 
 		// 当前指定的日期
-		String currentDayStr = null;
-
+		LocalDate currentDay = null;
 		LambdaQueryWrapper<SysDept> queryWrapper = Wrappers.lambdaQuery();
 		if (CollUtil.isNotEmpty(params)) {
 			// 指定的日期
-			currentDayStr = params.get(0);
+			currentDay = LocalDate.parse(params.get(0), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
 			// 指定的企业id
 			List<String> deptIds = StrUtil.split(params.get(1), ";");
 			queryWrapper.in(SysDept::getDeptId, deptIds);
 		} else {
 			// 默认取定期任务执行时的前一天日期
-			LocalDateTime currentDay = LocalDateTime.now().minusDays(1L);
-			currentDayStr = DateTimeFormatter.ofPattern("yyyy-MM-dd").format(currentDay);
+			currentDay = LocalDate.now().minusDays(1L);
 		}
+
+		LocalDateTime startOfDay = currentDay.atStartOfDay();
+		LocalDateTime endOfDay = startOfDay.plusDays(1L);
+
 		// 获取所有企业的信息
 		List<SysDept> depts = sysDeptMapper.selectList(queryWrapper);
 
-		String finalCurrentDayStr = currentDayStr;
+		LocalDate finalCurrentDay = currentDay;
 		depts.forEach(dept -> {
 			try {
 
@@ -503,11 +506,14 @@ public class SpringBeanTaskDemo {
 				helper.setFrom("yaoyi_report@yaoyi.net");
 				helper.setTo(dept.getEmails());
 
-				String title = "本企业结算成功数据(" + finalCurrentDayStr + ")";
+				String title = "本企业结算成功数据(" + DateTimeFormatter.ofPattern("yyyy-MM-dd").format(finalCurrentDay) + ")";
 				helper.setSubject(title);
 
 				// 获取指定企业当日结算的数据
-				List<WmScorePackageSettleExcelModel> excelModels = remoteScorePackageService.exportPackageSettle(dept.getDeptId(), SecurityConstants.FROM_IN);
+				Map<String, Object> reqParams = new HashMap<>();
+				reqParams.put("sendPackageDeptId", dept.getDeptId());
+				reqParams.put("notifyTime", new LocalDateTime[]{startOfDay, endOfDay});
+				List<WmScorePackageSettleExcelModel> excelModels = remoteScorePackageService.exportPackageSettle(reqParams, SecurityConstants.FROM_IN);
 				ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
 				EasyExcelFactory.write(byteArrayOutputStream, WmScorePackageSettleExcelModel.class)
 						.registerConverter(new LocalDateTimeConverter())
@@ -526,11 +532,14 @@ public class SpringBeanTaskDemo {
 				helper2.setFrom("yaoyi_report@yaoyi.net");
 				helper2.setTo(dept.getEmails());
 
-				String title2 = "MAH企业结算成功数据(" + finalCurrentDayStr + ")";
+				String title2 = "MAH企业结算成功数据(" + DateTimeFormatter.ofPattern("yyyy-MM-dd").format(finalCurrentDay) + ")";
 				helper2.setSubject(title2);
 
 				// 获取指定企业当日结算的数据
-				List<WmScorePackageSettleExcelModel> excelModels2 = remoteScorePackageService.exportPackageSettleByMAH(dept.getDeptId(), SecurityConstants.FROM_IN);
+				Map<String, Object> reqParams2 = new HashMap<>();
+				reqParams2.put("mahSettleDeptId", dept.getDeptId());
+				reqParams2.put("notifyTime", new LocalDateTime[]{startOfDay, endOfDay});
+				List<WmScorePackageSettleExcelModel> excelModels2 = remoteScorePackageService.exportPackageSettleByMAH(reqParams2, SecurityConstants.FROM_IN);
 				ByteArrayOutputStream byteArrayOutputStream2 = new ByteArrayOutputStream();
 				EasyExcelFactory.write(byteArrayOutputStream2, WmScorePackageSettleExcelModel.class)
 						.registerConverter(new LocalDateTimeConverter())

+ 11 - 2
hnqz-visual/hnqz-daemon-quartz/src/test/java/RemoteScorePackageServiceTest.java

@@ -17,7 +17,11 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.nio.file.Files;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @author lixuesong
@@ -30,9 +34,14 @@ public class RemoteScorePackageServiceTest {
 	@Autowired
 	private RemoteScorePackageService remoteScorePackageService;
 
-	@Test
+//	@Test
 	public void exportPackageSettleTest() {
-		List<WmScorePackageSettleExcelModel> excelModels = remoteScorePackageService.exportPackageSettle(1611890565, SecurityConstants.FROM_IN);
+		Map<String, Object> reqParams = new HashMap<>();
+		reqParams.put("sendPackageDeptId", 1611890565);
+		LocalDateTime startOfDay = LocalDate.now().minusDays(100L).atStartOfDay();
+		LocalDateTime endOfDay = startOfDay.plusDays(100L);
+		reqParams.put("notifyTime", new LocalDateTime[]{startOfDay, endOfDay});
+		List<WmScorePackageSettleExcelModel> excelModels = remoteScorePackageService.exportPackageSettle(reqParams, SecurityConstants.FROM_IN);
 		ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
 		EasyExcelFactory.write(byteArrayOutputStream, WmScorePackageSettleExcelModel.class)
 				.registerConverter(new LocalDateTimeConverter())