14 changed files with 247 additions and 125 deletions
@ -1,69 +0,0 @@ |
|||||||
package com.biutag.lan.controller.system; |
|
||||||
|
|
||||||
import com.biutag.lan.aop.Log; |
|
||||||
import com.biutag.lan.service.ICrontabService; |
|
||||||
import com.biutag.lan.validate.commons.IdValidate; |
|
||||||
import com.biutag.lan.validate.commons.PageValidate; |
|
||||||
import com.biutag.lan.validate.crontab.CrontabCreateValidate; |
|
||||||
import com.biutag.lan.validate.crontab.CrontabUpdateValidate; |
|
||||||
import com.biutag.lan.vo.system.CrontabDetailVo; |
|
||||||
import com.biutag.lan.vo.system.CrontabListedVo; |
|
||||||
import com.biutag.core.AjaxResult; |
|
||||||
import com.biutag.core.PageResult; |
|
||||||
import com.biutag.validator.annotation.IDMust; |
|
||||||
import io.swagger.annotations.Api; |
|
||||||
import io.swagger.annotations.ApiOperation; |
|
||||||
import jakarta.annotation.Resource; |
|
||||||
import org.quartz.SchedulerException; |
|
||||||
import org.springframework.validation.annotation.Validated; |
|
||||||
import org.springframework.web.bind.annotation.*; |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@RestController |
|
||||||
@RequestMapping("api/crontab") |
|
||||||
@Api(tags = "计划任务管理") |
|
||||||
public class CrontabController { |
|
||||||
|
|
||||||
@Resource |
|
||||||
ICrontabService iCrontabService; |
|
||||||
|
|
||||||
@GetMapping("/list") |
|
||||||
@ApiOperation(value="计划任务列表") |
|
||||||
public AjaxResult< PageResult<CrontabListedVo>> list(@Validated PageValidate pageValidate) { |
|
||||||
PageResult<CrontabListedVo> list = iCrontabService.list(pageValidate); |
|
||||||
return AjaxResult.success(list); |
|
||||||
} |
|
||||||
|
|
||||||
@GetMapping("/detail") |
|
||||||
@ApiOperation(value="计划任务详情") |
|
||||||
public AjaxResult<Object> detail(@Validated @IDMust() @RequestParam("id") Integer id) { |
|
||||||
CrontabDetailVo vo = iCrontabService.detail(id); |
|
||||||
return AjaxResult.success(vo); |
|
||||||
} |
|
||||||
|
|
||||||
@Log(title = "计划任务新增") |
|
||||||
@PostMapping("/add") |
|
||||||
@ApiOperation(value="计划任务新增") |
|
||||||
public AjaxResult<Void> add(@Validated @RequestBody CrontabCreateValidate createValidate) throws SchedulerException { |
|
||||||
iCrontabService.add(createValidate); |
|
||||||
return AjaxResult.success(); |
|
||||||
} |
|
||||||
|
|
||||||
@Log(title = "计划任务编辑") |
|
||||||
@PostMapping("/edit") |
|
||||||
@ApiOperation(value="计划任务编辑") |
|
||||||
public AjaxResult<Void> edit(@Validated @RequestBody CrontabUpdateValidate updateValidate) throws SchedulerException { |
|
||||||
iCrontabService.edit(updateValidate); |
|
||||||
return AjaxResult.success(); |
|
||||||
} |
|
||||||
|
|
||||||
@Log(title = "计划任务删除") |
|
||||||
@PostMapping("/del") |
|
||||||
@ApiOperation(value="计划任务删除") |
|
||||||
public AjaxResult<Void> del(@Validated @RequestBody IdValidate idValidate) throws SchedulerException { |
|
||||||
iCrontabService.del(idValidate.getId()); |
|
||||||
return AjaxResult.success(); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -0,0 +1,162 @@ |
|||||||
|
package com.biutag.lan; |
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil; |
||||||
|
import com.alibaba.excel.EasyExcel; |
||||||
|
import com.alibaba.excel.annotation.ExcelProperty; |
||||||
|
import com.alibaba.excel.context.AnalysisContext; |
||||||
|
import com.alibaba.excel.event.AnalysisEventListener; |
||||||
|
import com.alibaba.excel.read.listener.ReadListener; |
||||||
|
import com.alibaba.excel.util.ListUtils; |
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||||
|
import com.biutag.constants.AppConstants; |
||||||
|
import com.biutag.entity.setting.DictData; |
||||||
|
import com.biutag.entity.system.Dept; |
||||||
|
import com.biutag.lan.domain.Mail; |
||||||
|
import com.biutag.lan.domain.MailMark; |
||||||
|
import com.biutag.lan.domain.MailSource; |
||||||
|
import com.biutag.lan.mapper.MailMapper; |
||||||
|
import com.biutag.lan.mapper.MailMarkMapper; |
||||||
|
import com.biutag.lan.mapper.MailSourceMapper; |
||||||
|
import com.biutag.lan.service.IDictDataService; |
||||||
|
import com.biutag.lan.service.MailService; |
||||||
|
import com.biutag.mapper.setting.DictDataMapper; |
||||||
|
import com.biutag.mapper.system.DeptMapper; |
||||||
|
import jakarta.annotation.Resource; |
||||||
|
import lombok.Getter; |
||||||
|
import lombok.RequiredArgsConstructor; |
||||||
|
import lombok.Setter; |
||||||
|
import org.junit.jupiter.api.Test; |
||||||
|
import org.springframework.boot.test.context.SpringBootTest; |
||||||
|
|
||||||
|
import java.time.LocalDate; |
||||||
|
import java.time.LocalDateTime; |
||||||
|
import java.time.format.DateTimeFormatter; |
||||||
|
import java.util.*; |
||||||
|
|
||||||
|
@SpringBootTest |
||||||
|
public class SpringBootMailImportTest { |
||||||
|
|
||||||
|
@Resource |
||||||
|
private MailService mailService; |
||||||
|
|
||||||
|
@Resource |
||||||
|
private MailMapper mailMapper; |
||||||
|
|
||||||
|
@Resource |
||||||
|
private MailSourceMapper mailSourceMapper; |
||||||
|
|
||||||
|
@Resource |
||||||
|
private MailMarkMapper mailMarkMapper; |
||||||
|
@Resource |
||||||
|
private DictDataMapper dictDataMapper; |
||||||
|
|
||||||
|
@Resource |
||||||
|
private DeptMapper deptMapper; |
||||||
|
@Test |
||||||
|
public void test() { |
||||||
|
ExcelListener excelListener = new ExcelListener(); |
||||||
|
EasyExcel.read("D:\\deploy\\线下台账(0116).xlsx", excelListener).sheet().doRead(); |
||||||
|
List<LinkedHashMap<Integer, String>> dataList = excelListener.getDataList(); |
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); |
||||||
|
System.out.println(dataList); |
||||||
|
LocalDateTime now = LocalDateTime.now(); |
||||||
|
// mail mail_souce mail_mark
|
||||||
|
for (int i = 1; i < 2; i++) { |
||||||
|
LinkedHashMap<Integer, String> map = dataList.get(i); |
||||||
|
MailSource mailSource = new MailSource(); |
||||||
|
DictData dictData = dictDataMapper.selectOne(new LambdaQueryWrapper<DictData>().eq(DictData::getName, map.get(1)).eq(DictData::getTypeId, 7)); |
||||||
|
System.out.println(dictData.getValue()); |
||||||
|
Integer seqVal = mailMapper.getMailIdSeqVal(); |
||||||
|
int length = 6 - seqVal.toString().length(); |
||||||
|
StringBuilder zeroString = new StringBuilder(); |
||||||
|
for (int j = 0; j < length; j++) { |
||||||
|
zeroString.append('0'); |
||||||
|
} |
||||||
|
String id = map.get(2) + "0000" + dictData.getRemark() + zeroString + seqVal; |
||||||
|
LocalDateTime mailTime = LocalDate.parse(map.get(2), formatter).atStartOfDay(); |
||||||
|
mailSource.setId(id).setContactName(map.get(3)).setContactPhone(map.get(4)).setContent(map.get(7)) |
||||||
|
.setMailTime(mailTime).setCreateTime(now).setSignFlag(true).setAttachments("[]"); |
||||||
|
|
||||||
|
Dept dept = deptMapper.selectOne(new QueryWrapper<Dept>().eq("name", map.get(6))); |
||||||
|
Dept pDept = deptMapper.selectById(dept.getPid()); |
||||||
|
Mail mail = mailSource.toMail() |
||||||
|
.setMailLevel("一般信件") |
||||||
|
.setMailCategory(map.get(11)) |
||||||
|
.setMailFirstCategory(map.get(9)) |
||||||
|
.setMailSecondCategory(map.get(10)) |
||||||
|
.setMailThreeCategory(map.get(11)) |
||||||
|
.setSecondDeptId(dept.getPid()) |
||||||
|
.setSecondDeptName(pDept.getName()) |
||||||
|
.setThreeDeptId(dept.getId()) |
||||||
|
.setThreeDeptName(dept.getName()) |
||||||
|
.setCreateTime(now) |
||||||
|
.setUpdateTime(now) |
||||||
|
.setFlowKey("completion") |
||||||
|
.setFlowName("已办结") |
||||||
|
.setMailState("completion") |
||||||
|
.setSimpleFlowFlag(false) |
||||||
|
.setExtensionFlag(false) |
||||||
|
.setSource(dictData.getValue()) |
||||||
|
.setQualifiedProcessingStatus("合格") |
||||||
|
.setProblemSolvingStatus(true) |
||||||
|
.setSatisfactionStatus(map.get(12).equals("满意") || "申诉通过".equals(map.get(13)) ? "非常满意" : "不满意"); |
||||||
|
|
||||||
|
MailMark mailMark = new MailMark(); |
||||||
|
|
||||||
|
mailMark.setMailId(id).setCompleted(AppConstants.TRUE) |
||||||
|
.setResolved(AppConstants.TRUE) |
||||||
|
.setSatisfied(map.get(12).equals("满意") || "申诉通过".equals(map.get(13)) ?AppConstants.TRUE : AppConstants.FALSE) |
||||||
|
.setThreeDeptName(dept.getName()) |
||||||
|
.setThreeDeptId(dept.getId()) |
||||||
|
.setSecondDeptId(dept.getPid()) |
||||||
|
.setSecondDeptName(pDept.getName()) |
||||||
|
.setCompletionTime(mailTime.plusDays(4)) |
||||||
|
.setSignTimeout(false) |
||||||
|
.setContactWriterTimeout(false) |
||||||
|
.setProcessTimeout(false); |
||||||
|
mailSourceMapper.insert(mailSource); |
||||||
|
mailService.save(mail); |
||||||
|
mailMarkMapper.insert(mailMark); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Setter |
||||||
|
@Getter |
||||||
|
public static class DemoData { |
||||||
|
|
||||||
|
@ExcelProperty(index= 0) |
||||||
|
private String orderNo; |
||||||
|
|
||||||
|
@ExcelProperty(index= 1) |
||||||
|
private String source; |
||||||
|
|
||||||
|
@ExcelProperty(index= 2) |
||||||
|
private String date; |
||||||
|
|
||||||
|
@ExcelProperty(index= 3) |
||||||
|
private String contactName; |
||||||
|
|
||||||
|
@ExcelProperty(index= 4) |
||||||
|
private String contactPhone; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
static class ExcelListener extends AnalysisEventListener<LinkedHashMap<Integer, String>> { |
||||||
|
|
||||||
|
@Getter |
||||||
|
private List<LinkedHashMap<Integer, String>> dataList = new ArrayList<>(); |
||||||
|
|
||||||
|
@Override |
||||||
|
public void invoke(LinkedHashMap<Integer, String> data, AnalysisContext context) { |
||||||
|
dataList.add(data); // 将每行数据存入列表
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void doAfterAllAnalysed(AnalysisContext context) { |
||||||
|
System.out.println("All data has been read."); |
||||||
|
// 在此处可以对 dataList 中的数据进行处理
|
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1 @@ |
|||||||
|
uc3Y29XJfVtZtZTbmFMmz2zpO8d1f7nByTGClY3b2pmFtRfbzpMZT2f7Omz1GCm8dT2VuxpYfaWc2VDE2Q9OKbGMTYW5zljZ0eXZV9XRyBlPsCmaWFWF0NyZkYXZV9TIwRlPtMDMjQjAKItMkX2ZW5GU9RhdyNCMjAS0y0wNUV1MApm9k9Qc0X0dWNWU95hbuZ1VG9gpUdlYWZXV19W9uJza1bWX05j03JlcuRQLjA19DpUVfQ0UFVlQ99VTpbmCmJD0KRpcfSGVFdHdhFyZfSWcmVlRXQ9CheFX01W1i9Od9LTZXIEhTEKVyb2X1B3RfR1YtZTTmF25n1Ub0cFSHRnZlNlcUSFcgpmVyNfVvblc2lW1i9Od9NiZXIlRX4wCkaXX0V249RpbiZWRW1kVXQKTFUlX1Z05fNJTDRUTElT1T5DR0ZFRVJlhPhWZHK0ZFJjRK1jSscXdkdlhCFCb6c1bzJDJwVUUnKzRjF3FYVBdTWUVEF0QyMySyVHMnNXdkM4S1USOVIk9Rtuesb0dzlEZyFReYODc1Z09JViRJcEWXF2ZUh4TqZXN1p0tMdHViWGaTB1Z14vN3TkWm9Uk0VHdORVcgpkVSdfVPTlU0lUNF9MSFPXTkNmNlR5ZFbUQjditkoyNrVGbHUlh0V0TNckb2dExJs0UYT2ckt2p1piTrTzT2M3NQB3SZd0bzFnB5tweFNmdlF3VvV6VkaWM1VHpwY3NxaHVG8mRJgzW3Y3c2Umx5c2UFNUYnlCtt9DWoaGdEFXJq1Eawa3bUJ3JTNFKSTXcjhk5FQ5CWRVV19U9OJTSJQ0X0x0U9VOQ3clbGJWQxFDRLZVNXBkRkRtSnTmRmVGph9pbrU0dUEDl05oNybFY3h0ZFJqKXMDU1ZDR6UxSMS0aVlDJjNaZ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