测试问题修改

This commit is contained in:
cwchen 2024-04-24 14:49:42 +08:00
parent b2c47fcf2c
commit e50241a467
12 changed files with 300 additions and 53 deletions

View File

@ -0,0 +1,100 @@
package com.securitycontrol.common.core.utils;
import org.springframework.web.multipart.MultipartFile;
import java.util.Arrays;
import java.util.Locale;
/**
* 文件上传校验的公共方法
*
* @authorcwchen
* @date2024-03-11-10:11
* @version1.0
* @description工程管理-业务逻辑层
*/
public class UploadCheckUtils {
/**
* 文件大小 10MB(可用于图片和视频区分)
*/
public static final long IMG_FILE_SIZE = 10 * 1024 * 1024;
/**
* 只支持图片格式
*/
public static final String[] YES_IMAGE_SUPPORT = {".jpg", ".jpeg", ".png"};
/**
* 只支持视频格式
*/
public static final String[] YES_VIDEO_SUPPORT = {".mp4", ".avi", ".mp3"};
/**
* 只支持音频格式
*/
public static final String[] YES_AUDIO_SUPPORT = {".mp3"};
/**
* 只支持文件格式
*/
public static final String[] YES_FILE_SUPPORT = {".xlsx", ".xls", ".doc", ".docx", ".txt", ".csv"};
/**
* 全部文件(普通文件,图片, 视频,音频)后缀 支持的类型
*/
public static final String[] FILE_SUFFIX_SUPPORT = {".xlsx", ".xls", ".doc", ".docx", ".txt", ".csv",
".jpg", ".jpeg", ".png", ".mp4", ".avi", ".mp3"};
/**
* 文件名字 需要排除的字符
* 废弃: "(", ")","",".", "——", "_","-"
*/
public static final String[] FILE_NAME_EXCLUDE = {
"`", "!", "@", "#", "$", "%", "^", "&", "*", "=", "+",
"~", "·", "", "", "……", "", "",
"?", ",", "<", ">", ":", ";", "[", "]", "{", "}", "/", "\\", "|",
"", "", "", "", "", "", "", "", "", ""
};
public static final String SUFFIX = ".";
/**
* 图片上传文件校验大小名字后缀
*
* @param multipartFile multipartFile
*/
public static String uploadImgVerify(MultipartFile multipartFile) {
// 校验文件是否为空
if (multipartFile == null) {
return "上传图片不能为空";
}
// 校验文件名字
String originalFilename = multipartFile.getOriginalFilename();
if (originalFilename == null) {
return "上传图片名字不能为空";
}
for (String realKey : FILE_NAME_EXCLUDE) {
if (originalFilename.contains(realKey)) {
return "上传图片名称不允许出现"+realKey+"关键字";
}
}
// 校验文件后缀
if (!originalFilename.contains(SUFFIX)) {
return "图片不能没有后缀";
}
String suffix = originalFilename.substring(originalFilename.lastIndexOf('.'));
/*校验: 文件格式是否符合要求*/
if (!Arrays.asList(YES_IMAGE_SUPPORT).contains(suffix.toLowerCase(Locale.ROOT))) {
return "图片格式仅支持" + Arrays.asList(YES_IMAGE_SUPPORT).toString();
}
Long fileSize = multipartFile.getSize();
if (fileSize > IMG_FILE_SIZE) {
return "图片大小仅支持10MB以内";
}
return null;
}
}

View File

@ -1,6 +1,5 @@
package com.securitycontrol.common.core.utils.aes;
import com.sun.org.apache.bcel.internal.generic.RETURN;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@ -49,6 +48,7 @@ public class DateTimeHelper {
}
return false;
}
/**
* 增加 LocalDateTime ==> Date
*/
@ -394,7 +394,6 @@ public class DateTimeHelper {
}
/**
* 得到前一个月
*
@ -857,6 +856,7 @@ public class DateTimeHelper {
/**
* 两个日期之间的差值
*
* @param startDate
* @param endDate
* @return Long
@ -899,4 +899,22 @@ public class DateTimeHelper {
String endTime = sdfTwo.format(new Date()) + maxDate;
return startTime + " - " + endTime;
}
/**
* 比较两个时间
* @param startTime
* @param endTime
* @return boolean
* @description
* @author cwchen
* @date 2024/4/24 9:55
*/
public static boolean compareTime(String startTime, String endTime) {
Long aLong = convertDateStringToTimestamp(startTime, "yyyy-MM-dd");
Long bLong = convertDateStringToTimestamp(endTime, "yyyy-MM-dd");
if (aLong > bLong) {
return false;
}
return true;
}
}

View File

@ -129,10 +129,22 @@ public interface IProScheduleMapper {
/**
* 更新工序计划进度
*
* @param vo
* @description
* @author cwchen
* @date 2024/3/30 13:05
*/
void updateGxPlan(GxPlanProgressVo vo);
/**
* 获取工程进度
* @param vo
* @return List<Map < Object>>
* @description
* @author cwchen
* @date 2024/4/24 13:41
*/
@MapKey("bidCode")
List<Map<String, Object>> efficiencyAnalysis(ProScheduleVo vo);
}

View File

@ -9,6 +9,7 @@ import com.securitycontrol.common.core.constant.HttpStatus;
import com.securitycontrol.common.core.constant.SecurityConstants;
import com.securitycontrol.common.core.domain.Result;
import com.securitycontrol.common.core.utils.StringUtils;
import com.securitycontrol.common.core.utils.UploadCheckUtils;
import com.securitycontrol.common.core.utils.aes.AesCbcUtils;
import com.securitycontrol.common.core.utils.aes.DateTimeHelper;
import com.securitycontrol.common.core.utils.aes.ListHelper;
@ -108,6 +109,10 @@ public class HumanServiceImpl implements HumanService {
}
// 上传文件
if (file != null) {
String isVerify = UploadCheckUtils.uploadImgVerify(file);
if(StringUtils.isNotBlank(isVerify)){
return AjaxResult.error(isVerify);
}
Result result = remoteFileService.singleUploadFile(file, SecurityConstants.INNER);
if(result != null && result.getCode() == HttpStatus.ERROR) {
log.error("人员照片上传失败");

View File

@ -21,10 +21,8 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
/**
* @authorcwchen
@ -47,6 +45,30 @@ public class ProScheduleServiceImpl implements IProScheduleService {
List<ProScheduleVo> list = new ArrayList<>();
try {
list = mapper.getProScheduleLists(dto);
list.forEach(vo->{
List<Map<String, Object>> valueList = new ArrayList<>();
valueList = mapper.efficiencyAnalysis(vo);
Map<String, List<Map<String, Object>>> map = valueList.stream().collect(Collectors.groupingBy(item -> {
return String.valueOf(item.get("bidCode"));
}));
map.forEach((k, v) -> {
// 根据每个工程的工序计划及进度填报计算效率
Map<String, Object> dataMap = new HashMap<>(16);
BigDecimal value = new BigDecimal("0");
BigDecimal multipleValue = new BigDecimal("100");
for (int i = 0; i < v.size(); i++) {
if (Objects.nonNull(v.get(i).get("planId")) && Objects.nonNull(v.get(i).get("planProgress")) && Objects.nonNull(v.get(i).get("gxWeight"))) {
BigDecimal bigDecimal = new BigDecimal(String.valueOf(v.get(i).get("gxWeight")));
BigDecimal bigDecimal2 = new BigDecimal(String.valueOf(v.get(i).get("planProgress")));
value = value.add(bigDecimal.multiply(bigDecimal2).divide(multipleValue, 3, BigDecimal.ROUND_HALF_UP));
}
}
vo.setNowProSchedule(String.valueOf(value.doubleValue()));
});
if(CollectionUtils.isEmpty(valueList)){
vo.setNowProSchedule("0");
}
});
} catch (Exception e) {
log.error("获取工程进度列表", e);
}

View File

@ -10,6 +10,7 @@ import com.securitycontrol.common.core.constant.SecurityConstants;
import com.securitycontrol.common.core.domain.Result;
import com.securitycontrol.common.core.utils.ImportExcelUtils;
import com.securitycontrol.common.core.utils.StringUtils;
import com.securitycontrol.common.core.utils.UploadCheckUtils;
import com.securitycontrol.common.core.utils.aes.DateTimeHelper;
import com.securitycontrol.common.core.web.domain.AjaxResult;
import com.securitycontrol.common.security.utils.ValidatorsUtils;
@ -93,6 +94,16 @@ public class ProServiceImpl implements IProService {
if (StringUtils.isNotBlank(validResult)) {
return AjaxResult.error(validResult);
}
boolean flag = DateTimeHelper.compareTime(vo.getPlanStartTime(), vo.getPlanEndTime());
if(!flag){
return AjaxResult.error("计划开工时间不能晚于计划结束时间");
}
if(StringUtils.isNotBlank(vo.getStartTime()) && StringUtils.isNotBlank(vo.getEndTime())){
boolean flag2 = DateTimeHelper.compareTime(vo.getStartTime(), vo.getEndTime());
if(!flag2){
return AjaxResult.error("实际开始时间不能晚于实际结束时间");
}
}
String proId = getuid();
int result = mapper.proIsExist(vo);
if (result > 0) {
@ -116,6 +127,12 @@ public class ProServiceImpl implements IProService {
}
// 上传文件
if (files != null && types != null) {
for (MultipartFile file : files) {
String isVerify = UploadCheckUtils.uploadImgVerify(file);
if(StringUtils.isNotBlank(isVerify)){
return AjaxResult.error(isVerify);
}
}
Result uploadResult = remoteFileService.mostUploadFile(files, SecurityConstants.INNER);
if (uploadResult != null && uploadResult.getCode() == HttpStatus.ERROR) {
log.error("工程文件上传失败");
@ -562,6 +579,10 @@ public class ProServiceImpl implements IProService {
if (StringUtils.isNotBlank(validResult)) {
return AjaxResult.error(validResult);
}
boolean flag = DateTimeHelper.compareTime(vo.getPlanStartTime(), vo.getPlanEndTime());
if(!flag){
return AjaxResult.error("计划开始时间不能晚于计划结束时间");
}
int result = mapper.getTowerIsExist(vo);
if(result > 0){
return AjaxResult.error("杆塔或工序不能重复选择");

View File

@ -3,6 +3,7 @@ package com.securitycontrol.background.service.impl;
import com.securitycontrol.background.mapper.ISignProMapper;
import com.securitycontrol.background.service.ISignProService;
import com.securitycontrol.common.core.utils.StringUtils;
import com.securitycontrol.common.core.utils.aes.DateTimeHelper;
import com.securitycontrol.common.core.utils.uuid.IdUtils;
import com.securitycontrol.common.core.web.domain.AjaxResult;
import com.securitycontrol.common.security.utils.ValidatorsUtils;
@ -50,6 +51,16 @@ public class SignProServiceImpl implements ISignProService {
public AjaxResult addOrUpdateProject(ProjectVo vo) {
try {
String validResult = validatorsUtils.valid(vo, ProjectVo.Query.class);
boolean flag = DateTimeHelper.compareTime(vo.getPlanStartTime(), vo.getPlanEndTime());
if(!flag){
return AjaxResult.error("计划开始时间不能晚于计划开始时间");
}
if(StringUtils.isNotBlank(vo.getStartTime()) && StringUtils.isNotBlank(vo.getEndTime())){
boolean flag2 = DateTimeHelper.compareTime(vo.getStartTime(), vo.getEndTime());
if(!flag2){
return AjaxResult.error("实际开始时间不能晚于实际结束时间");
}
}
if (StringUtils.isNotBlank(validResult)) {
return AjaxResult.error(validResult);
}
@ -129,6 +140,10 @@ public class SignProServiceImpl implements ISignProService {
if (StringUtils.isNotBlank(validResult)) {
return AjaxResult.error(validResult);
}
boolean flag = DateTimeHelper.compareTime(vo.getStartDate(), vo.getCompleteDate());
if(!flag){
return AjaxResult.error("实际开工时间不能晚于实际竣工时间");
}
int result = mapper.isSignPro(vo);
if (result > 0) {
return AjaxResult.error("单项编码不能重复");

View File

@ -1,7 +1,9 @@
package com.securitycontrol.background.service.impl;
import com.securitycontrol.background.mapper.HumanManageMapper;
import com.securitycontrol.background.mapper.TeamManageMapper;
import com.securitycontrol.background.service.TeamService;
import com.securitycontrol.common.core.constant.Constant;
import com.securitycontrol.common.core.utils.StringUtils;
import com.securitycontrol.common.core.utils.aes.AesCbcUtils;
import com.securitycontrol.common.core.utils.uuid.IdUtils;
@ -21,6 +23,7 @@ import java.util.*;
/**
* 班组-业务逻辑层
*
* @author 10488
*/
@Service(value = "TeamService")
@ -30,6 +33,9 @@ public class TeamServiceImpl implements TeamService {
@Resource(name = "TeamManageMapper")
private TeamManageMapper mapper;
@Resource(name = "HumanManageMapper")
private HumanManageMapper humanManageMapper;
@Resource(name = "ValidatorsUtils")
private ValidatorsUtils validatorsUtils;
@ -83,6 +89,7 @@ public class TeamServiceImpl implements TeamService {
/**
* 班组是否存在
*
* @param list
* @param idNumber
* @return Boolean
@ -145,6 +152,22 @@ public class TeamServiceImpl implements TeamService {
List<HumanManageVo> list = new ArrayList<>();
try {
list = mapper.getTeamUserLists(dto);
for (HumanManageVo vo : list) {
String data = humanManageMapper.getUserAccessStatus(vo.getUserId(), Constant.ACCESS_TYPE, 1);
if (StringUtils.isNotEmpty(data)) {
String value = humanManageMapper.getUserAccessStatus(data, Constant.ACCESS_TYPE, 2);
vo.setStatus(StringUtils.isEmpty(value) ? "离场" : value);
} else {
vo.setStatus("离场");
}
String decryptIdNumber = AesCbcUtils.decrypt(vo.getIdNumber());
if (decryptIdNumber != null) {
vo.setIdNumber(decryptIdNumber);
}
if(StringUtils.isNotBlank(vo.getIdNumber())){
vo.setAge(String.valueOf(getAge(vo.getIdNumber())));
}
}
} catch (Exception e) {
log.error("获取班组人员列表", e);
}
@ -213,4 +236,22 @@ public class TeamServiceImpl implements TeamService {
return AjaxResult.error();
}
}
/**
* 根据身份证获取年龄
* @param idCard
* @return int
* @description
* @author cwchen
* @date 2024/4/24 14:37
*/
public static int getAge(String idCard) {
// 获取当前年份
int currentYear = Calendar.getInstance().get(Calendar.YEAR);
// 将身份证号的前四位即出生年份截取出来
int birthYear = Integer.parseInt(idCard.substring(6, 10));
// 计算年龄
int age = currentYear - birthYear;
return age;
}
}

View File

@ -121,14 +121,15 @@
</if>
AND ttp.del_falge = '0'
</where>
ORDER BY ttp.cratet_time DESC
</select>
<!--人员是否存在-->
<select id="userIsExist" resultType="java.util.Map">
<if test="userId == null or userId == ''">
SELECT user_id AS id,id_number AS value FROM t_team_people
SELECT user_id AS id,id_number AS value FROM t_team_people WHERE del_falge = '0'
</if>
<if test="userId != null and userId != ''">
SELECT user_id AS id,id_number AS value FROM t_team_people WHERE user_id != #{userId}
SELECT user_id AS id,id_number AS value FROM t_team_people WHERE user_id != #{userId} AND del_falge = '0'
</if>
</select>
<!--人员详情-->

View File

@ -149,4 +149,13 @@
INNER JOIN (SELECT MAX( create_time ) AS create_time FROM tb_project_progress WHERE plan_id = #{planId} GROUP BY gx_id) tpp2 ON tpp.create_time = tpp2.create_time
WHERE plan_id = #{planId}
</select>
<!--获取工程进度-->
<select id="efficiencyAnalysis" resultType="java.util.Map">
SELECT tgp.gx_weight AS gxWeight,
IFNULL(tgp.plan_progress,'0') AS planProgress,
tgp.bid_code AS bidCode,
tgp.plan_id AS planId
FROM tb_gx_plan tgp
WHERE tgp.bid_code = #{bidCode} AND tgp.del_flag = 0
</select>
</mapper>

View File

@ -244,8 +244,8 @@
tsp.vol_level AS volLevel,
tsp.line_length AS lineLength,
tsp.subs_cap AS subsCap,
CASE tsp.pro_type WHEN '1' THEN '变电' WHEN '2' THEN '线路' END AS proType,
CASE tsp.subs_type WHEN '1' THEN '土建' WHEN '2' THEN '电气' WHEN '3' THEN '变电' END AS subsType,
tsp.pro_type AS proType,
tsp.subs_type AS subsType,
tsp.estimate_type AS estimateType,
tsp.start_date AS startDate,
tsp.end_date AS endDate,

View File

@ -103,18 +103,20 @@
</select>
<!--班组是否存在班组人员-->
<select id="isPeopleByTeam" resultType="java.lang.Integer">
SELECT COUNT(*) FROM t_team_people WHERE team_id = #{id}
SELECT COUNT(*) FROM t_team_people WHERE team_id = #{id} AND del_falge = '0'
</select>
<!--班组人员数量-->
<select id="getTeamUserNum" resultType="java.lang.Integer">
SELECT COUNT(*) FROM t_team_people WHERE team_id = #{teamId}
SELECT COUNT(*) FROM t_team_people WHERE team_id = #{teamId} AND del_falge = '0'
</select>
<!--获取班组人员列表-->
<select id="getTeamUserLists" resultType="com.securitycontrol.entity.background.vo.HumanManageVo">
SELECT
ttp.user_id AS userId,
ttp.user_name AS userName,
sd.dict_name AS userType
sd.dict_name AS userType,
ttp.sex,
ttp.id_number AS idNumber
FROM t_team_people ttp
LEFT JOIN sys_dict sd ON ttp.user_type = sd.dict_code
<where>
@ -122,12 +124,13 @@
<if test="userName!=null and userName !=''">
AND INSTR(ttp.user_name,#{userName}) > 0
</if>
AND ttp.del_falge = '0'
</where>
</select>
<!--获取班组组员和未加入班组人员-->
<select id="getTeamUserAndNoBandingUser" resultType="java.util.Map">
SELECT user_id AS id,user_name AS userName,'1' AS type FROM t_team_people WHERE team_id = #{id}
SELECT user_id AS id,user_name AS userName,'1' AS type FROM t_team_people WHERE team_id = #{id} AND del_falge = '0'
UNION ALL
SELECT user_id AS id,user_name AS userName,'2' AS type FROM t_team_people WHERE team_id IS NULL OR team_id = ''
SELECT user_id AS id,user_name AS userName,'2' AS type FROM t_team_people WHERE team_id IS NULL OR team_id = '' AND (del_falge = '0')
</select>
</mapper>