diff --git a/src/main/java/com/zhgd/xmgl/modules/baotou/entity/WelderAssessmentRequest.java b/src/main/java/com/zhgd/xmgl/modules/baotou/entity/WelderAssessmentRequest.java index c036d4b81..3bfa8cdac 100644 --- a/src/main/java/com/zhgd/xmgl/modules/baotou/entity/WelderAssessmentRequest.java +++ b/src/main/java/com/zhgd/xmgl/modules/baotou/entity/WelderAssessmentRequest.java @@ -2,6 +2,9 @@ package com.zhgd.xmgl.modules.baotou.entity; import java.io.Serializable; import java.util.Date; +import java.util.HashMap; +import java.util.List; + import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; diff --git a/src/main/java/com/zhgd/xmgl/modules/baotou/entity/WelderSkillExam.java b/src/main/java/com/zhgd/xmgl/modules/baotou/entity/WelderSkillExam.java index 2cf1bef12..2b23e3192 100644 --- a/src/main/java/com/zhgd/xmgl/modules/baotou/entity/WelderSkillExam.java +++ b/src/main/java/com/zhgd/xmgl/modules/baotou/entity/WelderSkillExam.java @@ -47,24 +47,36 @@ public class WelderSkillExam implements Serializable { private java.lang.String originalCertificateValidityPeriod ; /**焊工作业证编号*/ @ApiModelProperty(value="焊工作业证编号") - private java.lang.String welderWorkPermitNumber ; - /**焊工考核项目*/ - @ApiModelProperty(value="焊工考核项目") - private java.lang.String welderAssessmentItem ; - /**现场考核日期*/ - @ApiModelProperty(value="现场考核日期") - private java.lang.String onSiteAssessmentDate ; - /**考核结果*/ - @ApiModelProperty(value="考核结果") - private java.lang.String assessmentResult ; - /**创建时间 yyyy-MM-dd HH:mm:ss*/ - @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") - @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") - @ApiModelProperty(value="创建时间 yyyy-MM-dd HH:mm:ss") - private java.util.Date createTime ; - /**更新时间 yyyy-MM-dd HH:mm:ss*/ - @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") - @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") - @ApiModelProperty(value="更新时间 yyyy-MM-dd HH:mm:ss") - private java.util.Date updateTime ; + private java.lang.String welderWorkPermitNumber; + /** + * 焊工考核项目 + */ + @ApiModelProperty(value = "焊工考核项目") + private java.lang.String welderAssessmentItem; + /** + * 现场考核日期 + */ + @ApiModelProperty(value = "现场考核日期") + private java.lang.String onSiteAssessmentDate; + /** + * 考核结果 + */ + @ApiModelProperty(value = "考核结果") + private java.lang.String assessmentResult; + /** + * 创建时间 yyyy-MM-dd HH:mm:ss + */ + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "创建时间 yyyy-MM-dd HH:mm:ss") + private java.util.Date createTime; + /** + * 更新时间 yyyy-MM-dd HH:mm:ss + */ + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "更新时间 yyyy-MM-dd HH:mm:ss") + private java.util.Date updateTime; + @ApiModelProperty(value = "焊工考核申请id") + private java.lang.Long requestId; } diff --git a/src/main/java/com/zhgd/xmgl/modules/baotou/plan/controller/PlanRecordController.java b/src/main/java/com/zhgd/xmgl/modules/baotou/plan/controller/PlanRecordController.java index b75699341..0628d9dc4 100644 --- a/src/main/java/com/zhgd/xmgl/modules/baotou/plan/controller/PlanRecordController.java +++ b/src/main/java/com/zhgd/xmgl/modules/baotou/plan/controller/PlanRecordController.java @@ -1,14 +1,18 @@ package com.zhgd.xmgl.modules.baotou.plan.controller; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.zhgd.annotation.OperLog; import com.zhgd.jeecg.common.api.vo.Result; -import com.zhgd.xmgl.modules.baotou.plan.entity.PlanFeedbackPeriod; -import com.zhgd.xmgl.modules.baotou.plan.entity.PlanRecord; -import com.zhgd.xmgl.modules.baotou.plan.service.IPlanRecordService; +import com.zhgd.xmgl.modules.baotou.plan.entity.*; +import com.zhgd.xmgl.modules.baotou.plan.mapper.PlanRecordMapper; +import com.zhgd.xmgl.modules.baotou.plan.service.*; +import com.zhgd.xmgl.modules.stuff.entity.StuffType; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -17,13 +21,13 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.MapUtils; import org.simpleframework.xml.core.Validate; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; /** @@ -38,8 +42,42 @@ import java.util.Map; @Slf4j @Api(tags = "进度计划编制相关Api") public class PlanRecordController { + @Lazy @Autowired private IPlanRecordService planRecordService; + @Lazy + @Autowired + private IPlanPbsService planPbsService; + @Lazy + @Autowired + private IPlanMilestoneService planMilestoneService; + @Lazy + @Autowired + private PlanRecordMapper planRecordMapper; + @Lazy + @Autowired + private IPlanFeedbackService planFeedbackService; + @Lazy + @Autowired + private IPlanPeriodService planPeriodService; + @Lazy + @Autowired + private IPlanFeedbackPeriodService planFeedbackPeriodService; + @Lazy + @Autowired + private IPlanMilestoneValService planMilestoneValService; + @Lazy + @Autowired + private IPlanCalendarTemplateService planCalendarTemplateService; + @Lazy + @Autowired + private IPlanWorkCategoryService planWorkCategoryService; + @Lazy + @Autowired + private IPlanChooseCategoryService planChooseCategoryService; + @Lazy + @Autowired + private IPlanFeedbackApprovalWorkService planFeedbackApprovalWorkService; /** * 分页列表查询 @@ -59,7 +97,6 @@ public class PlanRecordController { return Result.success(planRecordService.queryPageList(param)); } - /** * 列表查询 * @@ -154,6 +191,7 @@ public class PlanRecordController { @ApiOperation(value = "查询进度曲线", notes = "查询进度曲线", httpMethod = "GET") @ApiImplicitParams({ @ApiImplicitParam(name = "recordId", value = "计划编制id", paramType = "query", required = true, dataType = "String"), + @ApiImplicitParam(name = "pbsId", value = "进度PBSID(计划编制id和进度PBSID必传其中之一,都传以计划编制id为准)", paramType = "query", required = true, dataType = "String"), @ApiImplicitParam(name = "beginDate", value = "开始日期", paramType = "query", required = false, dataType = "String"), @ApiImplicitParam(name = "endDate", value = "结束日期", paramType = "query", required = false, dataType = "String"), @ApiImplicitParam(name = "year", value = "年份", paramType = "query", required = false, dataType = "String") @@ -166,12 +204,81 @@ public class PlanRecordController { param.put("endDate", year + "-12" + "-31"); } try { - return Result.success(planRecordService.getPlanCurve(param)); + String recordId = MapUtils.getString(param, "recordId"); + if (StrUtil.isNotBlank(recordId)) { + return Result.success(planRecordService.getPlanCurve(param)); + } else { + Long pbsId = MapUtils.getLong(param, "pbsId"); + List planPbs = planPbsService.getChildren(pbsId); + List pbsIds = planPbs.stream().map(PlanPbs::getId).collect(Collectors.toList()); + pbsIds.add(pbsId); + List> rtList = new ArrayList<>(); + List records = planRecordService.list(new LambdaQueryWrapper() + .eq(PlanRecord::getPbsId, pbsIds) + .eq(PlanRecord::getParentId, 0) + ); + Map> dateMap = new HashMap<>(); + String projectSn = planPbs.get(0).getProjectSn(); + List milestones = planMilestoneService.list(new LambdaQueryWrapper().eq(PlanMilestone::getProjectSn, projectSn)); + PlanPeriod planPeriod = planPeriodService.getOne(new LambdaQueryWrapper().eq(PlanPeriod::getProjectSn, projectSn)); + List allPlanRecords = planRecordMapper.selectList(new LambdaQueryWrapper().eq(PlanRecord::getProjectSn, projectSn)); + Map> childrenMap = new HashMap<>(); + for (PlanRecord record : records) { + childrenMap.put(record.getId(), this.getChildren(record, allPlanRecords)); + } + for (PlanRecord record : records) { + List periods = planRecordService.getPlanSharesForCurve(param, record, milestones, planPeriod, allPlanRecords, childrenMap.get(record.getId())); + for (PlanFeedbackPeriod period : periods) { + List periodList = dateMap.get(period.getPeriodStart()); + if (periodList == null) { + periodList = new ArrayList<>(); + dateMap.put(period.getPeriodStart(), periodList); + } + periodList.add(period); + } + } + List planShares = dateMap.entrySet().stream().map(o -> { + PlanFeedbackPeriod feedbackPeriod = new PlanFeedbackPeriod(); + List list = o.getValue(); + BigDecimal planYdz = BigDecimal.ZERO; + BigDecimal actualYdz = BigDecimal.ZERO; + for (PlanFeedbackPeriod period : list) { + planYdz = NumberUtil.add(planYdz, period.getPlanYdz()); + actualYdz = NumberUtil.add(actualYdz, period.getActualYdz()); + } + feedbackPeriod.setPlanYdz(NumberUtil.div(planYdz, list.size())); + feedbackPeriod.setActualYdz(NumberUtil.div(actualYdz, list.size())); + return feedbackPeriod; + }).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(planShares)) { + BigDecimal p = new BigDecimal("0"); + BigDecimal a = new BigDecimal("0"); + for (PlanFeedbackPeriod feedbackPeriod : planShares) { + HashMap map = new HashMap<>(); + map.put("time", DateUtil.formatDate(feedbackPeriod.getPeriodStart())); + map.put("plan", feedbackPeriod.getPlanYdz()); + map.put("actual", feedbackPeriod.getActualYdz()); + p = NumberUtil.add(p, feedbackPeriod.getPlanYdz()); + a = NumberUtil.add(a, feedbackPeriod.getActualYdz()); + map.put("planTotal", p); + map.put("actualTotal", a); + rtList.add(map); + } + } + return Result.success(rtList); + } } catch (Exception e) { return Result.success(new ArrayList<>(), e.getMessage()); } } + private List getChildren(PlanRecord st, List allList) { + return allList.stream() + .filter(m -> Objects.equals(m.getParentId(), st.getId())) + .peek(m -> m.setChildren(getChildren(m, allList))) + .collect(Collectors.toList()); + } + @OperLog(operModul = "进度计划编制管理", operType = "", operDesc = "查询项目里程碑") @ApiOperation(value = "查询项目里程碑", notes = "查询项目里程碑", httpMethod = "GET") @ApiImplicitParams({ diff --git a/src/main/java/com/zhgd/xmgl/modules/baotou/plan/service/IPlanPbsService.java b/src/main/java/com/zhgd/xmgl/modules/baotou/plan/service/IPlanPbsService.java index e74b3934f..1e76dbf4b 100644 --- a/src/main/java/com/zhgd/xmgl/modules/baotou/plan/service/IPlanPbsService.java +++ b/src/main/java/com/zhgd/xmgl/modules/baotou/plan/service/IPlanPbsService.java @@ -43,12 +43,16 @@ public interface IPlanPbsService extends IService { * @return */ void delete(String id); + /** * 根据id查询进度PBS信息 + * * @param id 进度PBS的id * @return */ PlanPbs queryById(String id); IPage queryTreePage(HashMap param); + + List getChildren(Long pbsId); } diff --git a/src/main/java/com/zhgd/xmgl/modules/baotou/plan/service/IPlanRecordService.java b/src/main/java/com/zhgd/xmgl/modules/baotou/plan/service/IPlanRecordService.java index 3f2c89717..1c366826e 100644 --- a/src/main/java/com/zhgd/xmgl/modules/baotou/plan/service/IPlanRecordService.java +++ b/src/main/java/com/zhgd/xmgl/modules/baotou/plan/service/IPlanRecordService.java @@ -3,6 +3,8 @@ package com.zhgd.xmgl.modules.baotou.plan.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import com.zhgd.xmgl.modules.baotou.plan.entity.PlanFeedbackPeriod; +import com.zhgd.xmgl.modules.baotou.plan.entity.PlanMilestone; +import com.zhgd.xmgl.modules.baotou.plan.entity.PlanPeriod; import com.zhgd.xmgl.modules.baotou.plan.entity.PlanRecord; import java.util.HashMap; @@ -72,7 +74,9 @@ public interface IPlanRecordService extends IService { List getPlanShares(Map param); + List getPlanSharesForCurve(Map param, PlanRecord record, List milestones, PlanPeriod planPeriod, List planRecords, List children); + List> getPlanCurve(Map param); - HashMap getProjectMilestone(HashMap param); + HashMap getProjectMilestone(HashMap param); } diff --git a/src/main/java/com/zhgd/xmgl/modules/baotou/plan/service/impl/PlanPbsServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/baotou/plan/service/impl/PlanPbsServiceImpl.java index c8faea355..41421c7c0 100644 --- a/src/main/java/com/zhgd/xmgl/modules/baotou/plan/service/impl/PlanPbsServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/baotou/plan/service/impl/PlanPbsServiceImpl.java @@ -22,7 +22,6 @@ import com.zhgd.xmgl.modules.baotou.plan.service.IPlanRecordService; import com.zhgd.xmgl.security.entity.UserInfo; import com.zhgd.xmgl.security.util.SecurityUtils; import com.zhgd.xmgl.util.ListUtils; -import com.zhgd.xmgl.util.MapBuilder; import com.zhgd.xmgl.util.PageUtil; import com.zhgd.xmgl.util.RefUtil; import org.springframework.beans.factory.annotation.Autowired; @@ -190,4 +189,8 @@ public class PlanPbsServiceImpl extends ServiceImpl impl return p; } + @Override + public List getChildren(Long pbsId) { + return baseMapper.getChildren(pbsId); + } } diff --git a/src/main/java/com/zhgd/xmgl/modules/baotou/plan/service/impl/PlanRecordServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/baotou/plan/service/impl/PlanRecordServiceImpl.java index a1db7310a..6d0fca022 100644 --- a/src/main/java/com/zhgd/xmgl/modules/baotou/plan/service/impl/PlanRecordServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/baotou/plan/service/impl/PlanRecordServiceImpl.java @@ -327,6 +327,46 @@ public class PlanRecordServiceImpl extends ServiceImpl getPlanSharesForCurve(Map param, PlanRecord record, List milestones, PlanPeriod planPeriod, List planRecords, List children) { + String beginDate = MapUtils.getString(param, "periodStart"); + String endDate = MapUtils.getString(param, "periodEnd"); + List feedbackPeriods; + //判断是否最后一级wbs,是的话需要显示里程碑 + children = ObjectUtil.cloneByStream(children); + children.add(record); + List trees = BeanUtil.copyToList(ListUtils.listToTree(JSONArray.parseArray(JSON.toJSONString(children)), "id", "parentId", "children"), PlanRecord.class); + Map map = this.getChildFeedbackPeriodMap(trees.get(0), planRecords, milestones, planPeriod); + feedbackPeriods = new ArrayList<>(map.values()); + if (CollUtil.isNotEmpty(feedbackPeriods)) { + if (StrUtil.isNotBlank(beginDate)) { + feedbackPeriods = feedbackPeriods.stream().filter(o -> DateUtil.compare(DateUtil.parseDate(beginDate), o.getPeriodEnd()) <= 0).collect(Collectors.toList()); + } + if (StrUtil.isNotBlank(endDate)) { + feedbackPeriods = feedbackPeriods.stream().filter(o -> DateUtil.compare(DateUtil.parseDate(endDate), o.getPeriodStart()) >= 0).collect(Collectors.toList()); + } + } + //去掉里程碑 + for (PlanFeedbackPeriod period : feedbackPeriods) { + period.setMilestoneVals(new ArrayList<>()); + } + //多的周期要删除,少的周期要添加 + List feedbackPeriods1 = new ArrayList<>(); + List myPeriods = this.getCalFeedbackPeriods(record); + for (PlanFeedbackPeriod myPeriod : myPeriods) { + Optional first = feedbackPeriods.stream().filter(o -> DateUtil.compare(o.getPeriodStart(), myPeriod.getPeriodStart()) == 0).findFirst(); + PlanFeedbackPeriod planFeedbackPeriod; + if (first.isPresent()) { + planFeedbackPeriod = first.get(); + } else { + planFeedbackPeriod = myPeriod; + } + feedbackPeriods1.add(planFeedbackPeriod); + } + feedbackPeriods1 = feedbackPeriods1.stream().sorted((o1, o2) -> o1.getPeriodStart().compareTo(o2.getPeriodStart())).collect(Collectors.toList()); + return feedbackPeriods1; + } + private List getCalFeedbackPeriods(PlanRecord record) { String recordId = String.valueOf(record.getId()); List feedbackPeriods = new ArrayList<>(); diff --git a/src/main/java/com/zhgd/xmgl/modules/baotou/service/impl/EngineerControllerCheckServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/baotou/service/impl/EngineerControllerCheckServiceImpl.java index 16a340291..beaa5ccf1 100644 --- a/src/main/java/com/zhgd/xmgl/modules/baotou/service/impl/EngineerControllerCheckServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/baotou/service/impl/EngineerControllerCheckServiceImpl.java @@ -122,7 +122,7 @@ public class EngineerControllerCheckServiceImpl extends ServiceImpl workerInfoList = workerInfoService.list(new LambdaQueryWrapper() + .eq(WorkerInfo::getProjectSn, request.getProjectSn())); + if (StrUtil.isNotBlank(request.getAssessmentPersonnel())) { + JSONArray ja = JSON.parseArray(request.getAssessmentPersonnel()); + for (int i = 0; i < ja.size(); i++) { + JSONObject jo = ja.getJSONObject(i); + JSONArray detail = jo.getJSONArray("field9890898665453"); + for (int j = 0; j < detail.size(); j++) { + JSONObject jo1 = detail.getJSONObject(j); + //筛选合格的 + if (!Objects.equals(FlowUtil.getInteger(jo1, "field1125873837893"), 1)) { + continue; + } + Optional op = workerInfoList.stream().filter(o -> o.getId().equals(MapUtils.getLong(jo, "field5383524265804"))).findFirst(); + if (op.isPresent()) { + WorkerInfo workerInfo = op.get(); + WelderSkillExam wse = new WelderSkillExam(); + wse.setProjectSn(request.getProjectSn()); + wse.setWelderName(workerInfo.getWorkerName()); + wse.setGender(Objects.equals(workerInfo.getSex(), 1) ? "男" : "女"); + wse.setWelderCertificateNumber(jo.getString("field1723198628254")); + wse.setWelderCertificateQualificationItem(jo1.getString("field1494098725099")); + wse.setOriginalCertificateValidityPeriod(jo.getString("field5004498659255")); + wse.setWelderWorkPermitNumber(jo.getString("field4547398747381")); + wse.setWelderAssessmentItem(jo1.getString("field4501024932536")); + wse.setOnSiteAssessmentDate(DateUtil.formatDate(DateUtil.parse(jo1.getString("field7688098758155")))); + wse.setAssessmentResult("合格"); + wse.setRequestId(request.getId()); + welderSkillExamService.add(wse); + } + } + } + } } @Override - public void edit(WelderAssessmentRequest welderAssessmentRequest) { - WelderAssessmentRequest oldWelderAssessmentRequest = baseMapper.selectById(welderAssessmentRequest.getId()); + public void edit(WelderAssessmentRequest request) { + WelderAssessmentRequest oldWelderAssessmentRequest = baseMapper.selectById(request.getId()); if (oldWelderAssessmentRequest == null) { throw new OpenAlertException("未找到对应实体"); } - baseMapper.updateById(welderAssessmentRequest); + baseMapper.updateById(request); + welderSkillExamService.remove(new LambdaQueryWrapper() + .eq(WelderSkillExam::getRequestId, request.getId())); + this.addSkillExam(request); } @Override @@ -91,6 +137,8 @@ public class WelderAssessmentRequestServiceImpl extends ServiceImpl() + .eq(WelderSkillExam::getRequestId, id)); } @Override @@ -149,6 +197,7 @@ public class WelderAssessmentRequestServiceImpl extends ServiceImpl i @Override public void saveBaseMenu(BaseMenu baseMenu) { if (baseMenu.getPriority() == null) { - baseMenu.setPriority(0); + baseMenu.setPriority(0D); } if (baseMenu.getStatus() == null) { baseMenu.setStatus(1); @@ -196,7 +196,7 @@ public class BaseMenuServiceImpl extends ServiceImpl i throw new OpenAlertException(MessageUtil.get("notFindErr")); } if (baseMenu.getPriority() == null) { - baseMenu.setPriority(0); + baseMenu.setPriority(0D); } baseMenuMapper.updateById(baseMenu); // 同步权限表里的信息 diff --git a/src/main/java/com/zhgd/xmgl/modules/bigdevice/service/impl/TowerServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/bigdevice/service/impl/TowerServiceImpl.java index b4d751c06..85968ec0c 100644 --- a/src/main/java/com/zhgd/xmgl/modules/bigdevice/service/impl/TowerServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/bigdevice/service/impl/TowerServiceImpl.java @@ -13,6 +13,7 @@ import com.zhgd.jeecg.common.mybatis.EntityMap; import com.zhgd.mqtt.server.IMqttSender; import com.zhgd.redis.lock.RedisRepository; import com.zhgd.xmgl.async.AsyncTower; +import com.zhgd.xmgl.constant.Cts; import com.zhgd.xmgl.modules.basicdata.entity.SystemUser; import com.zhgd.xmgl.modules.basicdata.enums.SystemUserAccountTypeEnum; import com.zhgd.xmgl.modules.basicdata.service.ICompanyService; @@ -27,10 +28,7 @@ import com.zhgd.xmgl.modules.project.entity.ProjectVideoConfig; import com.zhgd.xmgl.modules.project.enums.ProjectVideoConfigVideoTypeEnum; import com.zhgd.xmgl.modules.project.mapper.ProjectDevStatisticsMapper; import com.zhgd.xmgl.modules.project.service.IProjectVideoConfigService; -import com.zhgd.xmgl.util.MessageUtil; -import com.zhgd.xmgl.util.RefUtil; -import com.zhgd.xmgl.util.TimeUtil; -import com.zhgd.xmgl.util.YsVideoUtil; +import com.zhgd.xmgl.util.*; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.MapUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -471,7 +469,8 @@ public class TowerServiceImpl extends ServiceImpl implements @Override public void offlineAlarm(Tower offlineTower) { - List systemUserList = systemUserService.list(Wrappers.lambdaQuery().eq(SystemUser::getSn, offlineTower.getProjectSn())); +// List systemUserList = systemUserService.list(Wrappers.lambdaQuery().eq(SystemUser::getSn, offlineTower.getProjectSn())); + List systemUserList = systemUserService.getSystemUsersBySn(new MapBuilder().put(Cts.SN, offlineTower.getProjectSn()).put(Cts.QUERY_TYPE, Cts.PROJECT_LEVEL).build()); log.debug("要推送-----" + (systemUserList == null ? 0 : systemUserList.size()) + "个人员 塔吊离线通知消息"); asyncTower.sendOfflineAlarm(systemUserList, offlineTower, "有塔吊超过5分钟无数据,请注意。位置:" + offlineTower.getDevName(), "塔吊超过5分钟离线通知", "/pages"); } diff --git a/src/main/java/com/zhgd/xmgl/modules/exam/controller/ExamWorkerController.java b/src/main/java/com/zhgd/xmgl/modules/exam/controller/ExamWorkerController.java index 953f0eefa..cb9cc6692 100644 --- a/src/main/java/com/zhgd/xmgl/modules/exam/controller/ExamWorkerController.java +++ b/src/main/java/com/zhgd/xmgl/modules/exam/controller/ExamWorkerController.java @@ -1,6 +1,5 @@ package com.zhgd.xmgl.modules.exam.controller; -import cn.afterturn.easypoi.word.WordExportUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.io.FileUtil; @@ -37,7 +36,6 @@ import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.MapUtils; -import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.web.bind.annotation.*; @@ -47,8 +45,6 @@ import javax.servlet.http.HttpServletResponse; import java.io.File; import java.io.IOException; import java.math.BigDecimal; -import java.net.URLDecoder; -import java.net.URLEncoder; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; @@ -251,7 +247,7 @@ public class ExamWorkerController { String tempUrl = Fileutils.getExportTemplateFile("template/下载试卷模板.docx").getAbsolutePath(); // String tempUrl = "C:\\Users\\Administrator\\Desktop\\下载试卷模板.docx"; //生成word文档流 - EasyPoiUtil.exportNewLineWord(response, params, FileUtil.file(tempUrl)); + EasyPoiUtil.exportNewLineWordAndPicForExam(response, params, FileUtil.file(tempUrl)); } catch (Exception e) { log.error("导出试卷出现异常", e); @@ -417,17 +413,17 @@ public class ExamWorkerController { JSONArray ja = JSON.parseArray(question.getPic()); if (CollUtil.isNotEmpty(ja)) { //保存图片占位符 -// try { -// String imageKey = "image" + i[0]; -// String url = ja.getJSONObject(0).getString("url"); -// String dest = PathUtil.getBasePath() + "/temp/" + IdUtil.randomUUID() + "." + StrUtil.subAfter(url, ".", true); -// HttpUtil.downloadFile(url, dest); -// imageMap.put(imageKey, EasyPoiUtil.imgFormatting(dest, 18, 18)); -// content.append("##" + imageKey + "##"); -// params.put(imageKey, imageMap.get(imageKey)); -// } catch (Exception e) { -// log.error("导出word添加题目和选项错误", e); -// } + try { + String imageKey = "image" + i[0]; + String url = ja.getJSONObject(0).getString("url"); + String dest = PathUtil.getBasePath() + "/temp/" + IdUtil.randomUUID() + "." + StrUtil.subAfter(url, ".", true); + HttpUtil.downloadFile(url, dest); + imageMap.put(imageKey, EasyPoiUtil.imgFormatting(dest, 18, 18)); + content.append("##" + imageKey + "##"); + params.put(imageKey, imageMap.get(imageKey)); + } catch (Exception e) { + log.error("导出word添加题目和选项错误", e); + } } } String selectOption = question.getSelectOption(); @@ -442,8 +438,15 @@ public class ExamWorkerController { } content.append(" "); List optionList = question.getOptionList(); + //判断选项过长需要换行 + boolean newLine = optionList.stream().anyMatch(o -> (o.getOptionCode() + "、" + o.getOptionDesc()).length() > 26); + boolean first = true; //遍历选项 for (ExamQuestionOption option : optionList) { + if (newLine && !first) { + content.append("\n "); + } + first = false; content.append(option.getOptionCode()).append("、").append(option.getOptionDesc()).append(" "); } content.append("\n"); diff --git a/src/main/java/com/zhgd/xmgl/modules/file/service/impl/FiletransferServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/file/service/impl/FiletransferServiceImpl.java index ab9af24e8..e81dbe442 100644 --- a/src/main/java/com/zhgd/xmgl/modules/file/service/impl/FiletransferServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/file/service/impl/FiletransferServiceImpl.java @@ -37,8 +37,7 @@ public class FiletransferServiceImpl implements IFiletransferService { private ProjectFileAuthMapper projectFileAuthMapper; @Override - public void - uploadFile(HttpServletRequest request, UploadFileDTO uploadFileDTO) { + public void uploadFile(HttpServletRequest request, UploadFileDTO uploadFileDTO) { UploadFile uploadFile = new UploadFile(); uploadFile.setChunkNumber(uploadFileDTO.getChunkNumber()); uploadFile.setChunkSize(uploadFileDTO.getChunkSize()); diff --git a/src/main/java/com/zhgd/xmgl/modules/video/service/impl/VideoItemServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/video/service/impl/VideoItemServiceImpl.java index cba30a7b2..e7ccf7f6c 100644 --- a/src/main/java/com/zhgd/xmgl/modules/video/service/impl/VideoItemServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/video/service/impl/VideoItemServiceImpl.java @@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.zhgd.jeecg.common.execption.OpenAlertException; import com.zhgd.jeecg.common.mybatis.EntityMap; import com.zhgd.xmgl.async.AsyncCommon; +import com.zhgd.xmgl.constant.Cts; import com.zhgd.xmgl.modules.basicdata.entity.DictionariesRecord; import com.zhgd.xmgl.modules.basicdata.mapper.DictionariesRecordMapper; import com.zhgd.xmgl.modules.basicdata.service.ICompanyService; @@ -187,7 +188,7 @@ public class VideoItemServiceImpl extends ServiceImpl carCameras = carCameraMapper.selectList(new LambdaQueryWrapper().eq(CarCamera::getAirtightVideoItemId, itemId).or().eq(CarCamera::getWashVideoItemId, itemId)); + List carCameras = carCameraMapper.selectList(new LambdaQueryWrapper().eq(CarCamera::getAirtightVideoItemId, itemId).or().eq(CarCamera::getWashVideoItemId, itemId).last(Cts.IGNORE_DATA_SCOPE_CONDITION)); if (CollectionUtils.isNotEmpty(carCameras)) { throw new OpenAlertException("删除失败,请先解绑车辆相机"); } diff --git a/src/main/java/com/zhgd/xmgl/util/EasyPoiUtil.java b/src/main/java/com/zhgd/xmgl/util/EasyPoiUtil.java index df4053f4a..5dd155061 100644 --- a/src/main/java/com/zhgd/xmgl/util/EasyPoiUtil.java +++ b/src/main/java/com/zhgd/xmgl/util/EasyPoiUtil.java @@ -22,102 +22,92 @@ import java.net.URLEncoder; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.Set; @Slf4j public class EasyPoiUtil { -// /** -// * 导出word和图片 -// * -// * @param response -// * @param params -// * @param file -// * @throws Exception -// */ -// public static void exportNewLineWordAndPic(HttpServletResponse response, Map params, File file) { -// XWPFDocument doc = null; -// FileOutputStream tempFos = null; -// try { -// //导出临时文件 -// doc = WordExportUtil.exportWord07(URLDecoder.decode(file.getPath(), "UTF-8"), params); -// WordUtils.addBreakInCellForExam(doc.getParagraphs()); -// -// //把######改成占位符{{}} -// List paragraphs = doc.getParagraphs(); -// Iterator itPara = paragraphs.iterator(); -// while (itPara.hasNext()) { -// XWPFParagraph paragraph = (XWPFParagraph) itPara.next(); -// List run = paragraph.getRuns(); -// for (int i = 0; i < run.size(); i++) { -// XWPFRun xwpfRun = run.get(i); -// String text = xwpfRun.getText(xwpfRun.getTextPosition()); -// if (text.contains("##")) { -// String replacedText = text.replaceAll("##(.*?)##", "{{}}{{$1}}{{}}"); -//// xwpfRun.setText(replacedText,0); -//// // 为剩余行创建新的 XWPFRun -//// for (int j = 1; j < lines.length; j++) { -//// XWPFRun newRun = paragraph.insertNewRun(i + j); // 插入新的 XWPFRun -//// newRun.setText("{{}}"); // 设置新行的文本 -//// // 复制原始 XWPFRun 的样式到新的 XWPFRun -//// newRun.setBold(run.isBold()); -//// newRun.setItalic(run.isItalic()); -//// newRun.setFontSize(run.getFontSize()); -//// newRun.setFontFamily(run.getFontFamily()); -//// } -// // 清空当前 run 的文本 -// xwpfRun.setText("", 0); -// -// // 将替换后的文本拆分为多个部分,并设置蓝色字体 -// String[] parts = replacedText.split("(?=\\{\\{)|(?<=\\}\\})"); -// for (String part : parts) { -// XWPFRun newRun = paragraph.insertNewRun(i++); // 插入新的 run -// newRun.setText(part); -// if (part.equals("{{}}")) { -// newRun.setColor("0000FF"); // 设置蓝色字体 -// } -// } -// } -// } -// } -// String tempName = IdUtil.randomUUID() + ".docx"; -// String tempPath = PathUtil.getBasePath() + "/temp/" + tempName; -// tempFos = new FileOutputStream(tempPath); -// doc.write(tempFos); -// tempFos.close(); -// doc.close(); -// -// //导出response -// doc = WordExportUtil.exportWord07(URLDecoder.decode(tempPath, "UTF-8"), params); -// //设置响应体内容类型 -// response.setContentType("application/octet-stream"); -// //添加响应头 -// response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("下载试卷.docx", "UTF-8")); -// //暴露新添加的响应头 -// response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); -// //将word文档流输出到输出流中 -// doc.write(response.getOutputStream()); -// //关闭流 -// doc.close(); -//// FileUtil.del(tempPath); -// } catch (Exception e) { -// log.error("exportNewLineWord:", e); -// } finally { -// if (doc != null) { -// try { -// doc.close(); -// } catch (IOException e) { -// e.printStackTrace(); -// } -// } -// if (tempFos != null) { -// try { -// tempFos.close(); -// } catch (IOException e) { -// e.printStackTrace(); -// } -// } -// } -// } + /** + * 导出word和图片 + * + * @param response + * @param params + * @param file + * @throws Exception + */ + public static void exportNewLineWordAndPicForExam(HttpServletResponse response, Map params, File file) { + XWPFDocument doc = null; + FileOutputStream tempFos = null; + try { + //导出临时文件 + doc = WordExportUtil.exportWord07(URLDecoder.decode(file.getPath(), "UTF-8"), params); + WordUtils.addBreakInCellForExam(doc.getParagraphs()); + + //把######改成占位符{{}} + List paragraphs = doc.getParagraphs(); + Iterator itPara = paragraphs.iterator(); + while (itPara.hasNext()) { + XWPFParagraph paragraph = (XWPFParagraph) itPara.next(); + List run = paragraph.getRuns(); + for (int i = 0; i < run.size(); i++) { + XWPFRun xwpfRun = run.get(i); + String text = xwpfRun.getText(xwpfRun.getTextPosition()); + if (text.contains("##")) { + String replacedText = text.replaceAll("##(.*?)##", "{{}}{{$1}}{{}}"); + // 清空当前 run 的文本 + xwpfRun.setText("", 0); + + // 将替换后的文本拆分为多个部分,并设置蓝色字体 + String[] parts = replacedText.split("(?=\\{\\{)|(?<=\\}\\})"); + for (String part : parts) { + XWPFRun newRun = paragraph.insertNewRun(i++); // 插入新的 run + newRun.setText(part); + newRun.setFontSize(10); + newRun.setFontFamily("宋体"); + if (part.equals("{{}}")) { + newRun.setColor("0000FF"); // 设置蓝色字体 + } + } + } + } + } + String tempName = IdUtil.randomUUID() + ".docx"; + String tempPath = PathUtil.getBasePath() + "/temp/" + tempName; + tempFos = new FileOutputStream(tempPath); + doc.write(tempFos); + tempFos.close(); + doc.close(); + + //导出response + doc = WordExportUtil.exportWord07(URLDecoder.decode(tempPath, "UTF-8"), params); + //设置响应体内容类型 + response.setContentType("application/octet-stream"); + //添加响应头 + response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("下载试卷.docx", "UTF-8")); + //暴露新添加的响应头 + response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); + //将word文档流输出到输出流中 + doc.write(response.getOutputStream()); + //关闭流 + doc.close(); +// FileUtil.del(tempPath); + } catch (Exception e) { + log.error("exportNewLineWord:", e); + } finally { + if (doc != null) { + try { + doc.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (tempFos != null) { + try { + tempFos.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } /** * 导出word diff --git a/src/main/java/com/zhgd/xmgl/util/FlowUtil.java b/src/main/java/com/zhgd/xmgl/util/FlowUtil.java index e88c8709e..30cc728b6 100644 --- a/src/main/java/com/zhgd/xmgl/util/FlowUtil.java +++ b/src/main/java/com/zhgd/xmgl/util/FlowUtil.java @@ -103,6 +103,10 @@ public class FlowUtil { } + public static Long getLong(Map map, String key) { + return MapUtils.getLong(map, key); + } + public static String getPullDownManyStr(Map map, String key) { return Optional.ofNullable(map.get(key)).map(o -> "".equals(o) ? null : StrUtil.join(",", o)).orElse(null); } diff --git a/src/main/java/com/zhgd/xmgl/util/WordUtils.java b/src/main/java/com/zhgd/xmgl/util/WordUtils.java index 42bb736a4..36dc025e9 100644 --- a/src/main/java/com/zhgd/xmgl/util/WordUtils.java +++ b/src/main/java/com/zhgd/xmgl/util/WordUtils.java @@ -89,29 +89,32 @@ public class WordUtils { public static void addBreakInCellForExam(List paragraphs) { for (XWPFParagraph p : paragraphs) { List runs = p.getRuns(); - for (int i = 0; i < runs.size(); i++) { - XWPFRun run = runs.get(i); + if (runs.size() > 0) { + XWPFRun run = runs.get(0); String text = run.getText(0); // 获取完整文本 if (text != null && text.contains("\n")) { String[] lines = text.split("\n"); if (lines.length > 0) { // 设置第一行文本 run.setText(lines[0], 0); - + run.addBreak(); // 添加换行符 // 为剩余行创建新的 XWPFRun for (int j = 1; j < lines.length; j++) { - run.addBreak(); // 添加换行符 - XWPFRun newRun = p.insertNewRun(i + j); // 插入新的 XWPFRun + XWPFRun newRun = p.insertNewRun(j); // 插入新的 XWPFRun newRun.setText(lines[j]); // 设置新行的文本 // 复制原始 XWPFRun 的样式到新的 XWPFRun newRun.setBold(run.isBold()); newRun.setItalic(run.isItalic()); newRun.setFontSize(10); newRun.setFontFamily("宋体"); + if (j != lines.length - 1) { + newRun.addBreak(); + } } } } } } + } } diff --git a/src/main/resources/template/下载试卷模板.docx b/src/main/resources/template/下载试卷模板.docx index dbbd12178..5407f7380 100644 --- a/src/main/resources/template/下载试卷模板.docx +++ b/src/main/resources/template/下载试卷模板.docx @@ -1,7 +1,7 @@ -{{t1}} +{{t1}} {{c1}} {{t2}} {{c2}} {{t3}} {{c3}} - +