广脉:1、新增科目对照子表相关接口

This commit is contained in:
zhengyf 2025-06-06 16:29:35 +08:00
parent 10c49cb967
commit b93aa1f7af
9 changed files with 325 additions and 22 deletions

View File

@ -0,0 +1,70 @@
package com.hzya.frame.voucher.ae.comf.subject.controller;
import com.hzya.frame.voucher.ae.comf.subject.entity.AeConfSubjectContrastBEntity;
import com.hzya.frame.voucher.ae.comf.subject.service.IAeConfSubjectContrastBService;
import com.hzya.frame.voucher.ae.comf.subject.service.IAeConfSubjectContrastService;
import com.hzya.frame.web.action.DefaultController;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* Created by zydd on 2025-05-30 15:13
*/
@RestController
@RequestMapping("/ae/conf/subjectContrastB")
public class ContrastBController extends DefaultController {
@Autowired
private IAeConfSubjectContrastService contrastService;
@Autowired
private IAeConfSubjectContrastBService contrastBService;
@RequestMapping(value = "/queryAllByContrastId", method = RequestMethod.POST)
public JsonResultEntity queryAllByContrastId(@RequestBody AeConfSubjectContrastBEntity entity){
try {
List<AeConfSubjectContrastBEntity> all = contrastBService.queryAllByContrastId(entity);
return getSuccessMessageEntity("请求成功",all);
} catch (Exception e) {
e.printStackTrace();
return getFailureMessageEntity("请求失败",e.getMessage());
}
}
@RequestMapping(value = "/saveList", method = RequestMethod.POST)
public JsonResultEntity saveList(@RequestBody List<AeConfSubjectContrastBEntity> list){
try {
List<AeConfSubjectContrastBEntity> all = contrastBService.saveListEntity(list);
return getSuccessMessageEntity("请求成功",all);
} catch (Exception e) {
e.printStackTrace();
return getFailureMessageEntity("请求失败",e.getMessage());
}
}
@RequestMapping(value = "/updateList", method = RequestMethod.POST)
public JsonResultEntity updateList(@RequestBody List<AeConfSubjectContrastBEntity> list){
try {
List<AeConfSubjectContrastBEntity> all = contrastBService.updateList(list);
return getSuccessMessageEntity("请求成功",all);
} catch (Exception e) {
e.printStackTrace();
return getFailureMessageEntity("请求失败",e.getMessage());
}
}
@RequestMapping(value = "/deleteList", method = RequestMethod.POST)
public JsonResultEntity deleteList(@RequestBody List<AeConfSubjectContrastBEntity> list){
try {
contrastBService.deleteList(list);
return getSuccessMessageEntity("请求成功",null);
} catch (Exception e) {
e.printStackTrace();
return getFailureMessageEntity("请求失败",e.getMessage());
}
}
}

View File

@ -53,4 +53,24 @@ public class ContrastController extends DefaultController {
return getFailureMessageEntity("请求失败",e.getMessage());
}
}
@RequestMapping(value = "/update", method = RequestMethod.POST)
public JsonResultEntity update(@RequestBody AeConfSubjectContrastEntity entity){
try {
AeConfSubjectContrastEntity save = aeConfSubjectContrastService.updateEntity(entity);
return getSuccessMessageEntity("请求成功",save);
} catch (Exception e) {
e.printStackTrace();
return getFailureMessageEntity("请求失败",e.getMessage());
}
}
@RequestMapping(value = "/delete", method = RequestMethod.POST)
public JsonResultEntity delete(@RequestBody AeConfSubjectContrastEntity entity){
try {
AeConfSubjectContrastEntity save = aeConfSubjectContrastService.deleteEntity(entity);
return getSuccessMessageEntity("请求成功",save);
} catch (Exception e) {
e.printStackTrace();
return getFailureMessageEntity("请求失败",e.getMessage());
}
}
}

View File

