diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/entity/OperDefectStatisticsEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/entity/OperDefectStatisticsEntity.java index f888978..8b21637 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/entity/OperDefectStatisticsEntity.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/entity/OperDefectStatisticsEntity.java @@ -297,4 +297,15 @@ public class OperDefectStatisticsEntity extends TenantEntity { */ @ApiModelProperty(value = "操作票") private String ticketId; + /** + * 流程实例ID + */ + @ApiModelProperty(value = "流程实例") + private String checkProcessInstanceId; + /** + * 处理状态:已处理1,未处理0,默认0 + */ + @QueryField(condition = SqlCondition.EQUAL) + @ApiModelProperty(value = "处理状态:已处理1,未处理0,默认0") + private String handleStatus; } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/entity/OperPhenomenonEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/entity/OperPhenomenonEntity.java index e9dc6af..4a7f135 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/entity/OperPhenomenonEntity.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/entity/OperPhenomenonEntity.java @@ -395,5 +395,5 @@ public class OperPhenomenonEntity extends TenantEntity { @JsonSerialize(nullsUsing = NullSerializer.class) @TableField(exist = false) @ApiModelProperty(value = "处理人") - private Long flowHandler; + private String flowHandler; } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/DefectCheckServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/DefectCheckServiceImpl.java index 7a278e2..211a043 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/DefectCheckServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/DefectCheckServiceImpl.java @@ -2,6 +2,7 @@ package com.hnac.hzims.operational.defect.service.impl; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; @@ -27,6 +28,7 @@ import com.hnac.hzims.operational.defect.service.IDefectCheckService; import com.hnac.hzims.operational.defect.service.IOperAppearanceService; import com.hnac.hzims.operational.defect.service.IOperDefectService; import com.hnac.hzims.operational.defect.service.IOperDefectStatisticsService; +import com.hnac.hzims.operational.util.TimeUtils; import com.hnac.hzims.ticket.repair.entity.RepairEntity; import com.hnac.hzims.ticket.repair.fegin.IRepairClient; import lombok.RequiredArgsConstructor; @@ -166,7 +168,8 @@ public class DefectCheckServiceImpl extends BaseServiceImpl" + entity.getDefectCode(); // 开启新的缺陷流程 String businessKey = FlowUtil.getBusinessKey("hzims_oper_phenomenon", "" + entity.getId()); - Map variable = entityToMap(entity); + Map variable = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(entity,DateUtil.PATTERN_DATETIME), Map.class); +// variables.put("creator", TaskUtil.getTaskUser(String.valueOf(AuthUtil.getUserId()))); R result = processClient.startProcessInstanceContainNameByKey(TreatMethodConstant.DEFECT_CHECK, businessKey, processName, variable); // 流程开启失败 if (!result.isSuccess()) { @@ -251,17 +254,17 @@ public class DefectCheckServiceImpl extends BaseServiceImpl variables =(Map) processWorkFlowResponse.getVariables(); + Map variables = (Map) processWorkFlowResponse.getVariables(); //现象缺陷全表更新 - operPhenomenonEntity = mapToEntity(OperPhenomenonEntity.class, variables); + operPhenomenonEntity= JSONObject.parseObject(JSONObject.toJSONString(variables), new TypeReference(){}); } catch (Exception e) { log.info("消息转换失败"); return R.fail("消息转换失败"); } - + //设置当前环节+当前环节处理人 if (processWorkFlowResponse.getTaskId() != null || processWorkFlowResponse.getUserId() != null) { - operPhenomenonEntity.setCurrentOperator(processWorkFlowResponse.getNextStepOperator()); - operPhenomenonEntity.setCurrentLinkHandler(processWorkFlowResponse.getProcessDefinitionKey()); + operPhenomenonEntity.setCurrentOperator(processWorkFlowResponse.getTaskName()); + operPhenomenonEntity.setCurrentLinkHandler(processWorkFlowResponse.getNextStepOperator()); } //缺陷记录 OperDefectStatisticsEntity statisticsEntity = statisticsService.getOne(new LambdaUpdateWrapper() {{ @@ -271,7 +274,17 @@ public class DefectCheckServiceImpl extends BaseServiceImpl() {{ eq(OperAppearanceEntity::getDefectCode, operPhenomenonEntity.getDefectCode()); }}); - if (ObjectUtil.isNotEmpty(operPhenomenonEntity.getIsWarehousing()) && "1".equals(operPhenomenonEntity.getIsWarehousing())) { + //计算工时 + if(ObjectUtils.isNotEmpty(operPhenomenonEntity.getActStartTime())&&ObjectUtils.isNotEmpty(operPhenomenonEntity.getActEndTime())){ + Long differTime = TimeUtils.getDifferTime(operPhenomenonEntity.getActStartTime(), operPhenomenonEntity.getActEndTime()); + operPhenomenonEntity.setCheckHours(differTime.intValue()); + } + if(ObjectUtils.isNotEmpty(operPhenomenonEntity.getPlanStartTime())&&ObjectUtils.isNotEmpty(operPhenomenonEntity.getPlanEndTime())){ + Long differTime = TimeUtils.getDifferTime(operPhenomenonEntity.getPlanStartTime(), operPhenomenonEntity.getPlanEndTime()); + operPhenomenonEntity.setPlanHours(differTime.intValue()); + } + //缺陷库记录 + if (ObjectUtil.isNotEmpty(operPhenomenonEntity.getIsWarehousing()) && 1==(operPhenomenonEntity.getIsWarehousing())) { OperDefectEntity operDefectEntity = new OperDefectEntity(); BeanUtil.copy(operPhenomenonEntity, operDefectEntity); operDefectEntity.setProcessInstanceId(operPhenomenonEntity.getHandleTaskId().toString()); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperAppearanceServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperAppearanceServiceImpl.java index 9b9756c..b0ddfef 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperAppearanceServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperAppearanceServiceImpl.java @@ -5,7 +5,6 @@ import com.hnac.hzims.operational.defect.entity.OperAppearanceEntity; import com.hnac.hzims.operational.defect.mapper.OperAppearanceMapper; import com.hnac.hzims.operational.defect.service.IOperAppearanceService; import com.hnac.hzims.operational.defect.vo.OperAppearanceVO; -import net.logstash.logback.encoder.org.apache.commons.lang3.ObjectUtils; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.mp.support.Condition; import org.springblade.core.tool.utils.Func; @@ -23,7 +22,7 @@ public class OperAppearanceServiceImpl extends BaseServiceImpl getQueryWrapper(OperAppearanceVO operAppearanceVO) { LambdaQueryWrapper queryWrapper = Condition.getQueryWrapper(new OperAppearanceEntity(), operAppearanceVO); - if (ObjectUtils.isEmpty(operAppearanceVO)) { + if (Func.isNotEmpty(operAppearanceVO)) { if (StringUtil.isNotBlank(operAppearanceVO.getDefectCode())) { queryWrapper.eq(OperAppearanceEntity::getId, operAppearanceVO.getDefectCode()); } @@ -42,6 +41,9 @@ public class OperAppearanceServiceImpl extends BaseServiceImpl getQueryWrapper(OperDefectVO defectVO) { LambdaQueryWrapper queryWrapper = Condition.getQueryWrapper(new OperDefectEntity(), defectVO); - if (ObjectUtils.isEmpty(defectVO)) { + if (Func.isNotEmpty(defectVO)) { if (defectVO.getActStartTime() != null) { queryWrapper.ge(OperDefectEntity::getActStartTime, defectVO.getActStartTime()); } @@ -153,7 +153,7 @@ public class OperDefectServiceImpl extends BaseServiceImpl getQueryWrapper(OperDefectStatisticsVO statistics) { LambdaQueryWrapper queryWrapper = Condition.getQueryWrapper(new OperDefectStatisticsEntity(),statistics); - if(statistics.getActStartTime()!=null){ - queryWrapper.ge(OperDefectStatisticsEntity::getActStartTime,statistics.getActStartTime()); - } - if(statistics.getActEndTime()!=null){ - queryWrapper.le(OperDefectStatisticsEntity::getActStartTime,statistics.getActEndTime()); - } - if (statistics.getDefectLevel() != null) { - queryWrapper.like(OperDefectStatisticsEntity::getDefectLevel, statistics.getDefectLevel()); - } - if (statistics.getDisposer() != null) { - queryWrapper.eq(OperDefectStatisticsEntity::getDisposer, statistics.getDisposer()); - } - if (statistics.getConclusion() != null) { - queryWrapper.like(OperDefectStatisticsEntity::getConclusion, statistics.getConclusion()); - } - if (statistics.getConclusionTime() != null) { - queryWrapper.le(OperDefectStatisticsEntity::getConclusionTime, statistics.getConclusionTime()); - } - if (Func.isNotEmpty(statistics.getConclusionEndTime())) { - queryWrapper.ge(OperDefectStatisticsEntity::getConclusionTime, statistics.getConclusionEndTime()); - } - if (statistics.getCreateTime() != null) { - queryWrapper.le(OperDefectStatisticsEntity::getCreateTime, statistics.getCreateTime()); - } - if (Func.isNotEmpty(statistics.getCreateEndTime())) { - queryWrapper.ge(OperDefectStatisticsEntity::getCreateTime, statistics.getCreateEndTime()); - } - if (statistics.getEmCode() != null) { - queryWrapper.eq(OperDefectStatisticsEntity::getEmCode, statistics.getEmCode()); - } - if (statistics.getIsWarehousing() != null) { - queryWrapper.eq(OperDefectStatisticsEntity::getIsWarehousing, statistics.getIsWarehousing()); - } - if (statistics.getSourceCode() != null) { - queryWrapper.eq(OperDefectStatisticsEntity::getSourceCode, statistics.getSourceCode()); - } - if (statistics.getConclusionPeople() != null) { - queryWrapper.eq(OperDefectStatisticsEntity::getConclusionPeople, statistics.getConclusionPeople()); - } - if (statistics.getCreateDept() != null) { - queryWrapper.eq(OperDefectStatisticsEntity::getCreateDept, statistics.getCreateDept()); + if(Func.isNotEmpty(statistics)) { + if (statistics.getActStartTime() != null) { + queryWrapper.ge(OperDefectStatisticsEntity::getActStartTime, statistics.getActStartTime()); + } + if (statistics.getActEndTime() != null) { + queryWrapper.le(OperDefectStatisticsEntity::getActStartTime, statistics.getActEndTime()); + } + if (statistics.getDefectLevel() != null) { + queryWrapper.like(OperDefectStatisticsEntity::getDefectLevel, statistics.getDefectLevel()); + } + if (statistics.getDisposer() != null) { + queryWrapper.eq(OperDefectStatisticsEntity::getDisposer, statistics.getDisposer()); + } + if (statistics.getConclusion() != null) { + queryWrapper.like(OperDefectStatisticsEntity::getConclusion, statistics.getConclusion()); + } + if (statistics.getName() != null) { + queryWrapper.like(OperDefectStatisticsEntity::getName, statistics.getName()); + } + if (statistics.getConclusionTime() != null) { + queryWrapper.le(OperDefectStatisticsEntity::getConclusionTime, statistics.getConclusionTime()); + } + if (Func.isNotEmpty(statistics.getConclusionEndTime())) { + queryWrapper.ge(OperDefectStatisticsEntity::getConclusionTime, statistics.getConclusionEndTime()); + } + if (statistics.getCreateTime() != null) { + queryWrapper.le(OperDefectStatisticsEntity::getCreateTime, statistics.getCreateTime()); + } + if (Func.isNotEmpty(statistics.getCreateEndTime())) { + queryWrapper.ge(OperDefectStatisticsEntity::getCreateTime, statistics.getCreateEndTime()); + } + if (statistics.getIsDefect() != null) { + queryWrapper.eq(OperDefectStatisticsEntity::getIsDefect, statistics.getIsDefect()); + } + if (statistics.getEmCode() != null) { + queryWrapper.eq(OperDefectStatisticsEntity::getEmCode, statistics.getEmCode()); + } + if (statistics.getIsWarehousing() != null) { + queryWrapper.eq(OperDefectStatisticsEntity::getIsWarehousing, statistics.getIsWarehousing()); + } + if (statistics.getSourceCode() != null) { + queryWrapper.eq(OperDefectStatisticsEntity::getSourceCode, statistics.getSourceCode()); + } + if (statistics.getConclusionPeople() != null) { + queryWrapper.eq(OperDefectStatisticsEntity::getConclusionPeople, statistics.getConclusionPeople()); + } + if (statistics.getCreateDept() != null) { + queryWrapper.eq(OperDefectStatisticsEntity::getCreateDept, statistics.getCreateDept()); + } + } queryWrapper.orderByDesc(OperDefectStatisticsEntity::getCreateTime); return queryWrapper; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/TimeUtils.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/TimeUtils.java new file mode 100644 index 0000000..cf784b7 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/TimeUtils.java @@ -0,0 +1,28 @@ +package com.hnac.hzims.operational.util; + +import java.math.BigDecimal; +import java.util.Date; + +public class TimeUtils { + + private static int sheet1NowRow, sheet2NowRow; + + + /** + * 相差时数 + * @author ty + * @param endDate + * @param nowDate + * @return + */ + public static Long getDifferTime(Date endDate, Date nowDate) { +// long nd = 1000 * 24 * 60 * 60L; + long nh = 1000 * 60 * 60L; + // 获得两个时间的毫秒时间差异 + long diff = endDate.getTime() - nowDate.getTime(); + BigDecimal s=BigDecimal.valueOf(diff).divide(BigDecimal.valueOf(diff)).setScale(0, BigDecimal.ROUND_HALF_UP); + Long hour=s.longValue(); + return hour; + } + +}