pref#_优化量化考核编辑后导致数据Id不一致
This commit is contained in:
+51
-11
@@ -2,9 +2,12 @@ package com.budwk.app.zhgh.dayofficework.ghkh.controller;
|
||||
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.budwk.app.base.param.PageForm;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.zhgh.dayofficework.ghkh.model.Kh_bz;
|
||||
import com.budwk.app.zhgh.dayofficework.ghkh.model.Kh_zb;
|
||||
import com.budwk.app.zhgh.dayofficework.ghkh.model.Kh_zp;
|
||||
import com.budwk.app.zhgh.dayofficework.ghkh.model.kh_nr;
|
||||
import com.budwk.app.zhgh.dayofficework.ghkh.service.KhBzService;
|
||||
import com.budwk.app.zhgh.dayofficework.ghkh.service.KhNrService;
|
||||
@@ -16,13 +19,18 @@ import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.ioc.aop.Aop;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.POST;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
@@ -101,21 +109,53 @@ public class GhkhGhzbController {
|
||||
@SaCheckPermission("ghkh.khzb")
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public Result doEdit(@Param(value = "kh_zb") Kh_zb kh_zb, @Param(value = "type") String type) {
|
||||
khZbService.updateIgnoreNull(kh_zb);
|
||||
// 查出数据库里面的考核内容和标准,找出需要删除的
|
||||
List<kh_nr> nrList = khNrService.query(Cnd.where(kh_nr::getZb_id, "=", kh_zb.getId()));
|
||||
// 查出考核内容(那个傻逼写的,他妈的zb_id都他妈的不存,真的是人才嘞,我踏马还要去根据nrList里面的主键Id去查询)
|
||||
Set<String> nrIdList = nrList.stream().map(kh_nr::getId).collect(Collectors.toSet());
|
||||
List<Kh_bz> bzList = khBzService.query(Cnd.where(Kh_bz::getNr_id, "in", nrIdList));
|
||||
|
||||
List<kh_nr> query = khNrService.query(Cnd.where("zb_id", "=", kh_zb.getId()));
|
||||
// 构建考核内容
|
||||
List<kh_nr> nrs = kh_zb.getNrs().stream().peek(v -> v.setZb_id(kh_zb.getId())).toList();
|
||||
List<String> webNrIdList = nrs.stream().map(kh_nr::getId).toList();
|
||||
|
||||
for (kh_nr kh_nr : query) {
|
||||
System.err.println(kh_nr.getZb_id());
|
||||
khBzService.clear(Cnd.where("nr_id", "=", kh_nr.getId()));
|
||||
}
|
||||
// 构建考核标准
|
||||
List<Kh_bz> bzs = nrs.stream()
|
||||
.map(v -> {
|
||||
return v.getBzs().stream().peek(bz -> {
|
||||
bz.setNr_id(v.getId());
|
||||
bz.setZb_id(kh_zb.getId());
|
||||
}).toList();
|
||||
}).flatMap(List::stream).toList();
|
||||
List<String> webBzIdList = bzs.stream().map(Kh_bz::getId).toList();
|
||||
|
||||
khNrService.clear(Cnd.where("zb_id", "=", kh_zb.getId()));
|
||||
|
||||
for (kh_nr nr : kh_zb.getNrs()) {
|
||||
nr.setZb_id(kh_zb.getId());
|
||||
khNrService.insertWith(nr, "bzs");
|
||||
}
|
||||
// 找不同,找出需要删除的内容和标准
|
||||
List<kh_nr> deleteNrs = nrList.stream().filter(v -> !webNrIdList.contains(v.getId())).toList();
|
||||
List<Kh_bz> deleteBzs = bzList.stream().filter(v -> !webBzIdList.contains(v.getId())).toList();
|
||||
|
||||
// 找出bzs和nrs中Id是null的
|
||||
List<kh_nr> insertNrList = nrs.stream().filter(v -> StrUtil.isBlank(v.getId())).toList();
|
||||
List<Kh_bz> insertBzList = bzs.stream().filter(v -> StrUtil.isBlank(v.getId())).toList();
|
||||
|
||||
// 新增数据
|
||||
khBzService.insert(insertBzList);
|
||||
khNrService.insert(insertNrList);
|
||||
|
||||
// 删除数据
|
||||
if (Lang.isNotEmpty(deleteNrs)) {
|
||||
khNrService.delete(deleteNrs.stream().map(kh_nr::getId).toList());
|
||||
}
|
||||
if (Lang.isNotEmpty(deleteBzs)) {
|
||||
khBzService.delete(deleteBzs.stream().map(Kh_bz::getId).toList());
|
||||
}
|
||||
|
||||
// 修改考核指标
|
||||
khZbService.updateIgnoreNull(kh_zb);
|
||||
// 新增或修改考核内容
|
||||
khNrService.updateIgnoreNull(nrs);
|
||||
// 新增或修改考核标准
|
||||
khBzService.updateIgnoreNull(bzs);
|
||||
return Result.success();
|
||||
|
||||
}
|
||||
|
||||
@@ -309,7 +309,6 @@ layout("/layouts/v4/baseLayout.html"){
|
||||
},
|
||||
methods: {
|
||||
menuSelect(index, indexPath) {
|
||||
debugger
|
||||
try {
|
||||
const app = JSON.parse(window.sessionStorage.getItem("zhgh_sub_app"))
|
||||
window.sessionStorage.setItem("zhgh_sub_app_left_menu_active_index-" + app.id, index)
|
||||
@@ -319,7 +318,6 @@ layout("/layouts/v4/baseLayout.html"){
|
||||
},
|
||||
// 获取菜单
|
||||
getMenus(appId) {
|
||||
debugger
|
||||
if (!appId) return
|
||||
this.$axios.post("/platform/sys/user/subAppMenus", {appId}).then((res) => {
|
||||
if (res.code === 0) {
|
||||
@@ -334,7 +332,6 @@ layout("/layouts/v4/baseLayout.html"){
|
||||
|
||||
// 设置应用信息
|
||||
setAppInfo(app) {
|
||||
debugger
|
||||
if (app) {
|
||||
// 储存到缓存
|
||||
window.sessionStorage.setItem("zhgh_sub_app", JSON.stringify(app))
|
||||
@@ -350,7 +347,6 @@ layout("/layouts/v4/baseLayout.html"){
|
||||
},
|
||||
// 菜单回显
|
||||
echoMenus() {
|
||||
debugger
|
||||
try {
|
||||
const app = JSON.parse(window.sessionStorage.getItem("zhgh_sub_app"))
|
||||
this.activeMenuIndex = window.sessionStorage.getItem("zhgh_sub_app_left_menu_active_index-" + app.id)
|
||||
@@ -371,7 +367,6 @@ layout("/layouts/v4/baseLayout.html"){
|
||||
|
||||
// 地址选中
|
||||
hrefSelect() {
|
||||
debugger
|
||||
function findMenuPath(menus, targetHref) {
|
||||
function search(items, path) {
|
||||
for (const item of items) {
|
||||
@@ -404,7 +399,6 @@ layout("/layouts/v4/baseLayout.html"){
|
||||
|
||||
// 默认选中
|
||||
defaultSelect() {
|
||||
debugger
|
||||
// 查找第一个有href的子菜单
|
||||
function findFirstChildWithHref(menus) {
|
||||
for (const menu of menus) {
|
||||
@@ -430,7 +424,6 @@ layout("/layouts/v4/baseLayout.html"){
|
||||
}
|
||||
|
||||
const result = findFirstChildWithHref(this.menus)
|
||||
debugger
|
||||
if (result) {
|
||||
this.activeMenuIndex = result.menu.id
|
||||
this.openedMenus = result.parentIds
|
||||
@@ -451,7 +444,6 @@ layout("/layouts/v4/baseLayout.html"){
|
||||
},
|
||||
|
||||
init() {
|
||||
debugger
|
||||
// 页面加载时获取到正确的菜单
|
||||
const pathname = window.location.pathname
|
||||
if (!pathname.startsWith("/platform/v4/subApp")) {
|
||||
|
||||
@@ -150,8 +150,8 @@
|
||||
}
|
||||
|
||||
connect() {
|
||||
//const WS_URL = window.location.host + "${base}/websocket"
|
||||
const WS_URL = 'zhgh.jshvc.edu.cn' + "${base}/websocket"
|
||||
const WS_URL = window.location.host + "${base}/websocket"
|
||||
// const WS_URL = 'zhgh.jshvc.edu.cn' + "${base}/websocket"
|
||||
const protocol = window.location.protocol === "http:" ? "ws://" : "wss://"
|
||||
this.ws = new WebSocket(protocol + WS_URL)
|
||||
}
|
||||
|
||||
@@ -47,10 +47,10 @@ layout("/layouts/platform.html"){
|
||||
:width="column.width"
|
||||
header-align="center"
|
||||
show-overflow-tooltip>
|
||||
<template scope="{row}" v-if="column.prop==='startTime'">
|
||||
<template scope="{row}" v-if="column.prop=='startTime'">
|
||||
<span>{{row.startDateTime}} - {{row.endDateTime}}</span>
|
||||
</template>
|
||||
<template scope="{row}" v-else-if="column.prop==='disabled'">
|
||||
<template scope="{row}" v-else-if="column.prop=='disabled'">
|
||||
<el-switch
|
||||
v-model="row.disabled"
|
||||
active-color="#13ce66"
|
||||
|
||||
Reference in New Issue
Block a user