Browse Source

字典需求管理后台代码提交

yucheng 3 years ago
parent
commit
6ee60dbb77

+ 27 - 0
dmp-business/dmp-rwd-version/src/main/java/com/persagy/dmp/rwd/demand/constant/DemandBillState.java

@@ -0,0 +1,27 @@
+package com.persagy.dmp.rwd.demand.constant;
+
+import lombok.Getter;
+
+/**
+ * 需求状态
+ * @author Charlie Yu
+ * @date 2021-09-16
+ */
+@Getter
+public enum DemandBillState {
+    /** 需求状态 */
+    SAVING(0, "待提交"),
+    SUBMITTED(1, "待回复"),
+    APPROVED_ACCEPT(2, "已接受"),
+    APPROVED_REJECT(3, "已拒绝"),
+    SEND_BACK(4, "待完善"),
+    PROOFING(5, "论证中");
+
+    private Integer index;
+    private String name;
+
+    DemandBillState(Integer index, String name) {
+        this.index = index;
+        this.name = name;
+    }
+}

+ 24 - 0
dmp-business/dmp-rwd-version/src/main/java/com/persagy/dmp/rwd/demand/constant/DemandProductLine.java

@@ -0,0 +1,24 @@
+package com.persagy.dmp.rwd.demand.constant;
+
+import lombok.Getter;
+
+/**
+ * 产品线
+ * @author Charlie Yu
+ * @date 2021-09-16
+ */
+@Getter
+public enum DemandProductLine {
+    /** 产品线 */
+    BUSINESS(1, "业务"),
+    DEVELOPMENT(2, "研发"),
+    IMPLEMENTATION(3, "实施");
+
+    private Integer index;
+    private String name;
+
+    DemandProductLine(Integer index, String name) {
+        this.index = index;
+        this.name = name;
+    }
+}

+ 213 - 0
dmp-business/dmp-rwd-version/src/main/java/com/persagy/dmp/rwd/demand/controller/DictionaryDemandController.java

