保养管理 功能修改 审批 验收
This commit is contained in:
@@ -55,4 +55,32 @@ public class ByglController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/generateWorkOrder")
|
||||||
|
public BaseWebResult generateWorkOrder(@RequestBody Map<String,Object> model) {
|
||||||
|
Long id = lideeYunJiUtils.getMap2Long(model, "id");
|
||||||
|
byglByfaService.generateWorkOrder(id);
|
||||||
|
return BaseWebResult.success("成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/auditNotPass")
|
||||||
|
public BaseWebResult auditNotPass(@RequestBody Map<String,Object> model) {
|
||||||
|
Long id = lideeYunJiUtils.getMap2Long(model, "id");
|
||||||
|
if(id == null){
|
||||||
|
return BaseWebResult.error(FrameErrorCodeConstants.FRAME_OP_ERROR);
|
||||||
|
}
|
||||||
|
byglByfaService.auditNotPass(id);
|
||||||
|
return BaseWebResult.success("审批成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/orderAuditNotPass")
|
||||||
|
public BaseWebResult orderAuditNotPass(@RequestBody Map<String,Object> model) {
|
||||||
|
Long id = lideeYunJiUtils.getMap2Long(model, "id");
|
||||||
|
if(id == null){
|
||||||
|
return BaseWebResult.error(FrameErrorCodeConstants.FRAME_OP_ERROR);
|
||||||
|
}
|
||||||
|
byglByfaService.orderAuditNotPass(id);
|
||||||
|
return BaseWebResult.success("审批成功");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,20 @@
|
|||||||
package com.lideeyunji.core.framework.enhance.example.report.bygl;
|
package com.lideeyunji.core.framework.enhance.example.report.bygl;
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||||
import com.lideeyunji.core.framework.adapter.FrameWorkAdapter;
|
import com.lideeyunji.core.framework.adapter.FrameWorkAdapter;
|
||||||
import com.lideeyunji.core.framework.config.aspect.enhance.model.EnhanceContext;
|
import com.lideeyunji.core.framework.config.aspect.enhance.model.EnhanceContext;
|
||||||
import com.lideeyunji.core.framework.config.aspect.enhance.plugin.AroundAdvicePlugin;
|
import com.lideeyunji.core.framework.config.aspect.enhance.plugin.AroundAdvicePlugin;
|
||||||
import com.lideeyunji.core.framework.entity.ByManagementGd;
|
import com.lideeyunji.core.framework.entity.ByManagementGd;
|
||||||
import com.lideeyunji.core.framework.entity.ByManagementJl;
|
import com.lideeyunji.core.framework.entity.ByManagementJl;
|
||||||
|
import com.lideeyunji.core.framework.entity.ByManagementPlan;
|
||||||
import com.lideeyunji.core.framework.entity.ByManagementYs;
|
import com.lideeyunji.core.framework.entity.ByManagementYs;
|
||||||
import com.lideeyunji.core.framework.mapper.ByManagementGdMapper;
|
import com.lideeyunji.core.framework.mapper.*;
|
||||||
import com.lideeyunji.core.framework.mapper.ByManagementJlMapper;
|
|
||||||
import com.lideeyunji.core.framework.mapper.ByManagementYsMapper;
|
|
||||||
import com.lideeyunji.core.framework.mapper.ByglByjhMapper;
|
|
||||||
import com.lideeyunji.tool.framework.common.constant.ByglConstant;
|
import com.lideeyunji.tool.framework.common.constant.ByglConstant;
|
||||||
import com.lideeyunji.tool.framework.common.util.object.BeanUtils;
|
import com.lideeyunji.tool.framework.common.util.object.BeanUtils;
|
||||||
|
import com.lideeyunji.tool.framework.security.core.LoginUser;
|
||||||
|
import com.lideeyunji.tool.framework.security.core.util.SecurityFrameworkUtils;
|
||||||
import com.lideeyunji.tool.framework.yunji.tool.spring.SpringUtils;
|
import com.lideeyunji.tool.framework.yunji.tool.spring.SpringUtils;
|
||||||
import com.lideeyunji.tool.framework.yunji.utils.lideeYunJiUtils;
|
import com.lideeyunji.tool.framework.yunji.utils.lideeYunJiUtils;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -21,7 +22,12 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,7 +40,11 @@ public class ByglBygdBjPlugin implements AroundAdvicePlugin {
|
|||||||
/**
|
/**
|
||||||
* 操作类型常量
|
* 操作类型常量
|
||||||
*/
|
*/
|
||||||
private static final String SUBMIT_TYPE_CL = "cl";
|
private static final String SUBMIT_TYPE_CJZRCL = "cjzrcl";
|
||||||
|
private static final String SUBMIT_TYPE_WBZRCL = "wbzrcl";
|
||||||
|
private static final String SUBMIT_TYPE_SQRCL = "sqrcl";
|
||||||
|
|
||||||
|
|
||||||
private static final String SUBMIT_TYPE_YS = "ys";
|
private static final String SUBMIT_TYPE_YS = "ys";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,18 +52,19 @@ public class ByglBygdBjPlugin implements AroundAdvicePlugin {
|
|||||||
*/
|
*/
|
||||||
private static final int NOT_DELETED = 0;
|
private static final int NOT_DELETED = 0;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ByglByjhMapper byglByjhMapper;
|
|
||||||
|
|
||||||
@Autowired
|
@Resource
|
||||||
private ByManagementJlMapper byManagementJlMapper;
|
private ByManagementJlMapper byManagementJlMapper;
|
||||||
|
|
||||||
@Autowired
|
@Resource
|
||||||
private ByManagementYsMapper byManagementYsMapper;
|
private ByManagementYsMapper byManagementYsMapper;
|
||||||
|
|
||||||
@Autowired
|
@Resource
|
||||||
private ByManagementGdMapper byManagementGdMapper;
|
private ByManagementGdMapper byManagementGdMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ByManagementPlanMapper byManagementPlanMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beforeExecute(EnhanceContext enhanceContext) {
|
public void beforeExecute(EnhanceContext enhanceContext) {
|
||||||
Map<String, Object> params = enhanceContext.getParam().getParams();
|
Map<String, Object> params = enhanceContext.getParam().getParams();
|
||||||
@@ -64,12 +75,20 @@ public class ByglBygdBjPlugin implements AroundAdvicePlugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String id = lideeYunJiUtils.getMap2Str(params, "id");
|
String id = lideeYunJiUtils.getMap2Str(params, "id");
|
||||||
validateParams(id, submit_type);
|
if(StringUtils.isBlank(id)){
|
||||||
|
throw new IllegalArgumentException("工单ID不能为空");
|
||||||
|
}
|
||||||
FrameWorkAdapter adapter = SpringUtils.getBean(FrameWorkAdapter.class);
|
FrameWorkAdapter adapter = SpringUtils.getBean(FrameWorkAdapter.class);
|
||||||
|
|
||||||
switch (submit_type) {
|
switch (submit_type) {
|
||||||
case SUBMIT_TYPE_CL://处理操作
|
case SUBMIT_TYPE_CJZRCL://车间主任处理操作
|
||||||
handleClOperation(id, params, adapter);
|
handleCjzrclOperation(id, params, adapter);
|
||||||
|
break;
|
||||||
|
case SUBMIT_TYPE_WBZRCL://维保主任处理操作
|
||||||
|
handleWbzrclOperation(id, params, adapter);
|
||||||
|
break;
|
||||||
|
case SUBMIT_TYPE_SQRCL://申请人处理操作
|
||||||
|
handleSqrclOperation(id, params, adapter);
|
||||||
break;
|
break;
|
||||||
case SUBMIT_TYPE_YS://验收操作
|
case SUBMIT_TYPE_YS://验收操作
|
||||||
handleYsOperation(id, params, adapter);
|
handleYsOperation(id, params, adapter);
|
||||||
@@ -79,7 +98,24 @@ public class ByglBygdBjPlugin implements AroundAdvicePlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterExecute(EnhanceContext enhanceContext) {
|
public void afterExecute(EnhanceContext enhanceContext) {
|
||||||
|
Map<String, Object> params = enhanceContext.getParam().getParams();
|
||||||
|
Long id = lideeYunJiUtils.getMap2Long(params, "id");
|
||||||
|
if (id == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ByManagementGd gd = byManagementGdMapper.selectOne("id", id);
|
||||||
|
if (gd == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(ByglConstant.GD_STATE_BTG.equals(gd.getOrderState())){
|
||||||
|
gd.setOrderState(ByglConstant.GD_STATE_DKS);
|
||||||
|
gd.setLeaderUserYj(null);
|
||||||
|
gd.setWbcjzrUserYj(null);
|
||||||
|
gd.setLeaderUpkeepTime(null);
|
||||||
|
gd.setLeaderUserZt(0);
|
||||||
|
gd.setWbcjzrUserZt(0);
|
||||||
|
byManagementGdMapper.updateById(gd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -88,90 +124,180 @@ public class ByglBygdBjPlugin implements AroundAdvicePlugin {
|
|||||||
*/
|
*/
|
||||||
private void handleYsOperation(String id, Map<String, Object> params, FrameWorkAdapter adapter) {
|
private void handleYsOperation(String id, Map<String, Object> params, FrameWorkAdapter adapter) {
|
||||||
String gdys_yj = lideeYunJiUtils.getMap2Str(params, "gdys_yj");
|
String gdys_yj = lideeYunJiUtils.getMap2Str(params, "gdys_yj");
|
||||||
String pjxj = lideeYunJiUtils.getMap2Str(params, "pjxj");
|
|
||||||
|
|
||||||
ByManagementJl jl = byManagementJlMapper.selectById(id);
|
ByManagementYs ys = byManagementYsMapper.selectById(id);
|
||||||
|
|
||||||
jl.setYsTime(DateUtil.now());
|
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||||
jl.setPjxj(pjxj);
|
if (loginUser == null) {
|
||||||
jl.setState(ByglConstant.YSZT_STATE_YYS);
|
return;
|
||||||
jl.setGdysYj(gdys_yj);
|
}
|
||||||
jl.setUpdateTime(LocalDateTime.now());
|
Long userId = loginUser.getId();
|
||||||
jl.setUpdateUser(adapter.getOnlineUserId());
|
|
||||||
|
|
||||||
byManagementJlMapper.updateById(jl);
|
if(ys.getWbcjzrYsZt() == 0 && userId.equals(ys.getWbcjzrUserId())){
|
||||||
|
ys.setWbcjzrYsZt(1);
|
||||||
|
ys.setWbcjzrYsYj(gdys_yj);
|
||||||
|
}
|
||||||
|
|
||||||
ByManagementYs ys = BeanUtils.toBean(jl, ByManagementYs.class);
|
|
||||||
if(ys == null){
|
if(ys.getLeaderYsZt() == 0 && userId.equals(ys.getLeaderUserId())){
|
||||||
|
ys.setLeaderYsZt(1);
|
||||||
|
ys.setLeaderYsYj(gdys_yj);
|
||||||
|
}
|
||||||
|
if(ys.getLeaderYsZt() == 1 && ys.getWbcjzrYsZt() == 1){
|
||||||
|
ys.setYsTime(DateUtil.now());
|
||||||
|
ys.setState(ByglConstant.YSZT_STATE_YYS);
|
||||||
|
ys.setUpdateTime(LocalDateTime.now());
|
||||||
|
ys.setUpdateUser(adapter.getOnlineUserId());
|
||||||
|
|
||||||
|
//验收完之后需要修改计划表数据
|
||||||
|
//当前工单 修改为已完成
|
||||||
|
ByManagementGd gd = byManagementGdMapper.selectOne("order_id", ys.getOrderId());
|
||||||
|
gd.setOrderState(ByglConstant.BY_STATE_YWC);
|
||||||
|
byManagementGdMapper.updateById(gd);
|
||||||
|
|
||||||
|
String planId = gd.getPlanId();
|
||||||
|
|
||||||
|
//查询当前计划的工单
|
||||||
|
LambdaQueryWrapper<ByManagementGd> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(ByManagementGd::getPlanId, planId);
|
||||||
|
wrapper.eq(ByManagementGd::getOrderState, ByglConstant.BY_STATE_YWC);
|
||||||
|
List<ByManagementGd> byManagementGds = byManagementGdMapper.selectList(wrapper);
|
||||||
|
|
||||||
|
|
||||||
|
//当前计划
|
||||||
|
ByManagementPlan plan = byManagementPlanMapper.selectById(planId);
|
||||||
|
|
||||||
|
//保养周期
|
||||||
|
String interval = plan.getScheduledInterval();
|
||||||
|
if("1".equals(interval)) {//周期为180天
|
||||||
|
//如果有两条已完成的工单,则将计划状态修改为已完成
|
||||||
|
if(byManagementGds.size() >= 2) {
|
||||||
|
plan.setPlanState(ByglConstant.JH_STATE_YWC);
|
||||||
|
byManagementPlanMapper.updateById(plan);
|
||||||
|
}else{
|
||||||
|
String planUpkeepTime = gd.getPlanUpkeepTime();
|
||||||
|
// 解析完成时间(只有日期部分,需要转换为LocalDateTime)
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||||
|
LocalDate completeLocalDate = LocalDate.parse(planUpkeepTime, formatter);
|
||||||
|
LocalDateTime completeDate = completeLocalDate.atStartOfDay();
|
||||||
|
|
||||||
|
// 往后推180天
|
||||||
|
LocalDateTime nextMaintenanceDate = adjustToNextMonthFirstDayIfNeeded(completeDate.plusDays(180));
|
||||||
|
|
||||||
|
// 判断是否超过本年
|
||||||
|
int completeYear = completeDate.getYear();
|
||||||
|
int nextMaintenanceYear = nextMaintenanceDate.getYear();
|
||||||
|
boolean isCrossYear = nextMaintenanceYear > completeYear;
|
||||||
|
|
||||||
|
if(isCrossYear){
|
||||||
|
plan.setPlanState(ByglConstant.JH_STATE_YWC);
|
||||||
|
byManagementPlanMapper.updateById(plan);
|
||||||
|
}else{
|
||||||
|
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||||
|
String nextMaintenanceDateStr = nextMaintenanceDate.format(dateFormatter);
|
||||||
|
plan.setNextUpkeepTime(nextMaintenanceDateStr);
|
||||||
|
byManagementPlanMapper.updateById(plan);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else if("2".equals(interval)) {//周期为360天
|
||||||
|
plan.setPlanState(ByglConstant.JH_STATE_YWC);
|
||||||
|
byManagementPlanMapper.updateById(plan);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
byManagementYsMapper.updateById(ys);
|
||||||
|
|
||||||
|
ByManagementJl jl = BeanUtils.toBean(ys, ByManagementJl.class);
|
||||||
|
jl.setId(null);
|
||||||
|
if(jl == null){
|
||||||
throw new RuntimeException("对象转换失败");
|
throw new RuntimeException("对象转换失败");
|
||||||
}
|
}
|
||||||
byManagementYsMapper.updateById(ys);
|
byManagementJlMapper.insert(jl);
|
||||||
|
|
||||||
log.info("工单验收成功,ID: {}", id);
|
log.info("工单验收成功,ID: {}", id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理操作
|
* 车间主任处理操作
|
||||||
*/
|
*/
|
||||||
private void handleClOperation(String id, Map<String, Object> params, FrameWorkAdapter adapter) {
|
private void handleCjzrclOperation(String id, Map<String, Object> params, FrameWorkAdapter adapter) {
|
||||||
String bygd_cljg = lideeYunJiUtils.getMap2Str(params, "bygd_cljg");
|
String leader_user_yj = lideeYunJiUtils.getMap2Str(params, "leader_user_yj");
|
||||||
|
String leader_upkeep_time = lideeYunJiUtils.getMap2Str(params, "leader_upkeep_time");
|
||||||
int result = byglByjhMapper.updateClBygd(id, bygd_cljg, ByglConstant.BY_STATE_YWC);
|
|
||||||
|
|
||||||
if (result <= 0) {
|
|
||||||
log.info("工单处理失败,ID: {}", id);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ByManagementGd gd = byManagementGdMapper.selectById(id);
|
ByManagementGd gd = byManagementGdMapper.selectById(id);
|
||||||
ByManagementJl jl = createByManagementJl(gd, adapter);
|
gd.setLeaderUserYj(leader_user_yj);
|
||||||
byManagementJlMapper.insert(jl);
|
gd.setLeaderUserZt(1);
|
||||||
syncToYsTable(jl);
|
gd.setLeaderUpkeepTime(leader_upkeep_time);
|
||||||
|
if(ByglConstant.GD_STATE_DKS.equals(gd.getOrderState())){
|
||||||
log.info("工单处理成功,ID: {}", id);
|
gd.setOrderState(ByglConstant.GD_STATE_JXZ);
|
||||||
|
}
|
||||||
|
byManagementGdMapper.updateById(gd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建保养记录
|
* 维保主任处理操作
|
||||||
*/
|
*/
|
||||||
private ByManagementJl createByManagementJl(ByManagementGd gd, FrameWorkAdapter adapter) {
|
private void handleWbzrclOperation(String id, Map<String, Object> params, FrameWorkAdapter adapter) {
|
||||||
ByManagementJl jl = new ByManagementJl();
|
String wbcjzr_user_yj = lideeYunJiUtils.getMap2Str(params, "wbcjzr_user_yj");
|
||||||
jl.setId(IdWorker.getId());
|
ByManagementGd gd = byManagementGdMapper.selectById(id);
|
||||||
jl.setOrderId(gd.getOrderId());
|
gd.setWbcjzrUserYj(wbcjzr_user_yj);
|
||||||
jl.setOrderName(gd.getOrderName());
|
gd.setWbcjzrUserZt(1);
|
||||||
jl.setEquipmentInfo(gd.getEquipmentInfo());
|
if(ByglConstant.GD_STATE_DKS.equals(gd.getOrderState())){
|
||||||
jl.setEquipmentCode(gd.getEquipmentCode());
|
gd.setOrderState(ByglConstant.GD_STATE_JXZ);
|
||||||
jl.setUpkeepLevel(gd.getUpkeepLevel());
|
}
|
||||||
jl.setUpkeepTime(gd.getUpkeepTime());
|
byManagementGdMapper.updateById(gd);
|
||||||
jl.setPriority(gd.getPriority());
|
|
||||||
jl.setState(ByglConstant.YSZT_STATE_DYS);
|
|
||||||
jl.setExecutor(gd.getExecutor());
|
|
||||||
jl.setCreateTime(LocalDateTime.now());
|
|
||||||
jl.setCreateUser(adapter.getOnlineUserId());
|
|
||||||
jl.setIsDeleted(NOT_DELETED);
|
|
||||||
return jl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 同步到验收表
|
* 申请人处理操作
|
||||||
*/
|
*/
|
||||||
private void syncToYsTable(ByManagementJl jl) {
|
private void handleSqrclOperation(String id, Map<String, Object> params, FrameWorkAdapter adapter) {
|
||||||
ByManagementYs ys = BeanUtils.toBean(jl, ByManagementYs.class);
|
String bygd_cljg = lideeYunJiUtils.getMap2Str(params, "bygd_cljg");
|
||||||
if(ys == null){
|
String maintainer = lideeYunJiUtils.getMap2Str(params, "maintainer");
|
||||||
throw new RuntimeException("对象转换失败");
|
String schemeInfo = lideeYunJiUtils.getMap2Str(params, "scheme_info");
|
||||||
}
|
ByManagementGd gd = byManagementGdMapper.selectById(id);
|
||||||
|
gd.setBygdCljg(bygd_cljg);
|
||||||
|
gd.setMaintainer(maintainer);
|
||||||
|
gd.setSchemeInfo(schemeInfo);
|
||||||
|
gd.setOrderState(ByglConstant.GD_STATE_DYS);
|
||||||
|
gd.setUpkeepTime(LocalDate.now().toString());
|
||||||
|
byManagementGdMapper.updateById(gd);
|
||||||
|
|
||||||
|
ByManagementYs ys = new ByManagementYs();
|
||||||
|
ys.setOrderId(gd.getOrderId());
|
||||||
|
ys.setOrderName(gd.getOrderName());
|
||||||
|
ys.setEquipmentInfo(gd.getEquipmentInfo());
|
||||||
|
ys.setEquipmentCode(gd.getEquipmentCode());
|
||||||
|
ys.setUpkeepLevel(gd.getUpkeepLevel());
|
||||||
|
ys.setUpkeepTime(gd.getUpkeepTime());
|
||||||
|
ys.setPriority(gd.getPriority());
|
||||||
|
ys.setState(ByglConstant.YSZT_STATE_DYS);
|
||||||
|
ys.setExecutor(gd.getExecutor());
|
||||||
|
ys.setLeaderUserId(gd.getLeaderUserId());
|
||||||
|
ys.setWbcjzrUserId(gd.getWbcjzrUserId());
|
||||||
|
ys.setLeaderYsZt(0);
|
||||||
|
ys.setWbcjzrYsZt(0);
|
||||||
|
ys.setMaintainer(gd.getMaintainer());
|
||||||
|
ys.setSchemeInfo(gd.getSchemeInfo());
|
||||||
|
ys.setCreateTime(LocalDateTime.now());
|
||||||
|
ys.setCreateUser(adapter.getOnlineUserId());
|
||||||
|
ys.setIsDeleted(NOT_DELETED);
|
||||||
|
|
||||||
byManagementYsMapper.insert(ys);
|
byManagementYsMapper.insert(ys);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 参数校验
|
* 如果日期是28号、29号、30号或31号,顺延到下个月1号
|
||||||
*/
|
*/
|
||||||
private void validateParams(String id, String submit_type) {
|
private LocalDateTime adjustToNextMonthFirstDayIfNeeded(LocalDateTime date) {
|
||||||
if(StringUtils.isBlank(id)){
|
int dayOfMonth = date.getDayOfMonth();
|
||||||
throw new IllegalArgumentException("工单ID不能为空");
|
if (dayOfMonth >= 28) {
|
||||||
}
|
// 顺延到下个月1号
|
||||||
if(!SUBMIT_TYPE_CL.equals(submit_type) && !SUBMIT_TYPE_YS.equals(submit_type)){
|
return date.plusMonths(1).withDayOfMonth(1);
|
||||||
throw new IllegalArgumentException("不支持的操作类型: " + submit_type);
|
|
||||||
}
|
}
|
||||||
|
return date;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,8 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -24,7 +26,6 @@ public class ByglByjhLbPlugin implements AroundAdvicePlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beforeExecute(EnhanceContext enhanceContext) {
|
public void beforeExecute(EnhanceContext enhanceContext) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -38,6 +39,32 @@ public class ByglByjhLbPlugin implements AroundAdvicePlugin {
|
|||||||
Map<String, Object> countByPlanId = byglByjhMapper.getCountByPlanId(plan_id);
|
Map<String, Object> countByPlanId = byglByjhMapper.getCountByPlanId(plan_id);
|
||||||
record.put("plan_count",lideeYunJiUtils.getMap2Long(countByPlanId,"jhs"));
|
record.put("plan_count",lideeYunJiUtils.getMap2Long(countByPlanId,"jhs"));
|
||||||
record.put("completed_count",lideeYunJiUtils.getMap2Long(countByPlanId,"wcs"));
|
record.put("completed_count",lideeYunJiUtils.getMap2Long(countByPlanId,"wcs"));
|
||||||
|
|
||||||
|
// 计算距离下次保养时间还有几天(order_state为1时不计算)
|
||||||
|
String planState = lideeYunJiUtils.getMap2Str(record, "plan_state");
|
||||||
|
record.put("days_until_next_upkeep", "-");
|
||||||
|
if (!"1".equals(planState)) {
|
||||||
|
String nextUpkeepTimeStr = lideeYunJiUtils.getMap2Str(record, "next_upkeep_time");
|
||||||
|
if (Func.isNotEmpty(nextUpkeepTimeStr)) {
|
||||||
|
try {
|
||||||
|
// 解析日期字符串(格式:yyyy-MM-dd)
|
||||||
|
LocalDate nextUpkeepTime = LocalDate.parse(nextUpkeepTimeStr.substring(0, 10));
|
||||||
|
LocalDate today = LocalDate.now();
|
||||||
|
// 计算天数差(可能为负数,表示已过期)
|
||||||
|
long daysUntilNext = ChronoUnit.DAYS.between(today, nextUpkeepTime);
|
||||||
|
if(daysUntilNext<0){
|
||||||
|
record.put("days_until_next_upkeep", "已超期"+Math.abs(daysUntilNext)+"天");
|
||||||
|
}else {
|
||||||
|
record.put("days_until_next_upkeep", daysUntilNext+"天");
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("解析下次保养时间失败: {}", nextUpkeepTimeStr, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
record.put("next_upkeep_time", "-");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -33,6 +33,15 @@ public class ByglByjhPlugin implements AroundAdvicePlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void beforeExecute(EnhanceContext enhanceContext) {
|
public void beforeExecute(EnhanceContext enhanceContext) {
|
||||||
Map<String, Object> params = enhanceContext.getParam().getParams();
|
Map<String, Object> params = enhanceContext.getParam().getParams();
|
||||||
|
|
||||||
|
String scheduledDate = lideeYunJiUtils.getMap2Str(params, "scheduled_date");
|
||||||
|
String[] dates = scheduledDate.split(",");
|
||||||
|
if(dates.length > 0){
|
||||||
|
// 创建工单并设置planUpkeepTime
|
||||||
|
String planUpkeepTime = dates[0].trim();
|
||||||
|
params.put("next_upkeep_time", planUpkeepTime);
|
||||||
|
}
|
||||||
|
|
||||||
//新增方法默认状态字段
|
//新增方法默认状态字段
|
||||||
params.put("plan_state", ByglConstant.JH_STATE_JXZ);
|
params.put("plan_state", ByglConstant.JH_STATE_JXZ);
|
||||||
String plan_id = lideeYunJiUtils.getMap2Str(params, "plan_id");
|
String plan_id = lideeYunJiUtils.getMap2Str(params, "plan_id");
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
|
|
||||||
package com.lideeyunji.core.framework.entity;
|
package com.lideeyunji.core.framework.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.lideeyunji.tool.framework.yunji.model.global.BaseTenantEntity;
|
import com.lideeyunji.tool.framework.yunji.model.global.BaseTenantEntity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保养管理-保养工单
|
* 保养管理-保养工单
|
||||||
*/
|
*/
|
||||||
@@ -100,15 +104,80 @@ public class ByManagementGd extends BaseTenantEntity {
|
|||||||
*/
|
*/
|
||||||
private String schemeId;
|
private String schemeId;
|
||||||
|
|
||||||
/**
|
|
||||||
* 处理结果
|
|
||||||
*/
|
|
||||||
private String bygdCljg;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计划id
|
* 计划id
|
||||||
*/
|
*/
|
||||||
private String planId;
|
private String planId;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保养内容
|
||||||
|
*/
|
||||||
|
private String schemeInfo;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保养人
|
||||||
|
*/
|
||||||
|
private String maintainer;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备所属车间领导
|
||||||
|
*/
|
||||||
|
private Long leaderUserId;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 维保中心领导
|
||||||
|
*/
|
||||||
|
private Long wbcjzrUserId;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备所属车间领导意见
|
||||||
|
*/
|
||||||
|
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||||
|
private String leaderUserYj;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 维保中心领导意见
|
||||||
|
*/
|
||||||
|
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||||
|
private String wbcjzrUserYj;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车间领导确定保养时间
|
||||||
|
*/
|
||||||
|
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||||
|
private String leaderUpkeepTime;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理结果
|
||||||
|
*/
|
||||||
|
private String bygdCljg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车间领导审批状态
|
||||||
|
*/
|
||||||
|
private Integer leaderUserZt;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 维保领导审批状态
|
||||||
|
*/
|
||||||
|
private Integer wbcjzrUserZt;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,16 +67,51 @@ public class ByManagementJl extends BaseTenantEntity {
|
|||||||
*验收时间
|
*验收时间
|
||||||
*/
|
*/
|
||||||
private String ysTime;
|
private String ysTime;
|
||||||
|
/**
|
||||||
|
* 设备所属车间领导
|
||||||
|
*/
|
||||||
|
private Long leaderUserId;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*评价星级
|
* 维保中心领导
|
||||||
*/
|
*/
|
||||||
private String pjxj;
|
private Long wbcjzrUserId;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*验收意见
|
* 车间领导验收状态
|
||||||
*/
|
*/
|
||||||
private String gdysYj;
|
private Integer leaderYsZt;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 维保领导验收状态
|
||||||
|
*/
|
||||||
|
private Integer wbcjzrYsZt;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车间领导验收意见
|
||||||
|
*/
|
||||||
|
private String leaderYsYj;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 维保领导验收意见
|
||||||
|
*/
|
||||||
|
private String wbcjzrYsYj;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保养人
|
||||||
|
*/
|
||||||
|
private String maintainer;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保养内容
|
||||||
|
*/
|
||||||
|
private String schemeInfo;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,94 @@
|
|||||||
|
package com.lideeyunji.core.framework.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.lideeyunji.tool.framework.yunji.model.global.BaseTenantEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保养管理-保养计划
|
||||||
|
*/
|
||||||
|
@TableName("by_management_plan")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode
|
||||||
|
public class ByManagementPlan extends BaseTenantEntity {
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计划编号
|
||||||
|
*/
|
||||||
|
private String planId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计划名称
|
||||||
|
*/
|
||||||
|
private String planName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生产线
|
||||||
|
*/
|
||||||
|
private String deviceTypeName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备
|
||||||
|
*/
|
||||||
|
private String equipmentInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备编号
|
||||||
|
*/
|
||||||
|
private String equipmentCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保养级别
|
||||||
|
*/
|
||||||
|
private String upkeepLevel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保养方案
|
||||||
|
*/
|
||||||
|
private String schemeId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 可能更换零件
|
||||||
|
*/
|
||||||
|
private String possibleReplacements;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保养周期
|
||||||
|
*/
|
||||||
|
private String scheduledInterval;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下次保养时间
|
||||||
|
*/
|
||||||
|
private String nextUpkeepTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行人
|
||||||
|
*/
|
||||||
|
private String executor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
*/
|
||||||
|
private String planState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 起止时间
|
||||||
|
*/
|
||||||
|
private String scheduledDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保养内容
|
||||||
|
*/
|
||||||
|
private String schemeInfo;
|
||||||
|
}
|
||||||
@@ -70,14 +70,51 @@ public class ByManagementYs extends BaseTenantEntity {
|
|||||||
private String ysTime;
|
private String ysTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*评价星级
|
* 设备所属车间领导
|
||||||
*/
|
*/
|
||||||
private String pjxj;
|
private Long leaderUserId;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*验收意见
|
* 维保中心领导
|
||||||
*/
|
*/
|
||||||
private String gdysYj;
|
private Long wbcjzrUserId;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车间领导验收状态
|
||||||
|
*/
|
||||||
|
private Integer leaderYsZt;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 维保领导验收状态
|
||||||
|
*/
|
||||||
|
private Integer wbcjzrYsZt;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车间领导验收意见
|
||||||
|
*/
|
||||||
|
private String leaderYsYj;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 维保领导验收意见
|
||||||
|
*/
|
||||||
|
private String wbcjzrYsYj;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保养人
|
||||||
|
*/
|
||||||
|
private String maintainer;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保养内容
|
||||||
|
*/
|
||||||
|
private String schemeInfo;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package com.lideeyunji.core.framework.mapper;
|
package com.lideeyunji.core.framework.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.lideeyunji.core.framework.entity.ByManagementGd;
|
import com.lideeyunji.core.framework.entity.ByManagementGd;
|
||||||
|
import com.lideeyunji.tool.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保养管理-保养工单Mapper接口
|
* 保养管理-保养工单Mapper接口
|
||||||
*
|
*
|
||||||
* @date 2026-03-20
|
* @date 2026-03-20
|
||||||
*/
|
*/
|
||||||
public interface ByManagementGdMapper extends BaseMapper<ByManagementGd> {
|
public interface ByManagementGdMapper extends BaseMapperX<ByManagementGd> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.lideeyunji.core.framework.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.lideeyunji.core.framework.entity.ByManagementPlan;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保养管理-保养计划Mapper接口
|
||||||
|
*
|
||||||
|
* @date 2026-04-15
|
||||||
|
*/
|
||||||
|
public interface ByManagementPlanMapper extends BaseMapper<ByManagementPlan> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -17,4 +17,6 @@ public interface ByglByfaMapper {
|
|||||||
List<Map<String, Object>> getByXx(String dev_type, String dev_code);
|
List<Map<String, Object>> getByXx(String dev_type, String dev_code);
|
||||||
|
|
||||||
List<Map<String, Object>> getWxXx(String dev_type, String dev_code);
|
List<Map<String, Object>> getWxXx(String dev_type, String dev_code);
|
||||||
|
|
||||||
|
Map<String, Object> getScxXx(String scx);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,4 +14,10 @@ public interface IByglByfaService {
|
|||||||
List<Map<String, Object>> getByXx(String dev_type, String dev_code);
|
List<Map<String, Object>> getByXx(String dev_type, String dev_code);
|
||||||
|
|
||||||
List<Map<String, Object>> getWxXx(String dev_type, String dev_code);
|
List<Map<String, Object>> getWxXx(String dev_type, String dev_code);
|
||||||
|
|
||||||
|
void generateWorkOrder(Long id);
|
||||||
|
|
||||||
|
void auditNotPass(Long id);
|
||||||
|
|
||||||
|
void orderAuditNotPass(Long id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,13 +2,31 @@
|
|||||||
package com.lideeyunji.core.framework.service.impl;
|
package com.lideeyunji.core.framework.service.impl;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.lideeyunji.core.framework.entity.ByManagementGd;
|
||||||
|
import com.lideeyunji.core.framework.entity.ByManagementPlan;
|
||||||
|
import com.lideeyunji.core.framework.entity.ByManagementYs;
|
||||||
|
import com.lideeyunji.core.framework.mapper.ByManagementGdMapper;
|
||||||
|
import com.lideeyunji.core.framework.mapper.ByManagementPlanMapper;
|
||||||
|
import com.lideeyunji.core.framework.mapper.ByManagementYsMapper;
|
||||||
import com.lideeyunji.core.framework.mapper.ByglByfaMapper;
|
import com.lideeyunji.core.framework.mapper.ByglByfaMapper;
|
||||||
import com.lideeyunji.core.framework.service.IByglByfaService;
|
import com.lideeyunji.core.framework.service.IByglByfaService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import com.lideeyunji.service.system.api.IApiDeptApi;
|
||||||
|
import com.lideeyunji.service.system.dto.DeptRespDTO;
|
||||||
|
import com.lideeyunji.tool.framework.common.constant.ByglConstant;
|
||||||
|
import com.lideeyunji.tool.framework.common.util.object.BeanUtils;
|
||||||
|
import com.lideeyunji.tool.framework.yunji.enums.AcceptanceStatusEnum;
|
||||||
|
import com.lideeyunji.tool.framework.yunji.utils.lideeYunJiUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*保养管理-保养方案
|
*保养管理-保养方案
|
||||||
@@ -16,9 +34,27 @@ import java.util.Map;
|
|||||||
@Service
|
@Service
|
||||||
public class ByglByfaServiceImpl implements IByglByfaService {
|
public class ByglByfaServiceImpl implements IByglByfaService {
|
||||||
|
|
||||||
@Autowired
|
private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
|
||||||
|
|
||||||
|
private static final String ORDER_ID_PREFIX = "GD";
|
||||||
|
|
||||||
|
private static final Long WBCJ_ID = 145L;
|
||||||
|
|
||||||
|
@Resource
|
||||||
private ByglByfaMapper byglByfaMapper;
|
private ByglByfaMapper byglByfaMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ByManagementPlanMapper byManagementPlanMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ByManagementGdMapper byManagementGdMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ByManagementYsMapper byManagementYsMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IApiDeptApi apiDeptApi;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int changeFaState(String id, String state) {
|
public int changeFaState(String id, String state) {
|
||||||
int result = byglByfaMapper.changeFaState(id, state);
|
int result = byglByfaMapper.changeFaState(id, state);
|
||||||
@@ -36,4 +72,174 @@ public class ByglByfaServiceImpl implements IByglByfaService {
|
|||||||
|
|
||||||
return byglByfaMapper.getWxXx(dev_type, dev_code);
|
return byglByfaMapper.getWxXx(dev_type, dev_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void generateWorkOrder(Long id) {
|
||||||
|
//查询当前保养计划
|
||||||
|
ByManagementPlan plan = byManagementPlanMapper.selectById(id);
|
||||||
|
//查询当前计划的工单
|
||||||
|
LambdaQueryWrapper<ByManagementGd> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(ByManagementGd::getPlanId, id);
|
||||||
|
List<ByManagementGd> byManagementGds = byManagementGdMapper.selectList(wrapper);
|
||||||
|
|
||||||
|
ByManagementGd order = BeanUtils.toBean(plan, ByManagementGd.class);
|
||||||
|
order.setId(null);
|
||||||
|
order.setOrderId(generateOrderId());
|
||||||
|
order.setOrderName(plan.getPlanName());
|
||||||
|
order.setOrderState("0");
|
||||||
|
order.setPriority(order.getUpkeepLevel());
|
||||||
|
order.setApplyForParts("0");
|
||||||
|
order.setIsStopped("0");
|
||||||
|
order.setPlanId(id+"");
|
||||||
|
order.setSchemeInfo(plan.getSchemeInfo());
|
||||||
|
|
||||||
|
//需要查询对应设备车间的车间主任 维保主任
|
||||||
|
String scx = order.getDeviceTypeName();//生成线 需要去sblx查询对应车间
|
||||||
|
Map<String,Object> map= byglByfaMapper.getScxXx(scx);
|
||||||
|
Long deptId = lideeYunJiUtils.getMap2Long(map, "dept_id");
|
||||||
|
// 通过部门ID获取部门信息,进而获取负责人ID
|
||||||
|
Long leaderUserId = null;
|
||||||
|
if (deptId != null) {
|
||||||
|
DeptRespDTO dept = apiDeptApi.getDept(deptId);
|
||||||
|
if (dept != null) {
|
||||||
|
leaderUserId = dept.getLeaderUserId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
order.setLeaderUserId(leaderUserId);
|
||||||
|
//维保车间145 主任
|
||||||
|
Long wbcjzrUserId = null;
|
||||||
|
if (deptId != null) {
|
||||||
|
DeptRespDTO dept = apiDeptApi.getDept(WBCJ_ID);
|
||||||
|
if (dept != null) {
|
||||||
|
wbcjzrUserId = dept.getLeaderUserId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
order.setWbcjzrUserId(wbcjzrUserId);
|
||||||
|
|
||||||
|
//找到planUpkeepTime最近的一条工单
|
||||||
|
Optional<ByManagementGd> latestCompleted = byManagementGds.stream()
|
||||||
|
.filter(gd -> gd.getPlanUpkeepTime() != null && !gd.getPlanUpkeepTime().isEmpty())
|
||||||
|
.max(Comparator.comparing(gd -> {
|
||||||
|
try {
|
||||||
|
// 尝试解析完成时间,支持多种格式
|
||||||
|
String time = gd.getPlanUpkeepTime();
|
||||||
|
if (time.contains("T")) {
|
||||||
|
return LocalDateTime.parse(time, DateTimeFormatter.ISO_LOCAL_DATE_TIME);
|
||||||
|
} else if (time.contains(" ")) {
|
||||||
|
return LocalDateTime.parse(time, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||||
|
} else {
|
||||||
|
return LocalDateTime.parse(time + "T00:00:00", DateTimeFormatter.ISO_LOCAL_DATE_TIME);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
return LocalDateTime.MIN;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
String interval = plan.getScheduledInterval();//保养周期
|
||||||
|
String scheduledDate = plan.getScheduledDate();//首次保养时间区间
|
||||||
|
if("1".equals(interval)){//周期为180天
|
||||||
|
//判断最近的工单
|
||||||
|
if(latestCompleted.isPresent()){
|
||||||
|
if(byManagementGds.size() >= 2 ){//周期为180天左右半年1次 1年最多2次 超过就返回
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ByManagementGd completedGd = latestCompleted.get();
|
||||||
|
String planUpkeepTime = completedGd.getPlanUpkeepTime();
|
||||||
|
|
||||||
|
// 解析完成时间(只有日期部分,需要转换为LocalDateTime)
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||||
|
LocalDate completeLocalDate = LocalDate.parse(planUpkeepTime, formatter);
|
||||||
|
LocalDateTime completeDate = completeLocalDate.atStartOfDay();
|
||||||
|
|
||||||
|
// 往后推180天
|
||||||
|
LocalDateTime nextMaintenanceDate = adjustToNextMonthFirstDayIfNeeded(completeDate.plusDays(180));
|
||||||
|
|
||||||
|
// 判断是否超过本年
|
||||||
|
int completeYear = completeDate.getYear();
|
||||||
|
int nextMaintenanceYear = nextMaintenanceDate.getYear();
|
||||||
|
boolean isCrossYear = nextMaintenanceYear > completeYear;
|
||||||
|
|
||||||
|
if(isCrossYear){
|
||||||
|
return;
|
||||||
|
}else{
|
||||||
|
// 未超过本年,在当年内 保存工单
|
||||||
|
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||||
|
String nextMaintenanceDateStr = nextMaintenanceDate.format(dateFormatter);
|
||||||
|
order.setPlanUpkeepTime(nextMaintenanceDateStr);
|
||||||
|
|
||||||
|
byManagementGdMapper.insert(order);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
// 没有已完成的工单,使用scheduledDate的第一个时间
|
||||||
|
if(scheduledDate != null && !scheduledDate.isEmpty()){
|
||||||
|
String[] dates = scheduledDate.split(",");
|
||||||
|
if(dates.length > 0){
|
||||||
|
// 创建工单并设置planUpkeepTime
|
||||||
|
String planUpkeepTime = dates[0].trim();
|
||||||
|
order.setPlanUpkeepTime(planUpkeepTime);
|
||||||
|
byManagementGdMapper.insert(order);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else if("2".equals(interval)){//周期为360天
|
||||||
|
//周期为360天 要是没有工单可以生成 有工单直接返回
|
||||||
|
if(!latestCompleted.isPresent()){
|
||||||
|
// 没有已完成的工单,使用scheduledDate的第一个时间
|
||||||
|
if(scheduledDate != null && !scheduledDate.isEmpty()){
|
||||||
|
String[] dates = scheduledDate.split(",");
|
||||||
|
if(dates.length > 0){
|
||||||
|
// 创建工单并设置planUpkeepTime
|
||||||
|
String planUpkeepTime = dates[0].trim();
|
||||||
|
order.setPlanUpkeepTime(planUpkeepTime);
|
||||||
|
byManagementGdMapper.insert(order);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void auditNotPass(Long id) {
|
||||||
|
ByManagementGd gzbx = new ByManagementGd();
|
||||||
|
gzbx.setId(id);
|
||||||
|
gzbx.setOrderState(ByglConstant.GD_STATE_BTG);
|
||||||
|
byManagementGdMapper.updateById(gzbx);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void orderAuditNotPass(Long id) {
|
||||||
|
ByManagementYs ys = byManagementYsMapper.selectById(id);
|
||||||
|
ByManagementGd gd = byManagementGdMapper.selectOne("order_id", ys.getOrderId());
|
||||||
|
gd.setOrderState(ByglConstant.GD_STATE_YSBTG);
|
||||||
|
byManagementGdMapper.updateById(gd);
|
||||||
|
|
||||||
|
byManagementYsMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成工单ID
|
||||||
|
* 格式:GD + 时间戳(yyyyMMddHHmmss)
|
||||||
|
*/
|
||||||
|
private String generateOrderId() {
|
||||||
|
return ORDER_ID_PREFIX + LocalDateTime.now().format(DATE_TIME_FORMATTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 如果日期是28号、29号、30号或31号,顺延到下个月1号
|
||||||
|
*/
|
||||||
|
private LocalDateTime adjustToNextMonthFirstDayIfNeeded(LocalDateTime date) {
|
||||||
|
int dayOfMonth = date.getDayOfMonth();
|
||||||
|
if (dayOfMonth >= 28) {
|
||||||
|
// 顺延到下个月1号
|
||||||
|
return date.plusMonths(1).withDayOfMonth(1);
|
||||||
|
}
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -28,4 +28,15 @@
|
|||||||
is_deleted = 0
|
is_deleted = 0
|
||||||
AND dev_type = #{dev_type} AND dev_no = #{dev_code}
|
AND dev_type = #{dev_type} AND dev_no = #{dev_code}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="getScxXx" resultType="java.util.Map">
|
||||||
|
SELECT
|
||||||
|
*
|
||||||
|
FROM
|
||||||
|
dev_sblx
|
||||||
|
WHERE
|
||||||
|
is_deleted = 0
|
||||||
|
AND id = #{scx}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<select id="getCountByPlanId" resultType="java.util.Map">
|
<select id="getCountByPlanId" resultType="java.util.Map">
|
||||||
SELECT
|
SELECT
|
||||||
COUNT(*) AS jhs,
|
COUNT(*) AS jhs,
|
||||||
COUNT(CASE WHEN order_state = '1' THEN 1 ELSE NULL END) AS wcs
|
COUNT(CASE WHEN order_state = '3' THEN 1 ELSE NULL END) AS wcs
|
||||||
FROM
|
FROM
|
||||||
by_management_gd
|
by_management_gd
|
||||||
WHERE
|
WHERE
|
||||||
|
|||||||
@@ -13,8 +13,18 @@ public interface ByglConstant {
|
|||||||
|
|
||||||
/**待开始*/
|
/**待开始*/
|
||||||
String GD_STATE_DKS = "0";
|
String GD_STATE_DKS = "0";
|
||||||
|
/**进行中*/
|
||||||
|
String GD_STATE_JXZ = "1";
|
||||||
|
/**待验收*/
|
||||||
|
String GD_STATE_DYS = "2";
|
||||||
/**已完成*/
|
/**已完成*/
|
||||||
String BY_STATE_YWC = "1";
|
String BY_STATE_YWC = "3";
|
||||||
|
/**不通过*/
|
||||||
|
String GD_STATE_BTG = "4";
|
||||||
|
/**验收不通过*/
|
||||||
|
String GD_STATE_YSBTG = "5";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**方案停用*/
|
/**方案停用*/
|
||||||
String FA_STATE_TY = "0";
|
String FA_STATE_TY = "0";
|
||||||
|
|||||||
Reference in New Issue
Block a user