宣城同步宿州的一些改动

ds-xuancheng
luyya 2025-06-11 10:07:38 +08:00
parent b9e405d599
commit 2f1536afd9
6 changed files with 78 additions and 39 deletions

View File

@ -72,6 +72,7 @@ public class TDeviceController extends BaseController {
* device * device
*/ */
@SaCheckPermission("system:device:export") @SaCheckPermission("system:device:export")
@Log(title = "device", businessType = BusinessType.EXPORT) @Log(title = "device", businessType = BusinessType.EXPORT)
@PostMapping("/export") @PostMapping("/export")
public void export(TDeviceBo bo, HttpServletResponse response) { public void export(TDeviceBo bo, HttpServletResponse response) {

View File

@ -40,6 +40,8 @@ public class SysDept extends TenantEntity {
*/ */
private String deptName; private String deptName;
private String shortName;
/** /**
* *
@ -79,4 +81,6 @@ public class SysDept extends TenantEntity {
private String fullName; private String fullName;
private String isVisible;
} }

View File

@ -24,6 +24,7 @@ public class SysDeptBo extends BaseEntity {
/** /**
* id * id
*/ */
@Size(min = 0, max = 12, message = "部门机构代码长度不能超过{max}个字符")
private String deptId; private String deptId;
/** /**
@ -38,6 +39,9 @@ public class SysDeptBo extends BaseEntity {
@Size(min = 0, max = 30, message = "部门名称长度不能超过{max}个字符") @Size(min = 0, max = 30, message = "部门名称长度不能超过{max}个字符")
private String deptName; private String deptName;
@NotBlank(message = "部门简称不能为空")
private String shortName;
/** /**
* *
*/ */
@ -75,4 +79,6 @@ public class SysDeptBo extends BaseEntity {
private String fullName; private String fullName;
private String isVisible;
} }

View File

@ -52,6 +52,8 @@ public class SysDeptVo implements Serializable {
@ExcelProperty(value = "部门名称") @ExcelProperty(value = "部门名称")
private String deptName; private String deptName;
private String shortName;
/** /**
* *
*/ */
@ -93,6 +95,8 @@ public class SysDeptVo implements Serializable {
@ExcelDictFormat(dictType = "sys_normal_disable") @ExcelDictFormat(dictType = "sys_normal_disable")
private String status; private String status;
private String isVisible;
/** /**
* *
*/ */

View File

@ -16,8 +16,10 @@ import org.dromara.common.excel.core.ExcelListener;
import org.dromara.common.excel.core.ExcelResult; import org.dromara.common.excel.core.ExcelResult;
import org.dromara.common.satoken.utils.LoginHelper; import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.system.domain.bo.TDeviceBo; import org.dromara.system.domain.bo.TDeviceBo;
import org.dromara.system.domain.vo.SysDeptVo;
import org.dromara.system.domain.vo.TDeviceImportVo; import org.dromara.system.domain.vo.TDeviceImportVo;
import org.dromara.system.domain.vo.TDeviceVo; import org.dromara.system.domain.vo.TDeviceVo;
import org.dromara.system.service.ISysDeptService;
import org.dromara.system.service.ITDeviceService; import org.dromara.system.service.ITDeviceService;
import java.util.List; import java.util.List;
@ -27,6 +29,8 @@ public class TDeviceImportListener extends AnalysisEventListener<TDeviceImportVo
private final ITDeviceService deviceService; private final ITDeviceService deviceService;
private final ISysDeptService deptService;
private final Boolean isUpdateSupport; private final Boolean isUpdateSupport;
@ -37,15 +41,27 @@ public class TDeviceImportListener extends AnalysisEventListener<TDeviceImportVo
public TDeviceImportListener(Boolean isUpdateSupport) { public TDeviceImportListener(Boolean isUpdateSupport) {
this.deviceService = SpringUtils.getBean(ITDeviceService.class); this.deviceService = SpringUtils.getBean(ITDeviceService.class);
this.deptService = SpringUtils.getBean(ISysDeptService.class);
this.isUpdateSupport = isUpdateSupport; this.isUpdateSupport = isUpdateSupport;
} }
@Override @Override
public void invoke(TDeviceImportVo deviceImportVo, AnalysisContext context) { public void invoke(TDeviceImportVo deviceImportVo, AnalysisContext context) {
TDeviceVo deviceVo = this.deviceService.queryByDeviceCode(deviceImportVo.getDeviceCode());
if (null != deviceImportVo.getDeviceCode() && deviceImportVo.getDeviceCode().contains("设备编码为国标编码")){
failureNum = 1;
failureMsg.append("请删除Excel中提示必须删除的行后重新导入");
}else {
String deviceCode = deviceImportVo.getDeviceCode().replaceAll("[\\p{Zs}\\s]", "");
TDeviceVo deviceVo = this.deviceService.queryByDeviceCode(deviceCode);
try { try {
// 验证是否存在这个设备 // 验证是否存在这个设备
if (ObjectUtil.isNull(deviceVo)) { if (ObjectUtil.isNull(deviceVo)) {
deviceImportVo.setDeviceCode(deviceCode);
SysDeptVo deptVo = deptService.selectDeptById(deviceImportVo.getZzjgdm());
if(null != deptVo){
deviceImportVo.setZzjgmc(deptVo.getShortName());
}
TDeviceBo deviceBo = BeanUtil.toBean(deviceImportVo, TDeviceBo.class); TDeviceBo deviceBo = BeanUtil.toBean(deviceImportVo, TDeviceBo.class);
ValidatorUtils.validate(deviceBo); ValidatorUtils.validate(deviceBo);
deviceService.insertByBo(deviceBo); deviceService.insertByBo(deviceBo);
@ -53,6 +69,10 @@ public class TDeviceImportListener extends AnalysisEventListener<TDeviceImportVo
successMsg.append("<br/>").append(successNum).append("、设备 ").append(deviceBo.getDeviceCode()).append(" 导入成功"); successMsg.append("<br/>").append(successNum).append("、设备 ").append(deviceBo.getDeviceCode()).append(" 导入成功");
} else if (isUpdateSupport) { } else if (isUpdateSupport) {
Long id = deviceVo.getId(); Long id = deviceVo.getId();
SysDeptVo deptVo = deptService.selectDeptById(deviceVo.getZzjgdm());
if(null != deptVo){
deviceVo.setZzjgmc(deptVo.getShortName());
}
TDeviceBo deviceBo = BeanUtil.toBean(deviceVo, TDeviceBo.class); TDeviceBo deviceBo = BeanUtil.toBean(deviceVo, TDeviceBo.class);
deviceBo.setId(id); deviceBo.setId(id);
ValidatorUtils.validate(deviceBo); ValidatorUtils.validate(deviceBo);
@ -75,6 +95,8 @@ public class TDeviceImportListener extends AnalysisEventListener<TDeviceImportVo
} }
} }
}
@Override @Override
public void doAfterAllAnalysed(AnalysisContext context) { public void doAfterAllAnalysed(AnalysisContext context) {

View File

@ -70,7 +70,7 @@
</if> </if>
group by SUBSTRING(zzjgdm,1,8)) a group by SUBSTRING(zzjgdm,1,8)) a
on SUBSTRING(d.dept_id,1,8) = SUBSTRING(a.zzjgdm,1,8) on SUBSTRING(d.dept_id,1,8) = SUBSTRING(a.zzjgdm,1,8)
where `status` = '0' and del_flag =0 and parent_id = '341800000000' and dept_id like '341800%' where `status` = '0' and del_flag =0 and is_visible = '1' and parent_id = '341800000000' and dept_id like '341800%'
union union
@ -92,7 +92,7 @@
</if> </if>
group by SUBSTRING(zzjgdm,1,6)) a group by SUBSTRING(zzjgdm,1,6)) a
on SUBSTRING(d.dept_id,1,6) = SUBSTRING(a.zzjgdm,1,6) on SUBSTRING(d.dept_id,1,6) = SUBSTRING(a.zzjgdm,1,6)
where `status` = '0' and del_flag =0 and parent_id = '341800000000' and dept_id not like '341800%' where `status` = '0' and del_flag =0 and is_visible = '1' and parent_id = '341800000000' and dept_id not like '341800%'
union union
<!--派出所等三级四级机构--> <!--派出所等三级四级机构-->
@ -113,7 +113,7 @@
</if> </if>
group by SUBSTRING(zzjgdm,1,8)) a group by SUBSTRING(zzjgdm,1,8)) a
on SUBSTRING(d.dept_id,1,8) = SUBSTRING(a.zzjgdm,1,8) on SUBSTRING(d.dept_id,1,8) = SUBSTRING(a.zzjgdm,1,8)
where `status` = '0' and del_flag =0 and parent_id != '341800000000' and dept_id not like '341800%' and dept_id like '%0000' where `status` = '0' and del_flag =0 and is_visible = '1' and parent_id != '341800000000' and parent_id != '0' and dept_id like '%0000'
<!--大队等三级四级机构--> <!--大队等三级四级机构-->
UNION UNION
select dept_id as deptId,short_name as deptName,parent_id as parentId,IFNULL(onlineCount,0) as onlineCount,IFNULL(allCount,0) as allCount from sys_dept d select dept_id as deptId,short_name as deptName,parent_id as parentId,IFNULL(onlineCount,0) as onlineCount,IFNULL(allCount,0) as allCount from sys_dept d
@ -133,7 +133,8 @@
</if> </if>
group by SUBSTRING(zzjgdm,1,10)) a group by SUBSTRING(zzjgdm,1,10)) a
on SUBSTRING(d.dept_id,1,10) = SUBSTRING(a.zzjgdm,1,10) on SUBSTRING(d.dept_id,1,10) = SUBSTRING(a.zzjgdm,1,10)
where `status` = '0' and del_flag =0 and parent_id != '341800000000' and parent_id != '0' and dept_id like '341800%' and dept_id like '%00' where `status` = '0' and del_flag =0 and is_visible = '1' and parent_id != '341800000000'
and parent_id != '0' and dept_id not like '%0000' and dept_id like '%00'
union union
<!--四级机构--> <!--四级机构-->
@ -154,7 +155,7 @@
</if> </if>
group by zzjgdm) a group by zzjgdm) a
on d.dept_id = a.zzjgdm on d.dept_id = a.zzjgdm
where `status` = '0' and del_flag =0 and LENGTH(ancestors) = 40 where `status` = '0' and del_flag =0 and is_visible = '1' and dept_id not like '%00' and LENGTH(ancestors) >= 40
) a ) a
order by a.deptId asc order by a.deptId asc
</select> </select>
@ -175,7 +176,7 @@
LEFT JOIN LEFT JOIN
(select substring(zzjgdm,1,8) as zzjgdm ,count(*) as allCount from t_device where device_type = #{deviceType} and valid =1 group by SUBSTRING(zzjgdm,1,8)) a (select substring(zzjgdm,1,8) as zzjgdm ,count(*) as allCount from t_device where device_type = #{deviceType} and valid =1 group by SUBSTRING(zzjgdm,1,8)) a
on SUBSTRING(d.dept_id,1,8) = SUBSTRING(a.zzjgdm,1,8) on SUBSTRING(d.dept_id,1,8) = SUBSTRING(a.zzjgdm,1,8)
where `status` = '0' and del_flag =0 and parent_id = '340100000000' and dept_id like '340100%' where `status` = '0' and del_flag =0 and is_visible = '1' and parent_id = '340100000000' and dept_id like '340100%'
union union
@ -187,7 +188,7 @@
LEFT JOIN LEFT JOIN
(select substring(zzjgdm,1,6) as zzjgdm ,count(*) as allCount from t_device where device_type = #{deviceType} and valid =1 group by SUBSTRING(zzjgdm,1,6)) a (select substring(zzjgdm,1,6) as zzjgdm ,count(*) as allCount from t_device where device_type = #{deviceType} and valid =1 group by SUBSTRING(zzjgdm,1,6)) a
on SUBSTRING(d.dept_id,1,6) = SUBSTRING(a.zzjgdm,1,6) on SUBSTRING(d.dept_id,1,6) = SUBSTRING(a.zzjgdm,1,6)
where `status` = '0' and del_flag =0 and parent_id = '340100000000' and dept_id not like '340100%' where `status` = '0' and del_flag =0 and is_visible = '1' and parent_id = '340100000000' and dept_id not like '340100%'
union union
<!--派出所等三级四级机构--> <!--派出所等三级四级机构-->
@ -198,7 +199,7 @@
LEFT JOIN LEFT JOIN
(select substring(zzjgdm,1,8) as zzjgdm ,count(*) as allCount from t_device where device_type = #{deviceType} and valid = 1 group by SUBSTRING(zzjgdm,1,8)) a (select substring(zzjgdm,1,8) as zzjgdm ,count(*) as allCount from t_device where device_type = #{deviceType} and valid = 1 group by SUBSTRING(zzjgdm,1,8)) a
on SUBSTRING(d.dept_id,1,8) = SUBSTRING(a.zzjgdm,1,8) on SUBSTRING(d.dept_id,1,8) = SUBSTRING(a.zzjgdm,1,8)
where `status` = '0' and del_flag =0 and parent_id != '340100000000' and dept_id not like '340100%' and dept_id like '%0000' where `status` = '0' and del_flag =0 and is_visible = '1' and parent_id != '341800000000' and parent_id != '0' and dept_id like '%0000'
<!--大队等三级四级机构--> <!--大队等三级四级机构-->
UNION UNION
select dept_id as deptId,short_name as deptName,parent_id as parentId,IFNULL(onlineCount,0) as onlineCount,IFNULL(allCount,0) as allCount from sys_dept d select dept_id as deptId,short_name as deptName,parent_id as parentId,IFNULL(onlineCount,0) as onlineCount,IFNULL(allCount,0) as allCount from sys_dept d
@ -208,18 +209,19 @@
LEFT JOIN LEFT JOIN
(select substring(zzjgdm,1,10) as zzjgdm ,count(*) as allCount from t_device where device_type = #{deviceType} and valid = 1 group by SUBSTRING(zzjgdm,1,10)) a (select substring(zzjgdm,1,10) as zzjgdm ,count(*) as allCount from t_device where device_type = #{deviceType} and valid = 1 group by SUBSTRING(zzjgdm,1,10)) a
on SUBSTRING(d.dept_id,1,10) = SUBSTRING(a.zzjgdm,1,10) on SUBSTRING(d.dept_id,1,10) = SUBSTRING(a.zzjgdm,1,10)
where `status` = '0' and del_flag =0 and parent_id != '340100000000' and parent_id != '0' and dept_id like '340100%' and dept_id like '%00' where `status` = '0' and del_flag =0 and is_visible = '1' and parent_id != '341800000000'
and parent_id != '0' and dept_id not like '%0000' and dept_id like '%00'
union union
<!--四级机构--> <!--四级机构-->
select dept_id as deptId,dept_name as deptName,parent_id,IFNULL(onlineCount,0) onlineCount,IFNULL(allCount,0) as allCount from sys_dept d select dept_id as deptId,short_name as deptName,parent_id,IFNULL(onlineCount,0) onlineCount,IFNULL(allCount,0) as allCount from sys_dept d
left JOIN left JOIN
(select zzjgdm ,count(*) as onlineCount from t_device_redis where online =1 and device_type = #{deviceType} group by zzjgdm) o (select zzjgdm ,count(*) as onlineCount from t_device_redis where online =1 and device_type = #{deviceType} group by zzjgdm) o
on d.dept_id = o.zzjgdm on d.dept_id = o.zzjgdm
LEFT JOIN LEFT JOIN
(select zzjgdm as zzjgdm ,count(*) as allCount from t_device where device_type = #{deviceType} and valid = 1 group by zzjgdm) a (select zzjgdm as zzjgdm ,count(*) as allCount from t_device where device_type = #{deviceType} and valid = 1 group by zzjgdm) a
on d.dept_id = a.zzjgdm on d.dept_id = a.zzjgdm
where `status` = '0' and del_flag =0 and LENGTH(ancestors) = 40 where `status` = '0' and del_flag =0 and is_visible = '1' and dept_id not like '%00' and LENGTH(ancestors) >= 40
) count_temp ) count_temp
<where> <where>
<if test="deptId != null and deptId != ''"> <if test="deptId != null and deptId != ''">