@@ -0,0 +1,213 @@
+package com.persagy.dmp.rwd.demand.controller;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.OrderItem;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.persagy.dmp.common.constant.CommonConstant;
+import com.persagy.dmp.common.constant.ValidEnum;
+import com.persagy.dmp.common.context.AppContext;
+import com.persagy.dmp.common.exception.BusinessException;
+import com.persagy.dmp.common.model.entity.AuditableEntity;
+import com.persagy.dmp.common.model.response.CommonResult;
+import com.persagy.dmp.common.utils.JsonHelper;
+import com.persagy.dmp.common.utils.ParamCheckUtil;
+import com.persagy.dmp.common.utils.ResultHelper;
+import com.persagy.dmp.rwd.demand.constant.DemandBillState;
+import com.persagy.dmp.rwd.demand.entity.AnswerDemandVO;
+import com.persagy.dmp.rwd.demand.entity.DictionaryDemand;
+import com.persagy.dmp.rwd.demand.entity.QueryDemandVO;
+import com.persagy.dmp.rwd.demand.service.IDictionaryDemandService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.validation.Valid;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * 字典需求Controller
+ * @author Charlie Yu
+ * @date 2021-09-16
+ */
+@RestController
+@RequestMapping("/rwdedit/demand")
+public class DictionaryDemandController {
+
+    /** 可回复的状态 */
+    private static final Set<Integer> STATE_SET = CollUtil.newHashSet(
+            DemandBillState.APPROVED_ACCEPT.getIndex(), DemandBillState.APPROVED_REJECT.getIndex(),
+            DemandBillState.PROOFING.getIndex(), DemandBillState.SEND_BACK.getIndex());
+
+    @Autowired
+    private IDictionaryDemandService service;
+
+    /**
+     * 保存需求
+     * @param vo
+     * @return
+     */
+    @PostMapping("/save")
+    public CommonResult<DictionaryDemand> save(@Valid @RequestBody DictionaryDemand vo) {
+        ParamCheckUtil.checkParam(CommonConstant.QUERY_USERID);
+        // 校验
+        if(vo.getBillState() != null && !(DemandBillState.SAVING.getIndex().equals(vo.getBillState())
+                || DemandBillState.SEND_BACK.getIndex().equals(vo.getBillState()))) {
+            throw new BusinessException("只有待提交和待完善的需求可以修改");
+        }
+        vo = service.saveOrSubmit(vo, false);
+        return ResultHelper.single(vo);
+    }
+
+    /**
+     * 提交需求
+     * @param vo
+     * @return
+     */
+    @PostMapping("/submit")
+    public CommonResult<DictionaryDemand> submit(@Valid @RequestBody DictionaryDemand vo) {
+        ParamCheckUtil.checkParam(CommonConstant.QUERY_USERID);
+        // 校验
+        if(vo.getBillState() != null && !(DemandBillState.SAVING.getIndex().equals(vo.getBillState())
+                || DemandBillState.SEND_BACK.getIndex().equals(vo.getBillState()))) {
+            throw new BusinessException("只有待提交和待完善的需求可以修改");
+        }
+        vo = service.saveOrSubmit(vo, true);
+        return ResultHelper.single(vo);
+    }
+
+    /**
+     * 删除需求
+     * @return
+     */
+    @PostMapping("/delete")
+    public CommonResult delete(@Valid @RequestBody List<String> ids) {
+        ParamCheckUtil.checkParam(CommonConstant.QUERY_USERID);
+        if(CollUtil.isEmpty(ids)) {
+            throw new BusinessException("没有选择待删除的需求");
+        }
+        service.deleteByIds(ids);
+        return ResultHelper.success();
+    }
+
+    /**
+     * 答复需求
+     * @return
+     */
+    @PostMapping("/answer")
+    public CommonResult<List<DictionaryDemand>> answer(@Valid @RequestBody AnswerDemandVO answer) {
+        ParamCheckUtil.checkParam(CommonConstant.QUERY_USERID);
+        // 如果不是处理状态
+        if(!STATE_SET.contains(answer.getBillState())) {
+            throw new BusinessException("处理状态有误!");
+        }
+        // 保存
+        List<DictionaryDemand> vos = service.answer(answer.getIds(), answer.getBillState(),
+                answer.getRespondent(), answer.getReply(), answer.getEstimateTime());
+        return ResultHelper.multi(vos);
+    }
+
+    /**
+     * 查询草稿箱
+     * @return
+     * @throws IOException
+     */
+    @PostMapping("/queryDraft")
+    public CommonResult<List<DictionaryDemand>> queryDraft(@RequestBody Map<String, Object> map) {
+        return queryDemandByState(map, DemandBillState.SAVING.getIndex(), DemandBillState.SEND_BACK.getIndex());
+    }
+
+    /**
+     * 查询已提交
+     * @return
+     * @throws IOException
+     */
+    @PostMapping("/querySubmitted")
+    public CommonResult<List<DictionaryDemand>> querySubmitted(@RequestBody Map<String, Object> map) {
+        return queryDemandByState(map, DemandBillState.SUBMITTED.getIndex(),
+                DemandBillState.APPROVED_ACCEPT.getIndex(), DemandBillState.APPROVED_REJECT.getIndex(),
+                DemandBillState.PROOFING.getIndex());
+    }
+
+    /**
+     * 查询待办
+     * @return
+     * @throws IOException
+     */
+    @PostMapping("/queryTodo")
+    public CommonResult<List<DictionaryDemand>> queryTodo(@RequestBody Map<String, Object> map) {
+        return queryDemandByState(map, DemandBillState.SUBMITTED.getIndex(), DemandBillState.PROOFING.getIndex());
+    }
+
+    /**
+     * 查询已办
+     * @return
+     * @throws IOException
+     */
+    @PostMapping("/queryDone")
+    public CommonResult<List<DictionaryDemand>> queryDone(@RequestBody Map<String, Object> map) {
+        return queryDemandByState(map, DemandBillState.APPROVED_ACCEPT.getIndex(), DemandBillState.APPROVED_REJECT.getIndex());
+    }
+
+    /**
+     * 按状态查询
+     * @param map
+     * @param states
+     * @return
+     */
+    private CommonResult<List<DictionaryDemand>> queryDemandByState(Map<String, Object> map, Integer... states) {
+        ParamCheckUtil.checkParam(CommonConstant.QUERY_USERID);
+        QueryDemandVO cond = JsonHelper.toSingleEntityQuietly(map, QueryDemandVO.class);
+        Page pageable = JsonHelper.toSingleEntityQuietly(map, Page.class);
+        resetOrderItem(pageable);
+        // 组装查询条件
+        QueryWrapper<DictionaryDemand> wrapper = new QueryWrapper<>();
+        wrapper.eq("valid", ValidEnum.TRUE.getType());
+        // 查询待回复和论证中
+        wrapper.in("bill_state", states);
+        ensureQueryCond(wrapper, cond);
+        Page page = service.page(pageable, wrapper);
+        return ResultHelper.multi(page.getRecords(), page.getTotal());
+    }
+
+    /**
+     * 排序驼峰转下划线
+     * @param pageable
+     */
+    private void resetOrderItem(Page pageable) {
+        if(pageable == null || CollUtil.isEmpty(pageable.getOrders())) {
+            return;
+        }
+        List<OrderItem> orders = pageable.getOrders();
+        for(OrderItem order:orders) {
+            order.setColumn(StrUtil.toUnderlineCase(order.getColumn()));
+        }
+    }
+
+    /**
+     * 拼接查询条件
+     * @param wrapper
+     * @param cond
+     */
+    private void ensureQueryCond(QueryWrapper<DictionaryDemand> wrapper, QueryDemandVO cond) {
+        if(cond == null) {
+            return;
+        }
+        // 只查看我的需求
+        wrapper.eq(cond.getCreatorCond()!=null&&1==cond.getCreatorCond(),
+                AuditableEntity.PROP_CREATOR, AppContext.getContext().getAccountId());
+        // 模糊匹配
+        String matchColumn = " concat(code, '@', subject) ";
+        wrapper.like(StrUtil.isNotBlank(cond.getMatchingCond()), matchColumn, cond.getMatchingCond());
+        // 产线
+        wrapper.in(CollUtil.isNotEmpty(cond.getProductCond()), "product_line", cond.getProductCond());
+        // 状态
+        wrapper.in(CollUtil.isNotEmpty(cond.getStateCond()), "bill_state", cond.getStateCond());
+    }
+}

