Merge remote-tracking branch 'origin/master'
| | |
| | | public Map<String, Object> pageInsUnPass(Page page, UnPassPageDto unPassPageDto) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("head", PrintChina.printChina(UnPassPageDto.class)); |
| | | Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId("pageInsUnPass"); |
| | | if (map1.get("look") == 1) unPassPageDto.setCreateUser(map1.get("userId")); |
| | | map.put("body", insUnPassMapper.pageInsUnPass(page, QueryWrappers.queryWrappers(unPassPageDto))); |
| | | return map; |
| | | } |
| | |
| | | <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> |
| | | </resultMap> |
| | | <select id="pageInsUnPass" resultType="com.yuanchu.mom.dto.UnPassPageDto"> |
| | | -- select * |
| | | -- from ( |
| | | -- select |
| | | -- iu.*,io.entrust_code,u.name write_user_name |
| | | -- from ins_un_pass iu |
| | | -- left join ins_order io on io.id = iu.ins_order_id |
| | | -- left join user u on u.id = iu.create_user |
| | | -- ) a |
| | | select * |
| | | from ins_un_pass iu |
| | | </select> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.controller; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.annotation.ValueClassify; |
| | | import com.yuanchu.mom.pojo.AuxiliaryWorkingHours; |
| | | import com.yuanchu.mom.service.AuxiliaryWorkingHoursService; |
| | | import com.yuanchu.mom.utils.JackSonUtil; |
| | | import com.yuanchu.mom.vo.Result; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.AllArgsConstructor; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | | * è¾
å©å·¥æ¶ å端æ§å¶å¨ |
| | | * </p> |
| | | * |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2024-05-09 06:58:31 |
| | | */ |
| | | @Api(tags = "绩æç®¡ç-è¾
å©å·¥æ¶è®¾ç½®") |
| | | @AllArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/auxiliaryWorkingHours") |
| | | public class AuxiliaryWorkingHoursController { |
| | | @Resource |
| | | private AuxiliaryWorkingHoursService auxiliaryWorkingHoursService; |
| | | |
| | | @ApiOperation(value="æ¥è¯¢è¾
å©å·¥æ¶") |
| | | @PostMapping("/selectAuxiliaryWorkingHours") |
| | | public Result selectAuxiliaryWorkingHours(@RequestBody Map<String, Object> data) throws Exception { |
| | | Page page = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("page")), Page.class); |
| | | AuxiliaryWorkingHours entity = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("entity")), AuxiliaryWorkingHours.class); |
| | | return Result.success(auxiliaryWorkingHoursService.selectAuxiliaryWorkingHours(page,entity)); |
| | | } |
| | | @ValueClassify("å·¥æ¶ç®¡ç") |
| | | @ApiOperation(value="å é¤è¾
å©å·¥æ¶") |
| | | @PostMapping("/deleteAuxiliaryWorkingHours") |
| | | public Result deleteAuxiliaryWorkingHours(Integer id){ |
| | | return Result.success(auxiliaryWorkingHoursService.deleteAuxiliaryWorkingHours(id)); |
| | | } |
| | | @ValueClassify("å·¥æ¶ç®¡ç") |
| | | @ApiOperation(value="ä¿®æ¹è¾
å©å·¥æ¶") |
| | | @PostMapping("/upAuxiliaryWorkingHours") |
| | | public Result upAuxiliaryWorkingHours(@RequestBody AuxiliaryWorkingHours auxiliaryWorkingHours){ |
| | | return Result.success(auxiliaryWorkingHoursService.upAuxiliaryWorkingHours(auxiliaryWorkingHours)); |
| | | } |
| | | @ValueClassify("å·¥æ¶ç®¡ç") |
| | | @ApiOperation(value="æ°å¢è¾
å©å·¥æ¶") |
| | | @PostMapping("/insertAuxiliaryWorkingHours") |
| | | public Result insertAuxiliaryWorkingHours(@RequestBody AuxiliaryWorkingHours auxiliaryWorkingHours){ |
| | | return Result.success(auxiliaryWorkingHoursService.insertAuxiliaryWorkingHours(auxiliaryWorkingHours)); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | package com.yuanchu.mom.controller; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.write.style.HorizontalCellStyleStrategy; |
| | | import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.dto.PerformanceShiftAddDto; |
| | | import com.yuanchu.mom.pojo.PerformanceShift; |
| | | import com.yuanchu.mom.service.PerformanceShiftService; |
| | | import com.yuanchu.mom.utils.StyleUtils; |
| | | import com.yuanchu.mom.vo.Result; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | |
| | | /** |
| | |
| | | return Result.success(); |
| | | } |
| | | |
| | | @ApiOperation(value = "绩æç®¡ç-çæ¬¡-å页æ¥è¯¢") |
| | | @ApiOperation(value = "绩æç®¡ç-çæ¬¡-æä»½å页æ¥è¯¢") |
| | | @PostMapping("page") |
| | | public Result<?> performanceShiftPage(Integer size, Integer current, String time, String userName, String laboratory) { |
| | | return Result.success(performanceShiftService.performanceShiftPage(new Page<>(current, size), time, userName, laboratory)); |
| | | } |
| | | |
| | | @ApiOperation(value = "绩æç®¡ç-çæ¬¡-年份å页æ¥è¯¢") |
| | | @PostMapping("pageYear") |
| | | public Result<?> performanceShiftPageYear(Integer size, Integer current, String time, String userName, String laboratory) { |
| | | return Result.success(performanceShiftService.performanceShiftPageYear(new Page<>(current, size), time, userName, laboratory)); |
| | | } |
| | | |
| | | @ApiOperation(value = "绩æç®¡ç-çæ¬¡-çæ¬¡ç¶æä¿®æ¹") |
| | |
| | | performanceShiftService.performanceShiftUpdate(performanceShift); |
| | | return Result.success(); |
| | | } |
| | | |
| | | @ApiOperation(value = "绩æç®¡ç-çæ¬¡-导åº") |
| | | @GetMapping("update") |
| | | public void exportToExcel(@NotNull(message = "æ¶é´ä¸è½ä¸ºç©ºï¼") String time, String userName, String laboratory, HttpServletResponse response) throws Exception { |
| | | Map<Object, Object> data = performanceShiftService.exportToExcel(time, userName, laboratory); |
| | | // 设置åå
æ ¼æ ·å¼ |
| | | HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(StyleUtils.getHeadStyle(), StyleUtils.getContentStyle()); |
| | | // ä¿åå°ç¬¬ä¸ä¸ªsheetä¸ |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
| | | response.setHeader("requestType","excel"); |
| | | response.setHeader("Access-Control-Expose-Headers", "requestType"); |
| | | EasyExcel.write(response.getOutputStream()) |
| | | .head((List<List<String>>) data.get("header")) |
| | | .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) // èªéåºå宽 |
| | | .registerWriteHandler(horizontalCellStyleStrategy) |
| | | .sheet("模æ¿") |
| | | .doWrite((Collection<?>) data.get("data")); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.pojo.AuxiliaryWorkingHours; |
| | | |
| | | /** |
| | | * <p> |
| | | * è¾
å©å·¥æ¶ Mapper æ¥å£ |
| | | * </p> |
| | | * |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2024-05-09 06:58:31 |
| | | */ |
| | | public interface AuxiliaryWorkingHoursMapper extends BaseMapper<AuxiliaryWorkingHours> { |
| | | IPage<AuxiliaryWorkingHours> selectAuxiliaryWorkingHours(Page page, QueryWrapper<AuxiliaryWorkingHours> ew); |
| | | } |
| | |
| | | List<Map<String, Object>> performanceShiftYearPage(@Param("time") String time, |
| | | @Param("userName") String userName, |
| | | @Param("laboratory") String laboratory); |
| | | |
| | | IPage<Map<String, Object>> performanceShiftYear(Page<Object> page, String time, String userName, String laboratory); |
| | | |
| | | List<Map<String, Object>> performanceShiftYearList(String time, String userName, String laboratory); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | |
| | | import com.yuanchu.mom.annotation.ValueTableShow; |
| | | import com.yuanchu.mom.common.OrderBy; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import jdk.nashorn.internal.ir.annotations.Ignore; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | | |
| | | /** |
| | | * <p> |
| | | * è¾
å©å·¥æ¶ |
| | | * </p> |
| | | * |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2024-05-09 06:58:31 |
| | | */ |
| | | @Getter |
| | | @Setter |
| | | @TableName("auxiliary_working_hours") |
| | | @ApiModel(value = "AuxiliaryWorkingHours对象", description = "è¾
å©å·¥æ¶") |
| | | public class AuxiliaryWorkingHours extends OrderBy implements Serializable { |
| | | @ApiModelProperty("主é®ID") |
| | | @TableId(type = IdType.AUTO) |
| | | private Integer id; |
| | | @ValueTableShow(2) |
| | | @ApiModelProperty("ç¼å·") |
| | | private String number; |
| | | @ValueTableShow(3) |
| | | @ApiModelProperty("è¾
å©é¡¹ç®åç§°") |
| | | private String auxiliaryProject; |
| | | @ValueTableShow(5) |
| | | @ApiModelProperty("æ ¸åå·¥æ¶") |
| | | private Float approvedWorkingHour; |
| | | @ValueTableShow(7) |
| | | @ApiModelProperty("夿³¨") |
| | | private String remarks; |
| | | |
| | | @ApiModelProperty("å建人id") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Integer createUser; |
| | | |
| | | @ApiModelProperty("ä¿®æ¹äººid") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Integer updateUser; |
| | | |
| | | @ApiModelProperty("å建æ¶é´") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private LocalDateTime createTime; |
| | | |
| | | @ApiModelProperty("ä¿®æ¹æ¶é´") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private LocalDateTime updateTime; |
| | | |
| | | @ValueTableShow(6) |
| | | @ApiModelProperty("é¨é¨") |
| | | private String department; |
| | | @ValueTableShow(3) |
| | | @ApiModelProperty("å®éªå®¤") |
| | | private String laboratory; |
| | | @ValueTableShow(4) |
| | | @ApiModelProperty("åä½") |
| | | private String unit; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.pojo.AuxiliaryWorkingHours; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | | * è¾
å©å·¥æ¶ æå¡ç±» |
| | | * </p> |
| | | * |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2024-05-09 06:58:31 |
| | | */ |
| | | public interface AuxiliaryWorkingHoursService extends IService<AuxiliaryWorkingHours> { |
| | | Map<String, Object> selectAuxiliaryWorkingHours(Page page, AuxiliaryWorkingHours auxiliaryWorkingHours); |
| | | int deleteAuxiliaryWorkingHours(Integer id); |
| | | int upAuxiliaryWorkingHours(AuxiliaryWorkingHours auxiliaryWorkingHours); |
| | | int insertAuxiliaryWorkingHours(AuxiliaryWorkingHours auxiliaryWorkingHours); |
| | | } |
| | |
| | | package com.yuanchu.mom.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.yuanchu.mom.dto.PerformanceShiftAddDto; |
| | |
| | | Map<String, Object> performanceShiftPage(Page<Object> page, String time, String userName, String laboratory); |
| | | |
| | | void performanceShiftUpdate(PerformanceShift performanceShift); |
| | | |
| | | IPage<Map<String, Object>> performanceShiftPageYear(Page<Object> page, String time, String userName, String laboratory); |
| | | |
| | | Map<Object, Object> exportToExcel(String time, String userName, String laboratory) throws Exception; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.common.PrintChina; |
| | | import com.yuanchu.mom.pojo.AuxiliaryWorkingHours; |
| | | import com.yuanchu.mom.mapper.AuxiliaryWorkingHoursMapper; |
| | | import com.yuanchu.mom.service.AuxiliaryWorkingHoursService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.yuanchu.mom.utils.QueryWrappers; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | | * è¾
å©å·¥æ¶ æå¡å®ç°ç±» |
| | | * </p> |
| | | * |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2024-05-09 06:58:31 |
| | | */ |
| | | @Service |
| | | public class AuxiliaryWorkingHoursServiceImpl extends ServiceImpl<AuxiliaryWorkingHoursMapper, AuxiliaryWorkingHours> implements AuxiliaryWorkingHoursService { |
| | | |
| | | @Resource |
| | | private AuxiliaryWorkingHoursMapper auxiliaryWorkingHoursMapper; |
| | | @Override |
| | | public Map<String, Object> selectAuxiliaryWorkingHours(Page page, AuxiliaryWorkingHours auxiliaryWorkingHours) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("head", PrintChina.printChina(AuxiliaryWorkingHours.class)); |
| | | map.put("body", auxiliaryWorkingHoursMapper.selectAuxiliaryWorkingHours(page, QueryWrappers.queryWrappers(auxiliaryWorkingHours))); |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public int deleteAuxiliaryWorkingHours(Integer id) { |
| | | return auxiliaryWorkingHoursMapper.deleteById(id); |
| | | } |
| | | |
| | | @Override |
| | | public int upAuxiliaryWorkingHours(AuxiliaryWorkingHours auxiliaryWorkingHours) { |
| | | return auxiliaryWorkingHoursMapper.updateById(auxiliaryWorkingHours); |
| | | } |
| | | |
| | | @Override |
| | | public int insertAuxiliaryWorkingHours(AuxiliaryWorkingHours auxiliaryWorkingHours) { |
| | | return auxiliaryWorkingHoursMapper.insert(auxiliaryWorkingHours); |
| | | } |
| | | } |
| | |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | import com.yuanchu.mom.pojo.PerformanceShift; |
| | | import com.yuanchu.mom.service.EnumService; |
| | | import com.yuanchu.mom.service.PerformanceShiftService; |
| | | import com.yuanchu.mom.utils.JackSonUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | .set(PerformanceShift::getShift, performanceShift.getShift())); |
| | | } |
| | | |
| | | // public static void main(String[] args) { |
| | | // String dateStr = "2023-09-15 12:30:45"; |
| | | // LocalDateTime localDateTime = convertToLocalDateTime(dateStr); |
| | | // System.out.println(localDateTime); |
| | | // } |
| | | // |
| | | // public static LocalDateTime convertToLocalDateTime(String dateStr) { |
| | | // DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | // return LocalDateTime.parse(dateStr, formatter); |
| | | // } |
| | | @Override |
| | | public IPage<Map<String, Object>> performanceShiftPageYear(Page<Object> page, String time, String userName, String laboratory) { |
| | | IPage<Map<String, Object>> mapYearIPage = baseMapper.performanceShiftYear(page, time, userName, laboratory); |
| | | List<Enums> shiftType = enumService.selectEnumByCategory("çæ¬¡ç±»å"); |
| | | mapYearIPage.setRecords(annualAttendanceProcessing(mapYearIPage.getRecords(), shiftType)); |
| | | return mapYearIPage; |
| | | } |
| | | |
| | | // å¹´å页ä¸å¯¼åºå
±åä½¿ç¨ |
| | | public List<Map<String, Object>> annualAttendanceProcessing(List<Map<String, Object>> mapYearList, List<Enums> shiftType){ |
| | | for (Map<String, Object> map : mapYearList) { |
| | | Map<String, Object> resultMap = new LinkedHashMap<>(); |
| | | Map<String, Object> hashMapYear = new LinkedHashMap<>(); |
| | | int totalYearAttendance = 0; |
| | | // ä¸å¹´12个æ |
| | | for (int i = 1; i < 13; i++) { |
| | | Map<String, Object> hashMapMonth = new LinkedHashMap<>(); |
| | | int totalMonthAttendance = 0; |
| | | for (Enums enums : shiftType) { |
| | | if (!hashMapYear.containsKey(enums.getLabel())) { |
| | | hashMapYear.put(enums.getLabel(), 0); |
| | | } |
| | | // æ |
| | | if (ObjectUtils.isNotEmpty(map.get("month_str")) && map.get("work_time").equals(i)) { |
| | | String charArray = map.get("month_str").toString(); |
| | | int count = countOccurrences(charArray, i + "ï¼" + enums.getValue()); |
| | | hashMapMonth.put(enums.getLabel(), count); |
| | | hashMapYear.put(enums.getLabel(), Integer.parseInt(hashMapYear.get(enums.getLabel()).toString()) + count ); |
| | | if (enums.getValue().equals("0") || enums.getValue().equals("1") || enums.getValue().equals("2")) { |
| | | totalMonthAttendance += count; |
| | | totalYearAttendance += count; |
| | | } |
| | | } |
| | | // ç©ºæ°æ® |
| | | else { |
| | | map.put("work_time", i); |
| | | hashMapMonth.put(enums.getLabel(), 0); |
| | | } |
| | | } |
| | | hashMapMonth.put("totalMonthAttendance", totalMonthAttendance); |
| | | hashMapYear.put("totalYearAttendance", totalYearAttendance); |
| | | resultMap.put(i + "", hashMapMonth); |
| | | } |
| | | map.remove("month_str"); |
| | | map.remove("year_str"); |
| | | map.put("year", hashMapYear); |
| | | map.put("month", resultMap); |
| | | } |
| | | return mapYearList; |
| | | } |
| | | |
| | | public static int countOccurrences(String str, String target) { |
| | | int count = 0; |
| | | int index = 0; |
| | | while ((index = str.indexOf(target, index))!= -1) { |
| | | count++; |
| | | index += target.length(); |
| | | } |
| | | return count; |
| | | } |
| | | |
| | | public List<List<Object>> dataRequiredForProcessingIntoExcel(List<Map<String, Object>> list, List<Enums> enums) throws Exception { |
| | | List<List<Object>> data = new ArrayList<>(); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | List<Object> excelRowList = new ArrayList<>(); |
| | | excelRowList.add(i + 1); |
| | | excelRowList.add(list.get(i).get("account")); |
| | | excelRowList.add(list.get(i).get("name")); |
| | | Map<String, Object> year = JackSonUtil.unmarshal(JackSonUtil.marshal(list.get(i).get("year")), Map.class); |
| | | excelRowList.add(year.get("totalYearAttendance")); |
| | | enums.forEach(j -> { |
| | | excelRowList.add(year.get(j.getLabel())); |
| | | }); |
| | | Map<String, Map<String, Object>> month = JackSonUtil.unmarshal(JackSonUtil.marshal(list.get(i).get("month")), Map.class); |
| | | for (int j = 1; j < 13; j++) { |
| | | Object totalMonthAttendance = month.get(j + "").get("totalMonthAttendance"); |
| | | excelRowList.add(totalMonthAttendance); |
| | | for (Enums anEnum : enums) { |
| | | excelRowList.add(month.get(j + "").get(anEnum.getLabel())); |
| | | } |
| | | } |
| | | data.add(excelRowList); |
| | | } |
| | | return data; |
| | | } |
| | | |
| | | @Override |
| | | public Map<Object, Object> exportToExcel(String time, String userName, String laboratory) throws Exception { |
| | | Map<Object, Object> map = new HashMap<>(); |
| | | List<Enums> shiftType = enumService.selectEnumByCategory("çæ¬¡ç±»å"); |
| | | DateTimeFormatter formatters = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | // å°å符串æ¶é´è½¬æ¢ä¸º LocalDateTime ç±»åæ¶é´ |
| | | LocalDateTime localDateTime = LocalDateTime.parse(time, formatters); |
| | | map.put("header", getHeader(localDateTime.getYear() + " å¹´", shiftType)); |
| | | List<Map<String, Object>> mapYearList = baseMapper.performanceShiftYearList(time, userName, laboratory); |
| | | annualAttendanceProcessing(mapYearList, shiftType); |
| | | List<List<Object>> lists = dataRequiredForProcessingIntoExcel(mapYearList, shiftType); |
| | | map.put("data", lists); |
| | | return map; |
| | | } |
| | | |
| | | // è·å两个localDateTimeçæ¯ä¸å¤© |
| | | public static List<LocalDateTime> getLocalDateTimesBetween(LocalDateTime start, LocalDateTime end) { |
| | |
| | | return "æªç¥"; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è¿å表头 |
| | | * |
| | | * å¤å±List代表è¡å
å± List代表å ç¸åçåæ°æ®ä¼è¢«ä¸»å¨åå¹¶ |
| | | * æé åå表头 |
| | | * @return List<List<String>> |
| | | */ |
| | | private static List<List<String>> getHeader(String month, List<Enums> enums){ |
| | | List<List<String>> line = new ArrayList<>(); |
| | | line.add(Arrays.asList("è夿±æ»", "åºå·", "åºå·")); |
| | | line.add(Arrays.asList("è夿±æ»", "å·¥å·", "å·¥å·")); |
| | | line.add(Arrays.asList("è夿±æ»", "å§å", "å§å")); |
| | | line.add(Arrays.asList("åºå¤è¯¦æ
", month, "åºå¤")); |
| | | // å¹´ header |
| | | for (Enums anEnum : enums) { |
| | | line.add(Arrays.asList("è夿±æ»", month, anEnum.getLabel())); |
| | | } |
| | | // æheader |
| | | for (int i = 1; i < 13; i++) { |
| | | line.add(Arrays.asList("åºå¤è¯¦æ
", i + " æ", "åºå¤")); |
| | | for (Enums anEnum : enums) { |
| | | line.add(Arrays.asList("åºå¤è¯¦æ
", i + " æ", anEnum.getLabel())); |
| | | } |
| | | } |
| | | return line; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.utils; |
| | | |
| | | import com.alibaba.excel.write.metadata.style.WriteCellStyle; |
| | | import com.alibaba.excel.write.metadata.style.WriteFont; |
| | | import org.apache.poi.ss.usermodel.*; |
| | | |
| | | public class StyleUtils { |
| | | /** |
| | | * æ 颿 ·å¼ |
| | | * @return |
| | | */ |
| | | public static WriteCellStyle getHeadStyle(){ |
| | | // 头ççç¥ |
| | | WriteCellStyle headWriteCellStyle = new WriteCellStyle(); |
| | | // èæ¯é¢è² |
| | | headWriteCellStyle.setFillForegroundColor(IndexedColors.LIME.getIndex()); |
| | | headWriteCellStyle.setFillPatternType(FillPatternType.SOLID_FOREGROUND); |
| | | |
| | | // åä½ |
| | | WriteFont headWriteFont = new WriteFont(); |
| | | headWriteFont.setFontName("仿å®");//设置åä½åå |
| | | headWriteFont.setFontHeightInPoints((short)9);//设置åä½å¤§å° |
| | | headWriteFont.setBold(true);//åä½å ç² |
| | | headWriteFont.setColor((short) 1); |
| | | headWriteCellStyle.setWriteFont(headWriteFont); //卿 ·å¼ç¨åºç¨è®¾ç½®çåä½; |
| | | |
| | | // æ ·å¼ |
| | | headWriteCellStyle.setBorderBottom(BorderStyle.THIN);//设置åºè¾¹æ¡; |
| | | headWriteCellStyle.setBottomBorderColor((short) 1);//设置åºè¾¹æ¡é¢è²; |
| | | headWriteCellStyle.setBorderLeft(BorderStyle.THIN); //设置左边æ¡; |
| | | headWriteCellStyle.setLeftBorderColor((short) 1);//设置左边æ¡é¢è²; |
| | | headWriteCellStyle.setBorderRight(BorderStyle.THIN);//设置å³è¾¹æ¡; |
| | | headWriteCellStyle.setRightBorderColor((short) 1);//设置å³è¾¹æ¡é¢è²; |
| | | headWriteCellStyle.setBorderTop(BorderStyle.THIN);//设置顶边æ¡; |
| | | headWriteCellStyle.setTopBorderColor((short) 1); //设置顶边æ¡é¢è²; |
| | | |
| | | headWriteCellStyle.setWrapped(false); //设置èªå¨æ¢è¡; |
| | | |
| | | headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);//设置水平对é½çæ ·å¼ä¸ºå±
ä¸å¯¹é½; |
| | | headWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER); //设置åç´å¯¹é½çæ ·å¼ä¸ºå±
ä¸å¯¹é½; |
| | | headWriteCellStyle.setShrinkToFit(true);//è®¾ç½®ææ¬æ¶ç¼©è³åé |
| | | |
| | | return headWriteCellStyle; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * å
å®¹æ ·å¼ |
| | | * @return |
| | | */ |
| | | public static WriteCellStyle getContentStyle(){ |
| | | // å
容ççç¥ |
| | | WriteCellStyle contentWriteCellStyle = new WriteCellStyle(); |
| | | |
| | | // è¿ééè¦æå® FillPatternType 为FillPatternType.SOLID_FOREGROUND ä¸ç¶æ æ³æ¾ç¤ºèæ¯é¢è².头é»è®¤äº FillPatternTypeæä»¥å¯ä»¥ä¸æå® |
| | | contentWriteCellStyle.setFillForegroundColor(IndexedColors.LIGHT_GREEN.getIndex()); |
| | | contentWriteCellStyle.setFillPatternType(FillPatternType.SOLID_FOREGROUND); |
| | | |
| | | // 设置åä½ |
| | | WriteFont contentWriteFont = new WriteFont(); |
| | | contentWriteFont.setFontHeightInPoints((short) 9);//设置åä½å¤§å° |
| | | contentWriteFont.setFontName("仿å®"); //设置åä½åå |
| | | contentWriteCellStyle.setWriteFont(contentWriteFont);//卿 ·å¼ç¨åºç¨è®¾ç½®çåä½; |
| | | |
| | | //è®¾ç½®æ ·å¼; |
| | | // contentWriteCellStyle.setBorderBottom(BorderStyle.THIN);//设置åºè¾¹æ¡; |
| | | // contentWriteCellStyle.setBottomBorderColor((short) 1);//设置åºè¾¹æ¡é¢è²; |
| | | contentWriteCellStyle.setBorderLeft(BorderStyle.THIN); //设置左边æ¡; |
| | | contentWriteCellStyle.setLeftBorderColor((short) 1);//设置左边æ¡é¢è²; |
| | | contentWriteCellStyle.setBorderRight(BorderStyle.THIN);//设置å³è¾¹æ¡; |
| | | contentWriteCellStyle.setRightBorderColor((short) 1);//设置å³è¾¹æ¡é¢è²; |
| | | contentWriteCellStyle.setBorderTop(BorderStyle.THIN);//设置顶边æ¡; |
| | | contentWriteCellStyle.setTopBorderColor((short) 1); ///设置顶边æ¡é¢è²; |
| | | |
| | | contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);// æ°´å¹³å±
ä¸ |
| | | contentWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);// åç´å±
ä¸ |
| | | contentWriteCellStyle.setWrapped(false); //设置èªå¨æ¢è¡; |
| | | |
| | | // contentWriteCellStyle.setShrinkToFit(true);//è®¾ç½®ææ¬æ¶ç¼©è³åé |
| | | |
| | | return contentWriteCellStyle; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.yuanchu.mom.mapper.AuxiliaryWorkingHoursMapper"> |
| | | |
| | | <!-- éç¨æ¥è¯¢æ å°ç»æ --> |
| | | <resultMap id="BaseResultMap" type="com.yuanchu.mom.pojo.AuxiliaryWorkingHours"> |
| | | <id column="id" property="id" /> |
| | | <result column="number" property="number"/> |
| | | <result column="AuxiliaryProject" property="auxiliaryProject" /> |
| | | <result column="approved_working_hour" property="approvedWorkingHour" /> |
| | | <result column="remarks" property="remarks" /> |
| | | <result column="create_user" property="createUser" /> |
| | | <result column="update_user" property="updateUser" /> |
| | | <result column="create_time" property="createTime" /> |
| | | <result column="update_time" property="updateTime" /> |
| | | <result column="department" property="department" /> |
| | | <result column="laboratory" property="laboratory" /> |
| | | <result column="unit" property="unit"/> |
| | | </resultMap> |
| | | <select id="selectAuxiliaryWorkingHours" resultType="com.yuanchu.mom.pojo.AuxiliaryWorkingHours"> |
| | | select data.* |
| | | from ( |
| | | select |
| | | awh.id, |
| | | awh.number, |
| | | awh.auxiliary_project, |
| | | awh.laboratory, |
| | | awh.unit, |
| | | awh.approved_working_hour, |
| | | awh.department, |
| | | awh.remarks |
| | | FROM auxiliary_working_hours awh |
| | | ) data |
| | | <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''"> |
| | | ${ew.customSqlSegment} |
| | | </if> |
| | | </select> |
| | | </mapper> |
| | |
| | | <if test="laboratory != null and laboratory != ''"> |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="performanceShiftYear" resultType="java.util.Map"> |
| | | SELECT if(u.department is not null and u.department != '', CONCAT(u.name, 'ï¼', u.department, 'ï¼'), u.name) name, |
| | | s.user_id, u.account, |
| | | DATE_FORMAT(s.work_time, '%c') work_time, |
| | | GROUP_CONCAT(DATE_FORMAT(s.work_time, '%c'), 'ï¼', s.shift order by s.work_time SEPARATOR ';') month_str |
| | | FROM performance_shift s |
| | | LEFT JOIN user u on u.id = s.user_id |
| | | where s.shift is not NULL |
| | | and s.shift != '' |
| | | <if test="time != null and time != ''"> |
| | | and DATE_FORMAT(s.work_time, '%Y') = DATE_FORMAT(#{time}, '%Y' ) |
| | | </if> |
| | | <if test="userName != null and userName != ''"> |
| | | and u.name like concat('%', #{userName}, '%') |
| | | </if> |
| | | <if test="laboratory != null and laboratory != ''"> |
| | | </if> |
| | | GROUP BY u.id |
| | | order by s.work_time |
| | | </select> |
| | | |
| | | <select id="performanceShiftYearList" resultType="map"> |
| | | SELECT if(u.department is not null and u.department != '', CONCAT(u.name, 'ï¼', u.department, 'ï¼'), u.name) name, |
| | | s.user_id, u.account, |
| | | DATE_FORMAT(s.work_time, '%c') work_time, |
| | | GROUP_CONCAT(DATE_FORMAT(s.work_time, '%c'), 'ï¼', s.shift order by s.work_time SEPARATOR ';') month_str |
| | | FROM performance_shift s |
| | | LEFT JOIN user u on u.id = s.user_id |
| | | where s.shift is not NULL |
| | | and s.shift != '' |
| | | <if test="time != null and time != ''"> |
| | | and DATE_FORMAT(s.work_time, '%Y') = DATE_FORMAT(#{time}, '%Y' ) |
| | | </if> |
| | | <if test="userName != null and userName != ''"> |
| | | and u.name like concat('%', #{userName}, '%') |
| | | </if> |
| | | <if test="laboratory != null and laboratory != ''"> |
| | | </if> |
| | | GROUP BY u.id |
| | | order by s.work_time |
| | | </select> |
| | | </mapper> |
| | |
| | | <feign-okhttp.version>11.0</feign-okhttp.version> |
| | | <shiro.version>1.5.3</shiro.version> |
| | | <freemwork.version>2.3.32</freemwork.version> |
| | | <easyexcel.version>3.3.2</easyexcel.version> |
| | | <!--æäº¤å--> |
| | | <!-- æå
å导åºçè·¯å¾ --> |
| | | <package.path>${project.build.directory}/BLOG</package.path> |
| | | </properties> |
| | | |
| | | <dependencies> |
| | | <!-- https://mvnrepository.com/artifact/com.alibaba/easyexcel --> |
| | | <dependency> |
| | | <groupId>com.alibaba</groupId> |
| | | <artifactId>easyexcel</artifactId> |
| | | <version>${easyexcel.version}</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-web</artifactId> |
| | |
| | | @SpringBootTest |
| | | class SystemRunApplicationTest { |
| | | |
| | | |
| | | @Test |
| | | void contextLoads() { |
| | | void contextLoads() throws Exception { |
| | | |
| | | } |
| | | |
| | | } |