|
@@ -27,6 +27,7 @@ import com.diagbot.exception.CommonErrorCode;
|
|
|
import com.diagbot.exception.CommonException;
|
|
|
import com.diagbot.service.impl.VersionDetailServiceImpl;
|
|
|
import com.diagbot.service.impl.VersionInfoServiceImpl;
|
|
|
+import com.diagbot.util.BeanUtil;
|
|
|
import com.diagbot.util.DateUtil;
|
|
|
import com.diagbot.util.EntityUtil;
|
|
|
import com.diagbot.util.ListUtil;
|
|
@@ -58,28 +59,19 @@ public class VersionInfoFacade extends VersionInfoServiceImpl {
|
|
|
* @return
|
|
|
*/
|
|
|
public List<VersionWrapperDTO> getVersionInfoAll(Page page, String name) {
|
|
|
- // 查询最新的一条版本信息
|
|
|
+ // 模糊查询最新的一条版本信息
|
|
|
QueryWrapper<VersionInfo> versionInfoQuery = new QueryWrapper<>();
|
|
|
versionInfoQuery.eq("is_deleted", IsDeleteEnum.N.getKey()).eq("STATUS", StatusEnum.Enable.getKey())
|
|
|
.like("name", name).orderByDesc("refresh_time");
|
|
|
|
|
|
- // List<VersionInfo> versionInfos =list(versionInfoQuery);//
|
|
|
- // getOne(versionInfoQuery);
|
|
|
+ // 分页查询
|
|
|
IPage<VersionInfo> queryUserInformation = page(page, versionInfoQuery);
|
|
|
-
|
|
|
List<VersionInfo> versionInfos = queryUserInformation.getRecords();
|
|
|
-
|
|
|
List<VersionWrapperDTO> versionLists = new ArrayList<VersionWrapperDTO>();
|
|
|
- /*
|
|
|
- * List<String> modifierid =
|
|
|
- * versionInfos.stream().map(ac->ac.getModifier()).collect(Collectors.
|
|
|
- * toList()); RespDTO<Map<String, String>> userNamesDTO =
|
|
|
- * userServiceClient.getUserInfoByIds(modifierid); Map<String, String>
|
|
|
- * userNames = userNamesDTO.data;
|
|
|
- */
|
|
|
+ // 取出操作人id
|
|
|
List<String> modifierid = new ArrayList<>();
|
|
|
modifierid = versionInfos.stream().map(ac -> ac.getModifier()).collect(Collectors.toList());
|
|
|
-
|
|
|
+ // 根据操作人的id获取操作人信息
|
|
|
Map<String, String> userNames = new HashMap<>();
|
|
|
if (modifierid.size() > 0) {
|
|
|
RespDTO<Map<String, String>> userNamesDTO = userServiceClient.getUserInfoByIds(modifierid);
|
|
@@ -88,10 +80,8 @@ public class VersionInfoFacade extends VersionInfoServiceImpl {
|
|
|
}
|
|
|
userNames = userNamesDTO.data;
|
|
|
}
|
|
|
-
|
|
|
// 当查出的数据不为空时,取到版本id,再去版本明细表中查询详细的信息
|
|
|
- // System.out.println(detail.toString());
|
|
|
- for (VersionInfo versionInfo : versionInfos) {
|
|
|
+ /*for (VersionInfo versionInfo : versionInfos) {
|
|
|
VersionWrapperDTO versionList = new VersionWrapperDTO();
|
|
|
versionList.setId(versionInfo.getId());
|
|
|
versionList.setName(versionInfo.getName());
|
|
@@ -99,15 +89,16 @@ public class VersionInfoFacade extends VersionInfoServiceImpl {
|
|
|
versionList.setRefreshTime(versionInfo.getRefreshTime());
|
|
|
versionList.setStatus(versionInfo.getStatus());
|
|
|
versionLists.add(versionList);
|
|
|
- }
|
|
|
-
|
|
|
+ }*/
|
|
|
+ versionLists = BeanUtil.listCopyTo(versionInfos, VersionWrapperDTO.class);
|
|
|
+ // 取版本id查明细
|
|
|
List<Long> ids = new ArrayList<>();
|
|
|
if (versionInfos != null) {
|
|
|
// 当查出的数据不为空时,取到版本id,再去版本明细表中查询详细的信息
|
|
|
for (VersionInfo versionInfo : versionInfos) {
|
|
|
ids.add(versionInfo.getId());
|
|
|
}
|
|
|
-
|
|
|
+ // 获取明细信息
|
|
|
List<VersionDetailDTO> details = versionDetailFacade.getByIds(ids);
|
|
|
Map<Long, List<VersionDetailDTO>> map = new HashMap<>();
|
|
|
// 获取所有用户开通的产品信息
|
|
@@ -125,6 +116,12 @@ public class VersionInfoFacade extends VersionInfoServiceImpl {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 保存版本信息
|
|
|
+ *
|
|
|
+ * @param versionInfoVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public boolean saveVersionInfoAll(VersionInfoVO versionInfoVO) {
|
|
|
// 1.判断该版本号是否存在名字相同的数据
|
|
|
QueryWrapper<VersionInfo> templateInfoFand = new QueryWrapper<>();
|
|
@@ -134,7 +131,7 @@ public class VersionInfoFacade extends VersionInfoServiceImpl {
|
|
|
throw new CommonException(CommonErrorCode.NOT_EXISTS, "该版本号已存在");
|
|
|
}
|
|
|
|
|
|
- //增加版本数据
|
|
|
+ // 增加版本数据
|
|
|
VersionInfo versionInfo = new VersionInfo();
|
|
|
versionInfo.setCreator(UserUtils.getCurrentPrincipleID());
|
|
|
versionInfo.setGmtCreate(DateUtil.now());
|
|
@@ -146,10 +143,10 @@ public class VersionInfoFacade extends VersionInfoServiceImpl {
|
|
|
versionInfo.setRefreshTime(sdf.parse(versionInfoVO.getRefreshTime()));
|
|
|
} catch (ParseException e) {
|
|
|
throw new CommonException(CommonErrorCode.NOT_EXISTS, "时间格式有误");
|
|
|
- // e.printStackTrace();
|
|
|
}
|
|
|
versionInfo.setStatus(String.valueOf(StatusEnum.Enable.getKey()));
|
|
|
versionInfo.setRemark(versionInfoVO.getRemark());
|
|
|
+ // 优先保存版本号,成功后再保存明细信息
|
|
|
boolean res = save(versionInfo);
|
|
|
if (res) {
|
|
|
List<VersionDetail> dataNew = new ArrayList<VersionDetail>();
|
|
@@ -165,8 +162,6 @@ public class VersionInfoFacade extends VersionInfoServiceImpl {
|
|
|
versionDetail.setOrderNo(data.getOrderNo());
|
|
|
versionDetail.setTitle(data.getTitle());
|
|
|
versionDetail.setVersionId(versionInfo.getId());
|
|
|
- // System.out.println("========versionInfo.getId()======" +
|
|
|
- // versionInfo.getId());
|
|
|
versionDetail.setRemark(data.getRemark());
|
|
|
versionDetail.setStatus(String.valueOf(StatusEnum.Enable.getKey()));
|
|
|
dataNew.add(versionDetail);
|
|
@@ -174,13 +169,12 @@ public class VersionInfoFacade extends VersionInfoServiceImpl {
|
|
|
|
|
|
res = versionDetailServiceImpl.saveBatch(dataNew);
|
|
|
}
|
|
|
-
|
|
|
- // System.out.println(res);
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 更新
|
|
|
*
|
|
|
* @param versionInfoVO
|
|
|
* @return
|
|
@@ -193,6 +187,13 @@ public class VersionInfoFacade extends VersionInfoServiceImpl {
|
|
|
if (data == null) {
|
|
|
throw new CommonException(CommonErrorCode.NOT_EXISTS, "该数据不存在");
|
|
|
}
|
|
|
+ // 2.判断该版本号是否存在名字相同的数据
|
|
|
+ QueryWrapper<VersionInfo> templateInfoFand = new QueryWrapper<>();
|
|
|
+ templateInfoFand.eq("name", versionInfoVO.getName()).eq("is_deleted", IsDeleteEnum.N.getKey());
|
|
|
+ VersionInfo dataInfo = getOne(templateInfoFand);
|
|
|
+ if (dataInfo != null) {
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "该版本号已存在");
|
|
|
+ }
|
|
|
// 3.修改版本信息
|
|
|
VersionInfo versionInfo = new VersionInfo();
|
|
|
versionInfo.setId(versionInfoVO.getId());// 模板id
|
|
@@ -206,7 +207,6 @@ public class VersionInfoFacade extends VersionInfoServiceImpl {
|
|
|
// e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
versionInfo.setStatus(String.valueOf(StatusEnum.Enable.getKey()));
|
|
|
versionInfo.setRemark(versionInfoVO.getRemark());
|
|
|
versionInfo.setGmtModified(DateUtil.now());// 修改时间
|