+ 19 - 0
dmp-business/dmp-rwd-version/src/main/java/com/persagy/dmp/rwd/demand/dao/DictionaryDemandMapper.java

@@ -0,0 +1,19 @@
+package com.persagy.dmp.rwd.demand.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.persagy.dmp.rwd.demand.entity.DictionaryDemand;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * 字典需求 dao
+ * @author Charlie Yu
+ * @date 2021-09-16
+ */
+public interface DictionaryDemandMapper extends BaseMapper<DictionaryDemand> {
+
+    /**
+     * 更新编码
+     * @param id
+     */
+    void updateMaxCode(@Param("id") String id);
+}

+ 29 - 0
dmp-business/dmp-rwd-version/src/main/java/com/persagy/dmp/rwd/demand/entity/AnswerDemandVO.java

@@ -0,0 +1,29 @@
+package com.persagy.dmp.rwd.demand.entity;
+
+import com.persagy.dmp.common.lang.PsDate;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.util.List;
+
+/**
+ * 需求回复参数
+ * @author Charlie Yu
+ * @date 2021-09-16
+ */
+@Data
+public class AnswerDemandVO {
+
+    /** 需求IDs */
+    @NotNull(message = "主键不允许为空")
+    List<String> ids;
+    /** 需求状态 -  2:已接受 3:已拒绝 4:待完善 5:论证中 */
+    @NotNull(message = "需求状态不允许为空")
+    Integer billState;
+    /** 回复人 */
+    String respondent;
+    /** 回复内容 */
+    String reply;
+    /** 预计回复日期 */
+    PsDate estimateTime;
+}

+ 56 - 0
dmp-business/dmp-rwd-version/src/main/java/com/persagy/dmp/rwd/demand/entity/DictionaryDemand.java