@ -134,6 +134,42 @@ public class AeConfSubjectContrastBEntity extends BaseEntity {
* 来源档案值9
*/
private String factorid9;
/**
* 来源档案名称1
*/
private String factorname1;
/**
* 来源档案名称2
*/
private String factorname2;
/**
* 来源档案名称3
*/
private String factorname3;
/**
* 来源档案名称4
*/
private String factorname4;
/**
* 来源档案名称5
*/
private String factorname5;
/**
* 来源档案名称6
*/
private String factorname6;
/**
* 来源档案名称7
*/
private String factorname7;
/**
* 来源档案名称8
*/
private String factorname8;
/**
* 来源档案名称9
*/
private String factorname9;
/**
* 备注
*/

View File

@ -35,6 +35,15 @@
<result property="factorid7" column="factorid7" jdbcType="VARCHAR"/>
<result property="factorid8" column="factorid8" jdbcType="VARCHAR"/>
<result property="factorid9" column="factorid9" jdbcType="VARCHAR"/>
<result property="factorname1" column="factorname1" jdbcType="VARCHAR"/>
<result property="factorname2" column="factorname2" jdbcType="VARCHAR"/>
<result property="factorname3" column="factorname3" jdbcType="VARCHAR"/>
<result property="factorname4" column="factorname4" jdbcType="VARCHAR"/>
<result property="factorname5" column="factorname5" jdbcType="VARCHAR"/>
<result property="factorname6" column="factorname6" jdbcType="VARCHAR"/>
<result property="factorname7" column="factorname7" jdbcType="VARCHAR"/>
<result property="factorname8" column="factorname8" jdbcType="VARCHAR"/>
<result property="factorname9" column="factorname9" jdbcType="VARCHAR"/>
<result property="remark" column="remark" jdbcType="VARCHAR"/>
<result property="def1" column="def1" jdbcType="VARCHAR"/>
<result property="def2" column="def2" jdbcType="VARCHAR"/>
@ -85,7 +94,16 @@
,factorid7
,factorid8
,factorid9
,remark
,factorname1
,factorname2
,factorname3
,factorname4
,factorname5
,factorname6
,factorname7
,factorname8
,factorname9
,remark
,def1
,def2
,def3
@ -357,7 +375,6 @@
useGeneratedKeys="true">
insert into ae_conf_subject_contrast_b(
<trim suffix="" suffixOverrides=",">
<if test="id != null">id ,</if>
<if test="contrastId != null">contrast_id ,</if>
<if test="pkCorp != null and pkCorp != ''">pk_corp ,</if>
<if test="desdocvalue != null and desdocvalue != ''">desdocvalue ,</if>
@ -388,6 +405,15 @@
<if test="factorid7 != null and factorid7 != ''">factorid7 ,</if>
<if test="factorid8 != null and factorid8 != ''">factorid8 ,</if>
<if test="factorid9 != null and factorid9 != ''">factorid9 ,</if>
<if test="factorname1 != null and factorname1 != ''">factorname1 ,</if>
<if test="factorname2 != null and factorname2 != ''">factorname2 ,</if>
<if test="factorname3 != null and factorname3 != ''">factorname3 ,</if>
<if test="factorname4 != null and factorname4 != ''">factorname4 ,</if>
<if test="factorname5 != null and factorname5 != ''">factorname5 ,</if>
<if test="factorname6 != null and factorname6 != ''">factorname6 ,</if>
<if test="factorname7 != null and factorname7 != ''">factorname7 ,</if>
<if test="factorname8 != null and factorname8 != ''">factorname8 ,</if>
<if test="factorname9 != null and factorname9 != ''">factorname9 ,</if>
<if test="remark != null and remark != ''">remark ,</if>
<if test="def1 != null and def1 != ''">def1 ,</if>
<if test="def2 != null and def2 != ''">def2 ,</if>
@ -410,7 +436,6 @@
</trim>
)values(
<trim suffix="" suffixOverrides=",">
<if test="id != null">#{id} ,</if>
<if test="contrastId != null">#{contrastId} ,</if>
<if test="pkCorp != null and pkCorp != ''">#{pkCorp} ,</if>
<if test="desdocvalue != null and desdocvalue != ''">#{desdocvalue} ,</if>
@ -441,6 +466,15 @@
<if test="factorid7 != null and factorid7 != ''">#{factorid7} ,</if>
<if test="factorid8 != null and factorid8 != ''">#{factorid8} ,</if>
<if test="factorid9 != null and factorid9 != ''">#{factorid9} ,</if>
<if test="factorname1 != null and factorname1 != ''">#{factorname1} ,</if>
<if test="factorname2 != null and factorname2 != ''">#{factorname2} ,</if>
<if test="factorname3 != null and factorname3 != ''">#{factorname3} ,</if>
<if test="factorname4 != null and factorname4 != ''">#{factorname4} ,</if>
<if test="factorname5 != null and factorname5 != ''">#{factorname5} ,</if>
<if test="factorname6 != null and factorname6 != ''">#{factorname6} ,</if>
<if test="factorname7 != null and factorname7 != ''">#{factorname7} ,</if>
<if test="factorname8 != null and factorname8 != ''">#{factorname8} ,</if>
<if test="factorname9 != null and factorname9 != ''">#{factorname9} ,</if>
<if test="remark != null and remark != ''">#{remark} ,</if>
<if test="def1 != null and def1 != ''">#{def1} ,</if>
<if test="def2 != null and def2 != ''">#{def2} ,</if>

View File

@ -16,6 +16,8 @@
<result property="pkCorp" column="pk_corp" jdbcType="VARCHAR"/>
<result property="corpType" column="corp_type" jdbcType="VARCHAR"/>
<result property="desdocId" column="desdocid" jdbcType="VARCHAR"/>
<result property="desdocCode" column="desdoccode" jdbcType="VARCHAR"/>
<result property="desdocName" column="desdocname" jdbcType="VARCHAR"/>
<result property="pkSetcorp1" column="pk_setcorp1" jdbcType="VARCHAR"/>
<result property="remark" column="remark" jdbcType="VARCHAR"/>
<result property="def1" column="def1" jdbcType="VARCHAR"/>
@ -50,7 +52,9 @@
,pk_corp
,corp_type
,desdocid
,pk_setcorp1
,desdoccode
,desdocname
,pk_setcorp1
,remark
,def1
,def2
@ -250,6 +254,8 @@
<if test="pkCorp != null and pkCorp != ''">pk_corp ,</if>
<if test="corpType != null and corpType != ''">corp_type ,</if>
<if test="desdocId != null and desdocId != ''">desdocid ,</if>
<if test="desdocCode != null and desdocCode != ''">desdoccode ,</if>
<if test="desdocName != null and desdocName != ''">desdocname ,</if>
<if test="pkSetcorp1 != null and pkSetcorp1 != ''">pk_setcorp1 ,</if>
<if test="remark != null and remark != ''">remark ,</if>
<if test="def1 != null and def1 != ''">def1 ,</if>
@ -286,6 +292,8 @@
<if test="pkCorp != null and pkCorp != ''">#{pkCorp} ,</if>
<if test="corpType != null and corpType != ''">#{corpType} ,</if>
<if test="desdocId != null and desdocId != ''">#{desdocId} ,</if>
<if test="desdocCode != null and desdocCode != ''">#{desdocCode} ,</if>
<if test="desdocName != null and desdocName != ''">#{desdocName} ,</if>
<if test="pkSetcorp1 != null and pkSetcorp1 != ''">#{pkSetcorp1} ,</if>
<if test="remark != null and remark != ''">#{remark} ,</if>
<if test="def1 != null and def1 != ''">#{def1} ,</if>

View File

@ -2,6 +2,9 @@ package com.hzya.frame.voucher.ae.comf.subject.service;
import com.hzya.frame.voucher.ae.comf.subject.entity.AeConfSubjectContrastBEntity;
import com.hzya.frame.basedao.service.IBaseService;
import java.util.List;
/**
* 会计事项(accounting_event)-配置-科目对照_子表(AeConfSubjectContrastB)表服务接口
*
@ -9,4 +12,11 @@ import com.hzya.frame.basedao.service.IBaseService;
* @since 2025-06-05 15:13:29
*/
public interface IAeConfSubjectContrastBService extends IBaseService<AeConfSubjectContrastBEntity, String>{
List<AeConfSubjectContrastBEntity> queryAllByContrastId(AeConfSubjectContrastBEntity entity);
List<AeConfSubjectContrastBEntity> saveListEntity(List<AeConfSubjectContrastBEntity> list);
List<AeConfSubjectContrastBEntity> updateList(List<AeConfSubjectContrastBEntity> list);
void deleteList(List<AeConfSubjectContrastBEntity> list);
}

View File

@ -17,4 +17,6 @@ public interface IAeConfSubjectContrastService extends IBaseService<AeConfSubjec
AeConfSubjectContrastEntity queryById(AeConfSubjectContrastEntity entity);
AeConfSubjectContrastEntity saveEntity(AeConfSubjectContrastEntity entity) throws NoSuchFieldException, IllegalAccessException;
AeConfSubjectContrastEntity updateEntity(AeConfSubjectContrastEntity entity) throws Exception;
AeConfSubjectContrastEntity deleteEntity(AeConfSubjectContrastEntity entity) throws Exception;
}

View File

@ -1,12 +1,21 @@
package com.hzya.frame.voucher.ae.comf.subject.service.impl;
import cn.hutool.core.lang.Assert;
import com.hzya.frame.voucher.ae.comf.subject.dao.IAeConfSubjectContrastDao;
import com.hzya.frame.voucher.ae.comf.subject.entity.AeConfSubjectContrastBEntity;
import com.hzya.frame.voucher.ae.comf.subject.dao.IAeConfSubjectContrastBDao;
import com.hzya.frame.voucher.ae.comf.subject.entity.AeConfSubjectContrastEntity;
import com.hzya.frame.voucher.ae.comf.subject.service.IAeConfSubjectContrastBService;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import com.hzya.frame.basedao.service.impl.BaseService;
import java.util.ArrayList;
import java.util.List;
/**
* 会计事项(accounting_event)-配置-科目对照_子表(AeConfSubjectContrastB)表服务实现类
*
@ -15,12 +24,90 @@ import com.hzya.frame.basedao.service.impl.BaseService;
*/
@Service
public class AeConfSubjectContrastBServiceImpl extends BaseService<AeConfSubjectContrastBEntity, String> implements IAeConfSubjectContrastBService {
private IAeConfSubjectContrastBDao aeConfSubjectContrastBDao;
@Autowired
public void setAeConfSubjectContrastBDao(IAeConfSubjectContrastBDao dao) {
this.aeConfSubjectContrastBDao = dao;
this.dao = dao;
}
public void setAeConfSubjectContrastBDao(IAeConfSubjectContrastBDao dao) {
this.aeConfSubjectContrastBDao = dao;
this.dao = dao;
}
@Autowired
private IAeConfSubjectContrastDao aeConfSubjectContrastDao;
/**
* 根据contrastId查询所有子表
*/
@Override
public List<AeConfSubjectContrastBEntity> queryAllByContrastId(AeConfSubjectContrastBEntity entity) {
Assert.notNull(entity.getContrastId(), "根据科目对照子表查询所属所有子表时contrastId不能为空");
AeConfSubjectContrastBEntity aeConfSubjectContrastBEntity = new AeConfSubjectContrastBEntity();
aeConfSubjectContrastBEntity.setContrastId(entity.getContrastId());
List<AeConfSubjectContrastBEntity> query = aeConfSubjectContrastBDao.query(aeConfSubjectContrastBEntity);
return query;
}
/**
* 依次保存批量新增
*/
@Override
public List<AeConfSubjectContrastBEntity> saveListEntity(List<AeConfSubjectContrastBEntity> list) {
if (list == null || list.size() == 0) {
Assert.state(false, "批量新增科目对照子表时,子表不能为空。");
}
for (AeConfSubjectContrastBEntity aeConfSubjectContrastBEntity : list) {
Assert.notNull(aeConfSubjectContrastBEntity.getContrastId(), "新增科目对照子表时contrastId不能为空");
Assert.notNull(aeConfSubjectContrastBEntity.getPkCorp(), "新增科目对照子表时,公司主键不能为空");
}
//检查主表是否存在
AeConfSubjectContrastEntity aeConfSubjectContrastEntity = new AeConfSubjectContrastEntity();
aeConfSubjectContrastEntity.setId(String.valueOf(list.get(0).getContrastId()));
List<AeConfSubjectContrastEntity> query = aeConfSubjectContrastDao.query(aeConfSubjectContrastEntity);
if (query == null || query.size() == 0) {
Assert.state(false, "新增科目对照子表时,主表不存在。");
}
List<AeConfSubjectContrastBEntity> all = new ArrayList<>();
for (AeConfSubjectContrastBEntity aeConfSubjectContrastBEntity : list) {
AeConfSubjectContrastBEntity save = aeConfSubjectContrastBDao.save(aeConfSubjectContrastBEntity);
all.add(save);
}
return all;
}
@Override
public List<AeConfSubjectContrastBEntity> updateList(List<AeConfSubjectContrastBEntity> list) {
if (list == null || list.size() == 0) {
Assert.state(false, "批量修改科目对照子表时,子表不能为空。");
}
for (AeConfSubjectContrastBEntity aeConfSubjectContrastBEntity : list) {
Assert.notNull(aeConfSubjectContrastBEntity.getId(), "修改科目对照子表时子表id不能为空");
Assert.notNull(aeConfSubjectContrastBEntity.getContrastId(), "修改科目对照子表时,主表不能为空");
Assert.notNull(aeConfSubjectContrastBEntity.getPkCorp(), "修改科目对照子表时,子表公司主键不能为空");
}
//检查主表是否存在
AeConfSubjectContrastEntity aeConfSubjectContrastEntity = new AeConfSubjectContrastEntity();
aeConfSubjectContrastEntity.setId(String.valueOf(list.get(0).getContrastId()));
List<AeConfSubjectContrastEntity> query = aeConfSubjectContrastDao.query(aeConfSubjectContrastEntity);
if (query == null || query.size() == 0) {
Assert.state(false, "修改科目对照子表时,主表不存在。");
}
for (AeConfSubjectContrastBEntity aeConfSubjectContrastBEntity : list) {
aeConfSubjectContrastBDao.update(aeConfSubjectContrastBEntity);
}
return list;
}
@Override
public void deleteList(List<AeConfSubjectContrastBEntity> list) {
for (AeConfSubjectContrastBEntity aeConfSubjectContrastBEntity : list) {
Assert.notNull(aeConfSubjectContrastBEntity.getId(), "删除科目对照子表时子表id不能为空");
}
for (AeConfSubjectContrastBEntity aeConfSubjectContrastBEntity : list) {
aeConfSubjectContrastBDao.logicRemove(aeConfSubjectContrastBEntity);
}
}
}

View File

@ -86,16 +86,13 @@ public class AeConfSubjectContrastServiceImpl extends BaseService<AeConfSubjectC
List<AeConfSubjectContrastBEntity> contrastBList = entity.getContrastBEntityList();
Assert.notNull(contrastBList, "科目对照表新增时,来源档案不能为空!");
if (contrastBList == null || contrastBList.size() == 0) {
Assert.state(false, "科目对照表新增时来源档案VOS不能为空");
}
if (contrastBList.size() > 9) {
Assert.state(false, "科目对照表新增时来源档案VOS最多为9个");
}
//主表显示列数
// String[] split = entity.getSourceIds().split(",");
// Assert.notNull(contrastBList, "科目对照表新增时,来源档案不能为空!");
// if (contrastBList == null || contrastBList.size() == 0) {
// Assert.state(false, "科目对照表新增时来源档案VOS不能为空");
// }
// if (contrastBList.size() > 9) {
// Assert.state(false, "科目对照表新增时来源档案VOS最多为9个");
// }
// //校验子表
// for (int i = 1; i <= split.length; i++) {
@ -115,12 +112,51 @@ public class AeConfSubjectContrastServiceImpl extends BaseService<AeConfSubjectC
String Hid = saveH.getId();
String HpkCorp = saveH.getPkCorp();
if (contrastBList == null || contrastBList.size() == 0) {
return saveH;
}
//保存子表
for (AeConfSubjectContrastBEntity aeConfSubjectContrastBEntity : contrastBList) {
aeConfSubjectContrastBEntity.setContrastId(Long.valueOf(Hid));
aeConfSubjectContrastBEntity.setPkCorp(HpkCorp);
AeConfSubjectContrastBEntity saveB = aeConfSubjectContrastBDao.save(aeConfSubjectContrastBEntity);
aeConfSubjectContrastBDao.save(aeConfSubjectContrastBEntity);
}
return saveH;
}
/**
* 将原有的主子表全部删除再重新新增
*/
@Override
public AeConfSubjectContrastEntity updateEntity(AeConfSubjectContrastEntity entity) throws Exception {
Assert.notNull(entity.getId(), "科目对照表修改时科目对照表id不能为空");
AeConfSubjectContrastEntity aeConfSubjectContrastEntity = new AeConfSubjectContrastEntity();
aeConfSubjectContrastEntity.setId(entity.getId());
List<AeConfSubjectContrastEntity> query = aeConfSubjectContrastDao.query(aeConfSubjectContrastEntity);
if (query == null || query.size() == 0) {
Assert.state(false, "科目对照表修改时科目对照表id{},未查询到科目对照!", entity.getId());
}
deleteEntity(entity);
saveEntity(entity);
return null;
}
/**
* 将原有的主子表全部删除
*/
@Override
public AeConfSubjectContrastEntity deleteEntity(AeConfSubjectContrastEntity entity) throws Exception {
Assert.notNull(entity.getId(), "科目对照表删除时科目对照表id不能为空");
aeConfSubjectContrastDao.logicRemove(entity);
//查询子表
AeConfSubjectContrastBEntity ContrastBEntity = new AeConfSubjectContrastBEntity();
ContrastBEntity.setContrastId(Long.valueOf(entity.getId()));
List<AeConfSubjectContrastBEntity> query = aeConfSubjectContrastBDao.query(ContrastBEntity);
for (AeConfSubjectContrastBEntity aeConfSubjectContrastBEntity : query) {
aeConfSubjectContrastBDao.logicRemove(aeConfSubjectContrastBEntity);
}
return null;
}
}