Merge branch 'master' of http://118.89.139.230:10101/r/powerIntelligenceSystem
| | |
| | | <artifactId>poi-ooxml</artifactId> |
| | | <version>3.10.1</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>cn.afterturn</groupId> |
| | | <artifactId>easypoi-spring-boot-starter</artifactId> |
| | | <version>4.1.2</version> |
| | | <exclusions> |
| | | <exclusion> |
| | | <groupId>com.google.guava</groupId> |
| | | <artifactId>guava</artifactId> |
| | | </exclusion> |
| | | <exclusion> |
| | | <groupId>org.apache.poi</groupId> |
| | | <artifactId>poi-ooxml-schemas</artifactId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | |
| | | <!--<dependency> |
| | | <groupId>org.springframework.plugin</groupId> |
| | |
| | | return service.add(spare,file); |
| | | } |
| | | |
| | | @PostMapping("addByExcel") |
| | | @ApiOperation("excel导入") |
| | | public Response addByExcel(@RequestParam MultipartFile file) throws IOException { |
| | | return service.addByExcel(file); |
| | | } |
| | | |
| | | |
| | | @PostMapping("update") |
| | | @ApiOperation("修改") |
| | | public Response update(@RequestBody DeviceSpare spare) { |
| | |
| | | package com.whyc.controller; |
| | | |
| | | import com.whyc.dto.Real.ExportTinfDataDto; |
| | | import com.whyc.dto.Statistic.MonStic; |
| | | import com.whyc.service.ExportService; |
| | | import io.swagger.annotations.Api; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.text.ParseException; |
| | | |
| | | @RestController |
| | |
| | | public void exportBattTinfStatistic(HttpServletRequest req, HttpServletResponse resp ,@RequestBody MonStic stic) throws ParseException { |
| | | service.exportBattTinfStatistic(req,resp,stic); |
| | | } |
| | | |
| | | @PostMapping("exportTinfDataByTestRecordCount") |
| | | @ApiOperation(value = "历史测试数据导出") |
| | | public void exportTinfDataByTestRecordCount(HttpServletRequest req, HttpServletResponse resp ,@RequestBody ExportTinfDataDto dto) throws ParseException, IOException { |
| | | service.exportTinfDataByTestRecordCount(req,resp,dto); |
| | | } |
| | | } |
| | |
| | | import com.whyc.service.WorkflowLinkService; |
| | | import com.whyc.service.WorkflowMainService; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.CommonUtil; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | @GetMapping("ownStatistics") |
| | | @ApiOperation(value = "本人的单据统计",notes = "status含义:1-审批中,2-审批完成且通过,3-审批完成且驳回") |
| | | public Response<Map<Integer,Integer>> getOwnStatistics(int type){ |
| | | int userId = ActionUtil.getUser().getId().intValue(); |
| | | int userId = CommonUtil.getUser().getId().intValue(); |
| | | return service.getOwnStatistics(userId,type); |
| | | } |
| | | |
| | |
| | | @GetMapping("ownListPage") |
| | | @ApiOperation(value = "本人的单据列表分页",notes = "status传参:0:全部,1-审批中,2-审批完成且通过,3-审批完成且驳回") |
| | | public Response<PageInfo<WorkflowMain>> ownListPage(int type,int status,int pageNum,int pageSize){ |
| | | int userId = ActionUtil.getUser().getId().intValue(); |
| | | int userId = CommonUtil.getUser().getId().intValue(); |
| | | return service.ownListPage(userId,type,status,pageNum,pageSize); |
| | | } |
| | | |
| | |
| | | @GetMapping("receivedStatistics") |
| | | @ApiOperation(value = "接收到的单据统计",notes = "status含义:1-待接单,6-待审核,58-已审核") |
| | | public Response<Map<Integer,Integer>> getReceivedStatistics(int type){ |
| | | User user = ActionUtil.getUser(); |
| | | User user = CommonUtil.getUser(); |
| | | return service.getReceivedStatistics(type,user); |
| | | } |
| | | |
| | |
| | | @GetMapping("receivedListPage") |
| | | @ApiOperation(value = "接收到的单据列表分页", notes = "status传参:0-全部,1-待接单,6-待审核,5|8-已审核(通过|驳回)") |
| | | public Response<PageInfo<WorkflowMain>> getReceivedListPage(int type, int status, int pageNum, int pageSize) { |
| | | User user = ActionUtil.getUser(); |
| | | User user = CommonUtil.getUser(); |
| | | return service.getReceivedListPage(type, status, user, pageNum, pageSize); |
| | | } |
| | | |
New file |
| | |
| | | package com.whyc.dto.Real; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class ExportTinfDataDto { |
| | | private Integer battgroupId; |
| | | private Integer testRecordCount; |
| | | private String picGroupVol; |
| | | private String picBattVol; |
| | | private String picGroupCurr; |
| | | } |
| | |
| | | |
| | | import com.whyc.pojo.web_site.DeviceSpare; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface DeviceSpareMapper extends CustomMapper<DeviceSpare>{ |
| | | |
| | | void outBound(List<DeviceSpare> spareList); |
| | | |
| | | } |
| | |
| | | private Integer paramType; |
| | | |
| | | @ApiModelProperty(value = "标准参数对应数据名称") |
| | | private Integer paramName; |
| | | private String paramName; |
| | | |
| | | @ApiModelProperty(value = "基准值") |
| | | private Float basisVal; |
| | |
| | | wrapper.last(" limit 1"); |
| | | return mapper.selectOne(wrapper); |
| | | } |
| | | //历史测试数据导出 |
| | | public BatttestdataInf exportTinfDataByTestRecordCount(Integer battgroupId, Integer testRecordCount) { |
| | | QueryWrapper wrapper =new QueryWrapper(); |
| | | wrapper.eq("battgroup_id",battgroupId); |
| | | wrapper.eq("test_record_count",testRecordCount); |
| | | wrapper.last(" limit 1"); |
| | | return mapper.selectOne(wrapper); |
| | | } |
| | | } |
| | |
| | | import com.whyc.util.CommonUtil; |
| | | import com.whyc.util.ThreadLocalUtil; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.apache.poi.ss.usermodel.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | return new Response<List<DeviceSpare>>().set(1,deviceSpares); |
| | | } |
| | | |
| | | public void add(List<DeviceSpare> spareList) { |
| | | public void addBatch(List<DeviceSpare> spareList) { |
| | | mapper.insertBatchSomeColumn(spareList); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | public void outBound(List<DeviceSpare> spareList) { |
| | | mapper.outBound(spareList); |
| | | } |
| | | |
| | | public Response addByExcel(MultipartFile file) throws IOException { |
| | | //将文件流转化为workbook |
| | | Workbook book = WorkbookFactory.create(file.getInputStream()); |
| | | Sheet sheet = book.getSheetAt(0); |
| | | //获取最后一行 |
| | | int lastRowIndex = sheet.getLastRowNum(); |
| | | List<DeviceSpare> spareList = new ArrayList<>(); |
| | | for (int i = 1; i <= lastRowIndex; i++) { |
| | | DeviceSpare spare = new DeviceSpare(); |
| | | Row row = sheet.getRow(i); |
| | | //对每行的前7列进行非空校验 |
| | | for (int j = 0; j < 7; j++) { |
| | | Cell cell = row.getCell(j); |
| | | //非图片列进行非空校验.不合规无法上传 |
| | | if (cell == null || cell.getCellType() == CellType.BLANK) { |
| | | return new Response().set(1, false, "第" + (i + 1) + "行第" + (j + 1) + "列数据为空"); |
| | | } |
| | | } |
| | | //获取列的值 |
| | | String name = row.getCell(0).getStringCellValue(); |
| | | String model = row.getCell(1).getStringCellValue(); |
| | | String version = row.getCell(2).getStringCellValue(); |
| | | int quantity = (int) row.getCell(3).getNumericCellValue(); |
| | | String brand = row.getCell(4).getStringCellValue(); |
| | | String type = row.getCell(5).getStringCellValue(); |
| | | String supplier = row.getCell(6).getStringCellValue(); |
| | | spare.setName(name); |
| | | spare.setModel(model); |
| | | spare.setVersion(version); |
| | | spare.setQuantity(quantity); |
| | | spare.setBrand(brand); |
| | | spare.setType(type); |
| | | spare.setSupplier(supplier); |
| | | |
| | | spareList.add(spare); |
| | | //第七列为图片 TODO 待处理 |
| | | /*Cell cell = row.getCell(7); |
| | | CellType cellType = cell.getCellType(); |
| | | System.out.println("-");*/ |
| | | } |
| | | addBatch(spareList); |
| | | |
| | | return null; |
| | | } |
| | | } |
| | |
| | | package com.whyc.service; |
| | | |
| | | import cn.afterturn.easypoi.entity.ImageEntity; |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.TemplateExportParams; |
| | | import com.whyc.dto.Real.ExportTinfDataDto; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.dto.Statistic.MonStic; |
| | | import com.whyc.dto.Statistic.SticMonRes; |
| | | import com.whyc.mapper.CommonMapper; |
| | | import com.whyc.pojo.db_batt_testdata.BatttestdataId; |
| | | import com.whyc.pojo.db_batt_testdata.BatttestdataInf; |
| | | import com.whyc.pojo.db_user.User; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.ServletUtils; |
| | | import org.apache.poi.hssf.usermodel.*; |
| | | import org.apache.poi.ss.formula.functions.T; |
| | | import org.apache.poi.ss.usermodel.ClientAnchor; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.core.io.ClassPathResource; |
| | | import org.springframework.stereotype.Service; |
| | | import sun.misc.BASE64Decoder; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | |
| | | import java.net.URLEncoder; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | @Service |
| | | public class ExportService { |
| | | |
| | | @Autowired |
| | | private BatttestdataInfService battTinfService; |
| | | |
| | | @Autowired |
| | | private SubTablePageInfoService subTablePageInfoService; |
| | | |
| | | @Resource |
| | | private CommonMapper commonMapper; |
| | | |
| | | |
| | | //单节数量统计导出(1.2.14) |
| | |
| | | rowNum = rowNum+rowNumAdd+5; |
| | | } |
| | | } |
| | | //历史测试数据导出 |
| | | public void exportTinfDataByTestRecordCount(HttpServletRequest req, HttpServletResponse resp, ExportTinfDataDto dto) throws IOException { |
| | | Map<String,Object> map=new HashMap<>(); |
| | | //历史测试数据导出 |
| | | BatttestdataInf tinf = battTinfService.exportTinfDataByTestRecordCount(dto.getBattgroupId(), dto.getTestRecordCount()); |
| | | String tableName ="db_batt_testdata.tb_batttestdata_"+dto.getBattgroupId(); |
| | | //获取具体的放电数据 |
| | | List<BatttestdataId> dataList= subTablePageInfoService.exportTinfDataByTestRecordCount(dto.getBattgroupId(),dto.getTestRecordCount(),tableName); |
| | | map.put("dataList",dataList); |
| | | BASE64Decoder decoder = new BASE64Decoder(); |
| | | if(!dto.getPicGroupVol().equals("")) { |
| | | ImageEntity volImage = new ImageEntity(); |
| | | volImage.setData(decoder.decodeBuffer(dto.getPicGroupVol().substring(dto.getPicGroupVol().indexOf(",") + 1))); |
| | | volImage.setColspan(6); |
| | | volImage.setRowspan(17); |
| | | map.put("picGroupVol",volImage); |
| | | } |
| | | if(!dto.getPicBattVol().equals("")) { |
| | | ImageEntity volImage = new ImageEntity(); |
| | | volImage.setData(decoder.decodeBuffer(dto.getPicGroupVol().substring(dto.getPicBattVol().indexOf(",") + 1))); |
| | | volImage.setColspan(6); |
| | | volImage.setRowspan(17); |
| | | map.put("picBattVol",volImage); |
| | | } |
| | | if(!dto.getPicGroupCurr().equals("")) { |
| | | ImageEntity volImage = new ImageEntity(); |
| | | volImage.setData(decoder.decodeBuffer(dto.getPicGroupVol().substring(dto.getPicGroupCurr().indexOf(",") + 1))); |
| | | volImage.setColspan(6); |
| | | volImage.setRowspan(17); |
| | | map.put("picGroupCurr",volImage); |
| | | } |
| | | //获取导出模板地址 |
| | | ClassPathResource classPathResource = new ClassPathResource("excel_templates/batt_mon_static_template.xlsx"); |
| | | String path = classPathResource.getPath(); |
| | | TemplateExportParams templateExportParams1 = new TemplateExportParams(path,true); |
| | | Workbook wb = ExcelExportUtil.exportExcel(templateExportParams1, map); |
| | | try { |
| | | String fileName = "历史测试数据表.xls"; |
| | | resp.setContentType("application/vnd.ms-excel"); |
| | | resp.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "utf-8")); |
| | | resp.flushBuffer(); |
| | | wb.write(resp.getOutputStream()); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | |
| | | }); |
| | | return list; |
| | | } |
| | | //获取具体的放电数据 |
| | | public List<BatttestdataId> exportTinfDataByTestRecordCount(Integer battgroupId, Integer testRecordCount, String tableName) { |
| | | String sql="select distinct * from "+tableName+" "+ |
| | | " where test_record_count="+testRecordCount; |
| | | sql+=" order by record_time asc"; |
| | | List<BatttestdataId> list = sqlExecuteService.executeQuery_call(sql, new CallBack() { |
| | | @Override |
| | | public List getResults(ResultSet rs) throws SQLException { |
| | | List<BatttestdataId> list=new ArrayList<>(); |
| | | while (rs.next()){ |
| | | BatttestdataId data=new BatttestdataId(); |
| | | data.setNum(rs.getInt("num")); |
| | | data.setBattgroupId(rs.getInt("battgroup_id")); |
| | | data.setTestRecordCount(rs.getInt("test_record_count")); |
| | | data.setTestType(rs.getInt("test_type")); |
| | | data.setRecordNum(rs.getInt("record_num")); |
| | | data.setDataNew(rs.getInt("data_new")); |
| | | data.setDataAvailable(rs.getInt("data_available")); |
| | | data.setTestTimelong(rs.getInt("test_timelong")); |
| | | data.setTestCurr(rs.getFloat("test_curr")); |
| | | data.setTestCap(rs.getFloat("test_cap")); |
| | | data.setMonNum(rs.getInt("mon_num")); |
| | | data.setMonVol(rs.getFloat("mon_vol")); |
| | | data.setMonTmp(rs.getFloat("mon_tmp")); |
| | | data.setMonRes(rs.getFloat("mon_res")); |
| | | data.setTestStarttime(rs.getTimestamp("test_starttime")); |
| | | data.setRecordTime(rs.getTimestamp("record_time")); |
| | | data.setGroupVol(rs.getFloat("group_vol")); |
| | | data.setOnlineVol(rs.getFloat("online_vol")); |
| | | list.add(data); |
| | | } |
| | | return list; |
| | | } |
| | | }); |
| | | return list; |
| | | } |
| | | } |
| | |
| | | link.setDealAndClose(1); |
| | | } |
| | | }break; |
| | | //设备入库申请 TODO 入库影响库存 |
| | | //设备入库申请 |
| | | case 2: |
| | | //设备报废申请 |
| | | case 3:{ |
| | |
| | | link.setDealAndClose(1); |
| | | } |
| | | }break; |
| | | case 4:{ //TODO 出库申请 |
| | | case 4:{ // 出库申请 |
| | | if(link.getStatus() == WorkflowEnum.LINK_STATUS_PASS.getValue().intValue()){ |
| | | mainInDB.setStatus(WorkflowEnum.MAIN_STATUS_WAIT_FOR_DEALING.getValue()); |
| | | mainInDB.setStatus(WorkflowEnum.MAIN_STATUS_END_PASS.getValue()); |
| | | mainInDB.setEndTime(now); |
| | | mainInDB.setEndReason(link.getDealReason()); |
| | | mainService.updateById(mainInDB); |
| | | //获取出库申请单设备 |
| | | List<WorkflowDevice> deviceListInDB = deviceService.getByMainId(mainInDB.getId()); |
| | | List<DeviceSpare> spareList = new ArrayList<>(); |
| | | deviceListInDB.forEach(device -> { |
| | | DeviceSpare spare = new DeviceSpare(); |
| | | BeanUtils.copyProperties(device,spare); |
| | | spareList.add(spare); |
| | | }); |
| | | //更新库存 |
| | | deviceSpareService.outBound(spareList); |
| | | }else if(link.getStatus() == WorkflowEnum.LINK_STATUS_REJECT.getValue().intValue()){ |
| | | mainInDB.setStatus(WorkflowEnum.MAIN_STATUS_END_REJECT.getValue()); |
| | | mainInDB.setEndReason(link.getDealRejectReason()); |
| | | mainInDB.setEndTime(now); |
| | | //检查是否有关联工单.如果有关联工单,关联工单状态重置为完结待处理,完成时间重置为空 |
| | | if(mainInDB.getRelatedId() != null){ |
| | | Integer relatedId = mainInDB.getRelatedId(); |
| | | //mainService.resetRepairStatus(relatedId,mainInDB.getQuantity()); |
| | | } |
| | | mainService.updateById(mainInDB); |
| | | link.setDealAndClose(1); |
| | | } |
New file |
| | |
| | | <?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.whyc.mapper.DeviceSpareMapper" > |
| | | |
| | | <update id="outBound"> |
| | | <foreach collection="list" item="item" separator=";"> |
| | | update web_site.tb_device_spare set quantity = quantity - #{item.quantity} |
| | | where name = #{item.name} |
| | | and model = #{item.model} |
| | | and version = #{item.version} |
| | | and brand = #{item.brand} |
| | | and type = #{item.type} |
| | | and supplier = #{item.supplier} |
| | | </foreach> |
| | | </update> |
| | | </mapper> |
| | |
| | | l.id link_id, |
| | | l.main_id, |
| | | l.parent_id, |
| | | l.process_level as lProcessLevel, |
| | | l.process_level_name, |
| | | l.process_stage, |
| | | l.process_name, |
| | | l.create_time link_create_time, |
| | | l.deal_user_id, |
| | | l.deal_type, |
| | |
| | | <id column="link_id" property="id"/> |
| | | <result column="main_id" property="mainId"/> |
| | | <result column="parent_id" property="parentId"/> |
| | | <result column="lProcessLevel" property="processLevel"/> |
| | | <result column="process_level_name" property="processLevelName"/> |
| | | <result column="process_stage" property="processStage"/> |
| | | <result column="process_name" property="processName"/> |
| | | <result column="link_create_time" property="createTime"/> |
| | | <result column="deal_user_id" property="dealUserId"/> |
| | | <result column="deal_type" property="dealType"/> |
| | |
| | | <choose> |
| | | <!--全部--> |
| | | <when test="status==0"> |
| | | SELECT m.*,u.uName as create_user_name,<include refid="linkColumn" /> |
| | | FROM web_site.tb_workflow_main m,web_site.tb_workflow_link l,db_user.tb_user_inf u |
| | | SELECT m.*,u.name as create_user_name,<include refid="linkColumn" /> |
| | | FROM web_site.tb_workflow_main m,web_site.tb_workflow_link l,db_user.tb_user u |
| | | where m.id = l.main_id |
| | | and m.create_user_id = u.uId |
| | | and m.create_user_id = u.id |
| | | and m.type = #{type} |
| | | and l.deal_role_id = #{user.uRole} |
| | | and l.deal_role_id = #{user.role} |
| | | and l.deal_user_id is null |
| | | union all |
| | | SELECT m.*,u.uName as create_user_name,<include refid="linkColumn" /> |
| | | FROM web_site.tb_workflow_main m,web_site.tb_workflow_link l,db_user.tb_user_inf u |
| | | SELECT m.*,u.name as create_user_name,<include refid="linkColumn" /> |
| | | FROM web_site.tb_workflow_main m,web_site.tb_workflow_link l,db_user.tb_user u |
| | | where m.id = l.main_id |
| | | and m.create_user_id = u.uId |
| | | and m.create_user_id = u.id |
| | | and m.type = #{type} |
| | | and l.deal_user_id = #{user.uId} order by id desc |
| | | and l.deal_user_id = #{user.id} order by id desc |
| | | </when> |
| | | <!--待接单--> |
| | | <when test="status==1"> |
| | | SELECT m.*,u.uName as create_user_name,<include refid="linkColumn" /> |
| | | FROM web_site.tb_workflow_main m,web_site.tb_workflow_link l,db_user.tb_user_inf u |
| | | SELECT m.*,u.name as create_user_name,<include refid="linkColumn" /> |
| | | FROM web_site.tb_workflow_main m,web_site.tb_workflow_link l,db_user.tb_user u |
| | | where m.id = l.main_id |
| | | and m.create_user_id = u.uId |
| | | and m.create_user_id = u.id |
| | | and m.type = #{type} |
| | | and l.deal_role_id = #{user.uRole} |
| | | and l.deal_role_id = #{user.role} |
| | | and l.deal_user_id is null |
| | | and l.status = #{status} order by m.id desc |
| | | </when> |
| | | <otherwise> |
| | | SELECT m.*,u.uName as create_user_name,<include refid="linkColumn" /> |
| | | FROM web_site.tb_workflow_main m,web_site.tb_workflow_link l,db_user.tb_user_inf u |
| | | SELECT m.*,u.name as create_user_name,<include refid="linkColumn" /> |
| | | FROM web_site.tb_workflow_main m,web_site.tb_workflow_link l,db_user.tb_user u |
| | | where m.id = l.main_id |
| | | and m.create_user_id = u.uId |
| | | and m.create_user_id = u.id |
| | | and m.type = #{type} |
| | | and l.deal_user_id = #{user.uId} |
| | | and l.deal_user_id = #{user.id} |
| | | and l.status = #{status} order by m.id desc |
| | | </otherwise> |
| | | </choose> |