@@ -0,0 +1,56 @@
+package com.persagy.dmp.rwd.demand.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.persagy.dmp.common.lang.PsDate;
+import com.persagy.dmp.common.lang.PsDateTime;
+import com.persagy.dmp.common.model.entity.AuditableEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.hibernate.validator.constraints.Length;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * 标准字典需求
+ * @author Charlie Yu
+ * @date 2021-09-16
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@TableName(value = "dt_demand",autoResultMap = true)
+public class DictionaryDemand extends AuditableEntity {
+
+    /** 编码 - 6位流水号 */
+    private String code;
+    /** 用户名 */
+    @NotNull(message = "用户名不允许为空")
+    @Length(max = 40)
+    private String userName;
+    /** 部门名称 */
+    @NotNull(message = "部门名称不允许为空")
+    @Length(max = 40)
+    private String deptName;
+    /** 产线-1:业务 2:研发 3:实施 */
+    @NotNull(message = "产线不允许为空")
+    private Integer productLine;
+    /** 主题 */
+    @NotNull(message = "主题不允许为空")
+    @Length(max = 200)
+    private String subject;
+    /** 内容 */
+    @NotNull(message = "内容不允许为空")
+    @Length(max = 200)
+    private String content;
+    /** 需求状态 - 0:待提交 1:待回复 2:已接受 3:已拒绝 4:待完善 5:论证中 */
+    private Integer billState;
+    /** 回复人 */
+    private String respondent;
+    /** 回复内容 */
+    private String reply;
+    /** 提交时间 */
+    private PsDateTime submitTime;
+    /** 预计回复日期 */
+    private PsDate estimateTime;
+    /** 回复时间 */
+    private PsDateTime answerTime;
+}

+ 23 - 0
dmp-business/dmp-rwd-version/src/main/java/com/persagy/dmp/rwd/demand/entity/QueryDemandVO.java

@@ -0,0 +1,23 @@
+package com.persagy.dmp.rwd.demand.entity;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * 需求通用查询条件
+ * @author Charlie Yu
+ * @date 2021-09-16
+ */
+@Data
+public class QueryDemandVO {
+
+    /** 下拉筛选条件 - 0:所有需求 1:我的需求 */
+    private Integer creatorCond;
+    /** 模糊匹配 - 编码、主题 */
+    private String matchingCond;
+    /** 产线条件 */
+    private List<Integer> productCond;
+    /** 状态条件 */
+    private List<Integer> stateCond;
+}

+ 39 - 0
dmp-business/dmp-rwd-version/src/main/java/com/persagy/dmp/rwd/demand/service/IDictionaryDemandService.java

@@ -0,0 +1,39 @@
+package com.persagy.dmp.rwd.demand.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.persagy.dmp.common.lang.PsDate;
+import com.persagy.dmp.rwd.demand.entity.DictionaryDemand;
+
+import java.util.List;
+
+/**
+ * 字典需求 服务
+ * @author Charlie Yu
+ * @date 2021-09-16
+ */
+public interface IDictionaryDemandService extends IService<DictionaryDemand> {
+
+    /**
+     * 保存/提交
+     * @param vo
+     * @param submitFlag
+     * @return
+     */
+    DictionaryDemand saveOrSubmit(DictionaryDemand vo, Boolean submitFlag);
+
+    /**
+     * 通过id删除
+     * @param ids
+     */
+    void deleteByIds(List<String> ids);
+
+    /**
+     * 答复
+     * @param ids 需求IDs
+     * @param state 答复状态
+     * @param reply 答复信息
+     * @param date 预计答复日期
+     * @return
+     */
+    List<DictionaryDemand> answer(List<String> ids, Integer state, String respondent, String reply, PsDate date);
+}

+ 79 - 0
dmp-business/dmp-rwd-version/src/main/java/com/persagy/dmp/rwd/demand/service/impl/DictionaryDemandServiceImpl.java

