| | |
| | | package com.ycl.platform.service.impl; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.write.merge.LoopMergeStrategy; |
| | | import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ycl.handler.CommentWriteHandler; |
| | | import com.ycl.handler.CustomSheetWriteHandler; |
| | | import com.ycl.platform.domain.entity.CalculateRule; |
| | | import com.ycl.platform.domain.entity.TContract; |
| | | import com.ycl.platform.mapper.TContractMapper; |
| | | import com.ycl.platform.service.ITContractService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.net.URLEncoder; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 【请填写功能名称】Service业务层处理 |
| | | * |
| | | * |
| | | * @author ruoyi |
| | | * @date 2024-03-12 |
| | | */ |
| | | @Service |
| | | public class TContractServiceImpl extends ServiceImpl<TContractMapper, TContract> implements ITContractService |
| | | { |
| | | @Autowired |
| | | private TContractMapper tContractMapper; |
| | | |
| | | /** |
| | | * 查询【请填写功能名称】 |
| | | * |
| | | * @param id 【请填写功能名称】主键 |
| | | * @return 【请填写功能名称】 |
| | | */ |
| | | public class TContractServiceImpl extends ServiceImpl<TContractMapper, TContract> implements ITContractService { |
| | | @Override |
| | | public TContract selectTContractById(Long id) |
| | | { |
| | | return tContractMapper.selectTContractById(id); |
| | | public void importTemplate(HttpServletResponse response) { |
| | | try { |
| | | List<CalculateRule> list = getExcelData(); |
| | | ArrayList<String> arrayList = new ArrayList<>(); |
| | | arrayList.add("扣指定分数"); |
| | | arrayList.add("分数乘以数量"); |
| | | arrayList.add("除以数量后乘以分数"); |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | String fileName = URLEncoder.encode("导入合同模板", StandardCharsets.UTF_8).replace("\\+", "%20"); |
| | | response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx"); |
| | | // 第一列、第二列上下合并3行 |
| | | LoopMergeStrategy loopMergeStrategy1 = new LoopMergeStrategy(3, 0); |
| | | LoopMergeStrategy loopMergeStrategy2 = new LoopMergeStrategy(3, 1); |
| | | EasyExcel.write(response.getOutputStream(), CalculateRule.class) |
| | | .registerWriteHandler(loopMergeStrategy1) |
| | | .registerWriteHandler(loopMergeStrategy2) |
| | | // 自适应列宽 |
| | | .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) |
| | | // 下拉框 |
| | | .registerWriteHandler(new CustomSheetWriteHandler(arrayList)) |
| | | // 标注 |
| | | .registerWriteHandler(new CommentWriteHandler()) |
| | | .sheet("合同导入模板").doWrite(list); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询【请填写功能名称】列表 |
| | | * |
| | | * @param tContract 【请填写功能名称】 |
| | | * @return 【请填写功能名称】 |
| | | */ |
| | | @Override |
| | | public List<TContract> selectTContractList(TContract tContract) |
| | | { |
| | | return tContractMapper.selectTContractList(tContract); |
| | | } |
| | | |
| | | /** |
| | | * 新增【请填写功能名称】 |
| | | * |
| | | * @param tContract 【请填写功能名称】 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int insertTContract(TContract tContract) |
| | | { |
| | | return tContractMapper.insertTContract(tContract); |
| | | } |
| | | |
| | | /** |
| | | * 修改【请填写功能名称】 |
| | | * |
| | | * @param tContract 【请填写功能名称】 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int updateTContract(TContract tContract) |
| | | { |
| | | return tContractMapper.updateTContract(tContract); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除【请填写功能名称】 |
| | | * |
| | | * @param ids 需要删除的【请填写功能名称】主键 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteTContractByIds(Long[] ids) |
| | | { |
| | | return tContractMapper.deleteTContractByIds(ids); |
| | | } |
| | | |
| | | /** |
| | | * 删除【请填写功能名称】信息 |
| | | * |
| | | * @param id 【请填写功能名称】主键 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteTContractById(Long id) |
| | | { |
| | | return tContractMapper.deleteTContractById(id); |
| | | private List<CalculateRule> getExcelData() { |
| | | ArrayList<CalculateRule> list = new ArrayList<>(); |
| | | CalculateRule calculateRule1 = new CalculateRule(); |
| | | calculateRule1.setId(1L); |
| | | calculateRule1.setRuleName("视频平均在线率"); |
| | | calculateRule1.setRuleDesc("(1)视频在线率=视频在线数量÷前端服务配置数(应扣除不可抗力或与中标人服务无关造成的掉线除外。)"); |
| | | calculateRule1.setRuleCondition("≥98%"); |
| | | calculateRule1.setDeductCategory("扣指定分数"); |
| | | calculateRule1.setCalcFraction(0.00); |
| | | list.add(calculateRule1); |
| | | CalculateRule calculateRule2 = new CalculateRule(); |
| | | calculateRule2.setRuleDesc("(2)视频平均在线率:当月每日视频在线率的平均值。"); |
| | | calculateRule2.setRuleCondition("95%≤视频平均在线率<98%"); |
| | | calculateRule2.setDeductCategory("扣指定分数"); |
| | | calculateRule2.setCalcFraction(5.00); |
| | | list.add(calculateRule2); |
| | | CalculateRule calculateRule3 = new CalculateRule(); |
| | | calculateRule3.setRuleDesc("(3)视频在线率保留整数并且向下取整。"); |
| | | calculateRule3.setRuleCondition("90%≤视频平均在线率<95%"); |
| | | calculateRule3.setDeductCategory("扣指定分数"); |
| | | calculateRule3.setCalcFraction(10.00); |
| | | list.add(calculateRule3); |
| | | CalculateRule calculateRule4 = new CalculateRule(); |
| | | calculateRule4.setId(2L); |
| | | calculateRule4.setRuleName("前端感知源治理工作"); |
| | | calculateRule4.setRuleDesc("时钟同步(超过±3秒为不合格)"); |
| | | calculateRule4.setRuleCondition("视频监控摄像机时钟不同步,24小时内未修复的"); |
| | | calculateRule4.setDeductCategory("分数乘以数量"); |
| | | calculateRule4.setCalcFraction(0.1); |
| | | list.add(calculateRule4); |
| | | CalculateRule calculateRule7 = new CalculateRule(); |
| | | calculateRule7.setRuleName("…………"); |
| | | calculateRule7.setRuleDesc("…………"); |
| | | calculateRule7.setRuleCondition("…………"); |
| | | list.add(calculateRule7); |
| | | CalculateRule calculateRule6 = new CalculateRule(); |
| | | calculateRule6.setRuleName("…………"); |
| | | calculateRule6.setRuleDesc("…………"); |
| | | calculateRule6.setRuleCondition("…………"); |
| | | list.add(calculateRule6); |
| | | CalculateRule calculateRule5 = new CalculateRule(); |
| | | calculateRule5.setId(3L); |
| | | calculateRule5.setRuleName("后台系统的保障"); |
| | | calculateRule5.setRuleDesc("在个别设备故障但不影响该功能模块整体应用情况下,须在72小时以内排除故障。"); |
| | | calculateRule5.setRuleCondition("单次故障时长若超出144小时以后,每超出12小时(不足12小时按12小时计)"); |
| | | calculateRule5.setDeductCategory("除以数量后乘以分数"); |
| | | calculateRule5.setCalcFraction(2.00); |
| | | calculateRule5.setCalcUnit(12); |
| | | list.add(calculateRule5); |
| | | return list; |
| | | } |
| | | } |