¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.lihu.jh.framework.excel.core.convert; |
| | | |
| | | import com.alibaba.excel.converters.Converter; |
| | | import com.alibaba.excel.enums.CellDataTypeEnum; |
| | | import com.alibaba.excel.metadata.GlobalConfiguration; |
| | | import com.alibaba.excel.metadata.data.WriteCellData; |
| | | import com.alibaba.excel.metadata.property.ExcelContentProperty; |
| | | |
| | | import java.sql.Date; |
| | | import java.text.SimpleDateFormat; |
| | | |
| | | /** |
| | | * Excel Date 转æ¢å¨ |
| | | * <p> |
| | | * æ¯æ java.sql.Date ç±»åçè½¬æ¢ |
| | | */ |
| | | public class DateConvert implements Converter<Date> { |
| | | |
| | | @Override |
| | | public Class<?> supportJavaTypeKey() { |
| | | return Date.class; |
| | | } |
| | | |
| | | @Override |
| | | public CellDataTypeEnum supportExcelTypeKey() { |
| | | return CellDataTypeEnum.STRING; |
| | | } |
| | | |
| | | @Override |
| | | public WriteCellData<String> convertToExcelData(Date value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) { |
| | | if (value == null) { |
| | | return new WriteCellData<>(""); |
| | | } |
| | | |
| | | // 使ç¨é»è®¤æ ¼å¼ yyyy-MM-dd HH:mm:ss |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | return new WriteCellData<>(format.format(value)); |
| | | } |
| | | } |
| | |
| | | package cn.lihu.jh.framework.excel.core.util; |
| | | |
| | | import cn.lihu.jh.framework.excel.core.convert.DateConvert; |
| | | import cn.lihu.jh.framework.excel.core.handler.SelectSheetWriteHandler; |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.converters.longconverter.LongStringConverter; |
| | |
| | | .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) // åºäº column é¿åº¦ï¼èªå¨éé
ãæå¤§ 255 宽度 |
| | | .registerWriteHandler(new SelectSheetWriteHandler(head)) // åºäºåºå® sheet å®ç°ä¸ææ¡ |
| | | .registerConverter(new LongStringConverter()) // é¿å
Long ç±»å丢失精度 |
| | | .registerConverter(new DateConvert()) // æ¯æ java.sql.Date ç±»åè½¬æ¢ |
| | | .sheet(sheetName).doWrite(data); |
| | | // 设置 header å contentTypeãå卿åçåå æ¯ï¼é¿å
æ¥éæ¶ï¼ååº contentType å·²ç»è¢«ä¿®æ¹äº |
| | | response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, StandardCharsets.UTF_8.name())); |
| | |
| | | /** |
| | | * å¼åæ¶é´ |
| | | */ |
| | | @ExcelProperty("å¼åæ¶é´") |
| | | private Date doctorTime; |
| | | |
| | | } |
| | |
| | | Map<String, Object> processStep = (Map<String, Object>) component1.get("processStep"); |
| | | Map<String, Object> codeMap = (Map<String, Object>) processStep.get("code"); |
| | | String status = String.valueOf(codeMap.get("code")); |
| | | |
| | | Date date = null; |
| | | if (status.equals("3")) { |
| | | //è®°å½ç»è®°æ¶é´ |
| | | date = new Date(); |
| | | } |
| | | //ç¶ææ´æ° |
| | | Integer i = appointmentMapper.updateStatusByApplyNo(applyNo, status, null); |
| | | Integer i = appointmentMapper.updateStatusByApplyNo(applyNo, status, date); |
| | | log.info("ç³è¯·åç»è®°applyNo:{},ç¶æstatus:{},æ´æ°ç»æï¼{}", applyNo, status, i); |
| | | |
| | | } |
| | |
| | | |
| | | <update id="updateStatusByApplyNo"> |
| | | update lihu.appointment |
| | | set status = #{status} |
| | | set status = #{status},update_time=sysdate() |
| | | <if test="registerDate != null"> |
| | | , register_date = #{registerDate} |
| | | </if> |