@@ -0,0 +1,79 @@
+package com.persagy.dmp.rwd.demand.service.impl;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.BooleanUtil;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.persagy.dmp.common.constant.ValidEnum;
+import com.persagy.dmp.common.lang.PsDate;
+import com.persagy.dmp.common.lang.PsDateTime;
+import com.persagy.dmp.rwd.demand.constant.DemandBillState;
+import com.persagy.dmp.rwd.demand.dao.DictionaryDemandMapper;
+import com.persagy.dmp.rwd.demand.entity.DictionaryDemand;
+import com.persagy.dmp.rwd.demand.service.IDictionaryDemandService;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+/**
+ * 字典需求 实现类
+ * @author Charlie Yu
+ * @date 2021-09-16
+ */
+@Service
+@Transactional(rollbackFor = Exception.class)
+public class DictionaryDemandServiceImpl extends ServiceImpl<DictionaryDemandMapper, DictionaryDemand> implements IDictionaryDemandService {
+
+    @Override
+    public DictionaryDemand saveOrSubmit(DictionaryDemand vo, Boolean submitFlag) {
+        // 提交
+        if(BooleanUtil.isTrue(submitFlag)) {
+            vo.setBillState(DemandBillState.SUBMITTED.getIndex());
+            vo.setSubmitTime(new PsDateTime());
+        } else if(vo.getBillState() == null) {
+            vo.setBillState(DemandBillState.SAVING.getIndex());
+        }
+        vo.setValid(ValidEnum.TRUE.getType());
+        save(vo);
+        // 保存后,更新编码(有值就不再更新了)
+        getBaseMapper().updateMaxCode(vo.getId());
+        return getById(vo.getId());
+    }
+
+    @Override
+    public void deleteByIds(List<String> ids) {
+        if(CollUtil.isEmpty(ids)) {
+            return;
+        }
+        // 查询
+        List<DictionaryDemand> vos = listByIds(ids);
+        if(CollUtil.isEmpty(vos)) {
+            return;
+        }
+        vos.forEach(p -> p.setValid(ValidEnum.FALSE.getType()));
+        updateBatchById(vos);
+    }
+
+    @Override
+    public List<DictionaryDemand> answer(List<String> ids, Integer state, String respondent, String reply, PsDate date) {
+        if(CollUtil.isEmpty(ids) || state == null) {
+            return null;
+        }
+        // 查询
+        List<DictionaryDemand> vos = listByIds(ids);
+        // 赋值
+        PsDateTime now = new PsDateTime();
+        for(DictionaryDemand vo:vos) {
+            vo.setBillState(state);
+            vo.setRespondent(respondent);
+            vo.setReply(reply);
+            vo.setAnswerTime(now);
+            // 论证中的,需要填写预计回复日期
+            if(DemandBillState.PROOFING.getIndex().equals(state)) {
+                vo.setEstimateTime(date);
+            }
+        }
+        updateBatchById(vos);
+        return vos;
+    }
+}

+ 0 - 0
dmp-business/dmp-rwd-version/src/main/resources/db.init/data.sql


+ 0 - 22
dmp-business/dmp-rwd-version/src/main/resources/db.init/schema.sql

