diff --git a/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/controller/admin/templtp/TmplInscDatBsnController.java b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/controller/admin/templtp/TmplInscDatBsnController.java index 4233611b..1978e51d 100644 --- a/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/controller/admin/templtp/TmplInscDatBsnController.java +++ b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/controller/admin/templtp/TmplInscDatBsnController.java @@ -1,5 +1,6 @@ package com.zt.plat.module.base.controller.admin.templtp; +import cn.hutool.core.collection.CollUtil; import com.zt.plat.module.base.dal.dataobject.tmpltp.TmplInscDatBsnDO; import com.zt.plat.module.base.service.tmpltp.TmplInscDatBsnService; import org.springframework.web.bind.annotation.*; @@ -82,7 +83,9 @@ public class TmplInscDatBsnController implements BusinessControllerMarker { @PreAuthorize("@ss.hasPermission('base:tmpl-insc-dat-bsn:query')") public CommonResult getTmplInscDatBsn(@RequestParam("id") String id) { TmplInscDatBsnDO tmplInscDatBsn = tmplInscDatBsnService.getTmplInscDatBsn(id); - return success(BeanUtils.toBean(tmplInscDatBsn, TmplInscDatBsnRespVO.class)); + TmplInscDatBsnRespVO tmplInscDatBsnRespVO = BeanUtils.toBean(tmplInscDatBsn, TmplInscDatBsnRespVO.class); + tmplInscDatBsnRespVO.setFldVal(CollUtil.toList(tmplInscDatBsn.getFldVal().split(","))); + return success(tmplInscDatBsnRespVO); } @GetMapping("/page") diff --git a/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/controller/admin/templtp/vo/TmplInscDatBsnRespVO.java b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/controller/admin/templtp/vo/TmplInscDatBsnRespVO.java index d4687c71..de94d76c 100644 --- a/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/controller/admin/templtp/vo/TmplInscDatBsnRespVO.java +++ b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/controller/admin/templtp/vo/TmplInscDatBsnRespVO.java @@ -26,12 +26,12 @@ public class TmplInscDatBsnRespVO { @Schema(description = "用户填写的值") @ExcelProperty("用户填写的值") - private String fldVal; + private List fldVal; @Schema(description = "字段标识") @ExcelProperty("字段标识") - private String fldKy; + private List fldKy; diff --git a/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/controller/admin/templtp/vo/TmplInscDatBsnSaveReqVO.java b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/controller/admin/templtp/vo/TmplInscDatBsnSaveReqVO.java index 854e548a..5ea6df07 100644 --- a/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/controller/admin/templtp/vo/TmplInscDatBsnSaveReqVO.java +++ b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/controller/admin/templtp/vo/TmplInscDatBsnSaveReqVO.java @@ -1,5 +1,6 @@ package com.zt.plat.module.base.controller.admin.templtp.vo; +import com.alibaba.fastjson2.JSONArray; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import java.util.*; diff --git a/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/dal/mysql/tmpltp/TmplInscDatBsnMapper.java b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/dal/mysql/tmpltp/TmplInscDatBsnMapper.java index 33a63896..2d0b7c50 100644 --- a/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/dal/mysql/tmpltp/TmplInscDatBsnMapper.java +++ b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/dal/mysql/tmpltp/TmplInscDatBsnMapper.java @@ -1,14 +1,15 @@ package com.zt.plat.module.base.dal.mysql.tmpltp; -import java.util.*; - import com.zt.plat.framework.common.pojo.PageResult; -import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX; import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX; - +import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX; +import com.zt.plat.module.base.controller.admin.templtp.vo.TmplInscDatBsnPageReqVO; import com.zt.plat.module.base.dal.dataobject.tmpltp.TmplInscDatBsnDO; +import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Mapper; -import com.zt.plat.module.base.controller.admin.templtp.vo.*; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 业务实例字段值 Mapper @@ -26,5 +27,15 @@ public interface TmplInscDatBsnMapper extends BaseMapperX { .betweenIfPresent(TmplInscDatBsnDO::getCreateTime, reqVO.getCreateTime()) .orderByDesc(TmplInscDatBsnDO::getId)); } - + //物理删除 + @Delete({ + "" + }) + int physicalDeleteByBsnIds(@Param("ids") List ids); } diff --git a/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/dal/mysql/tmpltp/TmplInscItmBsnMapper.java b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/dal/mysql/tmpltp/TmplInscItmBsnMapper.java index 9b71b950..96ee2c8d 100644 --- a/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/dal/mysql/tmpltp/TmplInscItmBsnMapper.java +++ b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/dal/mysql/tmpltp/TmplInscItmBsnMapper.java @@ -6,8 +6,10 @@ import com.zt.plat.framework.common.pojo.PageResult; import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX; import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX; import com.zt.plat.module.base.dal.dataobject.tmpltp.TmplInscItmBsnDO; +import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Mapper; import com.zt.plat.module.base.controller.admin.templtp.vo.*; +import org.apache.ibatis.annotations.Param; /** * 业务实例条款值 Mapper @@ -26,4 +28,14 @@ public interface TmplInscItmBsnMapper extends BaseMapperX { .orderByDesc(TmplInscItmBsnDO::getId)); } + @Delete({ + "" + }) + int physicalDeleteByBsnIds(@Param("ids") List ids); } diff --git a/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/service/tmpltp/TmplInscBsnRelServiceImpl.java b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/service/tmpltp/TmplInscBsnRelServiceImpl.java index 296bdcd0..e0029fd0 100644 --- a/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/service/tmpltp/TmplInscBsnRelServiceImpl.java +++ b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/service/tmpltp/TmplInscBsnRelServiceImpl.java @@ -69,7 +69,7 @@ public class TmplInscBsnRelServiceImpl implements TmplInscBsnRelService { TmplInscBsnRelDO tmplInscBsnRel = BeanUtils.toBean(createReqVO, TmplInscBsnRelDO.class); tmplInscBsnRel.setRelativityId(createReqVO.getBsnId()); // tmplInscBsnRel.setBsnId(Long.valueOf(createReqVO.getUuid())); - tmplInscBsnRelMapper.insert(tmplInscBsnRel); + tmplInscBsnRelMapper.insertOrUpdate(tmplInscBsnRel); // 返回 return BeanUtils.toBean(tmplInscBsnRel, TmplInscBsnRelRespVO.class); } @@ -302,48 +302,49 @@ public class TmplInscBsnRelServiceImpl implements TmplInscBsnRelService { @Override public Map valueInfo(String cttId, String inscId) { - // 1、通过实例和合同Id获取业务 - TmplInscBsnRelDO tmplInscBsnRelDO = tmplInscBsnRelMapper.selectOne( - TmplInscBsnRelDO::getRelativityId, cttId, - TmplInscBsnRelDO::getInscId, inscId - ); - if (tmplInscBsnRelDO == null) { - throw exception(TMPL_INSC_BSN_REL_NOT_EXISTS); - } +// // 1、通过实例和合同Id获取业务 +// TmplInscBsnRelDO tmplInscBsnRelDO = tmplInscBsnRelMapper.selectOne( +// TmplInscBsnRelDO::getRelativityId, cttId, +// TmplInscBsnRelDO::getInscId, inscId +// ); +// if (tmplInscBsnRelDO == null) { +// throw exception(TMPL_INSC_BSN_REL_NOT_EXISTS); +// } +// +// List valueInfoS = new ArrayList<>(); +// // 2、获取绑定的字段 +// List tmplInscDatBsnList = tmplInscDatBsnService +// .getTmplInscDatBsnListByBsnId(String.valueOf(tmplInscBsnRelDO.getRelativityId())); +// +// +// Optional.ofNullable(tmplInscDatBsnList) +// .ifPresent(list -> list.forEach(tmplInscDatBsnRespVO -> { +// ValueInfo valueInfo = new ValueInfo( +// tmplInscDatBsnRespVO.getId(), +// tmplInscDatBsnRespVO.getFldKy(), +// tmplInscDatBsnRespVO.getFldVal(), +// "field", +// tmplInscDatBsnRespVO.getInscFldId() +// ); +// valueInfoS.add(valueInfo); +// })); +// +// // 3、获取条款 +// List tmplInscItmBsnList = tmplInscItmBsnService.getTmplInscItmBsnList(String.valueOf(tmplInscBsnRelDO.getRelativityId())); +// Optional.ofNullable(tmplInscItmBsnList) +// .ifPresent(list -> list.forEach(tmplInscItmBsnRespVO -> { +// ValueInfo valueInfo = new ValueInfo( +// tmplInscItmBsnRespVO.getId(), +// tmplInscItmBsnRespVO.getItmName(), +// tmplInscItmBsnRespVO.getVal(), +// "item", +// tmplInscItmBsnRespVO.getItmId() +// ); +// valueInfoS.add(valueInfo); +// })); - List valueInfoS = new ArrayList<>(); - // 2、获取绑定的字段 - List tmplInscDatBsnList = tmplInscDatBsnService - .getTmplInscDatBsnListByBsnId(String.valueOf(tmplInscBsnRelDO.getRelativityId())); - - - Optional.ofNullable(tmplInscDatBsnList) - .ifPresent(list -> list.forEach(tmplInscDatBsnRespVO -> { - ValueInfo valueInfo = new ValueInfo( - tmplInscDatBsnRespVO.getId(), - tmplInscDatBsnRespVO.getFldKy(), - tmplInscDatBsnRespVO.getFldVal(), - "field", - tmplInscDatBsnRespVO.getInscFldId() - ); - valueInfoS.add(valueInfo); - })); - - // 3、获取条款 - List tmplInscItmBsnList = tmplInscItmBsnService.getTmplInscItmBsnList(String.valueOf(tmplInscBsnRelDO.getRelativityId())); - Optional.ofNullable(tmplInscItmBsnList) - .ifPresent(list -> list.forEach(tmplInscItmBsnRespVO -> { - ValueInfo valueInfo = new ValueInfo( - tmplInscItmBsnRespVO.getId(), - tmplInscItmBsnRespVO.getItmName(), - tmplInscItmBsnRespVO.getVal(), - "item", - tmplInscItmBsnRespVO.getItmId() - ); - valueInfoS.add(valueInfo); - })); - - return Map.of("data", valueInfoS, "id", tmplInscBsnRelDO.getId()); + // return Map.of("data", valueInfoS, "id", tmplInscBsnRelDO.getId()); + return null; } @Override @@ -369,31 +370,31 @@ public class TmplInscBsnRelServiceImpl implements TmplInscBsnRelService { .getTmplInscDatBsnListByBsnId(String.valueOf(tmplInscBsnRelDO.getRelativityId())); - Optional.ofNullable(tmplInscDatBsnList) - .ifPresent(list -> list.forEach(tmplInscDatBsnRespVO -> { - ValueInfo valueInfo = new ValueInfo( - tmplInscDatBsnRespVO.getId(), - tmplInscDatBsnRespVO.getFldKy(), - tmplInscDatBsnRespVO.getFldVal(), - "field", - tmplInscDatBsnRespVO.getInscFldId() - ); - valueInfoS.add(valueInfo); - })); +// Optional.ofNullable(tmplInscDatBsnList) +// .ifPresent(list -> list.forEach(tmplInscDatBsnRespVO -> { +// ValueInfo valueInfo = new ValueInfo( +// tmplInscDatBsnRespVO.getId(), +// tmplInscDatBsnRespVO.getFldKy(), +// tmplInscDatBsnRespVO.getFldVal(), +// "field", +// tmplInscDatBsnRespVO.getInscFldId() +// ); +// valueInfoS.add(valueInfo); +// })); // 3、获取条款 List tmplInscItmBsnList = tmplInscItmBsnService.getTmplInscItmBsnList(String.valueOf(tmplInscBsnRelDO.getRelativityId())); - Optional.ofNullable(tmplInscItmBsnList) - .ifPresent(list -> list.forEach(tmplInscItmBsnRespVO -> { - ValueInfo valueInfo = new ValueInfo( - tmplInscItmBsnRespVO.getId(), - tmplInscItmBsnRespVO.getItmName(), - tmplInscItmBsnRespVO.getVal(), - "item", - tmplInscItmBsnRespVO.getItmId() - ); - valueInfoS.add(valueInfo); - })); +// Optional.ofNullable(tmplInscItmBsnList) +// .ifPresent(list -> list.forEach(tmplInscItmBsnRespVO -> { +// ValueInfo valueInfo = new ValueInfo( +// tmplInscItmBsnRespVO.getId(), +// tmplInscItmBsnRespVO.getItmName(), +// tmplInscItmBsnRespVO.getVal(), +// "item", +// tmplInscItmBsnRespVO.getItmId() +// ); +// valueInfoS.add(valueInfo); +// })); return Map.of("data", valueInfoS, "id", tmplInscBsnRelDO.getId()); } diff --git a/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/service/tmpltp/TmplInscDatBsnServiceImpl.java b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/service/tmpltp/TmplInscDatBsnServiceImpl.java index b1e33568..599b8654 100644 --- a/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/service/tmpltp/TmplInscDatBsnServiceImpl.java +++ b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/service/tmpltp/TmplInscDatBsnServiceImpl.java @@ -1,29 +1,24 @@ package com.zt.plat.module.base.service.tmpltp; import cn.hutool.core.collection.CollUtil; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import com.zt.plat.framework.tenant.core.aop.CompanyVisitIgnore; +import com.zt.plat.framework.common.pojo.PageResult; +import com.zt.plat.framework.common.util.object.BeanUtils; import com.zt.plat.framework.tenant.core.aop.TenantIgnore; +import com.zt.plat.module.base.controller.admin.templtp.vo.TmplInscDatBsnPageReqVO; +import com.zt.plat.module.base.controller.admin.templtp.vo.TmplInscDatBsnRespVO; +import com.zt.plat.module.base.controller.admin.templtp.vo.TmplInscDatBsnSaveReqVO; import com.zt.plat.module.base.dal.dataobject.tmpltp.TmplInscDatBsnDO; import com.zt.plat.module.base.dal.mysql.tmpltp.TmplInscDatBsnMapper; -import org.springframework.stereotype.Service; import jakarta.annotation.Resource; +import jodd.util.ArraysUtil; +import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; -import org.springframework.transaction.annotation.Transactional; - -import java.util.*; -import com.zt.plat.module.base.controller.admin.templtp.vo.*; - -import com.zt.plat.framework.common.pojo.PageResult; -import com.zt.plat.framework.common.pojo.PageParam; -import com.zt.plat.framework.common.util.object.BeanUtils; +import java.util.Arrays; +import java.util.List; import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception; -import static com.zt.plat.framework.common.util.collection.CollectionUtils.convertList; -import static com.zt.plat.framework.common.util.collection.CollectionUtils.diffList; -import static com.zt.plat.module.base.enums.ErrorCodeConstants.*; import static com.zt.plat.module.tmpltp.enums.ErrorCodeConstants.TMPL_INSC_DAT_BSN_EXISTS; import static com.zt.plat.module.tmpltp.enums.ErrorCodeConstants.TMPL_INSC_DAT_BSN_NOT_EXISTS; @@ -44,10 +39,13 @@ public class TmplInscDatBsnServiceImpl implements TmplInscDatBsnService { //判断存在 validateTmplInscDatBsnExistsByKey(createReqVO); // 插入 + createReqVO.setFldVal(null);// 兼容前端传入数组或者字符串 TmplInscDatBsnDO tmplInscDatBsn = BeanUtils.toBean(createReqVO, TmplInscDatBsnDO.class); tmplInscDatBsnMapper.insert(tmplInscDatBsn); // 返回 - return BeanUtils.toBean(tmplInscDatBsn, TmplInscDatBsnRespVO.class); + TmplInscDatBsnRespVO tmplInscDatBsnRespVO = BeanUtils.toBean(tmplInscDatBsn, TmplInscDatBsnRespVO.class); + tmplInscDatBsnRespVO.setFldVal(CollUtil.toList(tmplInscDatBsn.getFldVal().split(","))); + return tmplInscDatBsnRespVO; } private void validateTmplInscDatBsnExistsByKey(TmplInscDatBsnSaveReqVO createReqVO) { List tmplInscDatBsnDOS = tmplInscDatBsnMapper.selectList(TmplInscDatBsnDO::getInscFldId, createReqVO.getInscFldId(),TmplInscDatBsnDO::getBsnId, createReqVO.getBsnId()); @@ -59,10 +57,13 @@ public class TmplInscDatBsnServiceImpl implements TmplInscDatBsnService { @Override public void updateTmplInscDatBsn(TmplInscDatBsnSaveReqVO updateReqVO) { // 校验存在 - validateTmplInscDatBsnExists(updateReqVO.getId()); - // 更新 - TmplInscDatBsnDO updateObj = BeanUtils.toBean(updateReqVO, TmplInscDatBsnDO.class); - tmplInscDatBsnMapper.updateById(updateObj); + // validateTmplInscDatBsnExists(updateReqVO.getId()); + // 物理删除旧记录 + tmplInscDatBsnMapper.physicalDeleteByBsnIds(List.of(updateReqVO.getBsnId())); + + TmplInscDatBsnDO saveObj = BeanUtils.toBean(updateReqVO, TmplInscDatBsnDO.class); + saveObj.setId(null); + tmplInscDatBsnMapper.insert(saveObj); } @Override diff --git a/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/service/tmpltp/TmplInscItmBsnServiceImpl.java b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/service/tmpltp/TmplInscItmBsnServiceImpl.java index 2c87a572..505a3b2f 100644 --- a/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/service/tmpltp/TmplInscItmBsnServiceImpl.java +++ b/zt-module-base/zt-module-base-server/src/main/java/com/zt/plat/module/base/service/tmpltp/TmplInscItmBsnServiceImpl.java @@ -53,7 +53,7 @@ public class TmplInscItmBsnServiceImpl implements TmplInscItmBsnService { void validateTmplInscItmBsnExistsByKey(TmplInscItmBsnSaveReqVO createReqVO) { List tmplInscItmBsnDOS = tmplInscItmBsnMapper.selectList(TmplInscItmBsnDO::getBsnId, createReqVO.getBsnId(), TmplInscItmBsnDO::getInscItmId, createReqVO.getBsnId()); - if (!tmplInscItmBsnDOS.isEmpty()){ + if (!tmplInscItmBsnDOS.isEmpty()) { throw exception(TMPL_INSC_ITM_BSN_EXISTS); } } @@ -61,10 +61,14 @@ public class TmplInscItmBsnServiceImpl implements TmplInscItmBsnService { @Override public void updateTmplInscItmBsn(TmplInscItmBsnSaveReqVO updateReqVO) { // 校验存在 - validateTmplInscItmBsnExists(updateReqVO.getId()); + // validateTmplInscItmBsnExists(updateReqVO.getId()); // 更新 - TmplInscItmBsnDO updateObj = BeanUtils.toBean(updateReqVO, TmplInscItmBsnDO.class); - tmplInscItmBsnMapper.updateById(updateObj); + tmplInscItmBsnMapper.physicalDeleteByBsnIds(List.of(updateReqVO.getBsnId())); + TmplInscItmBsnDO saveObj = BeanUtils.toBean(updateReqVO, TmplInscItmBsnDO.class); + saveObj.setInscItmId(updateReqVO.getInstceItmId()); +// tmplInscItmBsnMapper.updateById(updateObj); + saveObj.setId(null); + tmplInscItmBsnMapper.insert(saveObj); } @Override