添加确认生成接口
This commit is contained in:
+13
@@ -5,6 +5,7 @@ import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.api.vo.ResultCommon;
|
||||
import com.jero.common.aspect.annotation.AutoLog;
|
||||
import com.jero.common.aspect.annotation.Translation;
|
||||
import com.jero.modules.activiti.process.part.entity.ProcessPartTypeApply;
|
||||
import com.jero.modules.activiti.process.part.entity.ProcessPartTypeApplyRecord;
|
||||
import com.jero.modules.activiti.process.part.service.IProcessPartTypeApplyRecordService;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -14,6 +15,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -133,4 +135,15 @@ public class ProcessPartTypeApplyRecordController {
|
||||
this.processPartTypeApplyRecordService.edit(processPartTypeApplyRecord);
|
||||
return Result.OK(ResultCommon.OK);
|
||||
}
|
||||
/**
|
||||
* 确认生成
|
||||
* @param processPartTypeApplyRecord
|
||||
*/
|
||||
@AutoLog(value = "业务支持-关键零部件型号库-确认生成")
|
||||
@ApiOperation(value="业务支持-关键零部件型号库-确认生成", notes="关键零部件型号库-确认生成")
|
||||
@PostMapping("/affirmGenerate")
|
||||
public Result<?> affirmGenerate(@RequestBody ProcessPartTypeApplyRecord processPartTypeApplyRecord) {
|
||||
return Result.OK(processPartTypeApplyRecordService.affirmGenerate(processPartTypeApplyRecord));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
@@ -24,4 +24,6 @@ public interface IProcessPartTypeApplyRecordService extends IService<ProcessPart
|
||||
String add(ProcessPartTypeApplyRecord processPartTypeApplyRecord);
|
||||
|
||||
void edit(ProcessPartTypeApplyRecord processPartTypeApplyRecord);
|
||||
|
||||
String affirmGenerate(ProcessPartTypeApplyRecord processPartTypeApplyRecord);
|
||||
}
|
||||
|
||||
+78
@@ -1,6 +1,7 @@
|
||||
package com.jero.modules.activiti.process.part.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.common.api.vo.ResultCommon;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
@@ -9,16 +10,21 @@ import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.modules.activiti.process.part.entity.ProcessPartTypeApplyRecord;
|
||||
import com.jero.modules.activiti.process.part.mapper.ProcessPartTypeApplyRecordMapper;
|
||||
import com.jero.modules.activiti.process.part.service.IProcessPartTypeApplyRecordService;
|
||||
import com.jero.modules.laws.part.constans.PartConstants;
|
||||
import com.jero.modules.laws.part.entity.LawsPartRelevance;
|
||||
import com.jero.modules.laws.part.service.ILawsPartRelevanceService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@@ -105,6 +111,78 @@ public class ProcessPartTypeApplyRecordServiceImpl extends ServiceImpl<ProcessPa
|
||||
}
|
||||
updateById(processPartTypeApplyRecord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String affirmGenerate(ProcessPartTypeApplyRecord processPartTypeApplyRecord) {
|
||||
ProcessPartTypeApplyRecord obj = getById(processPartTypeApplyRecord.getId());
|
||||
if(Objects.isNull(obj)){
|
||||
throw new JeroBootException(ResultCommon.NO_CORRESPONDING_DATA_FOUND);
|
||||
}
|
||||
LawsPartRelevance lawsPartRelevance = lawsPartRelevanceService.getById(obj.getPartRelevanceId());
|
||||
if(Objects.isNull(lawsPartRelevance)){
|
||||
throw new JeroBootException(ResultCommon.NO_CORRESPONDING_DATA_FOUND);
|
||||
}
|
||||
String partRelevanceType = "";
|
||||
// 型号型式是奇瑞型号的,按两种生成逻辑自动编号
|
||||
if(Objects.equals(lawsPartRelevance.getFormType(), PartConstants.FORM_TYPE1)){
|
||||
QueryWrapper<ProcessPartTypeApplyRecord> queryProcessPartTypeApplyRecord = new QueryWrapper<>();
|
||||
queryProcessPartTypeApplyRecord.select("max(part_relevance_type) as part_relevance_type");
|
||||
queryProcessPartTypeApplyRecord.likeLeft("part_relevance_type",lawsPartRelevance.getSystemCode());
|
||||
ProcessPartTypeApplyRecord max = getOne(queryProcessPartTypeApplyRecord,false);
|
||||
if(Objects.isNull(max)){
|
||||
partRelevanceType = lawsPartRelevance.getSystemCode() + "AAA";
|
||||
}else{
|
||||
String str = max.getPartRelevanceType().replace(lawsPartRelevance.getSystemCode(),"");
|
||||
partRelevanceType = lawsPartRelevance.getSystemCode() + generateNext(str);
|
||||
}
|
||||
}else{
|
||||
// 型号型式不是奇瑞型号的,设计工程师手填
|
||||
if(StringUtils.isEmpty(processPartTypeApplyRecord.getPartRelevanceType())){
|
||||
throw new JeroBootException((Objects.equals(LocaleContextHolder.getLocale(), Locale.ENGLISH) ?
|
||||
"关键零部件型号 is not null" : "关键零部件型号不能为空"));
|
||||
}
|
||||
partRelevanceType = processPartTypeApplyRecord.getPartRelevanceType();
|
||||
}
|
||||
LambdaUpdateWrapper<ProcessPartTypeApplyRecord> update = new LambdaUpdateWrapper<>();
|
||||
update.eq(ProcessPartTypeApplyRecord::getId,obj.getId());
|
||||
update.set(ProcessPartTypeApplyRecord::getPartRelevanceType,partRelevanceType);
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
update.set(ProcessPartTypeApplyRecord::getUpdateBy,sysUser.getUsername());
|
||||
update.set(ProcessPartTypeApplyRecord::getUpdateTime, new Date());
|
||||
update(update);
|
||||
return partRelevanceType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成给定字母序列的下一个字母序列。
|
||||
*
|
||||
* @param sequence 当前的三位大写字母序列
|
||||
* @return 下一个字母序列
|
||||
* @throws IllegalArgumentException 如果输入不是有效的三位大写字母序列
|
||||
*/
|
||||
public static String generateNext(String sequence) {
|
||||
// 检查输入是否有效
|
||||
if (sequence == null || sequence.length() != 3 || !sequence.matches("[A-Z]{3}")) {
|
||||
throw new IllegalArgumentException("Input must be a 3-character uppercase letter sequence.");
|
||||
}
|
||||
|
||||
char[] chars = sequence.toCharArray();
|
||||
|
||||
// 从最后一位开始处理
|
||||
for (int i = chars.length - 1; i >= 0; i--) {
|
||||
if (chars[i] < 'Z') { // 如果当前位不是'Z'
|
||||
chars[i]++; // 当前位加一
|
||||
break; // 结束循环
|
||||
} else { // 如果当前位已经是'Z'
|
||||
chars[i] = 'A'; // 重置当前位为'A'
|
||||
if (i == 0) { // 如果已经是最左边的一位了,那么整个序列需要回滚到"AAA"
|
||||
return "AAA";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new String(chars);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,4 +12,9 @@ public class PartConstants {
|
||||
*/
|
||||
public static final String STATUS_2 = "2";
|
||||
|
||||
/**
|
||||
* 奇瑞型号
|
||||
*/
|
||||
public static final String FORM_TYPE1 = "1";
|
||||
|
||||
}
|
||||
|
||||
+4
-3
@@ -13,6 +13,7 @@ import com.jero.common.system.query.QueryGenerator;
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.common.util.ImportExcelUtil;
|
||||
import com.jero.common.util.MessageUtils;
|
||||
import com.jero.modules.laws.part.constans.PartConstants;
|
||||
import com.jero.modules.laws.part.entity.LawsPartPmmPartitionInfo;
|
||||
import com.jero.modules.laws.part.entity.LawsPartRelevance;
|
||||
import com.jero.modules.laws.part.mapper.LawsPartRelevanceMapper;
|
||||
@@ -113,9 +114,9 @@ public class LawsPartRelevanceServiceImpl extends ServiceImpl<LawsPartRelevanceM
|
||||
}
|
||||
|
||||
private void checkData(LawsPartRelevance lawsPartRelevance) {
|
||||
// todo 是奇瑞型号的型号型式必填功能系统码和技术特性判定要求,不是奇瑞型号的不用填写
|
||||
// 是奇瑞型号的型号型式必填功能系统码和技术特性判定要求,不是奇瑞型号的不用填写
|
||||
List<String> formType = Arrays.asList(lawsPartRelevance.getFormType().split(","));
|
||||
if (formType.contains("1")) {
|
||||
if (formType.contains(PartConstants.FORM_TYPE1)) {
|
||||
if (StringUtils.isBlank(lawsPartRelevance.getSystemCode())) {
|
||||
throw new JeroBootException((Objects.equals(LocaleContextHolder.getLocale(), Locale.ENGLISH) ?
|
||||
"功能系统码 cannot be empty" : "功能系统码不能为空"));
|
||||
@@ -224,7 +225,7 @@ public class LawsPartRelevanceServiceImpl extends ServiceImpl<LawsPartRelevanceM
|
||||
}
|
||||
}
|
||||
List<String> formType = Arrays.asList(lawsPartRelevance.getFormType().split(","));
|
||||
if(formType.contains("1")){
|
||||
if(formType.contains(PartConstants.FORM_TYPE1)){
|
||||
if(StringUtils.isBlank(lawsPartRelevance.getSystemCode())){
|
||||
s.append(Objects.equals(LocaleContextHolder.getLocale(),Locale.ENGLISH) ?
|
||||
"功能系统码 cannot be empty," : "功能系统码不能为空,");
|
||||
|
||||
Reference in New Issue
Block a user