| | |
| | | <artifactId>hutool-all</artifactId> |
| | | <version>5.8.12</version> |
| | | </dependency> |
| | | <!--底下四个都是poi依赖--> |
| | | <dependency> |
| | | <groupId>org.apache.poi</groupId> |
| | | <artifactId>poi</artifactId> |
| | | <version>4.1.2</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.apache.poi</groupId> |
| | | <artifactId>poi-ooxml</artifactId> |
| | | <version>4.1.2</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.apache.poi</groupId> |
| | | <artifactId>poi-ooxml-schemas</artifactId> |
| | | <version>4.1.2</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.apache.poi</groupId> |
| | | <artifactId>poi-scratchpad</artifactId> |
| | | <version>4.1.2</version> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | |
| | |
| | | import com.yuanchu.limslaboratory.pojo.CnasAnnualPlan; |
| | | import com.yuanchu.limslaboratory.pojo.vo.CnasAnnualPlanVo; |
| | | import com.yuanchu.limslaboratory.service.CnasAnnualPlanService; |
| | | import com.yuanchu.limslaboratory.utils.JackSonUtil; |
| | | import com.yuanchu.limslaboratory.utils.RedisUtil; |
| | | import com.yuanchu.limslaboratory.vo.Result; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "page", value = "初始页", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "pageSize", value = "每一页数量", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "beginTime", value = "检验开始时间", dataTypeClass = Date.class), |
| | | @ApiImplicitParam(name = "endTime", value = "检验结束时间", dataTypeClass = Date.class), |
| | | @ApiImplicitParam(name = "planTime", value = "检验开始时间", dataTypeClass = Date.class), |
| | | }) |
| | | @GetMapping("/selectAllList") |
| | | public Result selectAllList(Integer page, Integer pageSize, @DateTimeFormat(pattern = "yyyy-MM-dd") Date beginTime, @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime) { |
| | | IPage<CnasAnnualPlanVo> reportPage = cnasAnnualPlanService.selectAllList(new Page(page, pageSize), beginTime, endTime); |
| | | public Result selectAllList(Integer page, Integer pageSize, @DateTimeFormat(pattern = "yyyy-MM") Date planTime) { |
| | | IPage<CnasAnnualPlanVo> reportPage = cnasAnnualPlanService.selectAllList(new Page(page, pageSize), planTime); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("total", reportPage.getTotal()); |
| | | map.put("row", reportPage.getRecords()); |
| | |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "CnasAnnualPlan", value = "审查对象", dataTypeClass = Integer.class, required = true) |
| | | }) |
| | | public Result addCnasAnnualPlan(@RequestBody CnasAnnualPlan cnasAnnualPlan) { |
| | | public Result addCnasAnnualPlan(@RequestHeader("X-Token") String token, @RequestBody CnasAnnualPlan cnasAnnualPlan) throws Exception { |
| | | Object object = RedisUtil.get(token); |
| | | Map<String, Object> unmarshal = JackSonUtil.unmarshal(JackSonUtil.marshal(object), Map.class); |
| | | String name = (String) unmarshal.get("name"); |
| | | cnasAnnualPlan.setKeyboarder(name); |
| | | //todo:获取name有问题 |
| | | cnasAnnualPlanService.save(cnasAnnualPlan); |
| | | return Result.success(); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "上传附件") |
| | | @PostMapping("/addAccessory") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "auditTime", value = "审核日期", dataTypeClass = Date.class, required = true), |
| | | @ApiImplicitParam(name = "file", value = "附件文件", dataTypeClass = MultipartFile.class, required = true) |
| | | }) |
| | | public Result addAccessory(@RequestHeader("X-Token") String token, Date auditTime, MultipartFile file) throws Exception { |
| | | //解析当前登录用户 |
| | | Object object = RedisUtil.get(token); |
| | | Map<String, Object> unmarshal = JackSonUtil.unmarshal(JackSonUtil.marshal(object), Map.class); |
| | | String name = (String) unmarshal.get("name"); |
| | | cnasAnnualPlanService.addAccessory(name, auditTime, file); |
| | | return Result.success(); |
| | | } |
| | | |
| | | @ApiOperation(value = "删除年度计划") |
| | | @GetMapping("/deleteCnasAnnualPlan") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "planId", value = "审核日期", dataTypeClass = Integer.class, required = true) |
| | | }) |
| | | public Result deleteCnasAnnualPlan(Integer planId) { |
| | | Integer isDeleteSuccess = cnasAnnualPlanService.deleteCnasAnnualPlan(planId); |
| | | if (isDeleteSuccess == 1){ |
| | | return Result.success("删除成功"); |
| | | } else { |
| | | return Result.fail("删除失败"); |
| | | } |
| | | } |
| | | } |
| | |
| | | * 查询审核计划 |
| | | * @return |
| | | */ |
| | | IPage<CnasAnnualPlanVo> selectAllList(Page<Object> objectPage, Date beginTime, Date endTime); |
| | | IPage<CnasAnnualPlanVo> selectAllList(Page<Object> objectPage, Integer year, Integer month); |
| | | } |
| | |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.Getter; |
| | |
| | | */ |
| | | @Data |
| | | @TableName("cnas_annual_plan") |
| | | @ApiModel(value="CnasAnnualPlan对象", description="") |
| | | public class CnasAnnualPlan implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | |
| | | |
| | | @ApiModelProperty(value = "不合格项目数") |
| | | private Integer count; |
| | | |
| | | @ApiModelProperty(value = "审核状态,0:即将开始,1:完成,2:逾期") |
| | | private Integer auditState; |
| | | |
| | | @TableLogic(value = "1", delval = "0") |
| | | @ApiModelProperty(value = "逻辑删除 正常>=1,删除<=0", hidden = true) |
| | |
| | | |
| | | @ApiModelProperty(value = "月份") |
| | | private Integer month; |
| | | |
| | | @ApiModelProperty(value = "审核状态,0:即将开始,1:完成,2:逾期") |
| | | private Integer auditState; |
| | | } |
| | |
| | | import com.yuanchu.limslaboratory.pojo.CnasAnnualPlan; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.yuanchu.limslaboratory.pojo.vo.CnasAnnualPlanVo; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.Date; |
| | | |
| | |
| | | * 查询审核计划 |
| | | * @return |
| | | */ |
| | | IPage<CnasAnnualPlanVo> selectAllList(Page<Object> objectPage, Date beginTime, Date endTime); |
| | | IPage<CnasAnnualPlanVo> selectAllList(Page<Object> objectPage, Date planTime); |
| | | |
| | | /** |
| | | * 上传附件 |
| | | */ |
| | | void addAccessory(String name, Date auditTime, MultipartFile file); |
| | | |
| | | /** |
| | | * 删除年度计划 |
| | | * @return |
| | | */ |
| | | Integer deleteCnasAnnualPlan(Integer planId); |
| | | } |
| | |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | import com.yuanchu.limslaboratory.service.CnasAnnualPlanService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | |
| | | |
| | | /** |
| | | * 查询审核计划 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | | public IPage<CnasAnnualPlanVo> selectAllList(Page<Object> objectPage, Date beginTime, Date endTime) { |
| | | IPage<CnasAnnualPlanVo> page = cnasAnnualPlanMapper.selectAllList(objectPage, beginTime, endTime); |
| | | public IPage<CnasAnnualPlanVo> selectAllList(Page<Object> objectPage, Date planTime) { |
| | | //判断是否有日期 |
| | | Integer yearTime = null; |
| | | Integer monthTime = null; |
| | | if (planTime != null) { |
| | | yearTime = DateUtil.year(planTime); |
| | | monthTime = DateUtil.month(planTime) + 2; |
| | | } |
| | | IPage<CnasAnnualPlanVo> page = cnasAnnualPlanMapper.selectAllList(objectPage, yearTime, monthTime); |
| | | page.getRecords().forEach(cnasAnnualPlanVo -> { |
| | | //获取计划时间 |
| | | Date time = cnasAnnualPlanVo.getPlanTime(); |
| | | //添加年 |
| | | //添加年月 |
| | | cnasAnnualPlanVo.setYear(DateUtil.year(time)); |
| | | //添加月 |
| | | cnasAnnualPlanVo.setMonth(DateUtil.month(time) + 1); |
| | | //判断审核状态 |
| | | //获取当前时间 |
| | | Date nowDate = new Date(); |
| | | //获取当前的年月 |
| | | int year = DateUtil.year(nowDate); |
| | | int month = DateUtil.month(nowDate) + 1; |
| | | if (cnasAnnualPlanVo.getAuditTime() == null && month > cnasAnnualPlanVo.getMonth() || year > cnasAnnualPlanVo.getYear()) { |
| | | cnasAnnualPlanVo.setAuditState(2); |
| | | } else if (cnasAnnualPlanVo.getAuditTime() != null) { |
| | | cnasAnnualPlanVo.setAuditState(1); |
| | | } else { |
| | | cnasAnnualPlanVo.setAuditState(0); |
| | | } |
| | | }); |
| | | return page; |
| | | } |
| | | |
| | | /** |
| | | * 上传附件 |
| | | */ |
| | | @Override |
| | | public void addAccessory(String name, Date auditTime, MultipartFile file) { |
| | | //todo: 上传附件未完成 |
| | | } |
| | | |
| | | /** |
| | | * 删除年度计划 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Integer deleteCnasAnnualPlan(Integer planId) { |
| | | LambdaUpdateWrapper<CnasAnnualPlan> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | updateWrapper.eq(CnasAnnualPlan::getId, planId); |
| | | updateWrapper.set(CnasAnnualPlan::getState, 0); |
| | | return cnasAnnualPlanMapper.update(new CnasAnnualPlan(), updateWrapper); |
| | | } |
| | | } |
| | |
| | | <!--查询审核计划--> |
| | | <select id="selectAllList" resultType="com.yuanchu.limslaboratory.pojo.vo.CnasAnnualPlanVo"> |
| | | select id, |
| | | audit_type, |
| | | department, |
| | | audit_purpose, |
| | | audit_leader, |
| | | audit_emp, |
| | | audit_pursuant, |
| | | audit_scope, |
| | | write_user, |
| | | keyboarder, |
| | | plan_time, |
| | | count, |
| | | audit_state, |
| | | state, |
| | | audit_time, |
| | | create_time, |
| | | update_time |
| | | audit_type, |
| | | department, |
| | | audit_purpose, |
| | | audit_leader, |
| | | audit_emp, |
| | | audit_pursuant, |
| | | audit_scope, |
| | | write_user, |
| | | keyboarder, |
| | | plan_time, |
| | | count, |
| | | state, |
| | | audit_time, |
| | | update_time |
| | | from cnas_annual_plan |
| | | where state = 1 |
| | | <if test="beginTime != null and endTime != null"> |
| | | and plan_time between #{beginTime} and #{endTime} |
| | | </if> |
| | | <if test="year != null and month != null"> |
| | | and year(plan_time) = #{year} |
| | | and month(plan_time) = #{month} |
| | | </if> |
| | | order by id desc |
| | | </select> |
| | | </mapper> |
| | |
| | | # redis数据库索引(默认为0),我们使用索引为3的数据库,避免和其他数据库冲突 |
| | | database: 0 |
| | | # redis服务器地址(默认为localhost) |
| | | host: localhost |
| | | host: 192.168.110.209 |
| | | # redis端口(默认为6379) |
| | | port: 6379 |
| | | # redis访问密码(默认为空) |
| | |
| | | package com.yuanchu.limslaboratory; |
| | | |
| | | import com.yuanchu.limslaboratory.pojo.vo.PlanVo; |
| | | import com.yuanchu.limslaboratory.service.PlanService; |
| | | import com.yuanchu.limslaboratory.service.UserService; |
| | | import org.apache.poi.hwpf.HWPFDocument; |
| | | import org.apache.poi.hwpf.extractor.WordExtractor; |
| | | import org.apache.poi.xwpf.extractor.XWPFWordExtractor; |
| | | import org.apache.poi.xwpf.usermodel.XWPFDocument; |
| | | import org.apache.poi.xwpf.usermodel.XWPFParagraph; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.FileInputStream; |
| | | import java.io.FileNotFoundException; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @SpringBootTest |
| | | class SysApplicationTests { |
| | |
| | | @Resource |
| | | private PlanService planService; |
| | | |
| | | @Resource |
| | | private UserService userService; |
| | | |
| | | @Test |
| | | void contextLoads() { |
| | | String newString = String.format("%06d", 77); |
| | | System.out.println("newString === " + newString); |
| | | |
| | | } |
| | | |
| | | @Test |
| | | void TT() { |
| | | List<PlanVo> planVos = planService.selectAllPlan(null, null, null, null); |
| | | planVos.forEach(System.out::println); |
| | | Map<String, Object> userInfo = userService.getUserInfo("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50IjoiYzhiMWFhYWNlYzM2NmMyNGU1ZDE4YzdlZWE5ZTU1MWIiLCJleHAiOjE2OTE3Mzk4MjV9.IZyU5jhTzpxedmmL25dhpkzQS7hth7gt-bzCx9fZyOk"); |
| | | System.out.println(userInfo.get("name")); |
| | | } |
| | | |
| | | @Test |
| | | void uploading() { |
| | | // 替换为doc或docx文件的路径 |
| | | String filePath = "D:\\20892\\desktop\\QR-14-01-02+++内部审核年度计划.doc"; |
| | | String info = ""; |
| | | try { |
| | | FileInputStream fis = new FileInputStream(filePath); |
| | | if (filePath.endsWith(".doc")) { |
| | | // 读取doc文件 |
| | | HWPFDocument doc = new HWPFDocument(fis); |
| | | WordExtractor docExtractor = new WordExtractor(doc); |
| | | String text = docExtractor.getText(); |
| | | System.out.println("doc:"); |
| | | info = text.trim(); |
| | | docExtractor.close(); |
| | | } else if (filePath.endsWith(".docx")) { |
| | | // 读取docx文件 |
| | | XWPFDocument docx = new XWPFDocument(fis); |
| | | XWPFWordExtractor docxExtractor = new XWPFWordExtractor(docx); |
| | | String text = docxExtractor.getText(); |
| | | System.out.println("docx:"); |
| | | info = text.trim(); |
| | | docxExtractor.close(); |
| | | } else { |
| | | System.out.println("不是word文件"); |
| | | } |
| | | fis.close(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | List<String> infoList = new ArrayList<String>(); |
| | | String[] split = info.split("\n"); |
| | | for (int i = 0; i < split.length; i++) { |
| | | System.out.println("======>" + split[i]); |
| | | if (i > 2) { |
| | | infoList.add(split[i]); |
| | | } |
| | | } |
| | | Map<String, String> result = new HashMap<>(); |
| | | //客户单位/项目名称 |
| | | String[] proAndUnit = infoList.get(0).split("\t"); |
| | | for (int i = 0; i < proAndUnit.length; i++) { |
| | | if (i == 1) { |
| | | result.put("unitName", proAndUnit[i]); |
| | | } |
| | | if (i == 3) { |
| | | result.put("projectName", proAndUnit[i]); |
| | | } |
| | | } |
| | | //填表人姓名/职位/联系电话/邮编 |
| | | String npty = infoList.get(1); |
| | | String nameAndDate = npty.split("form")[1].split("职位")[0]; |
| | | //姓名/日期 |
| | | result.put("nameAndDate", nameAndDate.trim()); |
| | | //职位 |
| | | String post = npty.split("Posts")[1].split("联系电话")[0]; |
| | | result.put("post", post.trim()); |
| | | //联系电话 |
| | | String phone = npty.split("number")[1].split("邮编")[0]; |
| | | result.put("telephone", phone); |
| | | //邮编 |
| | | String email = npty.split("邮编")[1].split("\t")[1]; |
| | | result.put("email", email); |
| | | //服务态度 |
| | | String replace = infoList.get(2).replace(" ", "").replace("\t", ""); |
| | | System.out.println(replace); |
| | | String[] split1 = replace.split("☑"); |
| | | for (int i = 0; i < split1.length; i++) { |
| | | System.out.println(split1[i]); |
| | | } |
| | | result.forEach((k, v) -> { |
| | | System.out.println("k======>" + k); |
| | | System.out.println("v======>" + v); |
| | | }); |
| | | } |
| | | |
| | | @Test |
| | | void upload() throws Exception { |
| | | String filePath = "D:\\20892\\desktop\\QR-14-01-02+++内部审核年度计划.doc"; |
| | | |
| | | String info = ""; |
| | | |
| | | FileInputStream fis = new FileInputStream(filePath); |
| | | if (filePath.endsWith(".doc")) { |
| | | // 读取doc文件 |
| | | HWPFDocument doc = new HWPFDocument(fis); |
| | | WordExtractor docExtractor = new WordExtractor(doc); |
| | | String text = docExtractor.getText(); |
| | | System.out.println("doc:"); |
| | | info = text.trim(); |
| | | docExtractor.close(); |
| | | } else if (filePath.endsWith(".docx")) { |
| | | // 读取docx文件 |
| | | XWPFDocument docx = new XWPFDocument(fis); |
| | | XWPFWordExtractor docxExtractor = new XWPFWordExtractor(docx); |
| | | String text = docxExtractor.getText(); |
| | | System.out.println("docx:"); |
| | | info = text.trim(); |
| | | docxExtractor.close(); |
| | | } else { |
| | | System.out.println("不是word文件"); |
| | | } |
| | | // System.out.println(info); |
| | | List<String> infoList = new ArrayList<>(); |
| | | String[] split = info.split("\n"); |
| | | for (int i = 0; i < split.length; i++) { |
| | | System.out.println("======>" + split[i]); |
| | | if (i > 2) { |
| | | infoList.add(split[i]); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |