问题修改

This commit is contained in:
jiang 2026-01-07 13:46:09 +08:00
parent 72b6d2ace7
commit 82e9a203c2
17 changed files with 166 additions and 148 deletions

View File

@ -205,7 +205,7 @@ public class BackChangeServiceImpl implements BackChangeService {
log.error(e.getMessage());
throw new RuntimeException(e.getMessage());
}
return AjaxResult.success("退库申请提交成功,等待审批", AjaxResult.class);
return AjaxResult.success("退库申请提交成功,等待审批", csDeviceVo.getDevInfo().getId());
}

View File

@ -69,7 +69,7 @@ public class BookCarServiceImpl implements BookCarService {
bmFileInfo.setModelId(bookCarDetail.getMaId());
bmFileInfo.setTaskType(MaterialConstants.MATERIAL_FILE_TYPE_CODE);
bmFileInfo.setFileType(0L);
List<BmFileInfo> mainFileInfoList = bmFileInfoMapper.selectBmFileInfoList(bmFileInfo);
List<BmFileInfo> mainFileInfoList = bmFileInfoMapper.selectMaFileInfoList(bookCarDetail.getMaId());
if (!CollectionUtils.isEmpty(mainFileInfoList)) {
bookCarDetail.setPicUrl(mainFileInfoList.get(0).getFileUrl());
}

View File

@ -1173,13 +1173,13 @@ public class DevChangeServiceImpl implements DevChangeService {
DevChangeVo entity = mapper.getChange(vo);
vo.setType(entity.getType());
List<DevChangeVo> list = mapper.getDevDetails(vo);
for (DevChangeVo devChangeVo : list) {
if (devChangeVo.getWorkingHours() == null) {
devChangeVo.setWorkingHours(0);
}
devChangeVo.setRemainingHours(devChangeVo.getMaxWorkingHours() - devChangeVo.getWorkingHours());
}
// for (DevChangeVo devChangeVo : list) {
// if (devChangeVo.getWorkingHours() == null) {
// devChangeVo.setWorkingHours(0);
// }
//
// devChangeVo.setRemainingHours(devChangeVo.getMaxWorkingHours() - devChangeVo.getWorkingHours());
// }
return list;
} catch (Exception e) {
log.error(e.getMessage());

View File

@ -38,9 +38,9 @@ public class MaDevInfoServiceImpl implements MaDevInfoService {
// && !deptId.equals(PROVINCE_COMPANY_DEPT_ID)) {
// o.setCompanyId(deptId);
// }
if(ADMIN_ID.equals(userId)){
if (ADMIN_ID.equals(userId)) {
o.setCompanyId(1L);
}else{
} else {
o.setCompanyId(deptId);
}
List<MaDevInfo> list = mapper.list(o);
@ -96,8 +96,8 @@ public class MaDevInfoServiceImpl implements MaDevInfoService {
// 兜底净值最低为0避免折旧后为负
netValue = netValue.compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : netValue;
if(item.getValue() == null ||!item.getValue().equals(netValue) ){
mapper.updatePrice(item.getMaId(),netValue);
if (item.getValue() == null || !item.getValue().equals(netValue)) {
mapper.updatePrice(item.getMaId(), netValue);
}
// 填充净值到实体字段
@ -107,7 +107,6 @@ public class MaDevInfoServiceImpl implements MaDevInfoService {
});
return list;
}
@ -140,10 +139,9 @@ public class MaDevInfoServiceImpl implements MaDevInfoService {
public DeviceCountBean deviceCount(MaDevInfo o) {
Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
Long userId = SecurityUtils.getLoginUser().getUserid();
// 管理员和省公司可查看所有数据
if (userId != null && deptId != null
&& !userId.equals(ADMIN_ID)
&& !deptId.equals(PROVINCE_COMPANY_DEPT_ID)) {
if (ADMIN_ID.equals(userId)) {
o.setCompanyId(1L);
} else {
o.setCompanyId(deptId);
}
return mapper.deviceCount(o);
@ -260,7 +258,7 @@ public class MaDevInfoServiceImpl implements MaDevInfoService {
// } else {
// companyId = null;
// }
if(ADMIN_ID.equals(userId)){
if (ADMIN_ID.equals(userId)) {
companyId = 1L;
}
Integer totalCount = mapper.selectTotalDeviceCount(companyId);

View File

@ -30,6 +30,8 @@ public interface BmFileInfoMapper {
*/
List<BmFileInfo> selectBmFileInfoList(BmFileInfo bmFileInfo);
List<BmFileInfo> selectMaFileInfoList(Long maId);
List<BmFileInfo> selectBmFileInfo(BmFileInfo bmFileInfo);
/**

View File

@ -72,16 +72,16 @@ import static com.bonus.common.biz.enums.MaStatusEnum.*;
@Slf4j
public class DevInfoServiceImpl implements DevInfoService {
// 装备主展示图片字典
private final Integer MAIN_IMAGES_DICT_VALUE = 0;
private final Integer MAIN_IMAGES_DICT_VALUE = 1;
// 装备详情展示图片字典
private final Integer DETAILS_IMAGES_DICT_VALUE = 1;
private final Integer DETAILS_IMAGES_DICT_VALUE = 2;
// 检测证明PDF附件字典
private final Integer EXAMINATION_PDF = 2;
private final Integer EXAMINATION_PDF = 3;
// 合格证PDF附件字典
private final Integer INSURANCE_PDF = 3;
private final Integer INSURANCE_PDF = 4;
@Resource
private DevInfoMapper devInfoMapper;
@ -123,7 +123,7 @@ public class DevInfoServiceImpl implements DevInfoService {
System.err.println("更新设备搜索量失败,不影响主业务流程");
}
BmFileInfo bmFileInfo = new BmFileInfo().setModelId(devInfoVo.getMaId()).setTaskType(MaterialConstants.MATERIAL_FILE_TYPE_CODE);
List<BmFileInfo> fileList = bmFileInfoMapper.selectBmFileInfoList(bmFileInfo);
List<BmFileInfo> fileList = bmFileInfoMapper.selectMaFileInfoList(maId);
ArrayList<Table> tableList = new ArrayList<>();
if (!CollectionUtils.isEmpty(fileList)) {
fileList.removeIf(Objects::isNull);
@ -424,34 +424,34 @@ public class DevInfoServiceImpl implements DevInfoService {
}
}*/
String code = "";
/* for (int i = 0; i < devInfo.getTableList().size(); i++) {*/
//获取用户信息
Long userId = SecurityUtils.getLoginUser().getUserid();
//保存用户信息
devInfo.setCreator(userId)
/*.setMaStatus(ON_HIRE.getCode())*/
.setOwnId(userId);
if (org.apache.commons.lang3.StringUtils.isBlank(code)) {
code = getString();
}
devInfo.setCode(code);
//devInfo.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId().toString());
devInfo.setDeviceCount(devInfo.getDeviceCount());
//devInfo.setIdentifyCode(devInfo.getTableList().get(i).getIdentifyCode());
//0914 添加字段
devInfo.setChangeStatus("1");
devInfo.setUpDownStatus("0");
int num = devInfoMapper.insertDevInfo(devInfo);
if (num == 0) {
return AjaxResult.error("设备信息SQL保存失败请修改后重试");
}
//devInfoMapper.updateTypeLeasePrice(devInfo);
code = "";
//保存自定义属性值
/* for (int i = 0; i < devInfo.getTableList().size(); i++) {*/
//获取用户信息
Long userId = SecurityUtils.getLoginUser().getUserid();
//保存用户信息
devInfo.setCreator(userId)
/*.setMaStatus(ON_HIRE.getCode())*/
.setOwnId(userId);
if (org.apache.commons.lang3.StringUtils.isBlank(code)) {
code = getString();
}
devInfo.setCode(code);
//devInfo.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId().toString());
devInfo.setDeviceCount(devInfo.getDeviceCount());
//devInfo.setIdentifyCode(devInfo.getTableList().get(i).getIdentifyCode());
//0914 添加字段
devInfo.setChangeStatus("1");
devInfo.setUpDownStatus("0");
int num = devInfoMapper.insertDevInfo(devInfo);
if (num == 0) {
return AjaxResult.error("设备信息SQL保存失败请修改后重试");
}
//devInfoMapper.updateTypeLeasePrice(devInfo);
code = "";
//保存自定义属性值
/*if (!CollectionUtils.isEmpty(devInfo.getDevInfoProperties())) {
devInfoMapper.insertDevInfoProperties(devInfo.getMaId(), devInfo.getDevInfoProperties());
}*/
//把文件保存到附件中
//把文件保存到附件中
/* Table table = devInfo.getTableList().get(i);
AjaxResult error = uploadFiles(table, devInfo, userId, i);
if (error != null) {
@ -1066,13 +1066,13 @@ public class DevInfoServiceImpl implements DevInfoService {
@Override
public Integer updateCheckStatus(String ids, String status) {
String[] split = ids.split(",");
if(split.length>0){
if (split.length > 0) {
List<MapBean> list = new ArrayList<>();
for (String s : split) {
list.add(new MapBean(s,status));
list.add(new MapBean(s, status));
}
return devInfoMapper.updateCheckStatus(list);
}else {
} else {
return 0;
}
}

View File

@ -171,29 +171,7 @@ public class ToBeScrapServiceImpl implements ToBeScrapService {
}
// 如果是编辑操作那么就直接把之前的任务删掉重新建立
if (Objects.equals("edit", bean.getOperationType())) {
scrapMapper.deleteChangeInfo(bean.getId());
}
String username = SecurityUtils.getLoginUser().getSysUser().getNickName();
//1创建退役任务单号
int thisMonthMaxOrder = scrapMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TypeEnums.TM_TASK_RETIRE.getTaskTypeId());
String code = genderTaskCode(thisMonthMaxOrder);
CsDeviceInfo deviceInfo = new CsDeviceInfo();
deviceInfo.setType(String.valueOf(TypeEnums.TM_TASK_RETIRE.getTaskTypeId()));
deviceInfo.setCode(code);
deviceInfo.setReviewStatus("0"); // 待审批状态
deviceInfo.setCreateUser(username);
deviceInfo.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getDeptId());
// 添加任务
int num = scrapMapper.addDeviceChangeApply(deviceInfo);
if (num < 1) {
throw new ServiceException("添加任务失败");
}
Long changeId = deviceInfo.getId();
// 保存任务明细
for (ToBeScrap toBeScrap : bean.getToBeScrapList()) {
BigDecimal onWayNum = Optional.ofNullable(scrapMapper.getDetailsNum(toBeScrap)).orElse(BigDecimal.ZERO);
// 获取已使用数量可能为null转0
BigDecimal usedNum = Optional.ofNullable(toBeScrap.getInStockNum()).orElse(BigDecimal.ZERO);
@ -222,12 +200,35 @@ public class ToBeScrapServiceImpl implements ToBeScrapService {
// 返回错误结果
return AjaxResult.error(errorMsg, AjaxResult.class);
}
}
// 如果是编辑操作那么就直接把之前的任务删掉重新建立
if (Objects.equals("edit", bean.getOperationType())) {
scrapMapper.deleteChangeInfo(bean.getId());
}
String username = SecurityUtils.getLoginUser().getSysUser().getNickName();
//1创建退役任务单号
int thisMonthMaxOrder = scrapMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TypeEnums.TM_TASK_RETIRE.getTaskTypeId());
String code = genderTaskCode(thisMonthMaxOrder);
CsDeviceInfo deviceInfo = new CsDeviceInfo();
deviceInfo.setType(String.valueOf(TypeEnums.TM_TASK_RETIRE.getTaskTypeId()));
deviceInfo.setCode(code);
deviceInfo.setReviewStatus("0"); // 待审批状态
deviceInfo.setCreateUser(username);
deviceInfo.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getDeptId());
// 添加任务
int num = scrapMapper.addDeviceChangeApply(deviceInfo);
if (num < 1) {
throw new ServiceException("添加任务失败");
}
Long changeId = deviceInfo.getId();
// 保存任务明细
for (ToBeScrap toBeScrap : bean.getToBeScrapList()) {
toBeScrap.setChangeId(changeId);
toBeScrap.setCreateUser(username);
if (CollectionUtils.isNotEmpty(toBeScrap.getBmFileInfos())) {
toBeScrap.setScrapUrl(toBeScrap.getBmFileInfos().get(0).getFileUrl());
}

View File

@ -195,7 +195,7 @@
</if>
</where>
GROUP BY mdi.code
GROUP BY mdi.code,cd.order_id
HAVING useNum &gt; 0 and useNum is not null
UNION ALL
@ -289,7 +289,6 @@
AND cd.pro_code = #{proCode}
</if>
</where>
GROUP BY tl.id
HAVING useNum &gt; 0 and useNum is not null
UNION ALL
@ -346,7 +345,7 @@
</if>
</where>
GROUP BY mdi.code
GROUP BY mdi.code,cd.order_id
HAVING useNum &gt; 0 and useNum is not null
UNION ALL

View File

@ -160,7 +160,7 @@
cs_device_change cds
LEFT JOIN cs_device_change_details dcd ON dcd.change_id = cds.id
WHERE
cds.del_flag = 0
cds.del_flag = 0 AND cds.review_status = 2
<if test="keyWord!=null and keyWord!=''">
and (
cds.pro_name like concat('%',#{keyWord},'%') or
@ -183,7 +183,7 @@
<if test="startTime!=null and startTime!='' and endTime!=null and endTime!='' ">
and cds.create_time between #{startTime} and #{endTime}
</if>
<if test="companyId !=null and companyId !=1" >
<if test="companyId !=null and companyId !=1">
and cds.company_id
in (
select dept_id from sys_dept where dept_id= #{companyId}

View File

@ -264,17 +264,18 @@
count(distinct if(mdi.change_status = '3', mdi.ma_id, null)) as share,
count(distinct if(mdi.change_status = '5', mdi.ma_id, null)) as underRepair
FROM ma_dev_info mdi
INNER JOIN ma_type_view mtv ON mtv.typeId = mdi.type_id
LEFT JOIN jj_sing_project jsp ON mdi.on_project = jsp.pro_code
LEFT JOIN sys_dept sd ON sd.dept_id = mdi.on_company
LEFT JOIN (SELECT max(next_check_time) next_check_time, ma_id from ma_dev_qc GROUP BY ma_id) mdq on
mdi.ma_id = mdq.ma_id
LEFT JOIN ma_supplier ms ON ms.supplier_id = mdi.supplier_id
LEFT JOIN sys_cnarea sc ON sc.area_code = mdi.province_id
<where>
mdi.is_active = '1' and mdi.entry_status = '1'
<if test="companyId != null">
AND mdi.on_company = #{companyId}
<if test="companyId !=null and companyId != 1">
AND mdi.on_company
in (
select dept_id from sys_dept where dept_id= #{companyId}
union
select dept_id from sys_dept where parent_id= #{companyId}
union
select dept_id from sys_dept where parent_id in (select dept_id from sys_dept where parent_id=
#{companyId})
)
</if>
</where>
</select>
@ -347,8 +348,18 @@
mdi.unit AS unit,
mdq.next_check_time AS nextMaintenanceDate,
mdi.max_working_hours AS maxServiceLifeYears,
0 AS repairCount,
0 AS usageCount,
(SELECT
COUNT(1)
FROM
cs_device_change_details cdcd
LEFT JOIN cs_device_change cdc ON cdc.id = cdcd.change_id
WHERE cdc.type= 4 and cdc.review_status = 2 AND cdcd.dev_code = mdi.code) AS repairCount,
(SELECT
COUNT(1)
FROM
cs_device_change_details cdcd
LEFT JOIN cs_device_change cdc ON cdc.id = cdcd.change_id
WHERE cdc.type= 1 and cdc.review_status = 2 and cdcd.dev_code = mdi.code) AS usageCount,
sc.name AS province
from ma_dev_info mdi
INNER JOIN ma_type_view mtv ON mtv.typeId = mdi.type_id
@ -367,7 +378,8 @@
union
select dept_id from sys_dept where parent_id= #{companyId}
union
select dept_id from sys_dept where parent_id in (select dept_id from sys_dept where parent_id= #{companyId})
select dept_id from sys_dept where parent_id in (select dept_id from sys_dept where parent_id=
#{companyId})
)
</if>
<if test="typeId != null and typeId != 0 ">
@ -525,23 +537,17 @@
<select id="selectTotalDeviceCount" resultType="java.lang.Integer">
SELECT COUNT(1)
from ma_dev_info mdi
INNER JOIN ma_type_view mtv ON mtv.typeId = mdi.type_id
LEFT JOIN jj_sing_project jsp ON mdi.on_project = jsp.pro_code
LEFT JOIN sys_dept sd ON sd.dept_id = mdi.on_company
LEFT JOIN (SELECT max(next_check_time) next_check_time, ma_id from ma_dev_qc GROUP BY ma_id) mdq on
mdi.ma_id = mdq.ma_id
LEFT JOIN ma_supplier ms ON ms.supplier_id = mdi.supplier_id
LEFT JOIN sys_cnarea sc ON sc.area_code = mdi.province_id
<where>
mdi.is_active = '1' and mdi.entry_status = '1'
<if test="companyId != nul and companyId != 1">
<if test="companyId != null and companyId != 1 ">
AND mdi.on_company
in (
select dept_id from sys_dept where dept_id= #{companyId}
union
select dept_id from sys_dept where parent_id= #{companyId}
union
select dept_id from sys_dept where parent_id in (select dept_id from sys_dept where parent_id= #{companyId})
select dept_id from sys_dept where parent_id in (select dept_id from sys_dept where parent_id=
#{companyId})
)
</if>
</where>

View File

@ -73,6 +73,15 @@
and task_type = 17
and file_type = 4
</select>
<select id="selectMaFileInfoList" resultType="com.bonus.common.biz.domain.BmFileInfo">
select id,
file_name fileName,
file_url fileUrl,
file_type AS fileType,
create_time
from ma_dev_file
WHERE ma_id = #{maId}
</select>
<insert id="insertBmFileInfo" parameterType="com.bonus.common.biz.domain.BmFileInfo" useGeneratedKeys="true" keyProperty="id">
insert into bm_file_info

View File

@ -82,7 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-- 第一个子查询:设备表数据
(
SELECT
IFNULL(mdf.file_url, bfi.url) AS picUrl,
mdf.file_url AS picUrl,
mtv.proType,
mtv.mainGx,
mtv.childGx,
@ -127,7 +127,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN bm_company_info c ON sd.dept_id = c.company_id
INNER JOIN ma_type_view mtv ON mtv.typeId = d.type_id
LEFT JOIN bm_file_info bfi ON d.ma_id = bfi.model_id AND bfi.file_type = '0' AND bfi.task_type = '17'
LEFT JOIN ma_dev_file mdf ON d.ma_id = mdf.ma_id AND mdf.file_type = '1' AND mdf.is_active = '1'
LEFT JOIN (
SELECT mdf.ma_id, mdf.file_url
FROM ma_dev_file mdf
WHERE mdf.file_type = '1' AND mdf.is_active = '1'
GROUP BY mdf.ma_id
) mdf ON mdf.ma_id = d.ma_id
WHERE
d.is_active = '1' AND d.ma_status='1'
AND d.up_down_status = '1'
@ -360,8 +365,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
d.brand as brand,
d.production_date as productionDate,
d.max_working_hours as workingHours,
sd.leader as person,
sd.phone as personPhone,
sd.leader as person,
sd.phone as personPhone,
d.on_company as companyId,
sd.dept_name as companyName,
c.operate_address as operateAddress,

View File

@ -94,9 +94,7 @@
INSERT INTO ma_dev_info (
<!-- 必选字段若业务要求必须传值可去掉if判断 -->
device_name,
device_count,
item_type_model,
manage_type,
code,
ma_status,
province_id,
@ -118,9 +116,7 @@
)
VALUES (
#{name},
#{count},
#{specificationModel},
#{manageType},
#{code},
'0',
#{province},
@ -258,41 +254,42 @@
<update id="updateDeviceByMaId">
UPDATE ma_dev_info
SET
device_name = #{name},
device_count = #{count},
item_type_model = #{specificationModel},
manage_type = #{manageType},
<!-- 非必填字段:有值才更新 -->
<if test="originalCode != null and originalCode != ''">
identify_code = #{originalCode},
</if>
<if test="typeId != null">
type_id = #{typeId},
</if>
<if test="manufacturerId != null and manufacturerId != ''">
supplier_id = #{manufacturerId},
</if>
<if test="productionDate != null">
production_date = #{productionDate},
</if>
<if test="maxServiceLifeYears != null">
max_working_hours = #{maxServiceLifeYears},
</if>
<if test="expirationTime != null">
expiration_time = #{expirationTime},
</if>
<if test="originalValue != null">
buy_price = #{originalValue},
</if>
<if test="purchaseDate != null">
purchase_date = #{purchaseDate},
</if>
<if test="unit != null">
unit = #{unit}
</if>
<!-- 用 <set> 标签替代直接写 SET 关键字,自动处理逗号问题 -->
<set>
device_name = #{name},
device_count = #{count},
item_type_model = #{specificationModel},
manage_type = #{manageType},
<!-- 非必填字段:有值才更新,前无需加逗号(加了也不影响,<set> 会自动处理) -->
<if test="originalCode != null and originalCode != ''">
identify_code = #{originalCode},
</if>
<if test="typeId != null">
type_id = #{typeId},
</if>
<if test="manufacturerId != null and manufacturerId != ''">
supplier_id = #{manufacturerId},
</if>
<if test="productionDate != null">
production_date = #{productionDate},
</if>
<if test="maxServiceLifeYears != null">
max_working_hours = #{maxServiceLifeYears},
</if>
<if test="expirationTime != null">
expiration_time = #{expirationTime},
</if>
<if test="originalValue != null">
buy_price = #{originalValue},
</if>
<if test="purchaseDate != null">
purchase_date = #{purchaseDate},
</if>
<if test="unit != null">
unit = #{unit} <!-- 最后一个字段可以不加逗号,也可以加,<set> 都会兼容 -->
</if>
</set>
WHERE
<!-- 注意:此处需要替换为实际的主键字段,例如 id -->
ma_id = #{maId}
</update>

View File

@ -147,7 +147,8 @@
</update>
<update id="updateDevStatus">
update ma_dev_info
set ma_status ='5'
set ma_status ='5',
change_status ='5'
where type_id = #{typeId}
and `code` = #{code}
</update>

View File

@ -436,8 +436,8 @@
FROM cs_device_change_details cdcd
LEFT JOIN cs_device_change cdc ON cdc.id = cdcd.change_id
WHERE cdcd.dev_type_id = #{typeId}
AND cdc.review_status in ('1','0','5') AND cdc.type ='3'
and cdcd.del_flag ='0'
AND cdc.review_status in ('1','0','5') AND cdc.type ='3' AND cdc.del_flag = '0'
and cdcd.del_flag ='0'
<if test="devCode!=null and devCode!=&quot;/&quot;">
AND cdcd.dev_code = #{devCode}
</if>

View File

@ -234,7 +234,7 @@
<if test="toolCode != null and toolCode != ''">
AND tl.tool_code LIKE CONCAT('%', #{toolCode}, '%')
</if>
<if test="companyId != null and companyId != 1">
<if test="companyId != null and companyId != 1 ">
<!-- AND (tl.company_id = #{companyId} OR tl.company_id IS NULL)-->
and tl.company_id in (
select dept_id from sys_dept where dept_id= #{companyId}

View File

@ -198,7 +198,7 @@
<if test="subProcess != null and subProcess != ''">
and mtv.childGx like concat('%', #{subProcess}, '%')
</if>
<if test="companyId != null and companyId != 1">
<if test="companyId != null and companyId != 1 ">
and mdi.on_company
in (
select dept_id from sys_dept where dept_id= #{companyId}