| | |
| | | <artifactId>spring-boot-starter-test</artifactId> |
| | | <scope>test</scope> |
| | | </dependency> |
| | | |
| | | |
| | | <dependency> |
| | | <groupId>org.jfree</groupId> |
| | | <artifactId>jfreechart</artifactId> |
| | | <version>1.5.5</version> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <build> |
| | |
| | | return docket("andon", Collections.singletonList("com.qianwen.smartman.modules.andon")); |
| | | } |
| | | |
| | | @Bean |
| | | public Docket workinghourDocket() { |
| | | return docket("workinghour", Collections.singletonList("com.qianwen.smartman.modules.workinghour")); |
| | | } |
| | | |
| | | private Docket docket(String groupName, List<String> basePackages) { |
| | | TypeResolver resolver = new TypeResolver(); |
| | | AlternateTypeRule listLongToString = AlternateTypeRules.newRule(resolver.resolve(List.class, new Type[]{Long.class}), resolver.resolve(List.class, new Type[]{String.class})); |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.smartman.common.utils; |
| | | |
| | | import java.time.Duration; |
| | | |
| | | public class DurationUtil { |
| | | /** |
| | | * å°æ¶é´å·®è½¬æ¢ä¸ºä¸æï¼å¦1天2å°æ¶3å15ç§ |
| | | * @param duration |
| | | * @return 䏿æ¶é´å·® |
| | | */ |
| | | public static String toChineseDuration(Duration duration) { |
| | | String dayStr = ""; |
| | | if(duration.toDays() > 0) { |
| | | dayStr = duration.toDays()+"天"; |
| | | } |
| | | |
| | | long temp; |
| | | |
| | | String secStr = ""; |
| | | if(duration.getSeconds() > 0) { |
| | | temp = duration.getSeconds()%60; |
| | | if(temp > 0) { |
| | | secStr = temp+"ç§"; |
| | | } |
| | | } |
| | | |
| | | String minStr = ""; |
| | | if(duration.toMinutes() > 0) { |
| | | temp = duration.toMinutes()%60; |
| | | if(temp > 0) { |
| | | minStr += temp+"å"; |
| | | } |
| | | } |
| | | |
| | | String hourStr = ""; |
| | | if(duration.toHours() > 0) { |
| | | temp = duration.toHours()%24; |
| | | if(temp > 0) { |
| | | hourStr = temp+"å°æ¶"; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | return dayStr + hourStr+minStr+secStr; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.smartman.common.vo; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | import javax.validation.constraints.NotEmpty; |
| | | |
| | | public class CommonIdsVO implements Serializable { |
| | | /** |
| | | * |
| | | */ |
| | | private static final long serialVersionUID = 1791423608430772402L; |
| | | @NotEmpty(message = "idsä¸è½ä¸ºç©º") |
| | | private List<Long> ids; |
| | | public List<Long> getIds() { |
| | | return ids; |
| | | } |
| | | public void setIds(List<Long> ids) { |
| | | this.ids = ids; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import com.qianwen.smartman.modules.smis.dto.WorkstationRealTimeStatusDTO; |
| | | import com.qianwen.smartman.modules.smis.excel.WorkstationImport; |
| | | import com.qianwen.smartman.modules.smis.service.IWorkstationService; |
| | | import com.qianwen.smartman.modules.smis.vo.DmpVariablesVO; |
| | | import com.qianwen.smartman.modules.smis.vo.FmsWorkstationGroupVO; |
| | | import com.qianwen.smartman.modules.smis.vo.FmsWorkstationQueryVO; |
| | | import com.qianwen.smartman.modules.smis.vo.WorkMachineEasyVO; |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.smartman.modules.workinghour.controller; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.qianwen.core.boot.ctrl.BladeController; |
| | | import com.qianwen.core.mp.support.Condition; |
| | | import com.qianwen.core.mp.support.Query; |
| | | import com.qianwen.core.oss.model.BladeFile; |
| | | import com.qianwen.core.scanner.modular.stereotype.ApiResource; |
| | | import com.qianwen.core.tenant.annotation.NonDS; |
| | | import com.qianwen.core.tool.api.R; |
| | | import com.qianwen.smartman.common.vo.CommonIdsVO; |
| | | import com.qianwen.smartman.modules.workinghour.service.PartWorkingHourExportService; |
| | | import com.qianwen.smartman.modules.workinghour.service.PartWorkingHourService; |
| | | import com.qianwen.smartman.modules.workinghour.vo.PartWorkingHourQueryVO; |
| | | import com.qianwen.smartman.modules.workinghour.vo.PartWorkingHourVO; |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | |
| | | @Api(value = "å·¥æ¶åæ", tags = {"å·¥æ¶åæ"}) |
| | | @RestController |
| | | @ApiResource({"workinghour"}) |
| | | @NonDS |
| | | @Validated |
| | | public class PartWorkHourController extends BladeController { |
| | | private Logger log = LoggerFactory.getLogger(this.getClass()); |
| | | @Autowired |
| | | private PartWorkingHourService partWorkingHourService; |
| | | @Autowired |
| | | private PartWorkingHourExportService partWorkingHourExportService; |
| | | |
| | | @PostMapping({"/page"}) |
| | | @ApiOperation("æ¥è¯¢é¶ä»¶å表å页") |
| | | public R<IPage<PartWorkingHourVO>> page(@RequestBody PartWorkingHourQueryVO queryVO,Query query) { |
| | | //@RequestParam(value = "partNo", required = false) String partNo, @RequestParam(value="workstationName", required = false) String workstationName, @RequestParam("startDate") LocalDate startDate, @RequestParam("endDate") LocalDate endDate |
| | | return R.data(partWorkingHourService.listPage(Condition.getPage(query), queryVO.getPartNo(), queryVO.getWorkstationName(), queryVO.getStartDate(),queryVO.getEndDate())); |
| | | } |
| | | |
| | | |
| | | |
| | | @PostMapping({"/listByIds"}) |
| | | @ApiOperation("æ¥è¯¢é¶ä»¶å表-æids") |
| | | public R<List<PartWorkingHourVO>> listByIds(@RequestBody CommonIdsVO idsVO) { |
| | | return R.data(partWorkingHourService.listVOByIds(idsVO.getIds())); |
| | | } |
| | | |
| | | |
| | | @GetMapping({"/exportold"}) |
| | | @ApiOperation("å·¥æ¶æ°æ®å¯¼åºold") |
| | | public R<BladeFile> exportOld(long id) { |
| | | return R.data(partWorkingHourService.export(id)); |
| | | } |
| | | |
| | | @GetMapping({"/export"}) |
| | | @ApiOperation("å·¥æ¶æ°æ®å¯¼åº") |
| | | public R<BladeFile> export(long id) { |
| | | try { |
| | | return R.data(partWorkingHourExportService.export(id)); |
| | | } catch (Exception e) { |
| | | log.error("导åºå
¬å¼æ°æ®é误",e); |
| | | |
| | | return R.fail(e.getMessage()); |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.smartman.modules.workinghour.controller; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import com.qianwen.core.boot.ctrl.BladeController; |
| | | import com.qianwen.core.oss.model.BladeFile; |
| | | import com.qianwen.core.scanner.modular.stereotype.ApiResource; |
| | | import com.qianwen.core.tenant.annotation.NonDS; |
| | | import com.qianwen.core.tool.api.R; |
| | | import com.qianwen.smartman.modules.workinghour.service.PartWorkingProcessService; |
| | | import com.qianwen.smartman.modules.workinghour.vo.PartWorkingProcessVO; |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | |
| | | @Api(value = "å·¥æ¶åæ", tags = {"å·¥æ¶åæ"}) |
| | | @RestController |
| | | @ApiResource({"workinghour"}) |
| | | @NonDS |
| | | @Validated |
| | | public class PartWorkingProcessController extends BladeController { |
| | | @Autowired |
| | | private PartWorkingProcessService partWorkingProcessService; |
| | | |
| | | |
| | | @GetMapping({"/working-process"}) |
| | | @ApiOperation("å å·¥è¿ç¨æ°æ®") |
| | | public R<List<PartWorkingProcessVO>> list(long id) { |
| | | return R.data(partWorkingProcessService.listByWorkinghourId(id)); |
| | | } |
| | | |
| | | @GetMapping({"/working-process-export"}) |
| | | @ApiOperation("å å·¥è¿ç¨æ°æ®å¯¼åº") |
| | | public R<BladeFile> export(long id) { |
| | | return R.data(partWorkingProcessService.export(id)); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.smartman.modules.workinghour.convert; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.mapstruct.Builder; |
| | | import org.mapstruct.Mapper; |
| | | import org.mapstruct.Mappings; |
| | | import org.mapstruct.factory.Mappers; |
| | | |
| | | import com.qianwen.smartman.modules.mdc.utils.ConvertUtils; |
| | | import com.qianwen.smartman.modules.workinghour.entity.PartWorkingHour; |
| | | import com.qianwen.smartman.modules.workinghour.vo.PartWorkingHourVO; |
| | | |
| | | @Mapper(builder = @Builder(disableBuilder = true), imports = {ConvertUtils.class}) |
| | | public interface PartWorkingHourConvert { |
| | | public static final PartWorkingHourConvert INSTANCE = (PartWorkingHourConvert) Mappers.getMapper(PartWorkingHourConvert.class); |
| | | |
| | | //@Mappings({@Mapping(target = "alarmTime", expression = "java(ConvertUtils.format(alarm.getTime()))"), @Mapping(target = "alarmCode", source = "code"), @Mapping(target = "alarmMsg", source = "message"), @Mapping(target = "count", expression = "java(ConvertUtils.defaultValue())")}) |
| | | @Mappings({}) |
| | | PartWorkingHourVO convert(PartWorkingHour pwh); |
| | | |
| | | @Mappings({}) |
| | | List<PartWorkingHourVO> convert(List<PartWorkingHour> alarms); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.smartman.modules.workinghour.convert; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.mapstruct.Builder; |
| | | import org.mapstruct.Mapper; |
| | | import org.mapstruct.Mappings; |
| | | import org.mapstruct.factory.Mappers; |
| | | |
| | | import com.qianwen.smartman.modules.mdc.utils.ConvertUtils; |
| | | import com.qianwen.smartman.modules.workinghour.entity.PartWorkingProcess; |
| | | import com.qianwen.smartman.modules.workinghour.vo.PartWorkingProcessVO; |
| | | |
| | | @Mapper(builder = @Builder(disableBuilder = true), imports = {ConvertUtils.class}) |
| | | public interface PartWorkingProcessConvert { |
| | | public static final PartWorkingProcessConvert INSTANCE = (PartWorkingProcessConvert) Mappers.getMapper(PartWorkingProcessConvert.class); |
| | | |
| | | //@Mappings({@Mapping(target = "alarmTime", expression = "java(ConvertUtils.format(alarm.getTime()))"), @Mapping(target = "alarmCode", source = "code"), @Mapping(target = "alarmMsg", source = "message"), @Mapping(target = "count", expression = "java(ConvertUtils.defaultValue())")}) |
| | | @Mappings({}) |
| | | PartWorkingProcessVO convert(PartWorkingProcess pwh); |
| | | |
| | | @Mappings({}) |
| | | List<PartWorkingProcessVO> convert(List<PartWorkingProcess> housrs); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.smartman.modules.workinghour.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | import org.apache.commons.lang3.builder.HashCodeBuilder; |
| | | |
| | | import com.qianwen.core.tenant.mp.TenantEntity; |
| | | |
| | | /** |
| | | * é¶ä»¶å·¥æ¶ |
| | | */ |
| | | @TableName("part_workinghour") |
| | | public class PartWorkingHour extends TenantEntity { |
| | | /** |
| | | * é¶ä»¶ç¼å· |
| | | */ |
| | | private String partNo; |
| | | /** |
| | | * å·¥åºå· |
| | | */ |
| | | private String processNo; |
| | | /** |
| | | * çæ¬¡ |
| | | */ |
| | | private String version; |
| | | /** |
| | | * å·¥ä½id |
| | | * */ |
| | | private long workstationId; |
| | | /** |
| | | * å¼å§æ¶é´*/ |
| | | private LocalDateTime startTime; |
| | | /** |
| | | * ç»ææ¶é´ |
| | | */ |
| | | private LocalDateTime endTime; |
| | | /** |
| | | * å æºæ¶é´(ç§) |
| | | */ |
| | | private Long occupancySecs; |
| | | /** |
| | | * è£
夹è°è¯æ¶é´(ç§) |
| | | */ |
| | | private Long clampingSecs; |
| | | /** |
| | | * é¦ä»¶ååæ¶é´(ç§) |
| | | */ |
| | | private Long firstWorkingSecs; |
| | | /** |
| | | * æ«ä»¶æå¸æ¶é´(ç§) |
| | | */ |
| | | private Long lastRemoveSecs; |
| | | /** |
| | | * é¦ä»¶è®¡éæ¶é´(ç§) |
| | | */ |
| | | private Long firstMeasureSecs; |
| | | |
| | | /** |
| | | * å å·¥æ¶é´(ç§) |
| | | */ |
| | | private Long processingSecs; |
| | | /** |
| | | * å夿¶é´(ç§) |
| | | */ |
| | | private Long prepareSecs; |
| | | /** |
| | | * åä»¶å·¥æ¶(ç§) |
| | | */ |
| | | private Long singleProcessSecs; |
| | | /** |
| | | * é¶ä»¶ç产æ°é |
| | | */ |
| | | private Long amount; |
| | | public String getPartNo() { |
| | | return partNo; |
| | | } |
| | | public void setPartNo(String partNo) { |
| | | this.partNo = partNo; |
| | | } |
| | | public String getProcessNo() { |
| | | return processNo; |
| | | } |
| | | public void setProcessNo(String processNo) { |
| | | this.processNo = processNo; |
| | | } |
| | | public String getVersion() { |
| | | return version; |
| | | } |
| | | public void setVersion(String version) { |
| | | this.version = version; |
| | | } |
| | | public long getWorkstationId() { |
| | | return workstationId; |
| | | } |
| | | public void setWorkstationId(long workstationId) { |
| | | this.workstationId = workstationId; |
| | | } |
| | | public LocalDateTime getStartTime() { |
| | | return startTime; |
| | | } |
| | | public void setStartTime(LocalDateTime startTime) { |
| | | this.startTime = startTime; |
| | | } |
| | | public LocalDateTime getEndTime() { |
| | | return endTime; |
| | | } |
| | | public void setEndTime(LocalDateTime endTime) { |
| | | this.endTime = endTime; |
| | | } |
| | | public Long getOccupancySecs() { |
| | | return occupancySecs; |
| | | } |
| | | public void setOccupancySecs(Long occupancySecs) { |
| | | this.occupancySecs = occupancySecs; |
| | | } |
| | | public Long getClampingSecs() { |
| | | return clampingSecs; |
| | | } |
| | | public void setClampingSecs(Long clampingSecs) { |
| | | this.clampingSecs = clampingSecs; |
| | | } |
| | | public Long getFirstWorkingSecs() { |
| | | return firstWorkingSecs; |
| | | } |
| | | public void setFirstWorkingSecs(Long firstWorkingSecs) { |
| | | this.firstWorkingSecs = firstWorkingSecs; |
| | | } |
| | | public Long getLastRemoveSecs() { |
| | | return lastRemoveSecs; |
| | | } |
| | | public void setLastRemoveSecs(Long lastRemoveSecs) { |
| | | this.lastRemoveSecs = lastRemoveSecs; |
| | | } |
| | | public Long getFirstMeasureSecs() { |
| | | return firstMeasureSecs; |
| | | } |
| | | public void setFirstMeasureSecs(Long firstMeasureSecs) { |
| | | this.firstMeasureSecs = firstMeasureSecs; |
| | | } |
| | | |
| | | public Long getProcessingSecs() { |
| | | return processingSecs; |
| | | } |
| | | public void setProcessingSecs(Long processingSecs) { |
| | | this.processingSecs = processingSecs; |
| | | } |
| | | public Long getPrepareSecs() { |
| | | return prepareSecs; |
| | | } |
| | | public void setPrepareSecs(Long prepareSecs) { |
| | | this.prepareSecs = prepareSecs; |
| | | } |
| | | public Long getSingleProcessSecs() { |
| | | return singleProcessSecs; |
| | | } |
| | | public void setSingleProcessSecs(Long singleProcessSecs) { |
| | | this.singleProcessSecs = singleProcessSecs; |
| | | } |
| | | public Long getAmount() { |
| | | return amount; |
| | | } |
| | | public void setAmount(Long amount) { |
| | | this.amount = amount; |
| | | } |
| | | |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.smartman.modules.workinghour.entity; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | |
| | | /** |
| | | * é¶ä»¶å å·¥è¿ç¨æ°æ® |
| | | */ |
| | | @TableName("part_working_process") |
| | | public class PartWorkingProcess{ |
| | | long id; |
| | | /** |
| | | * é¶ä»¶ç¼å· |
| | | */ |
| | | private String progName; |
| | | |
| | | /** |
| | | * å·¥ä½id |
| | | * */ |
| | | private long workinghourId; |
| | | /** |
| | | * å¼å§æ¶é´*/ |
| | | private LocalDateTime startTime; |
| | | /** |
| | | * ç»ææ¶é´ |
| | | */ |
| | | private LocalDateTime endTime; |
| | | |
| | | /** |
| | | * 设å¤ç¶æ |
| | | */ |
| | | private Integer deviceStatus; |
| | | |
| | | public long getId() { |
| | | return id; |
| | | } |
| | | public void setId(long id) { |
| | | this.id = id; |
| | | } |
| | | public String getProgName() { |
| | | return progName; |
| | | } |
| | | public void setProgName(String progName) { |
| | | this.progName = progName; |
| | | } |
| | | public long getWorkinghourId() { |
| | | return workinghourId; |
| | | } |
| | | public void setWorkinghourId(long workinghourId) { |
| | | this.workinghourId = workinghourId; |
| | | } |
| | | public LocalDateTime getStartTime() { |
| | | return startTime; |
| | | } |
| | | public void setStartTime(LocalDateTime startTime) { |
| | | this.startTime = startTime; |
| | | } |
| | | public LocalDateTime getEndTime() { |
| | | return endTime; |
| | | } |
| | | public void setEndTime(LocalDateTime endTime) { |
| | | this.endTime = endTime; |
| | | } |
| | | public Integer getDeviceStatus() { |
| | | return deviceStatus; |
| | | } |
| | | public void setDeviceStatus(Integer deviceStatus) { |
| | | this.deviceStatus = deviceStatus; |
| | | } |
| | | |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.smartman.modules.workinghour.excel; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | import org.apache.commons.lang3.builder.HashCodeBuilder; |
| | | |
| | | import com.qianwen.core.tenant.mp.TenantEntity; |
| | | |
| | | /** |
| | | * é¶ä»¶å·¥æ¶ |
| | | */ |
| | | |
| | | public class PartWorkingHourExcel{ |
| | | |
| | | @ExcelProperty({"é¶ä»¶ç¼å·"}) |
| | | private String partNo; |
| | | |
| | | @ExcelProperty({"å·¥åºå·"}) |
| | | private String processNo; |
| | | |
| | | @ExcelProperty({"çæ¬¡"}) |
| | | private String version; |
| | | |
| | | @ExcelProperty({"å·¥ä½"}) |
| | | private String workstationName; |
| | | |
| | | @ExcelProperty({"å¼å§æ¶é´"}) |
| | | private String startTime; |
| | | |
| | | @ExcelProperty({"ç»ææ¶é´"}) |
| | | private String endTime; |
| | | |
| | | @ExcelProperty({"å æºæ¶é´"}) |
| | | private String occupancySecs; |
| | | /** |
| | | * |
| | | */ |
| | | @ExcelProperty({"è£
夹è°è¯æ¶é´"}) |
| | | private String clampingSecs; |
| | | |
| | | @ExcelProperty({"é¦ä»¶ååæ¶é´"}) |
| | | private String firstWorkingSecs; |
| | | |
| | | @ExcelProperty({"æ«ä»¶æå¸æ¶é´"}) |
| | | private String lastRemoveSecs; |
| | | |
| | | @ExcelProperty({"é¦ä»¶è®¡éæ¶é´"}) |
| | | private String firstMeasureSecs; |
| | | |
| | | |
| | | @ExcelProperty({"å å·¥æ¶é´"}) |
| | | private String processingSecs; |
| | | |
| | | @ExcelProperty({"å夿¶é´"}) |
| | | private String prepareSecs; |
| | | |
| | | @ExcelProperty({"åä»¶å·¥æ¶"}) |
| | | private String singleProcessSecs; |
| | | |
| | | @ExcelProperty({"æ°é"}) |
| | | private Long amount; |
| | | public String getPartNo() { |
| | | return partNo; |
| | | } |
| | | public void setPartNo(String partNo) { |
| | | this.partNo = partNo; |
| | | } |
| | | public String getProcessNo() { |
| | | return processNo; |
| | | } |
| | | public void setProcessNo(String processNo) { |
| | | this.processNo = processNo; |
| | | } |
| | | public String getVersion() { |
| | | return version; |
| | | } |
| | | public void setVersion(String version) { |
| | | this.version = version; |
| | | } |
| | | |
| | | public String getWorkstationName() { |
| | | return workstationName; |
| | | } |
| | | public void setWorkstationName(String workstationName) { |
| | | this.workstationName = workstationName; |
| | | } |
| | | public String getStartTime() { |
| | | return startTime; |
| | | } |
| | | public void setStartTime(String startTime) { |
| | | this.startTime = startTime; |
| | | } |
| | | public String getEndTime() { |
| | | return endTime; |
| | | } |
| | | public void setEndTime(String endTime) { |
| | | this.endTime = endTime; |
| | | } |
| | | public Long getAmount() { |
| | | return amount; |
| | | } |
| | | public void setAmount(Long amount) { |
| | | this.amount = amount; |
| | | } |
| | | public String getOccupancySecs() { |
| | | return occupancySecs; |
| | | } |
| | | public void setOccupancySecs(String occupancySecs) { |
| | | this.occupancySecs = occupancySecs; |
| | | } |
| | | public String getClampingSecs() { |
| | | return clampingSecs; |
| | | } |
| | | public void setClampingSecs(String clampingSecs) { |
| | | this.clampingSecs = clampingSecs; |
| | | } |
| | | public String getFirstWorkingSecs() { |
| | | return firstWorkingSecs; |
| | | } |
| | | public void setFirstWorkingSecs(String firstWorkingSecs) { |
| | | this.firstWorkingSecs = firstWorkingSecs; |
| | | } |
| | | public String getLastRemoveSecs() { |
| | | return lastRemoveSecs; |
| | | } |
| | | public void setLastRemoveSecs(String lastRemoveSecs) { |
| | | this.lastRemoveSecs = lastRemoveSecs; |
| | | } |
| | | public String getFirstMeasureSecs() { |
| | | return firstMeasureSecs; |
| | | } |
| | | public void setFirstMeasureSecs(String firstMeasureSecs) { |
| | | this.firstMeasureSecs = firstMeasureSecs; |
| | | } |
| | | public String getProcessingSecs() { |
| | | return processingSecs; |
| | | } |
| | | public void setProcessingSecs(String processingSecs) { |
| | | this.processingSecs = processingSecs; |
| | | } |
| | | public String getPrepareSecs() { |
| | | return prepareSecs; |
| | | } |
| | | public void setPrepareSecs(String prepareSecs) { |
| | | this.prepareSecs = prepareSecs; |
| | | } |
| | | public String getSingleProcessSecs() { |
| | | return singleProcessSecs; |
| | | } |
| | | public void setSingleProcessSecs(String singleProcessSecs) { |
| | | this.singleProcessSecs = singleProcessSecs; |
| | | } |
| | | |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.smartman.modules.workinghour.excel; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import com.alibaba.excel.annotation.write.style.ColumnWidth; |
| | | import com.alibaba.excel.annotation.write.style.ContentRowHeight; |
| | | import com.alibaba.excel.annotation.write.style.HeadRowHeight; |
| | | |
| | | @HeadRowHeight(20) |
| | | @ColumnWidth(16) |
| | | @ContentRowHeight(18) |
| | | public class PartWorkingProcessExcel implements Serializable { |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | private static final long serialVersionUID = -5329911071641310785L; |
| | | |
| | | @ExcelProperty({"ç¨åºåç§°"}) |
| | | private String progName; |
| | | @ExcelProperty({"å¼å§æ¶é´"}) |
| | | private String startTime; |
| | | @ExcelProperty({"ç»ææ¶é´"}) |
| | | private String endTime; |
| | | @ExcelProperty({"æç»æ¶é¿"}) |
| | | private String duration; |
| | | @ExcelProperty({"ç¶æ"}) |
| | | private String deviceStateName; |
| | | public String getProgName() { |
| | | return progName; |
| | | } |
| | | public void setProgName(String progName) { |
| | | this.progName = progName; |
| | | } |
| | | public String getStartTime() { |
| | | return startTime; |
| | | } |
| | | public void setStartTime(String startTime) { |
| | | this.startTime = startTime; |
| | | } |
| | | public String getEndTime() { |
| | | return endTime; |
| | | } |
| | | public void setEndTime(String endTime) { |
| | | this.endTime = endTime; |
| | | } |
| | | public String getDuration() { |
| | | return duration; |
| | | } |
| | | public void setDuration(String duration) { |
| | | this.duration = duration; |
| | | } |
| | | public String getDeviceStateName() { |
| | | return deviceStateName; |
| | | } |
| | | public void setDeviceStateName(String deviceStateName) { |
| | | this.deviceStateName = deviceStateName; |
| | | } |
| | | |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.smartman.modules.workinghour.mapper; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.qianwen.core.datascope.annotation.DataAuth; |
| | | import com.qianwen.smartman.modules.smis.vo.WorkstationVO; |
| | | import com.qianwen.smartman.modules.workinghour.entity.PartWorkingHour; |
| | | import com.qianwen.smartman.modules.workinghour.vo.PartWorkingHourVO; |
| | | |
| | | public interface PartWorkingHourMapper extends BaseMapper<PartWorkingHour> { |
| | | |
| | | /** |
| | | * æ¥è¯¢å页å表 |
| | | * @param page |
| | | * @param partNo |
| | | * @param workstationName |
| | | * @param startDate |
| | | * @param endDate |
| | | * @return |
| | | */ |
| | | @DataAuth(code = "workstation") |
| | | List<PartWorkingHourVO> listPage(IPage<PartWorkingHourVO> page, @Param("partNo")String partNo, @Param("workstationName")String workstationName, @Param("startDate")LocalDate startDate, @Param("endDate")LocalDate endDate); |
| | | |
| | | /** |
| | | * æ ¹æ®idéæ©è®°å½ |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | List<PartWorkingHourVO> listVOByIds(List<Long> ids); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.smartman.modules.workinghour.mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.qianwen.smartman.modules.workinghour.entity.PartWorkingProcess; |
| | | import com.qianwen.smartman.modules.workinghour.vo.PartWorkingProcessVO; |
| | | |
| | | public interface PartWorkingProcessMapper extends BaseMapper<PartWorkingProcess> { |
| | | |
| | | |
| | | /** |
| | | * æ ¹æ®idéæ©è®°å½ |
| | | * @param workinghourId å·¥æ¶è¡¨id |
| | | * @return |
| | | */ |
| | | List<PartWorkingProcessVO> listVOByWorkingHourId(Long workinghourId); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.smartman.modules.workinghour.service; |
| | | |
| | | //import cn.hutool.core.util.StrUtil; |
| | | import org.jfree.chart.*; |
| | | import org.jfree.chart.axis.ValueAxis; |
| | | import org.jfree.chart.labels.*; |
| | | import org.jfree.chart.plot.*; |
| | | import org.jfree.chart.renderer.category.*; |
| | | import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; |
| | | import org.jfree.chart.ui.*; |
| | | import org.jfree.data.category.DefaultCategoryDataset; |
| | | import org.jfree.data.general.DefaultPieDataset; |
| | | import org.springframework.core.io.ClassPathResource; |
| | | |
| | | import java.awt.*; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.text.NumberFormat; |
| | | import java.util.List; |
| | | |
| | | public class JFreeChartUtil { |
| | | |
| | | public static String NO_DATA_MSG = "æ°æ®å 载失败"; |
| | | |
| | | /** |
| | | * çæä¸»é¢ |
| | | * |
| | | * @param fontName åä½åç§°ï¼é»è®¤ä¸ºå®ä½ï¼ |
| | | * @return |
| | | */ |
| | | public static StandardChartTheme createChartTheme(String fontName) throws Exception { |
| | | StandardChartTheme theme = new StandardChartTheme("unicode") { |
| | | public void apply(JFreeChart chart) { |
| | | chart.getRenderingHints().put(RenderingHints.KEY_TEXT_ANTIALIASING, |
| | | RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); |
| | | super.apply(chart); |
| | | } |
| | | }; |
| | | theme.setExtraLargeFont(getDefaultFont(Font.PLAIN, 20f)); |
| | | theme.setLargeFont(getDefaultFont(Font.PLAIN, 14f)); |
| | | theme.setRegularFont(getDefaultFont(Font.PLAIN, 12f)); |
| | | theme.setSmallFont(getDefaultFont(Font.PLAIN, 10f)); |
| | | return theme; |
| | | } |
| | | |
| | | /** |
| | | * è·åé»è®¤åä½ |
| | | * |
| | | * @param style |
| | | * @param size åä½å¤§å° |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public static Font getDefaultFont(int style, Float size) throws Exception { |
| | | //è·åå®ä½æä»¶ |
| | | //File defaultFontFile = new ClassPathResource("/font/simsun.ttc").getFile(); |
| | | //Font defaultFont = Font.createFont(Font.TRUETYPE_FONT, defaultFontFile); |
| | | Font defaultFont = new Font("å®ä½",style,size.intValue());//yysæ¹ |
| | | //defaultFont = defaultFont.deriveFont(style, size); |
| | | return defaultFont; |
| | | } |
| | | |
| | | /** |
| | | * åå»ºé¥¼å¾æ°æ®éå |
| | | * |
| | | * @param legendNameList å¾ä¾åç§°å表 |
| | | * @param dataList æ°æ®å表 |
| | | * @return |
| | | */ |
| | | public static DefaultPieDataset createDefaultPieDataset(List<String> legendNameList, List<Object> dataList) { |
| | | DefaultPieDataset dataset = new DefaultPieDataset(); |
| | | //å¾ä¾åç§°åè¡¨ææ°æ®å表为空 |
| | | if (legendNameList == null || legendNameList.size() <= 0 || dataList == null || dataList.size() <= 0) { |
| | | return dataset; |
| | | } |
| | | for (int i = 0; i < legendNameList.size() && legendNameList.size() == dataList.size(); i++) { |
| | | String value = dataList.get(i).toString(); |
| | | dataset.setValue(legendNameList.get(i), Double.valueOf(value)); |
| | | } |
| | | return dataset; |
| | | } |
| | | |
| | | /** |
| | | * 设置饼ç¶å¾æ¸²æ |
| | | */ |
| | | public static void setPieRender(Plot plot) { |
| | | plot.setNoDataMessage(NO_DATA_MSG); |
| | | plot.setInsets(new RectangleInsets(10, 10, 5, 10)); |
| | | PiePlot piePlot = (PiePlot) plot; |
| | | piePlot.setInsets(new RectangleInsets(0, 0, 0, 0)); |
| | | piePlot.setCircular(true);// åå½¢ |
| | | |
| | | // ç®åæ ç¾ |
| | | piePlot.setLabelGap(0.01); |
| | | piePlot.setInteriorGap(0.05D); |
| | | // å¾ä¾å½¢ç¶ |
| | | piePlot.setLegendItemShape(new Rectangle(10, 10)); |
| | | piePlot.setIgnoreNullValues(true); |
| | | // 廿æ ç¾èæ¯è² |
| | | piePlot.setLabelBackgroundPaint(null); |
| | | //廿å¾è¡¨èæ¯é¢è² |
| | | piePlot.setBackgroundPaint(null); |
| | | // 廿é´å½± |
| | | piePlot.setLabelShadowPaint(null); |
| | | // å»æè¾¹æ¡ |
| | | piePlot.setLabelOutlinePaint(null); |
| | | piePlot.setShadowPaint(null); |
| | | // æ¾ç¤ºæ ç¾æ°æ® |
| | | piePlot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}:{2}")); |
| | | } |
| | | |
| | | /** |
| | | * åå»ºç±»å«æ°æ®éå(æ±å½¢å¾ãæçº¿å¾) |
| | | * |
| | | * @param legendNameList å¾ä¾åç§°å表 |
| | | * @param xAxisNameList xè½´åç§°å表 |
| | | * @param dataList æ°æ®å表 |
| | | * @return |
| | | */ |
| | | public static DefaultCategoryDataset createDefaultCategoryDataset(List<String> legendNameList, List<String> xAxisNameList |
| | | , List<List<Object>> dataList) {//TODO è¿é |
| | | DefaultCategoryDataset dataset = new DefaultCategoryDataset(); |
| | | //å¾ä¾åç§°å表ãxè½´åç§°åè¡¨ææ°æ®å表为空 |
| | | if (xAxisNameList == null || xAxisNameList.size() <= 0 || legendNameList == null || legendNameList.size() <= 0 |
| | | || dataList == null || dataList.size() <= 0) { |
| | | return dataset; |
| | | } |
| | | for (int yAxisIndex = 0; yAxisIndex < legendNameList.size() && legendNameList.size() == dataList.size(); yAxisIndex++) { |
| | | String legendName = legendNameList.get(yAxisIndex); |
| | | List<Object> rowList = dataList.get(yAxisIndex); |
| | | //è¯¥ç»æ°æ®ä¸åå¨æè¯¥ç»æ°æ®æ»æ°ä¸çäºxè½´æ°æ®æ°é |
| | | if (rowList == null || rowList.size() != xAxisNameList.size()) { |
| | | continue; |
| | | } |
| | | for (int xAxisIndex = 0; xAxisIndex < rowList.size(); xAxisIndex++) { |
| | | String value = rowList.get(xAxisIndex).toString(); |
| | | dataset.setValue(Double.parseDouble(value), legendName, xAxisNameList.get(xAxisIndex)); |
| | | } |
| | | } |
| | | return dataset; |
| | | } |
| | | |
| | | /** |
| | | * 设置æ±ç¶å¾æ¸²æ |
| | | * |
| | | * @param plot |
| | | * @param isShowDataLabels æ¾ç¤ºæ°æ®å¼æ è®° |
| | | */ |
| | | public static void setBarRenderer(CategoryPlot plot, boolean isShowDataLabels) { |
| | | plot.setNoDataMessage(NO_DATA_MSG); |
| | | plot.setInsets(new RectangleInsets(10, 10, 5, 10)); |
| | | BarRenderer renderer = (BarRenderer) plot.getRenderer(); |
| | | // 设置æ±åæå¤§å®½åº¦ |
| | | renderer.setMaximumBarWidth(0.175); |
| | | //设置å¾è¡¨èæ¯é¢è²(éæ) |
| | | plot.setBackgroundPaint(null); |
| | | //æ¾ç¤ºæ°æ®å¼æ è®° |
| | | if (isShowDataLabels) { |
| | | renderer.setDefaultItemLabelsVisible(true); |
| | | } |
| | | renderer.setDefaultItemLabelGenerator(new StandardCategoryItemLabelGenerator()); |
| | | //注æï¼æ¤å¥å¾å
³é®ï¼è¥æ æ¤å¥ï¼é£æ°åçæ¾ç¤ºä¼è¢«è¦çï¼ç»äººæ°åæ²¡ææ¾ç¤ºåºæ¥çé®é¢ |
| | | renderer.setDefaultPositiveItemLabelPosition(new ItemLabelPosition( |
| | | ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER)); |
| | | |
| | | setXAixs(plot); |
| | | setYAixs(plot); |
| | | } |
| | | |
| | | /** |
| | | * 设置æçº¿å¾æ ·å¼ |
| | | * |
| | | * @param plot |
| | | * @param isShowDataLabels æ¯å¦æ¾ç¤ºæ°æ®æ ç¾ |
| | | * @param isShapesVisible æ¯å¦æ¾ç¤ºæ°æ®ç¹ |
| | | */ |
| | | public static void setLineRender(CategoryPlot plot, boolean isShowDataLabels, boolean isShapesVisible) { |
| | | plot.setNoDataMessage(NO_DATA_MSG); |
| | | plot.setInsets(new RectangleInsets(10, 10, 0, 10), false); |
| | | LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); |
| | | //设置å¾è¡¨èæ¯é¢è²(éæ) |
| | | plot.setBackgroundPaint(null); |
| | | renderer.setDefaultStroke(new BasicStroke(1.5F)); |
| | | //æ¾ç¤ºæ°æ®æ ç¾ |
| | | if (isShowDataLabels) { |
| | | renderer.setDefaultItemLabelsVisible(true); |
| | | renderer.setDefaultItemLabelGenerator(new StandardCategoryItemLabelGenerator(StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, |
| | | NumberFormat.getInstance())); |
| | | // ä½ç½® |
| | | renderer.setDefaultPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE1, TextAnchor.BOTTOM_CENTER)); |
| | | } |
| | | // æ°æ®ç¹ç»å¶å½¢ç¶ |
| | | renderer.setDefaultShapesVisible(isShapesVisible); |
| | | setXAixs(plot); |
| | | setYAixs(plot); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 设置æ£ç¹å¾æ ·å¼ |
| | | * |
| | | * @param plot |
| | | */ |
| | | public static void setScatterRender(XYPlot plot) { |
| | | plot.setNoDataMessage(NO_DATA_MSG); |
| | | plot.setInsets(new RectangleInsets(10, 10, 0, 10), false); |
| | | //设置å¾è¡¨èæ¯é¢è²(éæ) |
| | | plot.setBackgroundPaint(null); |
| | | setXAixs(plot); |
| | | setYAixs(plot); |
| | | } |
| | | |
| | | /** |
| | | * 设置类å«å¾è¡¨(CategoryPlot) Xåæ è½´çº¿æ¡é¢è²åæ ·å¼ |
| | | * |
| | | * @param plot |
| | | */ |
| | | public static void setXAixs(CategoryPlot plot) { |
| | | Color lineColor = new Color(31, 121, 170); |
| | | // Xåæ è½´é¢è² |
| | | plot.getDomainAxis().setAxisLinePaint(lineColor); |
| | | // Xåæ è½´æ è®°|ç«çº¿é¢è² |
| | | plot.getDomainAxis().setTickMarkPaint(lineColor); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 设置å¾è¡¨(XYPlot) Xåæ è½´çº¿æ¡é¢è²åæ ·å¼ |
| | | * |
| | | * @param plot |
| | | */ |
| | | public static void setXAixs(XYPlot plot) { |
| | | Color lineColor = new Color(31, 121, 170); |
| | | // Xåæ è½´é¢è² |
| | | plot.getDomainAxis().setAxisLinePaint(lineColor); |
| | | // Xåæ è½´æ è®°|ç«çº¿é¢è² |
| | | plot.getDomainAxis().setTickMarkPaint(lineColor); |
| | | // xè½´ç½æ ¼çº¿æ¡ |
| | | plot.setDomainGridlinePaint(new Color(192, 192, 192)); |
| | | } |
| | | |
| | | /** |
| | | * 设置类å«å¾è¡¨(CategoryPlot) Yåæ è½´çº¿æ¡é¢è²åæ ·å¼ åæ¶é²æ¢æ°æ®æ æ³æ¾ç¤º |
| | | * |
| | | * @param plot |
| | | */ |
| | | public static void setYAixs(CategoryPlot plot) { |
| | | Color lineColor = new Color(192, 208, 224); |
| | | ValueAxis axis = plot.getRangeAxis(); |
| | | // Yåæ è½´é¢è² |
| | | axis.setAxisLinePaint(lineColor); |
| | | // Yåæ è½´æ è®°|ç«çº¿é¢è² |
| | | axis.setTickMarkPaint(lineColor); |
| | | // éèYå»åº¦ |
| | | axis.setAxisLineVisible(false); |
| | | axis.setTickMarksVisible(false); |
| | | // Yè½´ç½æ ¼çº¿æ¡ |
| | | plot.setRangeGridlinePaint(new Color(192, 192, 192)); |
| | | plot.setRangeGridlineStroke(new BasicStroke(1)); |
| | | // 设置顶é¨Yåæ è½´é´è·,鲿¢æ°æ®æ æ³æ¾ç¤º |
| | | plot.getRangeAxis().setUpperMargin(0.1); |
| | | // 设置åºé¨Yåæ è½´é´è· |
| | | plot.getRangeAxis().setLowerMargin(0.1); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 设置å¾è¡¨(XYPlot) Yåæ è½´çº¿æ¡é¢è²åæ ·å¼ åæ¶é²æ¢æ°æ®æ æ³æ¾ç¤º |
| | | * |
| | | * @param plot |
| | | */ |
| | | public static void setYAixs(XYPlot plot) { |
| | | Color lineColor = new Color(192, 208, 224); |
| | | ValueAxis axis = plot.getRangeAxis(); |
| | | // Yåæ è½´é¢è² |
| | | axis.setAxisLinePaint(lineColor); |
| | | // Yåæ è½´æ è®°|ç«çº¿é¢è² |
| | | axis.setTickMarkPaint(lineColor); |
| | | // éèYå»åº¦ |
| | | axis.setAxisLineVisible(false); |
| | | axis.setTickMarksVisible(false); |
| | | // Yè½´ç½æ ¼çº¿æ¡ |
| | | plot.setRangeGridlinePaint(new Color(192, 192, 192)); |
| | | // 设置顶é¨Yåæ è½´é´è·,鲿¢æ°æ®æ æ³æ¾ç¤º |
| | | plot.getRangeAxis().setUpperMargin(0.1); |
| | | // 设置åºé¨Yåæ è½´é´è· |
| | | plot.getRangeAxis().setLowerMargin(0.1); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.smartman.modules.workinghour.service; |
| | | |
| | | import java.awt.Color; |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.text.NumberFormat; |
| | | import java.time.Duration; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import org.apache.commons.fileupload.FileItem; |
| | | import org.apache.commons.fileupload.disk.DiskFileItemFactory; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.poi.ss.usermodel.ClientAnchor.AnchorType; |
| | | import org.apache.poi.xssf.usermodel.XSSFClientAnchor; |
| | | import org.apache.poi.xssf.usermodel.XSSFDrawing; |
| | | import org.apache.poi.xssf.usermodel.XSSFSheet; |
| | | import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
| | | import org.jfree.chart.ChartFactory; |
| | | import org.jfree.chart.ChartUtils; |
| | | import org.jfree.chart.JFreeChart; |
| | | import org.jfree.chart.StandardChartTheme; |
| | | import org.jfree.chart.block.BlockBorder; |
| | | import org.jfree.chart.labels.AbstractCategoryItemLabelGenerator; |
| | | import org.jfree.chart.labels.CategoryItemLabelGenerator; |
| | | import org.jfree.chart.labels.ItemLabelAnchor; |
| | | import org.jfree.chart.labels.ItemLabelPosition; |
| | | import org.jfree.chart.plot.CategoryPlot; |
| | | import org.jfree.chart.plot.PlotOrientation; |
| | | import org.jfree.chart.renderer.category.StackedBarRenderer; |
| | | import org.jfree.chart.ui.RectangleEdge; |
| | | import org.jfree.chart.ui.RectangleInsets; |
| | | import org.jfree.chart.ui.TextAnchor; |
| | | import org.jfree.data.category.CategoryDataset; |
| | | import org.jfree.data.category.DefaultCategoryDataset; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import org.springframework.web.multipart.commons.CommonsMultipartFile; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.qianwen.core.excel.util.ExcelUtil; |
| | | import com.qianwen.core.mp.base.BaseServiceImpl; |
| | | import com.qianwen.core.oss.model.BladeFile; |
| | | import com.qianwen.core.tool.utils.DateUtil; |
| | | import com.qianwen.smartman.common.enums.DefaultWcsEnum; |
| | | import com.qianwen.smartman.common.utils.DurationUtil; |
| | | import com.qianwen.smartman.modules.resource.builder.oss.OssBuilder; |
| | | import com.qianwen.smartman.modules.smis.entity.Workstation; |
| | | import com.qianwen.smartman.modules.smis.mapper.WorkstationMapper; |
| | | import com.qianwen.smartman.modules.workinghour.entity.PartWorkingHour; |
| | | import com.qianwen.smartman.modules.workinghour.entity.PartWorkingProcess; |
| | | import com.qianwen.smartman.modules.workinghour.excel.PartWorkingHourExcel; |
| | | import com.qianwen.smartman.modules.workinghour.mapper.PartWorkingHourMapper; |
| | | import com.qianwen.smartman.modules.workinghour.mapper.PartWorkingProcessMapper; |
| | | |
| | | import cn.hutool.core.date.LocalDateTimeUtil; |
| | | |
| | | @Service |
| | | public class PartWorkingHourExportService extends BaseServiceImpl<PartWorkingHourMapper, PartWorkingHour> { |
| | | |
| | | @Autowired |
| | | private PartWorkingHourMapper partWorkingHourMapper; |
| | | @Autowired |
| | | private WorkstationMapper workstationMapper; |
| | | @Autowired |
| | | private PartWorkingProcessMapper partWorkingProcessMapper; |
| | | @Autowired |
| | | private OssBuilder ossBuilder; |
| | | |
| | | /** |
| | | * 导åºä¸æ¡æ°æ® |
| | | * |
| | | * @param id |
| | | * @return |
| | | * @throws IOException |
| | | */ |
| | | @Transactional(readOnly = true) |
| | | public BladeFile export(long id) throws Exception { |
| | | // QueryWrapper<PartWorkingProcess> wrapper = new QueryWrapper<>(); |
| | | // wrapper.lambda().eq(PartWorkingProcess::getWorkinghourId, id); |
| | | |
| | | // xx工件å¨xæºåº |
| | | PartWorkingHour partWorkingHour = partWorkingHourMapper.selectById(id); |
| | | Workstation ws = workstationMapper.selectById(partWorkingHour.getWorkstationId()); |
| | | String fileName = String.format("é¶ä»¶%sçå·¥æ¶æ°æ®-%s.xlsx", partWorkingHour.getPartNo(), DateUtil.time()); |
| | | |
| | | PartWorkingHourExcel excelObj = new PartWorkingHourExcel(); |
| | | excelObj.setPartNo(partWorkingHour.getPartNo()); |
| | | excelObj.setAmount(partWorkingHour.getAmount()); |
| | | |
| | | LocalDateTime start = LocalDateTime.now(); |
| | | LocalDateTime end; |
| | | Duration duration; |
| | | if (partWorkingHour.getClampingSecs() != null) { |
| | | end = start.plusSeconds(partWorkingHour.getClampingSecs()); |
| | | duration = Duration.between(start, end); |
| | | excelObj.setClampingSecs(DurationUtil.toChineseDuration(duration)); |
| | | } |
| | | final String format = "yyyy-MM-dd:hh:mm:ss"; |
| | | if (partWorkingHour.getEndTime() != null) { |
| | | excelObj.setEndTime(LocalDateTimeUtil.format(partWorkingHour.getEndTime(), format)); |
| | | } |
| | | |
| | | if (partWorkingHour.getFirstMeasureSecs() != null) { |
| | | end = start.plusSeconds(partWorkingHour.getFirstMeasureSecs()); |
| | | duration = Duration.between(start, end); |
| | | excelObj.setFirstMeasureSecs(DurationUtil.toChineseDuration(duration)); |
| | | } |
| | | |
| | | if (partWorkingHour.getFirstWorkingSecs() != null) { |
| | | end = start.plusSeconds(partWorkingHour.getFirstWorkingSecs()); |
| | | duration = Duration.between(start, end); |
| | | excelObj.setFirstWorkingSecs(DurationUtil.toChineseDuration(duration)); |
| | | } |
| | | |
| | | if (partWorkingHour.getLastRemoveSecs() != null) { |
| | | end = start.plusSeconds(partWorkingHour.getLastRemoveSecs()); |
| | | duration = Duration.between(start, end); |
| | | excelObj.setLastRemoveSecs(DurationUtil.toChineseDuration(duration)); |
| | | } |
| | | |
| | | if (partWorkingHour.getOccupancySecs() != null) { |
| | | end = start.plusSeconds(partWorkingHour.getOccupancySecs()); |
| | | duration = Duration.between(start, end); |
| | | excelObj.setOccupancySecs(DurationUtil.toChineseDuration(duration)); |
| | | } |
| | | |
| | | excelObj.setPartNo(partWorkingHour.getPartNo()); |
| | | |
| | | if (partWorkingHour.getPrepareSecs() != null) { |
| | | end = start.plusSeconds(partWorkingHour.getPrepareSecs()); |
| | | duration = Duration.between(start, end); |
| | | excelObj.setPrepareSecs(DurationUtil.toChineseDuration(duration)); |
| | | } |
| | | |
| | | if (partWorkingHour.getProcessingSecs() != null) { |
| | | end = start.plusSeconds(partWorkingHour.getProcessingSecs()); |
| | | duration = Duration.between(start, end); |
| | | excelObj.setProcessingSecs(DurationUtil.toChineseDuration(duration)); |
| | | } |
| | | |
| | | excelObj.setProcessNo(partWorkingHour.getProcessNo()); |
| | | |
| | | if (partWorkingHour.getSingleProcessSecs() != null) { |
| | | end = start.plusSeconds(partWorkingHour.getSingleProcessSecs()); |
| | | duration = Duration.between(start, end); |
| | | excelObj.setSingleProcessSecs(DurationUtil.toChineseDuration(duration)); |
| | | } |
| | | |
| | | excelObj.setStartTime(LocalDateTimeUtil.format(partWorkingHour.getStartTime(), format)); |
| | | |
| | | excelObj.setWorkstationName(ws.getName()); |
| | | |
| | | excelObj.setVersion(partWorkingHour.getVersion()); |
| | | |
| | | MultipartFile multipartFile = ExcelUtil.exportToMultipartFile(fileName, "é¶ä»¶å·¥æ¶", Arrays.asList(excelObj), |
| | | PartWorkingHourExcel.class); |
| | | |
| | | MultipartFile multipartFile2 = writeChart(id,multipartFile); |
| | | |
| | | BladeFile bladeFile = this.ossBuilder.tempTemplate().putFile(multipartFile2.getOriginalFilename(), |
| | | multipartFile2); |
| | | return bladeFile; |
| | | } |
| | | |
| | | /** |
| | | * å建å¾è¡¨ |
| | | * @param workinghourId |
| | | * @param multipartFile |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | MultipartFile writeChart(long workinghourId,MultipartFile multipartFile) throws Exception { |
| | | XSSFWorkbook workbook = new XSSFWorkbook(multipartFile.getInputStream()); |
| | | |
| | | byte[] chartBytes = barChart(workinghourId); |
| | | addPicture(workbook, chartBytes); |
| | | |
| | | DiskFileItemFactory factory = new DiskFileItemFactory(); |
| | | factory.setRepository(new File(System.getProperty("java.io.tmpdir"))); |
| | | |
| | | FileItem fileItem = factory.createItem("excel", multipartFile.getContentType(), true, |
| | | multipartFile.getOriginalFilename()); |
| | | |
| | | workbook.write(fileItem.getOutputStream()); |
| | | workbook.close(); |
| | | |
| | | return new CommonsMultipartFile(fileItem); |
| | | |
| | | } |
| | | |
| | | public static void addPicture(XSSFWorkbook wb, byte[] bytes) { |
| | | XSSFSheet sheet = wb.getSheetAt(0); |
| | | // ç»å¾ç顶级管çå¨ï¼ä¸ä¸ªsheetåªè½è·åä¸ä¸ªï¼ä¸å®è¦æ³¨æè¿ç¹ï¼ |
| | | // HSSFPatriarch patriarch = sheet.createDrawingPatriarch(); |
| | | XSSFDrawing patriarch = sheet.createDrawingPatriarch(); |
| | | // 设置å¾çä½ç½® |
| | | // å
«ä¸ªåæ°, åå个表示å¾ç离起å§åå
æ ¼åç»æåå
æ ¼è¾¹ç¼çä½ç½®ï¼ |
| | | // åå个表示起å§åç»æåå
æ ¼çä½ç½®, å¦ä¸è¡¨ç¤ºä»ç¬¬2åå°ç¬¬12å, ä»ç¬¬1è¡å°ç¬¬15è¡,éè¦æ³¨æexcelèµ·å§ä½ç½®æ¯0 |
| | | // {0,0,0,0,2,1,12,15}表示ä»ç¬¬2åå°ç¬¬12åï¼ä»ç¬¬1è¡å°ç¬¬15è¡ï¼åå
æ ¼å
é¨çè¾¹è·é½æ¯0 |
| | | // {0,0,0,0,1,4,20,5}表示ä»ç¬¬2åå°ç¬¬12åï¼ä»ç¬¬1è¡å°ç¬¬15è¡ï¼åå
æ ¼å
é¨çè¾¹è·é½æ¯0 |
| | | // HSSFClientAnchor anchor = new HSSFClientAnchor(anchors[0], anchors[1], |
| | | // anchors[2], anchors[3], (short) anchors[4], anchors[5], (short) anchors[6], |
| | | // anchors[7]); |
| | | |
| | | XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, 0, 3, 30, 10); // 1å-30åï¼3è¡-10è¡ |
| | | anchor.setAnchorType(AnchorType.DONT_MOVE_AND_RESIZE); |
| | | // æå
¥å¾ç |
| | | int pictureIndex = wb.addPicture(bytes, XSSFWorkbook.PICTURE_TYPE_JPEG); |
| | | // XSSFWorkbook.PICTURE_TYPE_JPEG |
| | | patriarch.createPicture(anchor, pictureIndex); |
| | | } |
| | | |
| | | public byte[] barChart(long workinghourId) throws Exception { |
| | | |
| | | // 设置æ±åæ¾ç¤ºå¯¹åºçæ°å¼ |
| | | |
| | | QueryWrapper<PartWorkingProcess> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda().eq(PartWorkingProcess::getWorkinghourId, workinghourId).orderByAsc(PartWorkingProcess::getStartTime); |
| | | List<PartWorkingProcess> processList = partWorkingProcessMapper.selectList(wrapper); |
| | | |
| | | // æ¯ææ ç¾æ¾ç¤ºçææåæ°æ® |
| | | List<List<Object>> dataList = new ArrayList<>(); |
| | | |
| | | Duration duration; |
| | | PartWorkingProcess process; |
| | | for(int i=0;i<processList.size();i++) { |
| | | //dataList.add(new ArrayList<>(Arrays.asList(133))); |
| | | process = processList.get(i); |
| | | duration = Duration.between(process.getStartTime(), process.getEndTime()); |
| | | dataList.add(Arrays.asList(duration.getSeconds())); |
| | | |
| | | //dataTable.add(new ArrayList<>(Arrays.asList(process.getProgName(), duration.getSeconds(), process.getDeviceStatus()))); |
| | | } |
| | | |
| | | JFreeChart chart = createStackedBarChart(workinghourId,"å 工记å½", dataList,processList, |
| | | JFreeChartUtil.createChartTheme("å®ä½"), "ç§", ""); |
| | | StackedBarRenderer renderer = new StackedBarRenderer(); |
| | | CategoryPlot plot = chart.getCategoryPlot(); |
| | | plot.setOutlineVisible(true); |
| | | |
| | | |
| | | //dataTable.add(new ArrayList<>(Arrays.asList("YZL4-1100-01-50-A-2-2", 242, "è¿è¡"))); |
| | | |
| | | renderer.setDefaultItemLabelsVisible(true); |
| | | renderer.setDefaultItemLabelGenerator(new MyCategoryItemLabelGenerator(processList)); |
| | | |
| | | renderer.setMaximumBarWidth(0.3); |
| | | |
| | | // æ±åé¢è²,æå 段就setå 个 |
| | | Color color; |
| | | String colorStr; |
| | | DefaultWcsEnum wcsEnum; |
| | | for(int i=0;i<processList.size();i++) { |
| | | process = processList.get(i); |
| | | //if(dataTable.get(i)) |
| | | //color = |
| | | wcsEnum = DefaultWcsEnum.of(process.getDeviceStatus()); |
| | | colorStr = StringUtils.removeStart(wcsEnum.getColor(), '#'); |
| | | color = new Color(Integer.parseInt(colorStr, 16)); |
| | | renderer.setSeriesPaint(i, color); |
| | | } |
| | | //renderer.setSeriesPaint(0, Color.green); |
| | | //renderer.setSeriesPaint(1, Color.yellow); |
| | | |
| | | ItemLabelPosition posi = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.HALF_ASCENT_CENTER); |
| | | //renderer.setDefaultNegativeItemLabelPosition(posi); |
| | | renderer.setDefaultPositiveItemLabelPosition(posi); |
| | | |
| | | int offset = 10; |
| | | renderer.setItemLabelInsets(new RectangleInsets(0, offset, offset, offset)); |
| | | plot.setRenderer(renderer); |
| | | |
| | | java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream(); |
| | | |
| | | ChartUtils.writeChartAsJPEG(bos, 1.0f, chart, 4096, 400, null); |
| | | |
| | | return bos.toByteArray(); |
| | | } |
| | | |
| | | /** |
| | | * å建å å æ±ç¶å¾ |
| | | * @param workinghourId |
| | | * @param chartTitle |
| | | * @param legendNameList |
| | | * @param xAxisNameList |
| | | * @param dataList |
| | | * @param theme |
| | | * @param yAxisTitle |
| | | * @param xAxisTitle |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | JFreeChart createStackedBarChart(long workinghourId,String chartTitle, List<List<Object>> dataList,List<PartWorkingProcess> processList, |
| | | StandardChartTheme theme, String yAxisTitle, String xAxisTitle) |
| | | throws Exception { |
| | | |
| | | |
| | | // 设置主é¢ï¼é²æ¢ä¸æä¹±ç |
| | | theme = theme == null ? JFreeChartUtil.createChartTheme("") : theme; |
| | | ChartFactory.setChartTheme(theme); |
| | | |
| | | boolean showLegend =false; |
| | | //List<String> pnamelist = processList.stream().map(p -> p.getProgName()).collect(Collectors.toList()); |
| | | |
| | | //DefaultCategoryDataset dataset = JFreeChartUtil.createDefaultCategoryDataset(pnamelist, Arrays.asList("xname"), dataList); |
| | | DefaultCategoryDataset dataset = createDataSet(processList); |
| | | JFreeChart chart = ChartFactory.createStackedBarChart(chartTitle, xAxisTitle, yAxisTitle, |
| | | dataset, |
| | | PlotOrientation.HORIZONTAL, showLegend, true, false); |
| | | // 设置æé¯é½¿ï¼é²æ¢å使¾ç¤ºä¸æ¸
æ¥ |
| | | chart.setTextAntiAlias(false); |
| | | // 对æ±åè¿è¡æ¸²æ |
| | | JFreeChartUtil.setBarRenderer(chart.getCategoryPlot(), true); |
| | | |
| | | //showLegend=falseæ
åµä¸ï¼ä¸å代ç ä¼å¼èµ·NPE |
| | | // è®¾ç½®æ æ³¨æ è¾¹æ¡ |
| | | //chart.getLegend().setFrame(new BlockBorder(Color.WHITE)); |
| | | // æ æ³¨ä½äºä¸ä¾§ |
| | | //chart.getLegend().setPosition(RectangleEdge.TOP); |
| | | |
| | | return chart; |
| | | } |
| | | |
| | | DefaultCategoryDataset createDataSet(List<PartWorkingProcess> processList){ |
| | | DefaultCategoryDataset dataset = new DefaultCategoryDataset(); |
| | | PartWorkingProcess p; |
| | | for (int xAxisIndex = 0; xAxisIndex < processList.size(); xAxisIndex++) { |
| | | p = processList.get(xAxisIndex); |
| | | //String value = rowList.get(xAxisIndex).toString(); |
| | | String value =p.getStartTime().toString(); |
| | | Duration duration = Duration.between(p.getStartTime(), p.getEndTime()); |
| | | value = duration.getSeconds()+""; |
| | | dataset.setValue(Double.parseDouble(value), xAxisIndex+"", "ç¨åºæ¶æ®µ"); |
| | | } |
| | | |
| | | return dataset; |
| | | } |
| | | } |
| | | |
| | | //èªå®ä¹æ ç¾çæ |
| | | class MyCategoryItemLabelGenerator extends AbstractCategoryItemLabelGenerator implements CategoryItemLabelGenerator { |
| | | // private final Integer category; |
| | | private List<PartWorkingProcess> dataTable; |
| | | |
| | | public MyCategoryItemLabelGenerator(List<PartWorkingProcess> dataTable) { |
| | | super("", NumberFormat.getInstance()); |
| | | this.dataTable = dataTable; |
| | | } |
| | | |
| | | @Override |
| | | public String generateLabel(CategoryDataset dataset, int row, int column) { |
| | | //Number val = dataset.getValue(row, column); |
| | | |
| | | PartWorkingProcess dataRow = this.dataTable.get(row); |
| | | // dataset. |
| | | /* |
| | | ALARM(1, "æ¥è¦"), |
| | | RUNNING(2, "è¿è¡"), |
| | | STANDBY(3, "å¾
æº"), |
| | | OFFLINE(4, "离线"), |
| | | DEBUGGING(5, "è°è¯"); |
| | | */ |
| | | |
| | | //DefaultWcsEnum wcsEnum = DefaultWcsEnum.of(dataRow.getDeviceStatus()); |
| | | //return dataRow.getProgName() + ",:" + val + "," + wcsEnum.getName(); |
| | | Duration duration = Duration.between(dataRow.getStartTime(), dataRow.getEndTime()); |
| | | return dataRow.getProgName() + "," + DurationUtil.toChineseDuration(duration); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.smartman.modules.workinghour.service; |
| | | |
| | | import java.time.Duration; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.qianwen.core.excel.util.ExcelUtil; |
| | | import com.qianwen.core.mp.base.BaseServiceImpl; |
| | | import com.qianwen.core.oss.model.BladeFile; |
| | | import com.qianwen.core.tool.utils.DateUtil; |
| | | import com.qianwen.smartman.common.enums.DefaultWcsEnum; |
| | | import com.qianwen.smartman.common.utils.DurationUtil; |
| | | import com.qianwen.smartman.modules.resource.builder.oss.OssBuilder; |
| | | import com.qianwen.smartman.modules.smis.entity.Workstation; |
| | | import com.qianwen.smartman.modules.smis.mapper.WorkstationMapper; |
| | | import com.qianwen.smartman.modules.workinghour.entity.PartWorkingHour; |
| | | import com.qianwen.smartman.modules.workinghour.entity.PartWorkingProcess; |
| | | import com.qianwen.smartman.modules.workinghour.excel.PartWorkingHourExcel; |
| | | import com.qianwen.smartman.modules.workinghour.excel.PartWorkingProcessExcel; |
| | | import com.qianwen.smartman.modules.workinghour.mapper.PartWorkingHourMapper; |
| | | import com.qianwen.smartman.modules.workinghour.vo.PartWorkingHourVO; |
| | | |
| | | import cn.hutool.core.date.LocalDateTimeUtil; |
| | | |
| | | @Service |
| | | public class PartWorkingHourService extends BaseServiceImpl<PartWorkingHourMapper, PartWorkingHour>{ |
| | | |
| | | @Autowired |
| | | private PartWorkingHourMapper partWorkingHourMapper; |
| | | @Autowired |
| | | private WorkstationMapper workstationMapper; |
| | | @Autowired |
| | | private OssBuilder ossBuilder; |
| | | |
| | | @Transactional(readOnly=true) |
| | | public IPage<PartWorkingHourVO> listPage(IPage<PartWorkingHourVO> workstationVOIPage, String partNo, String workstationName, LocalDate startDate, LocalDate endDate) { |
| | | |
| | | List<PartWorkingHourVO> workstationVOS = this.partWorkingHourMapper.listPage(workstationVOIPage, partNo, workstationName, startDate, endDate); |
| | | |
| | | return workstationVOIPage.setRecords(workstationVOS); |
| | | } |
| | | |
| | | |
| | | @Transactional(readOnly=true) |
| | | public List<PartWorkingHourVO> listVOByIds(List<Long> ids) { |
| | | return partWorkingHourMapper.listVOByIds(ids); |
| | | } |
| | | |
| | | /** |
| | | * 导åºä¸æ¡æ°æ® |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Transactional(readOnly=true) |
| | | public BladeFile export(long id) { |
| | | //QueryWrapper<PartWorkingProcess> wrapper = new QueryWrapper<>(); |
| | | //wrapper.lambda().eq(PartWorkingProcess::getWorkinghourId, id); |
| | | |
| | | //xx工件å¨xæºåº |
| | | PartWorkingHour partWorkingHour = partWorkingHourMapper.selectById(id); |
| | | Workstation ws = workstationMapper.selectById(partWorkingHour.getWorkstationId()); |
| | | String fileName = String.format("é¶ä»¶%sçå·¥æ¶æ°æ®-%s.xlsx", partWorkingHour.getPartNo(), DateUtil.time()); |
| | | |
| | | PartWorkingHourExcel excelObj = new PartWorkingHourExcel(); |
| | | excelObj.setPartNo(partWorkingHour.getPartNo()); |
| | | excelObj.setAmount(partWorkingHour.getAmount()); |
| | | |
| | | LocalDateTime start = LocalDateTime.now(); |
| | | LocalDateTime end; |
| | | Duration duration; |
| | | if(partWorkingHour.getClampingSecs() !=null) { |
| | | end = start.plusSeconds(partWorkingHour.getClampingSecs()); |
| | | duration = Duration.between(start, end); |
| | | excelObj.setClampingSecs(DurationUtil.toChineseDuration(duration)); |
| | | } |
| | | final String format = "yyyy-MM-dd:hh:mm:ss"; |
| | | if(partWorkingHour.getEndTime() !=null) { |
| | | excelObj.setEndTime(LocalDateTimeUtil.format(partWorkingHour.getEndTime(),format)); |
| | | } |
| | | |
| | | if(partWorkingHour.getFirstMeasureSecs() !=null) { |
| | | end = start.plusSeconds(partWorkingHour.getFirstMeasureSecs()); |
| | | duration = Duration.between(start, end); |
| | | excelObj.setFirstMeasureSecs(DurationUtil.toChineseDuration(duration)); |
| | | } |
| | | |
| | | if(partWorkingHour.getFirstWorkingSecs() !=null) { |
| | | end = start.plusSeconds(partWorkingHour.getFirstWorkingSecs()); |
| | | duration = Duration.between(start, end); |
| | | excelObj.setFirstWorkingSecs(DurationUtil.toChineseDuration(duration)); |
| | | } |
| | | |
| | | if(partWorkingHour.getLastRemoveSecs() !=null) { |
| | | end = start.plusSeconds(partWorkingHour.getLastRemoveSecs()); |
| | | duration = Duration.between(start, end); |
| | | excelObj.setLastRemoveSecs(DurationUtil.toChineseDuration(duration)); |
| | | } |
| | | |
| | | if(partWorkingHour.getOccupancySecs() !=null) { |
| | | end = start.plusSeconds(partWorkingHour.getOccupancySecs()); |
| | | duration = Duration.between(start, end); |
| | | excelObj.setOccupancySecs(DurationUtil.toChineseDuration(duration)); |
| | | } |
| | | |
| | | excelObj.setPartNo(partWorkingHour.getPartNo()); |
| | | |
| | | if(partWorkingHour.getPrepareSecs() !=null) { |
| | | end = start.plusSeconds(partWorkingHour.getPrepareSecs()); |
| | | duration = Duration.between(start, end); |
| | | excelObj.setPrepareSecs(DurationUtil.toChineseDuration(duration)); |
| | | } |
| | | |
| | | if(partWorkingHour.getProcessingSecs() !=null) { |
| | | end = start.plusSeconds(partWorkingHour.getProcessingSecs()); |
| | | duration = Duration.between(start, end); |
| | | excelObj.setProcessingSecs(DurationUtil.toChineseDuration(duration)); |
| | | } |
| | | |
| | | excelObj.setProcessNo(partWorkingHour.getProcessNo()); |
| | | |
| | | if(partWorkingHour.getSingleProcessSecs() !=null) { |
| | | end = start.plusSeconds(partWorkingHour.getSingleProcessSecs()); |
| | | duration = Duration.between(start, end); |
| | | excelObj.setSingleProcessSecs(DurationUtil.toChineseDuration(duration)); |
| | | } |
| | | |
| | | excelObj.setStartTime(LocalDateTimeUtil.format(partWorkingHour.getStartTime(),format)); |
| | | |
| | | |
| | | excelObj.setWorkstationName(ws.getName()); |
| | | |
| | | excelObj.setVersion(partWorkingHour.getVersion()); |
| | | |
| | | MultipartFile multipartFile = ExcelUtil.exportToMultipartFile(fileName, "é¶ä»¶å·¥æ¶", Arrays.asList(excelObj), PartWorkingHourExcel.class); |
| | | BladeFile bladeFile = this.ossBuilder.tempTemplate().putFile(multipartFile.getOriginalFilename(), multipartFile); |
| | | return bladeFile; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.smartman.modules.workinghour.service; |
| | | |
| | | import java.time.Duration; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import org.apache.commons.beanutils.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.qianwen.core.excel.util.ExcelUtil; |
| | | import com.qianwen.core.oss.model.BladeFile; |
| | | import com.qianwen.core.tool.utils.DateUtil; |
| | | import com.qianwen.smartman.common.enums.DefaultWcsEnum; |
| | | import com.qianwen.smartman.common.utils.DurationUtil; |
| | | import com.qianwen.smartman.modules.resource.builder.oss.OssBuilder; |
| | | import com.qianwen.smartman.modules.smis.entity.Workstation; |
| | | import com.qianwen.smartman.modules.smis.excel.WorkstationExcel; |
| | | import com.qianwen.smartman.modules.smis.mapper.WorkstationMapper; |
| | | import com.qianwen.smartman.modules.workinghour.convert.PartWorkingProcessConvert; |
| | | import com.qianwen.smartman.modules.workinghour.entity.PartWorkingHour; |
| | | import com.qianwen.smartman.modules.workinghour.entity.PartWorkingProcess; |
| | | import com.qianwen.smartman.modules.workinghour.excel.PartWorkingProcessExcel; |
| | | import com.qianwen.smartman.modules.workinghour.mapper.PartWorkingHourMapper; |
| | | import com.qianwen.smartman.modules.workinghour.mapper.PartWorkingProcessMapper; |
| | | import com.qianwen.smartman.modules.workinghour.vo.PartWorkingProcessVO; |
| | | |
| | | @Service |
| | | public class PartWorkingProcessService{ |
| | | |
| | | @Autowired |
| | | private PartWorkingProcessMapper partWorkingProcessMapper; |
| | | @Autowired |
| | | private WorkstationMapper workstationMapper; |
| | | @Autowired |
| | | private PartWorkingHourMapper partWorkingHourMapper; |
| | | @Autowired |
| | | private OssBuilder ossBuilder; |
| | | |
| | | |
| | | @Transactional(readOnly=true) |
| | | public List<PartWorkingProcessVO> listByWorkinghourId(Long workinghourId) { |
| | | QueryWrapper<PartWorkingProcess> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda().eq(PartWorkingProcess::getWorkinghourId, workinghourId).orderByAsc(PartWorkingProcess::getStartTime); |
| | | |
| | | return PartWorkingProcessConvert.INSTANCE.convert(partWorkingProcessMapper.selectList(wrapper)); |
| | | } |
| | | |
| | | /** |
| | | * å å·¥è¿ç¨æ°æ®å¯¼åº |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Transactional(readOnly=true) |
| | | public BladeFile export(long workinghourId) { |
| | | QueryWrapper<PartWorkingProcess> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda().eq(PartWorkingProcess::getWorkinghourId, workinghourId).orderByAsc(PartWorkingProcess::getStartTime); |
| | | List<PartWorkingProcess> data = partWorkingProcessMapper.selectList(wrapper); |
| | | List<PartWorkingProcessExcel> exportList = data.stream().map(p -> { |
| | | PartWorkingProcessExcel e = new PartWorkingProcessExcel(); |
| | | e.setProgName(p.getProgName()); |
| | | e.setStartTime(p.getStartTime().toString()); |
| | | e.setEndTime(p.getEndTime().toString()); |
| | | |
| | | Duration duration = Duration.between(p.getStartTime(), p.getEndTime()); |
| | | e.setDuration(DurationUtil.toChineseDuration(duration)); |
| | | e.setDeviceStateName(DefaultWcsEnum.of(p.getDeviceStatus()).getName()); |
| | | return e; |
| | | }).collect(Collectors.toList()); |
| | | //xx工件å¨xæºåº |
| | | PartWorkingHour partWorkingHour = partWorkingHourMapper.selectById(workinghourId); |
| | | Workstation ws = workstationMapper.selectById(partWorkingHour.getWorkstationId()); |
| | | String fileName = String.format("%sçå 工记å½-%s.xlsx", ws.getName(), DateUtil.time()); |
| | | MultipartFile multipartFile = ExcelUtil.exportToMultipartFile(fileName, "å 工记å½è¡¨", exportList, PartWorkingProcessExcel.class); |
| | | BladeFile bladeFile = this.ossBuilder.tempTemplate().putFile(multipartFile.getOriginalFilename(), multipartFile); |
| | | return bladeFile; |
| | | } |
| | | |
| | | |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.smartman.modules.workinghour.vo; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | |
| | | /** |
| | | * é¶ä»¶å·¥æ¶VO |
| | | */ |
| | | public class PartWorkingHourQueryVO { |
| | | |
| | | @ApiModelProperty("é¶ä»¶ç¼å·") |
| | | private String partNo; |
| | | |
| | | @ApiModelProperty("å·¥ä½åç§°") |
| | | private String workstationName; |
| | | |
| | | @ApiModelProperty("å¼å§æ¶é´") |
| | | private LocalDate startDate; |
| | | |
| | | @ApiModelProperty("ç»ææ¶é´") |
| | | private LocalDate endDate; |
| | | public String getPartNo() { |
| | | return partNo; |
| | | } |
| | | public void setPartNo(String partNo) { |
| | | this.partNo = partNo; |
| | | } |
| | | public String getWorkstationName() { |
| | | return workstationName; |
| | | } |
| | | public void setWorkstationName(String workstationName) { |
| | | this.workstationName = workstationName; |
| | | } |
| | | public LocalDate getStartDate() { |
| | | return startDate; |
| | | } |
| | | public void setStartDate(LocalDate startDate) { |
| | | this.startDate = startDate; |
| | | } |
| | | public LocalDate getEndDate() { |
| | | return endDate; |
| | | } |
| | | public void setEndDate(LocalDate endDate) { |
| | | this.endDate = endDate; |
| | | } |
| | | |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.smartman.modules.workinghour.vo; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | |
| | | /** |
| | | * é¶ä»¶å·¥æ¶VO |
| | | */ |
| | | public class PartWorkingHourVO { |
| | | |
| | | long id; |
| | | /** |
| | | * é¶ä»¶ç¼å· |
| | | */ |
| | | @ApiModelProperty("é¶ä»¶ç¼å·") |
| | | private String partNo; |
| | | |
| | | @ApiModelProperty("å·¥åºå·") |
| | | private String processNo; |
| | | |
| | | @ApiModelProperty("çæ¬¡") |
| | | private String version; |
| | | |
| | | @ApiModelProperty("å·¥ä½id") |
| | | private long workstationId; |
| | | |
| | | @ApiModelProperty("å·¥ä½åç§°") |
| | | private String workstationName; |
| | | |
| | | @ApiModelProperty("å¼å§æ¶é´") |
| | | private LocalDateTime startTime; |
| | | |
| | | @ApiModelProperty("ç»ææ¶é´") |
| | | private LocalDateTime endTime; |
| | | |
| | | @ApiModelProperty("å æºæ¶é´(ç§)") |
| | | private Long occupancySecs; |
| | | |
| | | @ApiModelProperty("è£
夹è°è¯æ¶é´(ç§)") |
| | | private Long clampingSecs; |
| | | |
| | | @ApiModelProperty("é¦ä»¶ååæ¶é´(ç§)") |
| | | private Long firstWorkingSecs; |
| | | |
| | | @ApiModelProperty("æ«ä»¶æå¸æ¶é´(ç§)") |
| | | private Long lastRemoveSecs; |
| | | |
| | | @ApiModelProperty("é¦ä»¶è®¡éæ¶é´(ç§)") |
| | | private Long firstMeasureSecs; |
| | | |
| | | @ApiModelProperty("å å·¥æ¶é´(ç§)") |
| | | private Long processingSecs; |
| | | |
| | | @ApiModelProperty("å夿¶é´(ç§)") |
| | | private Long prepareSecs; |
| | | |
| | | @ApiModelProperty(" åä»¶å·¥æ¶(ç§)") |
| | | private Long singleProcessSecs; |
| | | |
| | | @ApiModelProperty("æ°é") |
| | | private Long amount; |
| | | |
| | | public long getId() { |
| | | return id; |
| | | } |
| | | public void setId(long id) { |
| | | this.id = id; |
| | | } |
| | | public String getPartNo() { |
| | | return partNo; |
| | | } |
| | | public void setPartNo(String partNo) { |
| | | this.partNo = partNo; |
| | | } |
| | | public String getProcessNo() { |
| | | return processNo; |
| | | } |
| | | public void setProcessNo(String processNo) { |
| | | this.processNo = processNo; |
| | | } |
| | | public String getVersion() { |
| | | return version; |
| | | } |
| | | public void setVersion(String version) { |
| | | this.version = version; |
| | | } |
| | | public long getWorkstationId() { |
| | | return workstationId; |
| | | } |
| | | public void setWorkstationId(long workstationId) { |
| | | this.workstationId = workstationId; |
| | | } |
| | | public LocalDateTime getStartTime() { |
| | | return startTime; |
| | | } |
| | | public void setStartTime(LocalDateTime startTime) { |
| | | this.startTime = startTime; |
| | | } |
| | | public LocalDateTime getEndTime() { |
| | | return endTime; |
| | | } |
| | | public void setEndTime(LocalDateTime endTime) { |
| | | this.endTime = endTime; |
| | | } |
| | | public Long getOccupancySecs() { |
| | | return occupancySecs; |
| | | } |
| | | public void setOccupancySecs(Long occupancySecs) { |
| | | this.occupancySecs = occupancySecs; |
| | | } |
| | | public Long getClampingSecs() { |
| | | return clampingSecs; |
| | | } |
| | | public void setClampingSecs(Long clampingSecs) { |
| | | this.clampingSecs = clampingSecs; |
| | | } |
| | | public Long getFirstWorkingSecs() { |
| | | return firstWorkingSecs; |
| | | } |
| | | public void setFirstWorkingSecs(Long firstWorkingSecs) { |
| | | this.firstWorkingSecs = firstWorkingSecs; |
| | | } |
| | | public Long getLastRemoveSecs() { |
| | | return lastRemoveSecs; |
| | | } |
| | | public void setLastRemoveSecs(Long lastRemoveSecs) { |
| | | this.lastRemoveSecs = lastRemoveSecs; |
| | | } |
| | | public Long getFirstMeasureSecs() { |
| | | return firstMeasureSecs; |
| | | } |
| | | public void setFirstMeasureSecs(Long firstMeasureSecs) { |
| | | this.firstMeasureSecs = firstMeasureSecs; |
| | | } |
| | | public Long getPrepareSecs() { |
| | | return prepareSecs; |
| | | } |
| | | public void setPrepareSecs(Long prepareSecs) { |
| | | this.prepareSecs = prepareSecs; |
| | | } |
| | | public Long getSingleProcessSecs() { |
| | | return singleProcessSecs; |
| | | } |
| | | public void setSingleProcessSecs(Long singleProcessSecs) { |
| | | this.singleProcessSecs = singleProcessSecs; |
| | | } |
| | | public Long getAmount() { |
| | | return amount; |
| | | } |
| | | public void setAmount(Long amount) { |
| | | this.amount = amount; |
| | | } |
| | | public String getWorkstationName() { |
| | | return workstationName; |
| | | } |
| | | public void setWorkstationName(String workstationName) { |
| | | this.workstationName = workstationName; |
| | | } |
| | | public Long getProcessingSecs() { |
| | | return processingSecs; |
| | | } |
| | | public void setProcessingSecs(Long processingSecs) { |
| | | this.processingSecs = processingSecs; |
| | | } |
| | | |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.smartman.modules.workinghour.vo; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | |
| | | /** |
| | | * é¶ä»¶å·¥æ¶VO |
| | | */ |
| | | public class PartWorkingProcessVO { |
| | | |
| | | long id; |
| | | |
| | | @ApiModelProperty("ç¨åºåç§°") |
| | | private String progName; |
| | | |
| | | @ApiModelProperty("å·¥æ¶è¡¨id") |
| | | private long workinghourId; |
| | | |
| | | @ApiModelProperty("å¼å§æ¶é´") |
| | | private LocalDateTime startTime; |
| | | |
| | | @ApiModelProperty("ç»ææ¶é´") |
| | | private LocalDateTime endTime; |
| | | @ApiModelProperty("设å¤ç¶æ") |
| | | private Integer deviceStatus; |
| | | |
| | | public long getId() { |
| | | return id; |
| | | } |
| | | public void setId(long id) { |
| | | this.id = id; |
| | | } |
| | | public String getProgName() { |
| | | return progName; |
| | | } |
| | | public void setProgName(String progName) { |
| | | this.progName = progName; |
| | | } |
| | | public long getWorkinghourId() { |
| | | return workinghourId; |
| | | } |
| | | public void setWorkinghourId(long workinghourId) { |
| | | this.workinghourId = workinghourId; |
| | | } |
| | | public LocalDateTime getStartTime() { |
| | | return startTime; |
| | | } |
| | | public void setStartTime(LocalDateTime startTime) { |
| | | this.startTime = startTime; |
| | | } |
| | | public LocalDateTime getEndTime() { |
| | | return endTime; |
| | | } |
| | | public void setEndTime(LocalDateTime endTime) { |
| | | this.endTime = endTime; |
| | | } |
| | | public Integer getDeviceStatus() { |
| | | return deviceStatus; |
| | | } |
| | | public void setDeviceStatus(Integer deviceStatus) { |
| | | this.deviceStatus = deviceStatus; |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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.qianwen.smartman.modules.workinghour.mapper.PartWorkingHourMapper"> |
| | | |
| | | |
| | | <select id="listPage" resultType="com.qianwen.smartman.modules.workinghour.vo.PartWorkingHourVO"> |
| | | SELECT |
| | | h.id, |
| | | h.part_no, |
| | | process_no, |
| | | version, |
| | | workstation_id, |
| | | ws.name as workstation_name, |
| | | start_time, |
| | | end_time, |
| | | occupancy_secs, |
| | | clamping_secs, |
| | | first_working_secs, |
| | | last_remove_secs, |
| | | first_measure_secs, |
| | | processing_secs, |
| | | prepare_secs, |
| | | single_process_secs, |
| | | h.amount |
| | | FROM part_workinghour h |
| | | LEFT JOIN blade_workstation ws on h.workstation_id=ws.id |
| | | |
| | | <where> |
| | | h.is_deleted = 0 |
| | | <if test="partNo != null"> |
| | | and h.part_no like concat('%',#{partNo,jdbcType=VARCHAR},'%') |
| | | </if> |
| | | <if test="startDate != null"> |
| | | and h.start_time >= #{startDate} |
| | | </if> |
| | | <if test="endDate != null"> |
| | | and h.start_time < date_add(#{endDate}, INTERVAL 1 day) |
| | | </if> |
| | | </where> |
| | | ORDER BY h.start_time DESC |
| | | </select> |
| | | |
| | | <select id="listVOByIds" resultType="com.qianwen.smartman.modules.workinghour.vo.PartWorkingHourVO"> |
| | | SELECT |
| | | h.id, |
| | | h.part_no, |
| | | process_no, |
| | | version, |
| | | workstation_id, |
| | | ws.name as workstation_name, |
| | | start_time, |
| | | end_time, |
| | | occupancy_secs, |
| | | clamping_secs, |
| | | first_working_secs, |
| | | last_remove_secs, |
| | | first_measure_secs, |
| | | processing_secs, |
| | | prepare_secs, |
| | | single_process_secs, |
| | | h.amount |
| | | FROM part_workinghour h |
| | | LEFT JOIN blade_workstation ws on h.workstation_id=ws.id |
| | | |
| | | where h.id in |
| | | <foreach collection="ids" item="id" open="(" separator="," close=")"> |
| | | #{id} |
| | | </foreach> |
| | | |
| | | ORDER BY h.start_time DESC |
| | | </select> |
| | | |
| | | </mapper> |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | [{"prop":"dpUnit","label":"åä½"},{"prop":"ruleContent","label":"计ç®è§å","describe":"计ç®è§åæ¥æºäº[è§å管ç-计ç®è§å]ï¼éè¿luaèæ¬ç¼å计ç®è§åï¼å¯¹æ°æ®ç¹çåå§æ°æ®è¿è¡è®¡ç®ï¼çææ°çæ°æ®ç¹åæ°æ®ç¹å¼ã","sendCode":1,"isReqOptions":true,"type":"option","options":["s7status_trans"]},{"prop":"ruleArgs","label":"计ç®åæ°","describe":"æ ¹æ®è®¡ç®è§åï¼å¡«å计ç®åæ°ï¼å¤ä¸ªè®¡ç®åæ°ç¨è±æâï¼âéå¼ï¼æ³¨æ:dpValue为ééå°çå¼ä¸éè¦å¡«åã","sendCode":1},{"prop":"access","isRequired":true,"sendCode":1,"label":"æé","describe":"读åæé\\n RO(åªè¯»)ï¼åªå
许读åç¹ä½æ°æ®ã\\nRW(读/å)ï¼æ¢è½è¯»åæ°æ®ä¹è½åå
¥æ°æ®ã","default":"RO","type":"option","options":["RO","RW"]},{"prop":"pollingInterval","isRequired":true,"label":"轮询é´éï¼msï¼","describe":"轮询é´éï¼msï¼","default":1000},{"prop":"keepOriginalValue","isRequired":true,"sendCode":1,"label":"ä¿çåå§å¼","describe":"ä¿çåå§å¼","default":true,"type":"boolean"},{"prop":"isSave","isRequired":true,"sendCode":1,"label":"æ¯å¦åå¨","describe":"æ¯å¦åå¨","default":true,"type":"boolean"}] |
| | |
| | | [{"prop":"dpUnit","label":"åä½"},{"prop":"ruleContent","label":"计ç®è§å","describe":"计ç®è§åæ¥æºäº[è§å管ç-计ç®è§å]ï¼éè¿luaèæ¬ç¼å计ç®è§åï¼å¯¹æ°æ®ç¹çåå§æ°æ®è¿è¡è®¡ç®ï¼çææ°çæ°æ®ç¹åæ°æ®ç¹å¼ã","sendCode":1,"isReqOptions":true,"type":"option","options":["s7status_trans"]},{"prop":"ruleArgs","label":"计ç®åæ°","describe":"æ ¹æ®è®¡ç®è§åï¼å¡«å计ç®åæ°ï¼å¤ä¸ªè®¡ç®åæ°ç¨è±æâï¼âéå¼ï¼æ³¨æ:dpValue为ééå°çå¼ä¸éè¦å¡«åã","sendCode":1},{"prop":"access","isRequired":true,"sendCode":1,"label":"æé","describe":"读åæé\\n RO(åªè¯»)ï¼åªå
许读åç¹ä½æ°æ®ã\\nRW(读/å)ï¼æ¢è½è¯»åæ°æ®ä¹è½åå
¥æ°æ®ã","default":"RO","type":"option","options":["RO","RW"]},{"prop":"pollingInterval","isRequired":true,"label":"轮询é´éï¼msï¼","describe":"轮询é´éï¼msï¼","default":1000},{"prop":"keepOriginalValue","isRequired":true,"sendCode":1,"label":"ä¿çåå§å¼","describe":"ä¿çåå§å¼","default":true,"type":"boolean"},{"prop":"isSave","isRequired":true,"sendCode":1,"label":"æ¯å¦åå¨","describe":"æ¯å¦åå¨","default":true,"type":"boolean"}] |
| | | [{"prop":"dpUnit","label":"åä½"},{"prop":"access","isRequired":true,"sendCode":1,"label":"æé","describe":"读åæé\\n RO(åªè¯»)ï¼åªå
许读åç¹ä½æ°æ®ã\\nRW(读/å)ï¼æ¢è½è¯»åæ°æ®ä¹è½åå
¥æ°æ®ã","default":"RO","type":"option","options":["RO","RW"]},{"prop":"pollingInterval","isRequired":true,"label":"轮询é´éï¼msï¼","describe":"轮询é´éï¼msï¼","default":1000},{"prop":"keepOriginalValue","isRequired":true,"sendCode":1,"label":"ä¿çåå§å¼","describe":"ä¿çåå§å¼","default":true,"type":"boolean"},{"prop":"isSave","isRequired":true,"sendCode":1,"label":"æ¯å¦åå¨","describe":"æ¯å¦åå¨","default":true,"type":"boolean"}] |
¶Ô±ÈÐÂÎļþ |
| | |
| | | CREATE DATABASE root.f2; |
| | | |
| | | create device template output aligned(workstation_id INT64,value_collect INT64 encoding=TS_2DIFF,calendar_code TEXT encoding=DICTIONARY,factory_year INT32 encoding=RLE,factory_month INT32 encoding=RLE,factory_date INT32 encoding=RLE,factory_week INT32 encoding=RLE,shift_index INT32,shift_time_type INT32,is_sync BOOLEAN encoding=RLE,employee_id INT64); |
| | | |
| | | create device template aggregate_output aligned(workstation_id INT64,output INT64 encoding=TS_2DIFF,cur_output INT64 encoding=TS_2DIFF,pre_output INT64 encoding=TS_2DIFF,pre_time INT64 encoding=TS_2DIFF,calendar_code TEXT encoding=DICTIONARY,factory_year INT32 encoding=RLE,factory_month INT32 encoding=RLE,factory_date INT32 encoding=RLE,factory_week INT32 encoding=RLE,shift_index INT32,shift_time_type INT32,employee_id INT64); |
| | | |
| | | create device template aggregate_state aligned(workstation_id INT64,end_time INT64,duration_collect INT64 encoding=TS_2DIFF,calendar_code TEXT encoding=DICTIONARY,factory_year INT32 encoding=RLE,factory_month INT32 encoding=RLE,factory_date INT32 encoding=RLE,factory_week INT32 encoding=RLE,shift_index INT32 encoding=TS_2DIFF,shift_time_type INT32 encoding=TS_2DIFF,wcs INT32 encoding=TS_2DIFF,rps INT32 encoding=TS_2DIFF,is_deleted BOOLEAN encoding=RLE,is_plan INT32,employee_id INT64); |
| | | |
| | | create device template aggregate_state_with_feedback aligned(workstation_id INT64,end_time INT64,duration_collect INT64 encoding=TS_2DIFF,calendar_code TEXT encoding=DICTIONARY,factory_year INT32 encoding=RLE,factory_month INT32 encoding=RLE,factory_date INT32 encoding=RLE,factory_week INT32 encoding=RLE,shift_index INT32 encoding=TS_2DIFF,shift_time_type INT32 encoding=TS_2DIFF,wcs INT32 encoding=TS_2DIFF,rps INT32 encoding=TS_2DIFF,is_deleted BOOLEAN encoding=RLE,is_plan INT32,feedback_id INT64); |
| | | |
| | | create device template state aligned(workstation_id INT64,value_collect INT32,calendar_code TEXT encoding=DICTIONARY,factory_year INT32 encoding=RLE,factory_month INT32 encoding=RLE,factory_date INT32 encoding=RLE,factory_week INT32 encoding=RLE,shift_index INT32 encoding=TS_2DIFF,shift_time_type INT32 encoding=TS_2DIFF,wcs INT32 encoding=TS_2DIFF,rps INT32 encoding=TS_2DIFF,is_fix_point BOOLEAN encoding=RLE,is_sync BOOLEAN encoding=RLE,is_plan INT32, feedback_point_type INT32,feedback_id INT64,is_deleted BOOLEAN encoding=RLE,employee_id INT64); |
| | | |
| | | create device template process_param aligned (workstation_id INT64,v TEXT,n TEXT); |
| | | |
| | | create device template alarm aligned(workstation_id INT64,calendar_code TEXT encoding=DICTIONARY,factory_year INT32 encoding=RLE,factory_month INT32 encoding=RLE,factory_date INT32 encoding=RLE,factory_week INT32 encoding=RLE,shift_index INT32,shift_time_type INT32,code TEXT,message TEXT,level TEXT); |
| | | |
| | | create device template prog_name aligned(workstation_id INT64,name TEXT,part_no TEXT,process_no TEXT,version TEXT,seg_total INT32,seg_no INT32); |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /*å·¥æ¶åææ¨¡å*/ |
| | | |
| | | DROP TABLE IF EXISTS `part_workinghour`; |
| | | CREATE TABLE `part_workinghour` |
| | | ( |
| | | `id` bigint(0) NOT NULL COMMENT '主é®', |
| | | `status` tinyint(0) NULL DEFAULT NULL COMMENT 'ç¶æ', |
| | | `is_deleted` int NULL DEFAULT NULL COMMENT 'å é¤', |
| | | `create_user` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'å建人', |
| | | `create_dept` bigint(0) NULL DEFAULT NULL COMMENT 'å建é¨é¨', |
| | | `create_time` datetime(0) NULL DEFAULT NULL COMMENT 'å建æ¶é´', |
| | | `update_user` bigint(0) NULL DEFAULT NULL COMMENT 'æ´æ°äºº', |
| | | `update_time` datetime(0) NULL DEFAULT NULL COMMENT 'æ´æ°æ¶é´', |
| | | `tenant_id` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT 'ç§æ·', |
| | | `part_no` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'é¶ä»¶ç¼å·', |
| | | `process_no` varchar(20) NULL DEFAULT NULL COMMENT 'å·¥åºå·', |
| | | `version` varchar(20) NULL DEFAULT NULL COMMENT 'çæ¬¡', |
| | | |
| | | `seg_total` int NULL DEFAULT NULL COMMENT 'å·¥åºæ®µæ°', |
| | | `workstation_id` bigint NULL DEFAULT 0 COMMENT 'å·¥ä½id', |
| | | `start_time` datetime(3) NULL DEFAULT NULL COMMENT 'å¼å§æ¶é´', |
| | | `end_time` datetime(3) NULL DEFAULT NULL COMMENT 'ç»ææ¶é´', |
| | | `occupancy_secs` bigint NULL DEFAULT 0 COMMENT 'å æºæ¶é´(ç§)', |
| | | `clamping_secs` bigint NULL DEFAULT 0 COMMENT 'è£
夹è°è¯æ¶é´(ç§)', |
| | | `first_working_secs` bigint NULL DEFAULT 0 COMMENT 'é¦ä»¶ååæ¶é´(ç§)', |
| | | `last_remove_secs` bigint NULL DEFAULT 0 COMMENT 'æ«ä»¶æå¸æ¶é´(ç§)', |
| | | `first_measure_secs` bigint NULL DEFAULT 0 COMMENT 'é¦ä»¶è®¡éæ¶é´(ç§)', |
| | | `processing_secs` bigint NULL DEFAULT 0 COMMENT 'å å·¥æ¶é´(ç§)', |
| | | `prepare_secs` bigint NULL DEFAULT 0 COMMENT 'å夿¶é´(ç§)', |
| | | `single_process_secs` bigint NULL DEFAULT 0 COMMENT 'åä»¶å·¥æ¶(ç§)', |
| | | `amount` bigint NULL DEFAULT 0 COMMENT 'æ°é(è¯¥æ¹æ¬¡å
)', |
| | | PRIMARY KEY (`id`) USING BTREE |
| | | ) ENGINE = InnoDB |
| | | CHARACTER SET = utf8mb4 |
| | | COLLATE = utf8mb4_general_ci COMMENT = 'é¶ä»¶å·¥æ¶' |
| | | ROW_FORMAT = Dynamic; |
| | | |
| | | DROP TABLE IF EXISTS `part_working_process`; |
| | | CREATE TABLE `part_working_process` |
| | | ( |
| | | `id` bigint(0) NOT NULL COMMENT '主é®', |
| | | `status` tinyint(0) NULL DEFAULT NULL COMMENT 'ç¶æ', |
| | | `is_deleted` int NULL DEFAULT NULL COMMENT 'å é¤', |
| | | `create_user` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'å建人', |
| | | `create_dept` bigint(0) NULL DEFAULT NULL COMMENT 'å建é¨é¨', |
| | | `create_time` datetime(0) NULL DEFAULT NULL COMMENT 'å建æ¶é´', |
| | | `update_user` bigint(0) NULL DEFAULT NULL COMMENT 'æ´æ°äºº', |
| | | `update_time` datetime(0) NULL DEFAULT NULL COMMENT 'æ´æ°æ¶é´', |
| | | `prog_name` varchar(120) NULL DEFAULT NULL COMMENT 'ç¨åºåç§°', |
| | | `workinghour_id` bigint NOT NULL COMMENT 'é¶ä»¶å·¥æ¶è¡¨id', |
| | | `start_time` datetime(3) NULL DEFAULT NULL COMMENT 'å¼å§æ¶é´', |
| | | `end_time` datetime(3) NULL DEFAULT NULL COMMENT 'ç»ææ¶é´', |
| | | `device_status` int NULL DEFAULT NULL COMMENT '设å¤ç¶æ', |
| | | PRIMARY KEY (`id`) USING BTREE |
| | | ) ENGINE = InnoDB |
| | | CHARACTER SET = utf8mb4 |
| | | COLLATE = utf8mb4_general_ci COMMENT = 'é¶ä»¶å å·¥è¿ç¨è®°å½' |
| | | ROW_FORMAT = Dynamic; |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.smartman.common.utils; |
| | | |
| | | import static org.junit.jupiter.api.Assertions.assertEquals; |
| | | |
| | | import java.time.Duration; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import org.junit.jupiter.api.Test; |
| | | |
| | | public class DurationUtilTest { |
| | | |
| | | @Test |
| | | public void toChineseDuration() { |
| | | //new Duration() |
| | | LocalDateTime end = LocalDateTime.now(); |
| | | LocalDateTime start = end.minusHours(25);//25å°æ¶ |
| | | Duration duration = Duration.between(start, end); |
| | | |
| | | String str = DurationUtil.toChineseDuration(duration); |
| | | assertEquals("1天1å°æ¶",str); |
| | | |
| | | start = end.minusHours(3); |
| | | duration = Duration.between(start, end); |
| | | str = DurationUtil.toChineseDuration(duration); |
| | | assertEquals("3å°æ¶",str); |
| | | |
| | | |
| | | start = end.minusHours(1).minusMinutes(5).minusSeconds(22); |
| | | duration = Duration.between(start, end); |
| | | str = DurationUtil.toChineseDuration(duration); |
| | | assertEquals("1å°æ¶5å22ç§",str); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.smartman.modules.workinghour.service; |
| | | |
| | | import java.io.FileOutputStream; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import org.apache.poi.ss.usermodel.BorderStyle; |
| | | import org.apache.poi.ss.usermodel.CellStyle; |
| | | import org.apache.poi.ss.usermodel.Chart; |
| | | import org.apache.poi.ss.usermodel.ClientAnchor; |
| | | import org.apache.poi.ss.usermodel.Drawing; |
| | | import org.apache.poi.ss.usermodel.FillPatternType; |
| | | import org.apache.poi.ss.usermodel.HorizontalAlignment; |
| | | import org.apache.poi.ss.usermodel.IndexedColors; |
| | | import org.apache.poi.ss.util.CellRangeAddress; |
| | | import org.apache.poi.xssf.streaming.SXSSFRow; |
| | | import org.apache.poi.xssf.streaming.SXSSFSheet; |
| | | import org.apache.poi.xssf.streaming.SXSSFWorkbook; |
| | | import org.apache.poi.xssf.usermodel.XSSFChart; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource; |
| | | import org.openxmlformats.schemas.drawingml.x2006.chart.CTBarChart; |
| | | import org.openxmlformats.schemas.drawingml.x2006.chart.CTBarSer; |
| | | import org.openxmlformats.schemas.drawingml.x2006.chart.CTBoolean; |
| | | import org.openxmlformats.schemas.drawingml.x2006.chart.CTCatAx; |
| | | import org.openxmlformats.schemas.drawingml.x2006.chart.CTChart; |
| | | import org.openxmlformats.schemas.drawingml.x2006.chart.CTDLbls; |
| | | import org.openxmlformats.schemas.drawingml.x2006.chart.CTLegend; |
| | | import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource; |
| | | import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumRef; |
| | | import org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea; |
| | | import org.openxmlformats.schemas.drawingml.x2006.chart.CTScaling; |
| | | import org.openxmlformats.schemas.drawingml.x2006.chart.CTSerTx; |
| | | import org.openxmlformats.schemas.drawingml.x2006.chart.CTStrRef; |
| | | import org.openxmlformats.schemas.drawingml.x2006.chart.CTValAx; |
| | | import org.openxmlformats.schemas.drawingml.x2006.chart.STAxPos; |
| | | import org.openxmlformats.schemas.drawingml.x2006.chart.STBarDir; |
| | | import org.openxmlformats.schemas.drawingml.x2006.chart.STBarGrouping; |
| | | import org.openxmlformats.schemas.drawingml.x2006.chart.STDispBlanksAs; |
| | | import org.openxmlformats.schemas.drawingml.x2006.chart.STLegendPos; |
| | | import org.openxmlformats.schemas.drawingml.x2006.chart.STOrientation; |
| | | import org.openxmlformats.schemas.drawingml.x2006.chart.STTickLblPos; |
| | | |
| | | public class PartWorkingHourServiceTest { |
| | | static SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); |
| | | |
| | | private static String systemTime = System.currentTimeMillis()+"";//df.format(System.currentTimeMillis());; |
| | | private static SXSSFWorkbook wb = new SXSSFWorkbook(); |
| | | |
| | | private SXSSFSheet sheet = null; |
| | | |
| | | @Test |
| | | public void testMain() { |
| | | // åæ®µå |
| | | List<String> fldNameArr = new ArrayList(); |
| | | |
| | | // æ é¢ |
| | | List<String> titleArr = new ArrayList(); |
| | | |
| | | // æ¨¡ææ°æ® |
| | | List<Map> dataList = new ArrayList(); |
| | | |
| | | Map dataMap1 = new HashMap(); |
| | | |
| | | dataMap1.put("value1", "è´§å¸åºé"); |
| | | |
| | | dataMap1.put("value2", Math.floor(Math.random() * 100) + ""); |
| | | |
| | | dataMap1.put("value3", Math.floor(Math.random() * 100) + ""); |
| | | |
| | | dataMap1.put("value4", Math.floor(Math.random() * 100) + ""); |
| | | |
| | | Map dataMap2 = new HashMap(); |
| | | |
| | | dataMap2.put("value1", "ææ°åºé"); |
| | | |
| | | dataMap2.put("value2", Math.floor(Math.random() * 100) + ""); |
| | | |
| | | dataMap2.put("value3", Math.floor(Math.random() * 100) + ""); |
| | | |
| | | dataMap2.put("value4", Math.floor(Math.random() * 100) + ""); |
| | | |
| | | Map dataMap3 = new HashMap(); |
| | | |
| | | dataMap3.put("value1", "åè¡åºé"); |
| | | |
| | | dataMap3.put("value2", Math.floor(Math.random() * 100) + ""); |
| | | |
| | | dataMap3.put("value3", Math.floor(Math.random() * 100) + ""); |
| | | |
| | | dataMap3.put("value4", Math.floor(Math.random() * 100) + ""); |
| | | |
| | | Map dataMap4 = new HashMap(); |
| | | |
| | | dataMap4.put("value1", "åºå¸åºé"); |
| | | |
| | | dataMap4.put("value2", Math.floor(Math.random() * 100) + ""); |
| | | |
| | | dataMap4.put("value3", Math.floor(Math.random() * 100) + ""); |
| | | |
| | | dataMap4.put("value4", Math.floor(Math.random() * 100) + ""); |
| | | |
| | | |
| | | |
| | | fldNameArr.add("value1"); |
| | | |
| | | fldNameArr.add("value2"); |
| | | |
| | | fldNameArr.add("value3"); |
| | | |
| | | fldNameArr.add("value4"); |
| | | |
| | | titleArr.add("ç±»å"); |
| | | |
| | | titleArr.add("ä¹°å
¥"); |
| | | |
| | | titleArr.add("ååº"); |
| | | |
| | | titleArr.add("å红"); |
| | | |
| | | dataList.add(dataMap1); |
| | | |
| | | dataList.add(dataMap2); |
| | | |
| | | dataList.add(dataMap3); |
| | | |
| | | dataList.add(dataMap4); |
| | | |
| | | |
| | | |
| | | //PoiExcelUtil ecu = new PoiExcelUtil(); |
| | | |
| | | try { |
| | | |
| | | // å建æ±ç¶å¾ |
| | | //ecu.createBarChart(titleArr, fldNameArr, dataList); |
| | | createBarChart(titleArr, fldNameArr, dataList); |
| | | // å建饼ç¶å¾ |
| | | // ecu.createPieChart(titleArr, fldNameArr, dataList); |
| | | |
| | | // å建æçº¿å¾ |
| | | //ecu.createTimeXYChar(titleArr, fldNameArr, dataList); |
| | | // |
| | | // å建é¢ç§¯å¾ |
| | | //ecu.createAreaChart(titleArr, fldNameArr, dataList); |
| | | |
| | | String title="æµè¯æ°æ®"; |
| | | //导åºå°æä»¶ |
| | | FileOutputStream out = new FileOutputStream(new File("D:/PoiExcel/"+systemTime+"_"+title+".xls")); |
| | | |
| | | wb.write(out); |
| | | |
| | | out.close(); |
| | | |
| | | } catch (IOException e) { |
| | | |
| | | e.printStackTrace(); |
| | | |
| | | } |
| | | |
| | | } |
| | | /** |
| | | * å建æ±ç¶å¾(å 积å¾ï¼å¤ç») |
| | | * |
| | | * @throws IOException |
| | | */ |
| | | |
| | | public void createBarChart(List<String> titleArr, List<String> fldNameArr, List<Map> dataList) { |
| | | |
| | | // å建ä¸ä¸ªsheet页 |
| | | sheet = wb.createSheet("sheet0"); |
| | | // drawSheet0Table(sheet,titleArr,fldNameArr,dataList); |
| | | // å 积=STBarGrouping.STACKED å¤ç»=STBarGrouping.CLUSTERED |
| | | //boolean result = drawSheet0Map(sheet, STBarGrouping.CLUSTERED, fldNameArr, dataList, titleArr); |
| | | |
| | | boolean result = drawSheet0Map(sheet, STBarGrouping.STACKED, fldNameArr, dataList, titleArr);//yysæ¹ |
| | | System.out.println("çææ±ç¶å¾(å 积orå¤ç»)-->" + result); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * çææ±ç¶å¾ |
| | | * |
| | | * @param sheet é¡µç¾ |
| | | * @param group æ±ç¶å¾ç±»å(å 积,å¤ç») |
| | | * @param fldNameArr åæ åç§° |
| | | * @param dataList ç»è®¡æ°æ® |
| | | * @return |
| | | */ |
| | | |
| | | // private boolean drawSheet0Map(SXSSFSheet sheet, Enum group, List fldNameArr, List<Map> dataList, List titleArr) { |
| | | private boolean drawSheet0Map(SXSSFSheet sheet, STBarGrouping.Enum group, List<String> fldNameArr, List<Map> dataList, List<String> titleArr) { |
| | | |
| | | boolean result = false; |
| | | |
| | | // è·åsheetåç§° |
| | | String sheetName = sheet.getSheetName(); |
| | | |
| | | result = drawSheet0Table(sheet, titleArr, fldNameArr, dataList); |
| | | |
| | | // å建ä¸ä¸ªç»å¸ |
| | | Drawing drawing = sheet.createDrawingPatriarch(); |
| | | |
| | | // ç»ä¸ä¸ªå¾åºå |
| | | // åå个é»è®¤0ï¼ä»ç¬¬8è¡å°ç¬¬25è¡,ä»ç¬¬0åå°ç¬¬6åçåºå |
| | | |
| | | ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 0, 8, 6, 25); |
| | | |
| | | // å建ä¸ä¸ªchart对象 |
| | | Chart chart = drawing.createChart(anchor); |
| | | |
| | | CTChart ctChart = ((XSSFChart) chart).getCTChart(); |
| | | |
| | | CTPlotArea ctPlotArea = ctChart.getPlotArea(); |
| | | |
| | | // å建æ±ç¶å¾æ¨¡å |
| | | CTBarChart ctBarChart = ctPlotArea.addNewBarChart(); |
| | | |
| | | CTBoolean ctBoolean = ctBarChart.addNewVaryColors(); |
| | | |
| | | ctBarChart.getVaryColors().setVal(true); |
| | | |
| | | // 设置å¾ç±»å |
| | | // STBarGrouping.Enum group = null; |
| | | ctBarChart.addNewGrouping().setVal(group); |
| | | |
| | | ctBoolean.setVal(true); |
| | | |
| | | |
| | | //ctBarChart.addNewBarDir().setVal(STBarDir.COL); |
| | | ctBarChart.addNewBarDir().setVal(STBarDir.BAR);//yangysmod ,æ¹æäºæ¨ªå |
| | | // æ¯å¦æ·»å å·¦ä¾§åæ è½´ |
| | | ctChart.addNewDispBlanksAs().setVal(STDispBlanksAs.ZERO); |
| | | |
| | | ctChart.addNewShowDLblsOverMax().setVal(true); |
| | | |
| | | // 设置è¿ä¸¤ä¸ªåæ°æ¯ä¸ºäºå¨STACKED模å¼ä¸çæå 积模å¼ï¼(standard)æ 忍¡å¼æ¶éè¦å°è¿ä¸¤è¡å»æ |
| | | if ("stacked".equals(group.toString()) || "percentStacked".equals(group.toString())) { |
| | | |
| | | ctBarChart.addNewGapWidth().setVal(150); |
| | | |
| | | ctBarChart.addNewOverlap().setVal((byte) 100); |
| | | |
| | | } |
| | | |
| | | // å建åºå,å¹¶ä¸è®¾ç½®éä¸åºå |
| | | //for (int i = 0; i < fldNameArr.size() - 1; i++) { |
| | | |
| | | CTBarSer ctBarSer = ctBarChart.addNewSer(); |
| | | |
| | | CTSerTx ctSerTx = ctBarSer.addNewTx(); |
| | | |
| | | // å¾ä¾åº |
| | | CTStrRef ctStrRef = ctSerTx.addNewStrRef(); |
| | | |
| | | // éå®åºå第0è¡,第1,2,3åæ é¢ä½ä¸ºå¾ä¾ //1 2 3 |
| | | //String legendDataRange = new CellRangeAddress(0, 0, i + 1, i + 1).formatAsString(sheetName, true); |
| | | |
| | | //ctStrRef.setF(legendDataRange); |
| | | |
| | | ctBarSer.addNewIdx().setVal(3);// |
| | | //ctBarSer. |
| | | // æ¨ªåæ åº |
| | | CTAxDataSource cttAxDataSource = ctBarSer.addNewCat(); |
| | | |
| | | ctStrRef = cttAxDataSource.addNewStrRef(); |
| | | |
| | | // é第0å,第1-6è¡ä½ä¸ºæ¨ªåæ åºå |
| | | String axisDataRange = new CellRangeAddress(1, dataList.size(), 0, 0).formatAsString(sheetName, true); |
| | | |
| | | ctStrRef.setF(axisDataRange); |
| | | |
| | | // æ°æ®åºå |
| | | CTNumDataSource ctNumDataSource = ctBarSer.addNewVal(); |
| | | |
| | | CTNumRef ctNumRef = ctNumDataSource.addNewNumRef(); |
| | | |
| | | // é第1-6è¡,第1-3åä½ä¸ºæ°æ®åºå //1 2 3 |
| | | //String numDataRange = new CellRangeAddress(1, dataList.size(), i + 1, i + 1).formatAsString(sheetName, true); |
| | | String numDataRange = new CellRangeAddress(1, dataList.size(), 1, 1).formatAsString(sheetName, true);//yangys mod |
| | | |
| | | System.out.println("æ°æ®åºå"+numDataRange); |
| | | |
| | | ctNumRef.setF(numDataRange); |
| | | |
| | | |
| | | // æ·»å æ±ç¶è¾¹æ¡çº¿ |
| | | ctBarSer.addNewSpPr().addNewLn().addNewSolidFill().addNewSrgbClr().setVal(new byte[]{0, 0, 0}); |
| | | |
| | | // 设置è´è½´é¢è²ä¸æ¯ç½è² |
| | | ctBarSer.addNewInvertIfNegative().setVal(false); |
| | | |
| | | // 设置æ ç¾æ ¼å¼ |
| | | ctBoolean.setVal(false); |
| | | |
| | | CTDLbls newDLbls = ctBarSer.addNewDLbls(); |
| | | |
| | | newDLbls.setShowLegendKey(ctBoolean); |
| | | |
| | | ctBoolean.setVal(true); |
| | | newDLbls.setShowVal(ctBoolean); |
| | | |
| | | ctBoolean.setVal(false); |
| | | |
| | | newDLbls.setShowCatName(ctBoolean); |
| | | newDLbls.setShowSerName(ctBoolean); |
| | | newDLbls.setShowPercent(ctBoolean); |
| | | newDLbls.setShowBubbleSize(ctBoolean); |
| | | newDLbls.setShowLeaderLines(ctBoolean); |
| | | |
| | | //} |
| | | |
| | | // åè¯BarChartå®æåæ è½´ï¼å¹¶ç»å®ä»¬id |
| | | ctBarChart.addNewAxId().setVal(123456); |
| | | |
| | | ctBarChart.addNewAxId().setVal(123457); |
| | | |
| | | // æ¨ªåæ |
| | | CTCatAx ctCatAx = ctPlotArea.addNewCatAx(); |
| | | |
| | | ctCatAx.addNewAxId().setVal(123456); // id of the cat axis |
| | | |
| | | CTScaling ctScaling = ctCatAx.addNewScaling(); |
| | | |
| | | ctScaling.addNewOrientation().setVal(STOrientation.MIN_MAX); |
| | | |
| | | ctCatAx.addNewAxPos().setVal(STAxPos.B); |
| | | |
| | | ctCatAx.addNewCrossAx().setVal(123457); // id of the val axis |
| | | |
| | | ctCatAx.addNewTickLblPos().setVal(STTickLblPos.NEXT_TO); |
| | | |
| | | // çºµåæ |
| | | CTValAx ctValAx = ctPlotArea.addNewValAx(); |
| | | |
| | | ctValAx.addNewAxId().setVal(123457); // id of the val axis |
| | | |
| | | ctScaling = ctValAx.addNewScaling(); |
| | | |
| | | ctScaling.addNewOrientation().setVal(STOrientation.MIN_MAX); |
| | | |
| | | // 设置ä½ç½® |
| | | ctValAx.addNewAxPos().setVal(STAxPos.L); |
| | | |
| | | ctValAx.addNewCrossAx().setVal(123456); // id of the cat axis |
| | | |
| | | ctValAx.addNewTickLblPos().setVal(STTickLblPos.NEXT_TO); |
| | | |
| | | // æ¯å¦å é¤ä¸»å·¦è¾¹è½´ |
| | | ctValAx.addNewDelete().setVal(false); |
| | | |
| | | // æ¯å¦å 餿¨ªåæ |
| | | ctCatAx.addNewDelete().setVal(false); |
| | | |
| | | // legend徿³¨ |
| | | |
| | | |
| | | // if (true) { |
| | | CTLegend ctLegend = ctChart.addNewLegend(); |
| | | |
| | | ctLegend.addNewLegendPos().setVal(STLegendPos.B); |
| | | |
| | | ctLegend.addNewOverlay().setVal(false); |
| | | // } |
| | | |
| | | return result; |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * çææ°æ®è¡¨ |
| | | * |
| | | * @param sheet sheet页对象 |
| | | * @param titleArr è¡¨å¤´åæ®µ |
| | | * @param fldNameArr 左边æ é¢å段 |
| | | * @param dataList æ°æ® |
| | | * @return æ¯å¦çææå |
| | | */ |
| | | |
| | | private boolean drawSheet0Table(SXSSFSheet sheet, List<String> titleArr, List<String> fldNameArr, List<Map> dataList) { |
| | | |
| | | // æµè¯æ¶è¿åå¼ |
| | | boolean result = true; |
| | | |
| | | // åå§åè¡¨æ ¼æ ·å¼ |
| | | List styleList = tableStyle(); |
| | | |
| | | // æ ¹æ®æ°æ®å建excel第ä¸è¡æ é¢è¡ |
| | | SXSSFRow row0 = sheet.createRow(0); |
| | | |
| | | for (int i = 0; i < titleArr.size(); i++) { |
| | | |
| | | // 设置æ é¢ |
| | | row0.createCell(i).setCellValue(titleArr.get(i)); |
| | | |
| | | // 设置æ é¢è¡æ ·å¼ |
| | | row0.getCell(i).setCellStyle((CellStyle) styleList.get(0)); |
| | | |
| | | } |
| | | |
| | | // å¡«å
æ°æ® |
| | | for (int i = 0; i < dataList.size(); i++) { |
| | | |
| | | // è·åæ¯ä¸é¡¹çæ°æ® |
| | | Map data = (Map) dataList.get(i); |
| | | |
| | | // 设置æ¯ä¸è¡çåæ®µæ é¢åæ°æ® |
| | | SXSSFRow rowi = sheet.createRow(i + 1); |
| | | |
| | | for (int j = 0; j < data.size(); j++) { |
| | | |
| | | // 夿æ¯å¦æ¯æ é¢å段å |
| | | if (j == 0) { |
| | | |
| | | rowi.createCell(j).setCellValue((String) data.get("value" + (j + 1))); |
| | | |
| | | // è®¾ç½®å·¦è¾¹åæ®µæ ·å¼ |
| | | sheet.getRow(i + 1).getCell(j).setCellStyle((CellStyle) styleList.get(0)); |
| | | |
| | | } else { |
| | | |
| | | rowi.createCell(j).setCellValue(Double.valueOf((String) data.get("value" + (j + 1)))); |
| | | |
| | | // è®¾ç½®æ°æ®æ ·å¼ |
| | | sheet.getRow(i + 1).getCell(j).setCellStyle((CellStyle) styleList.get(2)); |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | return result; |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * çæè¡¨æ ¼æ ·å¼ |
| | | * |
| | | * @return |
| | | */ |
| | | |
| | | private static List tableStyle() { |
| | | |
| | | List cellStyleList = new ArrayList(); |
| | | |
| | | // æ ·å¼åå¤ |
| | | // æ 颿 ·å¼ |
| | | CellStyle style = wb.createCellStyle(); |
| | | |
| | | style.setFillForegroundColor(IndexedColors.ROYAL_BLUE.getIndex()); |
| | | |
| | | style.setFillPattern(FillPatternType.SOLID_FOREGROUND); |
| | | |
| | | style.setBorderBottom(BorderStyle.THIN); // ä¸è¾¹æ¡ |
| | | |
| | | style.setBorderLeft(BorderStyle.THIN);// å·¦è¾¹æ¡ |
| | | |
| | | style.setBorderTop(BorderStyle.THIN);// ä¸è¾¹æ¡ |
| | | |
| | | style.setBorderRight(BorderStyle.THIN);// å³è¾¹æ¡ |
| | | |
| | | style.setAlignment(HorizontalAlignment.CENTER); |
| | | |
| | | cellStyleList.add(style); |
| | | |
| | | CellStyle style1 = wb.createCellStyle(); |
| | | |
| | | style1.setBorderBottom(BorderStyle.THIN); // ä¸è¾¹æ¡ |
| | | |
| | | style1.setBorderLeft(BorderStyle.THIN);// å·¦è¾¹æ¡ |
| | | |
| | | style1.setBorderTop(BorderStyle.THIN);// ä¸è¾¹æ¡ |
| | | |
| | | style1.setBorderRight(BorderStyle.THIN);// å³è¾¹æ¡ |
| | | |
| | | style1.setAlignment(HorizontalAlignment.CENTER); |
| | | |
| | | cellStyleList.add(style1); |
| | | |
| | | CellStyle cellStyle = wb.createCellStyle(); |
| | | |
| | | cellStyle.setBorderTop(BorderStyle.THIN);// ä¸è¾¹æ¡ |
| | | |
| | | cellStyle.setBorderBottom(BorderStyle.THIN); // ä¸è¾¹æ¡ |
| | | |
| | | cellStyle.setBorderLeft(BorderStyle.THIN);// å·¦è¾¹æ¡ |
| | | |
| | | cellStyle.setBorderRight(BorderStyle.THIN);// å³è¾¹æ¡ |
| | | |
| | | cellStyle.setAlignment(HorizontalAlignment.CENTER);// æ°´å¹³å¯¹é½æ¹å¼ |
| | | |
| | | // cellStyle.setVerticalAlignment(VerticalAlignment.TOP);//åç´å¯¹é½æ¹å¼ |
| | | cellStyleList.add(cellStyle); |
| | | |
| | | return cellStyleList; |
| | | |
| | | } |
| | | |
| | | |
| | | //https://blog.csdn.net/Lyq2017901206/article/details/126547542 |
| | | |
| | | } |