1.7问题修改-责任人导入关联修改
This commit is contained in:
parent
7e5d8e1cf0
commit
8ae2f19837
@ -25,14 +25,28 @@ public class PersonReadListener implements ReadListener<ResponsiblePerson> {
|
||||
|
||||
@Override
|
||||
public void invoke(ResponsiblePerson responsiblePerson, AnalysisContext analysisContext) {
|
||||
if (
|
||||
responsiblePerson.getDepartment() == null ||
|
||||
responsiblePerson.getUsername() == null ||
|
||||
responsiblePerson.getUserAccount() == null ||
|
||||
responsiblePerson.getSubsystem() == null
|
||||
) {
|
||||
problems.setFlag(true);
|
||||
problems.getErrors().add("责任人导入失败:" + responsiblePerson.getUsername() + "数据不完整");
|
||||
return;
|
||||
}
|
||||
XdapUserView user = responsiblePersonService
|
||||
.getUserByDeptAndName(responsiblePerson.getDepartment(), responsiblePerson.getPartsName());
|
||||
.getUserByDeptAndName(responsiblePerson.getDepartment(), responsiblePerson.getUserAccount(), responsiblePerson.getUsername());
|
||||
if (user == null || user.getUserId() == null) {
|
||||
problems.setFlag(true);
|
||||
problems.getErrors().add("责任人导入失败:" + responsiblePerson.getPartsName() + "无法找到");
|
||||
problems.getErrors().add("责任人导入失败:用户" + responsiblePerson.getUsername() + "无法找到");
|
||||
} else if (user.getDepartmentId() == null) {
|
||||
problems.setFlag(true);
|
||||
problems.getErrors().add("责任人导入失败:部门" + responsiblePerson.getUsername() + "无法找到");
|
||||
} else {
|
||||
responsiblePerson.setUserId(user.getUserId());
|
||||
responsiblePerson.setDepartmentId(user.getDepartmentId());
|
||||
responsiblePerson.setPersonLevel(1);
|
||||
responsiblePerson.setCreationDate(Timestamp.valueOf(LocalDateTime.now()));
|
||||
cachedDataList.add(responsiblePerson);
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ import java.sql.Timestamp;
|
||||
@Table("yfsjglpt_model_responsible_person")
|
||||
@SQLQuery(value = {
|
||||
@SQL(view = "getResponsibleAndName",
|
||||
sql = "SELECT ymrp.*, xu.username FROM yfsjglpt_model_responsible_person ymrp JOIN xdap_users xu ON ymrp.user_id = xu.id where ymrp.person_level = #level order by creation_date desc")
|
||||
sql = "SELECT ymrp.*, xu.username, xu.user_number as userAccount FROM yfsjglpt_model_responsible_person ymrp JOIN xdap_users xu ON ymrp.user_id = xu.id where ymrp.person_level = #level order by creation_date desc")
|
||||
})
|
||||
public class ResponsiblePerson extends MpaasBasePojo {
|
||||
@RowID(sequence = "responsible_person_s", type = RowIDType.UUID)
|
||||
@ -24,7 +24,7 @@ public class ResponsiblePerson extends MpaasBasePojo {
|
||||
private String department;
|
||||
@ExcelProperty("子系统")
|
||||
private String subsystem;
|
||||
private String partsName;
|
||||
// private String partsName;
|
||||
private Integer personLevel;
|
||||
|
||||
private Timestamp creationDate;
|
||||
|
||||
@ -6,7 +6,7 @@ import lombok.Data;
|
||||
|
||||
@SQLQuery(value = {
|
||||
@SQL(view = "getUserByDeptAndName",
|
||||
sql = "SELECT xu.id AS userId, xd.id AS departmentId FROM xdap_users xu LEFT JOIN xdap_dept_users xdu ON xu.id = xdu.user_id LEFT JOIN xdap_departments xd ON xdu.department_id = xd.id WHERE xu.username = #username AND xd.structure_name = #department")
|
||||
sql = "SELECT xu.id AS userId, xd.id AS departmentId FROM xdap_users xu LEFT JOIN xdap_dept_users xdu ON xu.id = xdu.user_id LEFT JOIN xdap_departments xd ON xdu.department_id = xd.id WHERE xu.username = #username AND xd.structure_name = #department AND xu.user_number = #account")
|
||||
})
|
||||
@Data
|
||||
public class XdapUserView {
|
||||
|
||||
@ -41,7 +41,8 @@ public interface ResponsiblePersonService {
|
||||
|
||||
MyResponse importPerson(MultipartFile file, String userId);
|
||||
|
||||
XdapUserView getUserByDeptAndName(@NotBlank String dept, @NotBlank String name);
|
||||
|
||||
void importAllPerson(List<ResponsiblePerson> cachedDataList, MyResponse problems);
|
||||
|
||||
XdapUserView getUserByDeptAndName(String department, String userAccount, String username);
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package com.xdap.self_development.service.impl;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
|
||||
import com.definesys.mpaas.query.db.PageQueryResult;
|
||||
import com.xdap.api.moudle.department.pojo.entity.XdapDepartments;
|
||||
import com.xdap.api.moudle.user.pojo.XdapUsers;
|
||||
import com.xdap.runtime.service.RuntimeDatasourceService;
|
||||
import com.xdap.self_development.common.MyResponse;
|
||||
@ -25,7 +26,6 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
@ -60,7 +60,6 @@ public class ResponsiblePersonServiceImpl implements ResponsiblePersonService {
|
||||
responsiblePerson.setUserId(form.getUserId());
|
||||
responsiblePerson.setSubsystem(form.getSubsystem());
|
||||
responsiblePerson.setPersonLevel(1);
|
||||
responsiblePerson.setCreationDate(Timestamp.valueOf(LocalDateTime.now()));
|
||||
bd.getBusinessDatabase().doInsert(responsiblePerson);
|
||||
}
|
||||
|
||||
@ -80,7 +79,7 @@ public class ResponsiblePersonServiceImpl implements ResponsiblePersonService {
|
||||
responsiblePerson.setDepartmentId(form.getDepartmentId());
|
||||
responsiblePerson.setUserId(form.getUserId());
|
||||
responsiblePerson.setSubsystem(form.getSubsystem());
|
||||
responsiblePerson.setPartsName(form.getPartsName());
|
||||
// responsiblePerson.setPartsName(form.getPartsName());
|
||||
responsiblePerson.setPersonLevel(2);
|
||||
bd.getBusinessDatabase().doInsert(responsiblePerson);
|
||||
}
|
||||
@ -93,7 +92,6 @@ public class ResponsiblePersonServiceImpl implements ResponsiblePersonService {
|
||||
.update("user_id", form.getUserId())
|
||||
.update("department", form.getDepartment())
|
||||
.update("subsystem", form.getSubsystem())
|
||||
.update("creation_date", Timestamp.valueOf(LocalDateTime.now()))
|
||||
.doUpdate(ResponsiblePerson.class);
|
||||
}
|
||||
|
||||
@ -120,7 +118,8 @@ public class ResponsiblePersonServiceImpl implements ResponsiblePersonService {
|
||||
public PageQueryResult<ResponsiblePerson> getDeptResponsible(DeptResponsiblePageForm form) {
|
||||
|
||||
return bd.getBusinessDatabase()
|
||||
.viewQueryMode(true).view("getResponsibleAndName")
|
||||
.viewQueryMode(true)
|
||||
.view("getResponsibleAndName")
|
||||
.setVar("level", 1)
|
||||
.doPageQuery(form.getPageNumber(), form.getPageSize(), ResponsiblePerson.class);
|
||||
}
|
||||
@ -187,9 +186,9 @@ public class ResponsiblePersonServiceImpl implements ResponsiblePersonService {
|
||||
response.setDateHeader("Expires", 0);
|
||||
|
||||
List<ResponsiblePerson> list = bd.getBusinessDatabase()
|
||||
.viewQueryMode(true).view("getResponsibleAndName")
|
||||
.viewQueryMode(true)
|
||||
.view("getResponsibleAndName")
|
||||
.setVar("level", 1)
|
||||
.orderBy("creation_date", "desc")
|
||||
.doQuery(ResponsiblePerson.class);
|
||||
|
||||
EasyExcel.write(response.getOutputStream(), ResponsiblePerson.class)
|
||||
@ -247,7 +246,7 @@ public class ResponsiblePersonServiceImpl implements ResponsiblePersonService {
|
||||
try (InputStream inputStream = file.getInputStream()) {
|
||||
EasyExcel.read(
|
||||
inputStream,
|
||||
Parameter.class,
|
||||
ResponsiblePerson.class,
|
||||
new PersonReadListener(this, problems)
|
||||
).doReadAll();
|
||||
|
||||
@ -259,14 +258,20 @@ public class ResponsiblePersonServiceImpl implements ResponsiblePersonService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public XdapUserView getUserByDeptAndName(String dept, String name) {
|
||||
return bd.getBusinessDatabase()
|
||||
.viewQueryMode(true)
|
||||
.view("getResponsibleAndName")
|
||||
.setVar("department", dept)
|
||||
.setVar("username", name)
|
||||
.doQueryFirst(XdapUserView.class);
|
||||
|
||||
public XdapUserView getUserByDeptAndName(String department, String userAccount, String username) {
|
||||
XdapUserView xdapUserView = new XdapUserView();
|
||||
xdapUserView.setDepartmentId(
|
||||
bd.getBusinessDatabase()
|
||||
.eq("structure_name", department)
|
||||
.doQueryFirst(XdapDepartments.class).getId()
|
||||
);
|
||||
xdapUserView.setUserId(
|
||||
bd.getBusinessDatabase()
|
||||
.eq("user_number", userAccount)
|
||||
.eq("username", username)
|
||||
.doQueryFirst(XdapUsers.class).getId()
|
||||
);
|
||||
return xdapUserView;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -280,7 +285,7 @@ public class ResponsiblePersonServiceImpl implements ResponsiblePersonService {
|
||||
.doQuery(ResponsiblePerson.class);
|
||||
|
||||
if (!responsiblePeople.isEmpty()) {
|
||||
problems.setFlag(false);
|
||||
problems.setFlag(true);
|
||||
problems.getErrors().add("部门:" + item.getDepartment() + "子系统:" + item.getSubsystem() + "已存在责任人");
|
||||
} else {
|
||||
bd.getBusinessDatabase().doInsert(item);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user