From a5794a18c1b5dc89ace53a80ee6f12c056d46546 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E8=A3=95=E8=B4=A2?= Date: Sat, 4 Feb 2023 23:16:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=86=E5=8F=B2=E6=8A=A5=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/xmMenuComment/XmMenuCommentEdit.vue | 204 ------------ .../com/xm/core/ctrl/XmRptDataController.java | 296 ++++++++++++++++++ .../java/com/xm/core/entity/XmRptData.java | 65 ++++ .../com/xm/core/service/XmRptDataService.java | 24 ++ .../mapper/xm/core/dao/XmRptDataMapper.xml | 196 ++++++++++++ 5 files changed, 581 insertions(+), 204 deletions(-) delete mode 100644 xm-core-ui/src/views/xm/core/xmMenuComment/XmMenuCommentEdit.vue create mode 100644 xm-core/src/main/java/com/xm/core/ctrl/XmRptDataController.java create mode 100644 xm-core/src/main/java/com/xm/core/entity/XmRptData.java create mode 100644 xm-core/src/main/java/com/xm/core/service/XmRptDataService.java create mode 100644 xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmRptDataMapper.xml diff --git a/xm-core-ui/src/views/xm/core/xmMenuComment/XmMenuCommentEdit.vue b/xm-core-ui/src/views/xm/core/xmMenuComment/XmMenuCommentEdit.vue deleted file mode 100644 index 71df12c5..00000000 --- a/xm-core-ui/src/views/xm/core/xmMenuComment/XmMenuCommentEdit.vue +++ /dev/null @@ -1,204 +0,0 @@ - - - - - \ No newline at end of file diff --git a/xm-core/src/main/java/com/xm/core/ctrl/XmRptDataController.java b/xm-core/src/main/java/com/xm/core/ctrl/XmRptDataController.java new file mode 100644 index 00000000..787c09a1 --- /dev/null +++ b/xm-core/src/main/java/com/xm/core/ctrl/XmRptDataController.java @@ -0,0 +1,296 @@ +package com.xm.core.ctrl; + +import java.util.*; +import java.util.stream.Collectors; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.StringUtils; +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.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import io.swagger.annotations.*; + +import static com.mdp.core.utils.ResponseHelper.*; +import static com.mdp.core.utils.BaseUtils.*; +import com.mdp.core.entity.Tips; +import com.mdp.core.err.BizException; +import com.mdp.mybatis.PageUtils; +import com.mdp.core.utils.RequestUtils; +import com.mdp.core.utils.NumberUtil; +import com.mdp.safe.client.entity.User; +import com.mdp.safe.client.utils.LoginUtils; +import io.swagger.annotations.*; +import springfox.documentation.annotations.ApiIgnore; + +import com.xm.core.service.XmRptDataService; +import com.xm.core.entity.XmRptData; + +/** + * url编制采用rest风格,如对xm_rpt_data xm_rpt_data的操作有增删改查,对应的url分别为:
+ * 组织 com 顶级模块 xm 大模块 core 小模块
+ * 实体 XmRptData 表 xm_rpt_data 当前主键(包括多主键): id; + ***/ +@RestController("xm.core.xmRptDataController") +@RequestMapping(value="/**/core/xmRptData") +@Api(tags={"xm_rpt_data操作接口"}) +public class XmRptDataController { + + static Logger logger =LoggerFactory.getLogger(XmRptDataController.class); + + @Autowired + private XmRptDataService xmRptDataService; + + + Map fieldsMap = toMap(new XmRptData()); + + + @ApiOperation( value = "查询xm_rpt_data信息列表",notes=" ") + @ApiEntityParams( XmRptData.class ) + @ApiImplicitParams({ + @ApiImplicitParam(name="pageSize",value="每页大小,默认20条",required=false), + @ApiImplicitParam(name="pageNum",value="当前页码,从1开始",required=false), + @ApiImplicitParam(name="total",value="总记录数,服务器端收到0时,会自动计算总记录数,如果上传>0的不自动计算",required=false), + @ApiImplicitParam(name="count",value="是否计算总记录条数,如果count=true,则计算计算总条数,如果count=false 则不计算",required=false), + @ApiImplicitParam(name="orderBy",value="排序列 如性别、学生编号排序 orderBy = sex desc,student desc",required=false), + }) + @ApiResponses({ + @ApiResponse(code = 200,response=XmRptData.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'错误码'},total:总记录数,data:[数据对象1,数据对象2,...]}") + }) + @RequestMapping(value="/list",method=RequestMethod.GET) + public Map listXmRptData( @ApiIgnore @RequestParam Map xmRptData){ + Map m = new HashMap<>(); + Tips tips=new Tips("查询成功"); + RequestUtils.transformArray(xmRptData, "ids"); + PageUtils.startPage(xmRptData); + List> xmRptDataList = xmRptDataService.selectListMapByWhere(xmRptData); //列出XmRptData列表 + PageUtils.responePage(m, xmRptDataList); + m.put("data",xmRptDataList); + + m.put("tips", tips); + return m; + } + + + + /** + @ApiOperation( value = "新增一条xm_rpt_data信息",notes=" ") + @ApiResponses({ + @ApiResponse(code = 200,response=XmRptData.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") + }) + @RequestMapping(value="/add",method=RequestMethod.POST) + public Map addXmRptData(@RequestBody XmRptData xmRptData) { + Map m = new HashMap<>(); + Tips tips=new Tips("成功新增一条数据"); + try{ + boolean createPk=false; + if(!StringUtils.hasText(xmRptData.getId())) { + createPk=true; + xmRptData.setId(xmRptDataService.createKey("id")); + } + if(createPk==false){ + if(xmRptDataService.selectOneObject(xmRptData) !=null ){ + return failed("pk-exists","编号重复,请修改编号再提交"); + } + } + xmRptDataService.insert(xmRptData); + m.put("data",xmRptData); + }catch (BizException e) { + tips=e.getTips(); + logger.error("",e); + }catch (Exception e) { + tips.setFailureMsg(e.getMessage()); + logger.error("",e); + } + m.put("tips", tips); + return m; + } + */ + + /** + @ApiOperation( value = "删除一条xm_rpt_data信息",notes=" ") + @ApiResponses({ + @ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}") + }) + @RequestMapping(value="/del",method=RequestMethod.POST) + public Map delXmRptData(@RequestBody XmRptData xmRptData){ + Map m = new HashMap<>(); + Tips tips=new Tips("成功删除一条数据"); + try{ + if(!StringUtils.hasText(xmRptData.getId())) { + return failed("pk-not-exists","请上送主键参数id"); + } + XmRptData xmRptDataDb = xmRptDataService.selectOneObject(xmRptData); + if( xmRptDataDb == null ){ + return failed("data-not-exists","数据不存在,无法删除"); + } + xmRptDataService.deleteByPk(xmRptData); + }catch (BizException e) { + tips=e.getTips(); + logger.error("",e); + }catch (Exception e) { + tips.setFailureMsg(e.getMessage()); + logger.error("",e); + } + m.put("tips", tips); + return m; + } + */ + + /** + @ApiOperation( value = "根据主键修改一条xm_rpt_data信息",notes=" ") + @ApiResponses({ + @ApiResponse(code = 200,response=XmRptData.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") + }) + @RequestMapping(value="/edit",method=RequestMethod.POST) + public Map editXmRptData(@RequestBody XmRptData xmRptData) { + Map m = new HashMap<>(); + Tips tips=new Tips("成功更新一条数据"); + try{ + if(!StringUtils.hasText(xmRptData.getId())) { + return failed("pk-not-exists","请上送主键参数id"); + } + XmRptData xmRptDataDb = xmRptDataService.selectOneObject(xmRptData); + if( xmRptDataDb == null ){ + return failed("data-not-exists","数据不存在,无法修改"); + } + xmRptDataService.updateSomeFieldByPk(xmRptData); + m.put("data",xmRptData); + }catch (BizException e) { + tips=e.getTips(); + logger.error("",e); + }catch (Exception e) { + tips.setFailureMsg(e.getMessage()); + logger.error("",e); + } + m.put("tips", tips); + return m; + } + */ + + /** + @ApiOperation( value = "批量修改某些字段",notes="") + @ApiEntityParams( value = XmRptData.class, props={ }, remark = "xm_rpt_data", paramType = "body" ) + @ApiResponses({ + @ApiResponse(code = 200,response=XmRptData.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") + }) + @RequestMapping(value="/editSomeFields",method=RequestMethod.POST) + public Map editSomeFields( @ApiIgnore @RequestBody Map xmRptDataMap) { + Map m = new HashMap<>(); + Tips tips=new Tips("成功更新一条数据"); + try{ + List ids= (List) xmRptDataMap.get("ids"); + if(ids==null || ids.size()==0){ + return failed("ids-0","ids不能为空"); + } + + Set fields=new HashSet<>(); + fields.add("id"); + for (String fieldName : xmRptDataMap.keySet()) { + if(fields.contains(fieldName)){ + return failed(fieldName+"-no-edit",fieldName+"不允许修改"); + } + } + Set fieldKey=xmRptDataMap.keySet().stream().filter(i-> fieldsMap.containsKey(i)).collect(Collectors.toSet()); + fieldKey=fieldKey.stream().filter(i->!StringUtils.isEmpty(xmRptDataMap.get(i) )).collect(Collectors.toSet()); + + if(fieldKey.size()<=0) { + return failed("fieldKey-0","没有需要更新的字段"); + } + XmRptData xmRptData = fromMap(xmRptDataMap,XmRptData.class); + List xmRptDatasDb=xmRptDataService.selectListByIds(ids); + if(xmRptDatasDb==null ||xmRptDatasDb.size()==0){ + return failed("data-0","记录已不存在"); + } + List can=new ArrayList<>(); + List no=new ArrayList<>(); + User user = LoginUtils.getCurrentUserInfo(); + for (XmRptData xmRptDataDb : xmRptDatasDb) { + Tips tips2 = new Tips("检查通过"); + if(!tips2.isOk()){ + no.add(xmRptDataDb); + }else{ + can.add(xmRptDataDb); + } + } + if(can.size()>0){ + xmRptDataMap.put("ids",can.stream().map(i->i.getId()).collect(Collectors.toList())); + xmRptDataService.editSomeFields(xmRptDataMap); + } + List msgs=new ArrayList<>(); + if(can.size()>0){ + msgs.add(String.format("成功更新以下%s条数据",can.size())); + } + if(no.size()>0){ + msgs.add(String.format("以下%s个数据无权限更新",no.size())); + } + if(can.size()>0){ + tips.setOkMsg(msgs.stream().collect(Collectors.joining())); + }else { + tips.setFailureMsg(msgs.stream().collect(Collectors.joining())); + } + //m.put("data",xmMenu); + }catch (BizException e) { + tips=e.getTips(); + logger.error("",e); + }catch (Exception e) { + tips.setFailureMsg(e.getMessage()); + logger.error("",e); + } + m.put("tips", tips); + return m; + } + */ + + /** + @ApiOperation( value = "根据主键列表批量删除xm_rpt_data信息",notes=" ") + @ApiResponses({ + @ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}") + }) + @RequestMapping(value="/batchDel",method=RequestMethod.POST) + public Map batchDelXmRptData(@RequestBody List xmRptDatas) { + Map m = new HashMap<>(); + Tips tips=new Tips("成功删除"); + try{ + if(xmRptDatas.size()<=0){ + return failed("data-0","请上送待删除数据列表"); + } + List datasDb=xmRptDataService.selectListByIds(xmRptDatas.stream().map(i-> i.getId() ).collect(Collectors.toList())); + + List can=new ArrayList<>(); + List no=new ArrayList<>(); + for (XmRptData data : datasDb) { + if(true){ + can.add(data); + }else{ + no.add(data); + } + } + List msgs=new ArrayList<>(); + if(can.size()>0){ + xmRptDataService.batchDelete(can); + msgs.add(String.format("成功删除%s条数据.",can.size())); + } + + if(no.size()>0){ + msgs.add(String.format("以下%s条数据不能删除.【%s】",no.size(),no.stream().map(i-> i.getId() ).collect(Collectors.joining(",")))); + } + if(can.size()>0){ + tips.setOkMsg(msgs.stream().collect(Collectors.joining())); + }else { + tips.setFailureMsg(msgs.stream().collect(Collectors.joining())); + } + }catch (BizException e) { + tips=e.getTips(); + logger.error("",e); + }catch (Exception e) { + tips.setFailureMsg(e.getMessage()); + logger.error("",e); + } + m.put("tips", tips); + return m; + } + */ +} diff --git a/xm-core/src/main/java/com/xm/core/entity/XmRptData.java b/xm-core/src/main/java/com/xm/core/entity/XmRptData.java new file mode 100644 index 00000000..ba1ba7e5 --- /dev/null +++ b/xm-core/src/main/java/com/xm/core/entity/XmRptData.java @@ -0,0 +1,65 @@ +package com.xm.core.entity; + +import lombok.Data; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.Date; + +/** + * 组织 com 顶级模块 xm 大模块 core 小模块
+ * 实体 XmRptData所有属性名:
+ * "cfgId","报表配置主键","id","报表主键","rptName","报表名称","rptData","报表数据json对象,比rptCfg.cfg多了rawDatas","cuserid","创建人编号","cbranchId","创建人机构号","cusername","创建人名称","ctime","创建日期","bizDate","归属业务日期yyyy-MM-dd型","bizType","业务类型,同rpt_config.biz_type";
+ * 当前主键(包括多主键):
+ * id;
+ */ + @Data +@ApiModel(description="xm_rpt_data") +public class XmRptData implements java.io.Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(notes="报表主键,主键",allowEmptyValue=true,example="",allowableValues="") + String id; + + + @ApiModelProperty(notes="报表配置主键",allowEmptyValue=true,example="",allowableValues="") + String cfgId; + + @ApiModelProperty(notes="报表名称",allowEmptyValue=true,example="",allowableValues="") + String rptName; + + @ApiModelProperty(notes="报表数据json对象,比rptCfg.cfg多了rawDatas",allowEmptyValue=true,example="",allowableValues="") + String rptData; + + @ApiModelProperty(notes="创建人编号",allowEmptyValue=true,example="",allowableValues="") + String cuserid; + + @ApiModelProperty(notes="创建人机构号",allowEmptyValue=true,example="",allowableValues="") + String cbranchId; + + @ApiModelProperty(notes="创建人名称",allowEmptyValue=true,example="",allowableValues="") + String cusername; + + @ApiModelProperty(notes="创建日期",allowEmptyValue=true,example="",allowableValues="") + Date ctime; + + @ApiModelProperty(notes="归属业务日期yyyy-MM-dd型",allowEmptyValue=true,example="",allowableValues="") + String bizDate; + + @ApiModelProperty(notes="业务类型,同rpt_config.biz_type",allowEmptyValue=true,example="",allowableValues="") + String bizType; + + /** + *报表主键 + **/ + public XmRptData(String id) { + this.id = id; + } + + /** + * xm_rpt_data + **/ + public XmRptData() { + } + +} \ No newline at end of file diff --git a/xm-core/src/main/java/com/xm/core/service/XmRptDataService.java b/xm-core/src/main/java/com/xm/core/service/XmRptDataService.java new file mode 100644 index 00000000..3a6096ff --- /dev/null +++ b/xm-core/src/main/java/com/xm/core/service/XmRptDataService.java @@ -0,0 +1,24 @@ +package com.xm.core.service; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.util.List; +import java.util.Map; +import org.springframework.stereotype.Service; +import com.mdp.core.service.BaseService; +import static com.mdp.core.utils.BaseUtils.*; +import com.mdp.core.entity.Tips; +import com.mdp.core.err.BizException; + +import com.xm.core.entity.XmRptData; +/** + * 父类已经支持增删改查操作,因此,即使本类什么也不写,也已经可以满足一般的增删改查操作了.
+ * 组织 com 顶级模块 xm 大模块 core 小模块
+ * 实体 XmRptData 表 xm_rpt_data 当前主键(包括多主键): id; + ***/ +@Service("xm.core.xmRptDataService") +public class XmRptDataService extends BaseService { + static Logger logger =LoggerFactory.getLogger(XmRptDataService.class); + +} + diff --git a/xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmRptDataMapper.xml b/xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmRptDataMapper.xml new file mode 100644 index 00000000..9a410e31 --- /dev/null +++ b/xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmRptDataMapper.xml @@ -0,0 +1,196 @@ + + + + + + + + + and (res.id) in + + ( #{item}) + + + + + + + + + + + + + + + + + + + + + + + + + + insert into xm_rpt_data( + + ) values ( + #{cfgId},#{id},#{rptName},#{rptData},#{cuserid},#{cbranchId},#{cusername},#{ctime},#{bizDate},#{bizType} + ) + + + + + delete from xm_rpt_data res + + + + + + + + delete from xm_rpt_data + where id = #{id} + + + + + update xm_rpt_data + + + + where id = #{id} + + + + + update xm_rpt_data + + + + where id = #{id} + + + + + + + + update xm_rpt_data + set + + where id = #{item.id} + + + + + + update xm_rpt_data + + + + where (id) in + + ( #{item}) + + + + + delete from xm_rpt_data + where + (id) in + + ( #{item.id} ) + + + + + + + cfg_id,id,rpt_name,rpt_data,cuserid,cbranch_id,cusername,ctime,biz_date,biz_type + + + + + and res.cfg_id = #{cfgId} + and res.id = #{id} + and res.rpt_name = #{rptName} + and res.rpt_data = #{rptData} + and res.cuserid = #{cuserid} + and res.cbranch_id = #{cbranchId} + and res.cusername = #{cusername} + and date_format(res.ctime,'%Y-%m-%d') = date_format(#{ctime},'%Y-%m-%d') + and res.biz_date = #{bizDate} + and res.biz_type = #{bizType} + + + + cfg_id = #{cfgId}, + rpt_name = #{rptName}, + rpt_data = #{rptData}, + cuserid = #{cuserid}, + cbranch_id = #{cbranchId}, + cusername = #{cusername}, + ctime = #{ctime}, + biz_date = #{bizDate}, + biz_type = #{bizType} + + + cfg_id = #{cfgId}, + rpt_name = #{rptName}, + rpt_data = #{rptData}, + cuserid = #{cuserid}, + cbranch_id = #{cbranchId}, + cusername = #{cusername}, + ctime = #{ctime}, + biz_date = #{bizDate}, + biz_type = #{bizType}, + + + + cfg_id = #{item.cfgId}, + rpt_name = #{item.rptName}, + rpt_data = #{item.rptData}, + cuserid = #{item.cuserid}, + cbranch_id = #{item.cbranchId}, + cusername = #{item.cusername}, + ctime = #{item.ctime}, + biz_date = #{item.bizDate}, + biz_type = #{item.bizType} + + \ No newline at end of file