@@ -1,25 +0,0 @@
-CREATE TABLE IF NOT EXISTS `dt_define_version` (
-  `id` varchar(40) NOT NULL COMMENT '主键',
-  `version` varchar(40) DEFAULT NULL COMMENT '版本编号,全局唯一',
-  `state` varchar(2) DEFAULT NULL COMMENT '版本状态,0-已取消,1-待确认,2-待发布,3-发布中,4-已完成',
-  `last_flag` tinyint(4) DEFAULT NULL COMMENT '最新标识,0-非最新,1-最新',
-  `last_version` varchar(40) DEFAULT NULL COMMENT '上一版本号',
-  `show_order` int(11) DEFAULT NULL COMMENT '显示顺序',
-  `confirm_user` varchar(32) DEFAULT NULL COMMENT '确认人',
-  `confirm_time` char(14) DEFAULT NULL COMMENT '确认时间,格式为yyyyMMddHHmmss',
-  `publish_user` varchar(32) DEFAULT NULL COMMENT '发布人',
-  `publish_time` char(14) DEFAULT NULL COMMENT '发布时间,格式为yyyyMMddHHmmss',
-  `finish_time` char(14) DEFAULT NULL COMMENT '完成时间,格式为yyyyMMddHHmmss',
-  `creator` varchar(32) DEFAULT NULL COMMENT '创建人',
-  `creation_time` char(14) DEFAULT NULL COMMENT '创建时间,格式为yyyyMMddHHmmss',
-  `modifier` varchar(32) DEFAULT NULL COMMENT '最后更新人',
-  `modified_time` char(14) DEFAULT NULL COMMENT '最后更新时间,格式为yyyyMMddHHmmss',
-  `valid` tinyint(4) DEFAULT NULL COMMENT '合法标识,0-无效,1-有效',
-  `ts` timestamp NULL DEFAULT NULL COMMENT '乐观锁',
-  PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='版本定义表';
-
-

+ 1 - 0
dmp-business/dmp-rwd-version/src/main/resources/db/init/data.sql

@@ -0,0 +1 @@
+select 1 from dual;

+ 45 - 0
dmp-business/dmp-rwd-version/src/main/resources/db/init/schema.sql

@@ -0,0 +1,45 @@
+CREATE TABLE IF NOT EXISTS `dt_define_version` (
+  `id` varchar(40) NOT NULL COMMENT '主键',
+  `version` varchar(40) DEFAULT NULL COMMENT '版本编号,全局唯一',
+  `state` varchar(2) DEFAULT NULL COMMENT '版本状态,0-已取消,1-待确认,2-待发布,3-发布中,4-已完成',
+  `last_flag` tinyint(4) DEFAULT NULL COMMENT '最新标识,0-非最新,1-最新',
+  `last_version` varchar(40) DEFAULT NULL COMMENT '上一版本号',
+  `show_order` int(11) DEFAULT NULL COMMENT '显示顺序',
+  `confirm_user` varchar(32) DEFAULT NULL COMMENT '确认人',
+  `confirm_time` char(14) DEFAULT NULL COMMENT '确认时间,格式为yyyyMMddHHmmss',
+  `publish_user` varchar(32) DEFAULT NULL COMMENT '发布人',
+  `publish_time` char(14) DEFAULT NULL COMMENT '发布时间,格式为yyyyMMddHHmmss',
+  `finish_time` char(14) DEFAULT NULL COMMENT '完成时间,格式为yyyyMMddHHmmss',
+  `creator` varchar(32) DEFAULT NULL COMMENT '创建人',
+  `creation_time` char(14) DEFAULT NULL COMMENT '创建时间,格式为yyyyMMddHHmmss',
+  `modifier` varchar(32) DEFAULT NULL COMMENT '最后更新人',
+  `modified_time` char(14) DEFAULT NULL COMMENT '最后更新时间,格式为yyyyMMddHHmmss',
+  `valid` tinyint(4) DEFAULT NULL COMMENT '合法标识,0-无效,1-有效',
+  `ts` timestamp NULL DEFAULT NULL COMMENT '乐观锁',
+  PRIMARY KEY (`id`)
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COMMENT = '版本定义表' ROW_FORMAT = Dynamic;
+
+CREATE TABLE IF NOT EXISTS `dt_demand`  (
+  `id` varchar(40) NOT NULL COMMENT '主键',
+  `code` varchar(40) NULL DEFAULT NULL COMMENT '编码-全局唯一',
+  `user_name` varchar(200) NOT NULL COMMENT '用户名',
+  `dept_name` varchar(40) NOT NULL COMMENT '部门名称',
+  `product_line` tinyint(0) NOT NULL COMMENT '产线 - 1:业务 2:研发 3:实施',
+  `subject` varchar(1024) NULL DEFAULT NULL COMMENT '主题',
+  `content` varchar(40) NOT NULL DEFAULT '0' COMMENT '内容',
+  `bill_state` tinyint(0) NOT NULL DEFAULT 0 COMMENT '需求状态 - 0:待提交 1:待回复 2:已接受 3:已拒绝 4:待完善 5:论证中',
+  `respondent` varchar(40) NULL DEFAULT NULL COMMENT '回复人',
+  `reply` varchar(40) NULL DEFAULT NULL COMMENT '回复内容',
+  `submit_time` varchar(40) NULL DEFAULT NULL COMMENT '提交时间',
+  `estimate_time` varchar(40) NULL DEFAULT NULL COMMENT '预计回复日期',
+  `answer_time` varchar(40) NULL DEFAULT NULL COMMENT '回复时间',
+  `creator` varchar(32) NULL DEFAULT NULL COMMENT '创建人',
+  `creation_time` char(14) NULL DEFAULT NULL COMMENT '创建时间',
+  `modifier` varchar(32) NULL DEFAULT NULL COMMENT '最后修改人',
+  `modified_time` char(14) NULL DEFAULT NULL COMMENT '最后修改时间',
+  `valid` tinyint(0) NULL DEFAULT NULL COMMENT '合法标识',
+  `ts` timestamp(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '乐观锁',
+  PRIMARY KEY (`id`) USING BTREE,
+  INDEX `idx_state`(`bill_state`) USING BTREE
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COMMENT = '字典需求' ROW_FORMAT = Dynamic;
+

+ 9 - 0
dmp-business/dmp-rwd-version/src/main/resources/mapper/DictionaryDemandMapper.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.persagy.dmp.rwd.demand.dao.DictionaryDemandMapper">
+
+    <update id="updateMaxCode">
+        update dt_demand m, (select ifnull(max(code), '9999')+1 as max_code from dt_demand) n
+        set m.code = n.max_code where m.id = #{id} and m.code is null
+	</update>
+</mapper>