diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/OperationalConstants.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/OperationalConstants.java index 93810fc..145e762 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/OperationalConstants.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/OperationalConstants.java @@ -373,6 +373,27 @@ public class OperationalConstants { this.name = name; } } + public enum DutyLogLevel { + /** + * 水电站 + */ + importLevel("1", "重要"), + /** + * 风电 + */ + generalLevel("2", "一般"), + ordinaryLevel("3", "普通"); + /** + * 泵站 + */ + @Getter + private String val; + @Getter + private String name; - + private DutyLogLevel(String val, String name) { + this.val = val; + this.name = name; + } + } } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/entity/ImsDutyLogEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/entity/ImsDutyLogEntity.java new file mode 100644 index 0000000..d8a3792 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/entity/ImsDutyLogEntity.java @@ -0,0 +1,110 @@ +package com.hnac.hzims.operational.duty.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.tenant.mp.TenantEntity; + +import java.io.Serializable; + + +/** + * 实体类 + * + * @author Chill + */ +@Data +@TableName("hz_ims_duty_log") +@ApiModel(value = "ImsDutyLog对象", description = "值班日志") +@EqualsAndHashCode(callSuper = true) +public class ImsDutyLogEntity extends TenantEntity implements Serializable{ + + private static final long serialVersionUID = -2877981299088576156L; + /** + * 值班ID + */ + @ApiModelProperty(value = "值班ID") + private Long dutyId; + /** + * 日期 + */ + @ApiModelProperty(value = "日期") + private String time; + /** + * 值班时间 + */ + private String dutyTime; + /** + * 班类 + */ + @ApiModelProperty(value = "班类") + private String classType; + /** + * 已执行操作票 + */ + private String operationFinish="0"; + /** + * 未执行操作票 + */ + private String operationUnFinish="0"; + /** + * 作废操作票 + */ + private String operationCancel="0"; + /** + * 执行中工作票 + */ + private String workDoing="0"; + /** + * 未执行工作票 + */ + private String workUnFinish="0"; + /** + * 终结工作票 + */ + private String workFinish="0"; + /** + * 作废工作票 + */ + private String workCancel="0"; + /** + * 交班值班长 + */ + private String handMaster; + /** + * 交班值班员 + */ + private String handNumber; + /** + * 交班时间 + */ + private String handTime; + /** + * 接班值班长 + */ + private String carryMaster; + /** + * 接班值班员 + */ + private String carryNumber; + /** + * 接班时间 + */ + private String carryTime; + /** + * 交接班会照片 + */ + private String dutyPic; + /** + * 值班情况 + */ + private String dutyStatus; + /** + * 上级通知及注意事项 + */ + private String notice; + + +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/entity/ImsDutyRecEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/entity/ImsDutyRecEntity.java index 7fd2b1c..0735f33 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/entity/ImsDutyRecEntity.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/entity/ImsDutyRecEntity.java @@ -1,6 +1,7 @@ package com.hnac.hzims.operational.duty.entity; import com.baomidou.mybatisplus.annotation.SqlCondition; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.databind.annotation.JsonSerialize; @@ -102,5 +103,8 @@ public class ImsDutyRecEntity extends TenantEntity { @QueryField(condition = SqlCondition.LIKE) private String dealChain; + @ApiModelProperty(value = "值班日志") + @TableField(exist=false) + private ImsDutyLogEntity imsDutyLogEntity; } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/vo/ImsDutyRecVO.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/vo/ImsDutyRecVO.java index 38f9302..6fb1a04 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/vo/ImsDutyRecVO.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/vo/ImsDutyRecVO.java @@ -2,6 +2,7 @@ package com.hnac.hzims.operational.duty.vo; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.NullSerializer; +import com.hnac.hzims.operational.duty.entity.ImsDutyLogEntity; import com.hnac.hzims.operational.duty.entity.ImsDutyRecEntity; import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiOperation; @@ -42,4 +43,7 @@ public class ImsDutyRecVO extends ImsDutyRecEntity { @ApiModelProperty(value = "站点名称") private String stationName; + + @ApiModelProperty(value = "值班日志") + private ImsDutyLogEntity imsDutyLogEntity; } diff --git a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/entity/WorkTicketInfoEntity.java b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/entity/WorkTicketInfoEntity.java index 5fda1e0..785d20c 100644 --- a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/entity/WorkTicketInfoEntity.java +++ b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/entity/WorkTicketInfoEntity.java @@ -499,5 +499,7 @@ public class WorkTicketInfoEntity extends TenantEntity implements Serializable { @ApiModelProperty("是否线下 : 1-线下,0-线上") private Boolean isOffline; + @ApiModelProperty + private Integer implementStatus; } diff --git a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/feign/ITicketInfoClient.java b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/feign/ITicketInfoClient.java index 96f07b1..ae992f7 100644 --- a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/feign/ITicketInfoClient.java +++ b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/feign/ITicketInfoClient.java @@ -33,6 +33,8 @@ public interface ITicketInfoClient { String GET_TICKET_PASS_BY_IDS = API_PREFIX + "/getTicketPassByIds"; String GET_WORK_TICKET_TRANSFER = API_PREFIX + "/getWorkTicketTransfer"; String GET_WORK_TICKET_STATISTIC = API_PREFIX + "/getWorkTicketStatistic"; + String GET_WORK_TICKET_INFO = API_PREFIX + "/getWorkTicketInfo"; + String GET_OPERATE_TICKET_INFO = API_PREFIX + "/getOperateTicketInfo"; String GET_OPERATE_TICKET_STATISTIC = API_PREFIX + "/getOperateTicketStatistic"; String GET_OPERATE_WORK_STATISTIC = API_PREFIX + "/getOperateWorkStatistic"; String GET_WORK_TICKET_CHECK = API_PREFIX + "/getWorkTicketCheck"; @@ -90,6 +92,24 @@ public interface ITicketInfoClient { @PostMapping(GET_WORK_TICKET_STATISTIC) R getWorkTicketStatistic(@RequestBody Map params); + + /** + * 根据时间,和机构获取对应工作票 + * @param params startDate endDate deptList + * @return + */ + @PostMapping(GET_WORK_TICKET_INFO) + R> getWorkTicketInfo(@RequestBody Map params); + + + /** + * 根据时间,和机构获取对应操作票 + * @param params startDate endDate deptList + * @return + */ + @PostMapping(GET_OPERATE_TICKET_INFO) + R> getOperateTicketInfo(@RequestBody Map params); + /** * 获取首页操作票统计结果 * @return diff --git a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/feign/TicketInfoClientFallback.java b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/feign/TicketInfoClientFallback.java index aa58b72..bc833cf 100644 --- a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/feign/TicketInfoClientFallback.java +++ b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/feign/TicketInfoClientFallback.java @@ -51,6 +51,16 @@ public class TicketInfoClientFallback implements ITicketInfoClient { } @Override + public R> getWorkTicketInfo(Map params) { + return R.fail("查询失败!"); + } + + @Override + public R> getOperateTicketInfo(Map params) { + return R.fail("查询失败!"); + } + + @Override public R getOperateTicketStatistic(Map paramMap) { return null; } diff --git a/hzims-service/operational/pom.xml b/hzims-service/operational/pom.xml index fbb805c..7f60701 100644 --- a/hzims-service/operational/pom.xml +++ b/hzims-service/operational/pom.xml @@ -106,12 +106,12 @@ cn.afterturn easypoi-base - 3.2.0 + 4.4.0 cn.afterturn easypoi-annotation - 3.2.0 + 4.4.0 diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/controller/ImsDutyRecController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/controller/ImsDutyRecController.java index 07d391a..166bad4 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/controller/ImsDutyRecController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/controller/ImsDutyRecController.java @@ -1,17 +1,17 @@ package com.hnac.hzims.operational.duty.controller; +import cn.afterturn.easypoi.word.WordExportUtil; import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.common.logs.annotation.OperationAnnotation; import com.hnac.hzims.common.logs.enums.BusinessType; import com.hnac.hzims.common.logs.enums.OperatorType; +import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.operational.duty.dto.ImsDutyRecDTO; -import com.hnac.hzims.operational.duty.entity.AnalyseExample; -import com.hnac.hzims.operational.duty.entity.ImsDutyEmergencyEntity; -import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity; -import com.hnac.hzims.operational.duty.entity.ImsDutyRecEntity; +import com.hnac.hzims.operational.duty.entity.*; import com.hnac.hzims.operational.duty.service.IImsAnalyseExampleService; import com.hnac.hzims.operational.duty.service.IImsDutyEmergencyService; +import com.hnac.hzims.operational.duty.service.IImsDutyLogService; import com.hnac.hzims.operational.duty.service.IImsDutyRecService; import com.hnac.hzims.operational.duty.vo.ImsDutyEmergencyVo; import com.hnac.hzims.operational.duty.vo.ImsDutyRecVO; @@ -21,7 +21,10 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.secure.utils.AuthUtil; @@ -32,8 +35,11 @@ import org.springblade.flow.core.entity.BladeFlow; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; +import java.net.URLEncoder; +import java.util.HashMap; /** @@ -45,13 +51,16 @@ import javax.validation.Valid; @AllArgsConstructor @RequestMapping("/imsDutyRec") @Api(value = "值班交接controller", tags = "值班交接相关操作(交接班管理)") +@Slf4j public class ImsDutyRecController extends BladeController { - - private final IImsDutyRecService imsDutyRecService; + @Resource + private IImsDutyRecService imsDutyRecService; @Resource private IImsDutyEmergencyService iImsDutyEmergencyService; @Resource private IImsAnalyseExampleService iImsAnalyseExampleService; + @Resource + private IImsDutyLogService imsDutyLogService; /** * 详情 @@ -147,7 +156,6 @@ public class ImsDutyRecController extends BladeController { if(null == deptId){ deptId = Long.valueOf(AuthUtil.getDeptId()); } - return imsDutyRecService.getTheManinGroupRec(deptId); } @@ -335,7 +343,76 @@ public class ImsDutyRecController extends BladeController { public R changeShift(@Valid @RequestBody ImsDutyRecDTO imsDutyRecDTO) { return R.status(imsDutyRecService.changeShift(imsDutyRecDTO)); } +// /** +// * 查询交接班值班日志 +// */ +// @GetMapping("/getDutyLog") +// @ApiOperationSupport(order = 1) +// @ApiOperation(value = "查询交接班值班日志", notes = "传入imsDutyRec") +// public R getDutyLog(ImsDutyLogEntity imsDutyLogEntity) { +// R res=imsDutyLogService.getDutyLog(imsDutyLogEntity); +// return res; +// } + /** + * 新增交接班值班日志 + */ + @GetMapping("/saveDutyLog") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "新增交接班值班日志", notes = "传入imsDutyRec") + public R saveDutyLog(@RequestBody ImsDutyLogEntity imsDutyLogEntity) { + boolean b = imsDutyLogService.saveOrUpdate(imsDutyLogEntity); + if (b){ + return R.success("保存成功"); + }else { + return R.fail("保存失败"); + } + } + /** + * 查询值班日志列表-分页 + */ + @GetMapping("/queryDutyLogList") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "查询值班日志列表-分页", notes = "传入imsDutyRec") + public R> queryDutyLogList(ImsDutyLogEntity imsDutyLogEntity, Query query) { + IPage page = imsDutyLogService.page(Condition.getPage(query), Condition.getQueryWrapper(imsDutyLogEntity)); + return R.data(page); + } + /** + * 导出交接班值班日志 + */ + @GetMapping("/exportDutyLog") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "导出交接班值班日志", notes = "传入imsDutyRec") + public void exportDutyLog(HttpServletResponse response, @ApiParam(value = "當前排班Id", required = true) String dutyId){ + HashMap map = new HashMap<>(); + imsDutyLogService.exportDutyLog(dutyId,map); + String dutyTime =""; + if (StringUtils.isNotBlank(map.get("dutyTime").toString())) { + dutyTime = map.get("dutyTime").toString(); + } + // 下载导出 + String filename = dutyTime+"值班日志"; + // 设置头信息 + response.setCharacterEncoding("UTF-8"); + response.setContentType("application/vnd.ms-excel"); + ServletOutputStream outputStream = null; + try { + //设置xlsx格式 + response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename + ".docx", "UTF-8")); + //创建一个输出流 + outputStream = response.getOutputStream(); + XWPFDocument xwpfDocument = WordExportUtil.exportWord07("template/dutyLogTemplate.docx", map); + //写入数据 + xwpfDocument.write(outputStream); + // 关闭 + outputStream.close(); + xwpfDocument.close(); + } catch (Exception e) { + e.printStackTrace(); + log.error("转换对象失败!"); + } + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyLogMapper.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyLogMapper.java new file mode 100644 index 0000000..2fb9f65 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyLogMapper.java @@ -0,0 +1,15 @@ +package com.hnac.hzims.operational.duty.mapper; + + +import com.hnac.hzims.operational.duty.entity.ImsDutyLogEntity; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +/** + * Mapper 接口 + * + * @author Chill + */ +public interface ImsDutyLogMapper extends UserDataScopeBaseMapper { + + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyLogMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyLogMapper.xml new file mode 100644 index 0000000..013468b --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyLogMapper.xml @@ -0,0 +1,4 @@ + + + + diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyLogService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyLogService.java new file mode 100644 index 0000000..6213480 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyLogService.java @@ -0,0 +1,16 @@ +package com.hnac.hzims.operational.duty.service; + +import com.hnac.hzims.operational.duty.entity.ImsDutyLogEntity; +import org.springblade.core.mp.base.BaseService; +import java.util.HashMap; + +/** + * 服务类 + * + * @author Chill + */ +public interface IImsDutyLogService extends BaseService { + + void exportDutyLog(String dutyId, HashMap map); + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyRecService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyRecService.java index 35c4d6e..67e1e50 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyRecService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyRecService.java @@ -5,6 +5,7 @@ import com.hnac.hzims.operational.duty.dto.ChangeShiftsReqDTO; import com.hnac.hzims.operational.duty.dto.ChangeShiftsRspDTO; import com.hnac.hzims.operational.duty.dto.ImsDutyRecDTO; import com.hnac.hzims.operational.duty.entity.ImsDutyClassEntity; +import com.hnac.hzims.operational.duty.entity.ImsDutyLogEntity; import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity; import com.hnac.hzims.operational.duty.entity.ImsDutyRecEntity; import com.hnac.hzims.operational.duty.vo.ImsDutyRecVO; @@ -135,4 +136,6 @@ public interface IImsDutyRecService extends BaseService { * @return */ Boolean dealDutyRecFlow(ImsDutyRecDTO recDTO); + + R getDutyLog(ImsDutyLogEntity imsDutyLogEntity); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyLogServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyLogServiceImpl.java new file mode 100644 index 0000000..f6ace80 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyLogServiceImpl.java @@ -0,0 +1,179 @@ +package com.hnac.hzims.operational.duty.service.impl; + +import cn.afterturn.easypoi.entity.ImageEntity; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.hnac.hzims.operational.OperationalConstants; +import com.hnac.hzims.operational.duty.entity.*; +import com.hnac.hzims.operational.duty.mapper.ImsDutyLogMapper; +import com.hnac.hzims.operational.duty.service.*; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.io.IOUtils; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.tool.utils.Func; +import org.springframework.stereotype.Service; +import java.io.*; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.*; + + +/** + * 服务实现类 + * + * @author Chill + */ +@Slf4j +@Service +public class ImsDutyLogServiceImpl extends BaseServiceImpl implements IImsDutyLogService { + + @Override + public void exportDutyLog(String dutyId, HashMap map) { + ImsDutyLogEntity res = this.baseMapper.selectOne(new LambdaQueryWrapper() {{ + eq(ImsDutyLogEntity::getDutyId, dutyId) + .last(" limit 1");}}); +// ImsDutyLogEntity res=new ImsDutyLogEntity(); + if (Func.isNotEmpty(res)){ + map.put("time",res.getTime()); + map.put("dutyTime",res.getDutyTime()); + map.put("classType",res.getClassType()); + + String dutyStatus = res.getDutyStatus(); + if (StringUtils.isNotBlank(dutyStatus)){ + List> dutyStatusList = JSONObject.parseObject(dutyStatus, + new TypeReference< List>>() { + }); + + for (HashMap stringStringHashMap : dutyStatusList) { + for (OperationalConstants.DutyLogLevel value : OperationalConstants.DutyLogLevel.values()) { + if (value.getVal().equals(stringStringHashMap.get("level"))){ + stringStringHashMap.replace("level",value.getName()); + } + } + } + + map.put("dutyStatus",dutyStatusList); + }else { + ArrayList> dutyStatusList = new ArrayList<>(); + HashMap temp = new HashMap<>(); + temp.put("name", ""); + temp.put("status",""); + temp.put("level", ""); + dutyStatusList.add(temp); + map.put("dutyStatus",dutyStatusList); + } + + + map.put("operationFinish",res.getOperationFinish()); + map.put("operationUnFinish",res.getOperationUnFinish()); + map.put("operationCancel",res.getOperationCancel()); + map.put("workDoing",res.getWorkDoing()); + map.put("workUnFinish",res.getWorkUnFinish()); + map.put("workFinish",res.getWorkFinish()); + map.put("workCancel",res.getWorkCancel()); + + String notice = res.getNotice(); + if (StringUtils.isNotBlank(notice)){ + List> noticeItemList = JSONObject.parseObject(notice, + new TypeReference< List>>() { + }); + for (HashMap stringStringHashMap : noticeItemList) { + for (OperationalConstants.DutyLogLevel value : OperationalConstants.DutyLogLevel.values()) { + if (value.getVal().equals(stringStringHashMap.get("level"))){ + stringStringHashMap.replace("level",value.getName()); + } + } + } + map.put("notice",noticeItemList); + }else { + ArrayList> noticeItemList = new ArrayList<>(2); + HashMap temp = new HashMap<>(); + temp.put("item", ""); + temp.put("level",""); + noticeItemList.add(temp); + map.put("notice",noticeItemList); + } + map.put("handMaster",res.getHandMaster()); + map.put("handNumber",res.getHandNumber()); + map.put("handTime",res.getHandTime()); + map.put("carryMaster",res.getCarryMaster()); + map.put("carryNumber",res.getCarryNumber()); + map.put("carryTime",res.getCarryTime()); + map.put("carryMaster",res.getCarryMaster()); + List imageEntityList = new ArrayList<>(); + if (StringUtils.isNotBlank(res.getDutyPic())) { + String[] dutyPicSplit = res.getDutyPic().split(","); + for (String string : dutyPicSplit) { + ImageEntity imageEntity = new ImageEntity(imgToByte("/template/img" + downloadFileByUrl(string, "/template/img")), 225, 163); + imageEntity.setUrl(string); + imageEntityList.add(imageEntity); + } + map.put("dutyPic",imageEntityList); + } + } + + } + + + private byte[] imgToByte(String tempImgPath) { + File file = new File(tempImgPath); + byte[] buffer = null; + try { + FileInputStream fis = new FileInputStream(file); + ByteArrayOutputStream bos = new ByteArrayOutputStream(1000); + byte[] b = new byte[1000]; + int n; + while ((n = fis.read(b)) != -1) { + bos.write(b, 0, n); + } + fis.close(); + bos.close(); + buffer = bos.toByteArray(); + } catch (IOException e) { + log.error(e.getMessage()); + } + //删除临时文件 + file.delete(); + return buffer; + } + + private String downloadFileByUrl(String fileUrl, String downloadFileDir){ + URL url = null; + String fileName = null; + try { + url = new URL(fileUrl); + HttpURLConnection connection = (HttpURLConnection)url.openConnection(); + connection.setConnectTimeout(5000); + connection.setReadTimeout(5000); + connection.connect(); + + int responseCode = connection.getResponseCode(); + if (responseCode == 200) { + + InputStream inputStream = connection.getInputStream(); + + int lastSlashIndex = fileUrl.lastIndexOf("/"); + if (lastSlashIndex > 0){ + fileName = fileUrl.substring(lastSlashIndex+1); + String filePath = downloadFileDir + fileName; + File file = new File(filePath); + if (file.exists()){ + file.delete(); + } + OutputStream outputStream = new FileOutputStream(file); + // 将文件流拷贝到本地处理 + IOUtils.copy(inputStream, outputStream); + }else { + throw new ServiceException("下载文件路径异常:" + downloadFileDir); + } + } + } catch (Exception e) { + throw new ServiceException("文件图片下载失败!"); + } + return fileName; + } + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java index 38179d0..83fbfed 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java @@ -34,6 +34,10 @@ import com.hnac.hzims.operational.duty.vo.ImsRecVo; import com.hnac.hzims.operational.duty.vo.ImsSchedulingVo; import com.hnac.hzims.operational.duty.wrapper.ImsDutyRecWrapper; import com.hnac.hzims.operational.station.service.IStationService; +import com.hnac.hzims.ticket.allTicket.dto.TicketStatisticDTO; +import com.hnac.hzims.ticket.standardTicket.entity.StandardTicketInfoEntity; +import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity; +import com.hnac.hzims.ticket.workTicket.feign.ITicketInfoClient; import com.hnac.hzinfo.inspect.plan.PlanContants; import com.hnac.hzinfo.inspect.plan.feign.IInspectPlanClient; import com.hnac.hzinfo.inspect.plan.vo.PlanVO; @@ -49,6 +53,7 @@ import org.springblade.flow.core.entity.BladeFlow; import org.springblade.flow.core.feign.IFlowClient; import org.springblade.flow.core.utils.TaskUtil; import org.springblade.system.feign.ISysClient; +import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.entity.User; import org.springblade.system.user.feign.IUserClient; import org.springframework.beans.factory.annotation.Autowired; @@ -57,6 +62,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.Assert; import org.springframework.util.ObjectUtils; +import javax.annotation.Resource; import java.math.BigDecimal; import java.sql.Time; import java.text.SimpleDateFormat; @@ -65,6 +71,8 @@ import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; +import static org.springblade.core.tool.utils.DateUtil.PATTERN_DATETIME; + /** * 服务实现类 @@ -74,12 +82,15 @@ import java.util.stream.Collectors; @Slf4j @Service public class ImsDutyRecServiceImpl extends BaseServiceImpl implements IImsDutyRecService { - + @Resource + private ITicketInfoClient ticketInfoClient; @Autowired private ImsDutyMainMapper imsDutyMainMapper; @Autowired private IImsDutyMainService imsDutyMainService; @Autowired + private IImsDutyLogService imsDutyLogService; + @Autowired private IImsDutyClassService imsDutyClassService; @Autowired private IImsDutyGroupService imsDutyGroupService; @@ -228,7 +239,11 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl() {{ + eq(ImsDutyLogEntity::getDutyId, dutyId); + }}); + imsDutyRecVO.setImsDutyLogEntity(dutyLogEntity); } imsDutyRecVOIPage.setRecords(records); return imsDutyRecVOIPage; @@ -505,7 +524,13 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl dutyLog = this.getDutyLog(imsDutyLogEntity); + if(dutyLog.isSuccess()&&ObjectUtil.isNotEmpty(dutyLog.getData())){ + ImsDutyLogEntity data = dutyLog.getData(); + vo.setImsDutyLogEntity(data); + } ImsDutyRecEntity dutyRecEntity = this.baseMapper.selectOne(new LambdaQueryWrapper() {{ eq(ImsDutyRecEntity::getDutyId, entity.getPreDutyId()); }}); @@ -824,12 +849,17 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl() {{ + eq(ImsDutyClassEntity::getId, mainEntityById.getClassId()); + last("limit 1"); + }}); + String dutyTime = DateUtil.format(mainEntityById.getDutyDate(), DateUtil.PATTERN_DATE) + " " +DateUtil.format(classEntity.getStartTime(), DateUtil.PATTERN_TIME); + Date dutyDate = DateUtil.parse(dutyTime, PATTERN_DATETIME); if (dutyDate.getTime() > parse.getTime()) { - return R.fail("值班时间不能大于当前时间"); + return R.fail("指定的值班开始时间不能晚于当前时间"); } - ImsDutyMainEntity mainEntityById = imsDutyMainService.getById(id); //获取当前值班 ImsDutyMainEntity mainEntity = imsDutyMainService.getOne(new LambdaQueryWrapper() {{ @@ -998,7 +1028,7 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl() {{ @@ -1019,7 +1049,7 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl parse.getTime()) { bool = true; strDate = calculateDutyDate(parse); @@ -1051,7 +1081,7 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl parse.getTime()) { strDate = calculateDutyDate(parse); } @@ -1085,7 +1115,7 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpllambdaUpdate() + .set(ImsDutyLogEntity::getCarryTime, DateUtil.format(new Date(), PATTERN_DATETIME)) + .eq(ImsDutyLogEntity::getDutyId,imsDutyLogEntity.getDutyId()) + ); + log.info("更新值班日志"); } ImsDutyRecEntity dutyRec = BeanUtil.copy(recDTO, ImsDutyRecEntity.class); // 更新交班值班 @@ -1464,4 +1499,138 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl getDutyLog(ImsDutyLogEntity imsDutyLogEntity) { + String deptId = AuthUtil.getUser().getDeptId(); + if (com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isNotEmpty(imsDutyLogEntity)&& com.baomidou.mybatisplus.core.toolkit.ObjectUtils.isNotEmpty(imsDutyLogEntity.getDutyId())) { + ImsDutyLogEntity res = imsDutyLogService.getOne(new LambdaQueryWrapper() {{ + eq(ImsDutyLogEntity::getDutyId, imsDutyLogEntity.getDutyId()) + .last(" limit 1");}}); + if (Func.isNotEmpty(res)){ + return R.data(res); + } + } + ImsDutyMainEntity mainEntity = imsDutyMainMapper.selectOne(new LambdaQueryWrapper() {{ + eq(ImsDutyMainEntity::getId, imsDutyLogEntity.getDutyId()) + .last(" limit 1"); + }}); + if (cn.hutool.core.util.ObjectUtil.isEmpty(mainEntity)) { + return R.success("您当前未值班"); + } + Long mainId = mainEntity.getId(); + ImsDutyMainEntity carryEntity = imsDutyMainMapper.selectOne(new LambdaQueryWrapper() {{ + eq(ImsDutyMainEntity::getPreDutyId, mainId) + .last(" limit 1"); + }}); + if (cn.hutool.core.util.ObjectUtil.isEmpty(carryEntity)) { + return R.success("没有接班计划,请到排班计划进行排班"); + } + + ImsDutyLogEntity dutyLogEntity=new ImsDutyLogEntity(); + dutyLogEntity.setDutyId(mainId); + //值班-交接班基本信息 + dutyLogEntity.setTime(DateUtil.format(new Date(), "yyyy-MM-dd")); + ImsDutyClassEntity classEntity = imsDutyClassService.getById(mainEntity.getClassId()); + dutyLogEntity.setClassType(classEntity.getClassName()); + String startTime = DateUtil.format(mainEntity.getDutyDate(), "yyyy-MM-dd") + " " +DateUtil.format(classEntity.getStartTime(), "HH:mm:ss"); + String endTime = DateUtil.format(carryEntity.getDutyDate(), "yyyy-MM-dd")+ " " + DateUtil.format(classEntity.getEndTime(), "HH:mm:ss"); + String dutyTime = startTime + "至" +endTime; + dutyLogEntity.setDutyTime(dutyTime); + ImsDutyRecEntity rec = this.getOne(Wrappers.lambdaQuery() + .eq(ImsDutyRecEntity::getDutyId, mainId) + .last("limit 1;")); + dutyLogEntity.setHandMaster(getManagerName(mainEntity)); + dutyLogEntity.setHandNumber(getManagerNumber(mainEntity)); + dutyLogEntity.setCarryMaster(getManagerName(carryEntity)); + dutyLogEntity.setCarryNumber(getManagerNumber(carryEntity)); + if (ObjectUtil.isNotEmpty(rec)) { + dutyLogEntity.setHandTime(DateUtil.format(rec.getExecTime(), "yyyy-MM-dd HH:mm:ss")); + dutyLogEntity.setCarryTime(DateUtil.format(rec.getAcceptTime(), "yyyy-MM-dd HH:mm:ss")); + } + //工作票 + Map paramMap = new HashMap<>(); + paramMap.put("startDate", startTime); + paramMap.put("endDate", endTime); + paramMap.put("deptList", deptId); + R> workTicketInfo = ticketInfoClient.getWorkTicketInfo(paramMap); + if(workTicketInfo.isSuccess()&& cn.hutool.core.util.ObjectUtil.isNotEmpty(workTicketInfo.getData())){ + List ticketInfoData = workTicketInfo.getData(); + // 工作票终结数量 + Integer ticketInfoCompleteNum = ticketInfoData.stream().filter(item -> "结束".equals(item.getFlowTaskName())) + .collect(Collectors.toList()).size(); + dutyLogEntity.setWorkFinish(ticketInfoCompleteNum.toString()); + //工作票作废 + List invalidList = ticketInfoData.stream().filter(item -> "废票".equals(item.getFlowTaskName())) + .collect(Collectors.toList()); + dutyLogEntity.setWorkCancel(String.valueOf(invalidList.size())); + Integer i=0; + //工作票未执行数量 + List unExecutedList = ticketInfoData.stream() + .filter(item -> i.equals(item.getImplementStatus())) + .collect(Collectors.toList()); + dutyLogEntity.setWorkUnFinish(String.valueOf(unExecutedList.size())); + // 工作票执行数量 + Integer ticketInfoStartNum = ticketInfoData.size() - ticketInfoCompleteNum-ticketInfoCompleteNum-invalidList.size()-unExecutedList.size(); + dutyLogEntity.setWorkDoing(ticketInfoStartNum.toString()); + } + R> operateTicketInfo = ticketInfoClient.getOperateTicketInfo(paramMap); + if(operateTicketInfo.isSuccess()&& cn.hutool.core.util.ObjectUtil.isNotEmpty(operateTicketInfo.getData())){ + List operateTicketInfoData = operateTicketInfo.getData(); + Integer finishSize = operateTicketInfoData.stream().filter(item -> "结束".equals(item.getFlowTaskName())) + .collect(Collectors.toList()).size(); + dutyLogEntity.setOperationFinish(finishSize.toString()); + Integer invalidSize= operateTicketInfoData.stream().filter(item -> "废票".equals(item.getFlowTaskName())) + .collect(Collectors.toList()).size(); + dutyLogEntity.setOperationCancel(invalidSize.toString()); + Integer doingNum = operateTicketInfoData.size() - finishSize - invalidSize; + dutyLogEntity.setOperationUnFinish(doingNum.toString()); + } + TicketStatisticDTO ticketStatisticDTO=new TicketStatisticDTO(); + ticketStatisticDTO.setStartDate(DateUtil.format(classEntity.getStartTime(),"yyyy-MM-dd HH:mm:ss")); + ticketStatisticDTO.setEndDate(DateUtil.format(classEntity.getEndTime(),"yyyy-MM-dd HH:mm:ss")); + ticketStatisticDTO.setDeptIds(deptId); + return R.data(dutyLogEntity); + } + + + private String getManagerName(ImsDutyMainEntity mainEntity) { + String managerName=""; + if (cn.hutool.core.util.ObjectUtil.isNotEmpty(mainEntity.getDutyGroupId())){ + Long dutyGroupId = mainEntity.getDutyGroupId(); + ImsDutyGroupEntity groupEntity = imsDutyGroupService.getById(dutyGroupId); + User manager = UserCache.getUser(groupEntity.getManagerId()); + if (cn.hutool.core.util.ObjectUtil.isNotEmpty(manager)){ + managerName=manager.getName(); + } + }else { + ImsDutyMainPersonEntity dutyMainPerson = imsDutyMainPersonService.getOne(new LambdaQueryWrapper() {{ + eq(ImsDutyMainPersonEntity::getDutyMainId, mainEntity.getId()) + .last(" limit 1"); + }}); + User manager = UserCache.getUser(dutyMainPerson.getDutyChargePerson()); + if (cn.hutool.core.util.ObjectUtil.isNotEmpty(manager)){ + managerName=manager.getName(); + } + } + return managerName; + } + + private String getManagerNumber(ImsDutyMainEntity mainEntity) { + String handNumber=""; + String[] split = mainEntity.getDutyPersonIds().split("\\^"); + if (null != split && split.length > 0) { + for (int j = 0; j < split.length; j++) { + User user = UserCache.getUser(Long.valueOf(split[j])); + if (org.springblade.core.tool.utils.ObjectUtil.isNotEmpty(user)) { + if (j == split.length - 1) { + handNumber= handNumber + user.getName(); + } else { + handNumber= handNumber + user.getName()+ "、"; + } + } + } + } + return handNumber; + } } diff --git a/hzims-service/operational/src/main/resources/template/dutyLogTemplate.docx b/hzims-service/operational/src/main/resources/template/dutyLogTemplate.docx new file mode 100644 index 0000000..24dea45 Binary files /dev/null and b/hzims-service/operational/src/main/resources/template/dutyLogTemplate.docx differ diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/feign/TicketInfoClient.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/feign/TicketInfoClient.java index bf60416..3c9d3f5 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/feign/TicketInfoClient.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/feign/TicketInfoClient.java @@ -183,6 +183,40 @@ public class TicketInfoClient implements ITicketInfoClient { return R.data(workTicketStatisticVO); } + @Override + @PostMapping("/getWorkTicketInfo") + public R> getWorkTicketInfo(@RequestBody Map params) { + String startDate = (String) params.get("startDate"); + String endDate = (String) params.get("endDate"); + List deptList = (List) params.get("deptList"); + log.info("查询工作票"); + List infoList = infoService.list(new LambdaQueryWrapper() {{ + ge(WorkTicketInfoEntity::getPlanStartTime, startDate); + le(WorkTicketInfoEntity::getPlanStartTime, endDate); + in(WorkTicketInfoEntity::getCreateDept, deptList); + }}); + return R.data(infoList); + } + /** + * 获取首页操作票统计结果 + * + * @param params + * @return + */ + @Override + @PostMapping("/getOperateTicketInfo") + public R> getOperateTicketInfo(@RequestBody Map params) { + String startDate = (String) params.get("startDate"); + String endDate = (String) params.get("endDate"); + List deptList = (List) params.get("deptList"); + List standardTicketList = standardService.list(new LambdaQueryWrapper() {{ + ge(StandardTicketInfoEntity::getStartTime, startDate); + le(StandardTicketInfoEntity::getStartTime, endDate); + in(StandardTicketInfoEntity::getCreateDept, deptList); + }}); + return R.data(standardTicketList); + } + /** * 获取首页操作票统计结果 *