From 5620edca7d35b4f8cc2c0074785953b97ae917ff Mon Sep 17 00:00:00 2001 From: 199901012 Date: Tue, 16 Mar 2021 23:21:14 +0800 Subject: [PATCH] =?UTF-8?q?'=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/HighApproveController.java | 67 ++++++++++++++++-- .../bweb/controller/HighCouponController.java | 1 + .../java/com/hai/dao/HighApproveMapper.java | 31 ++++---- .../com/hai/dao/HighApproveSqlProvider.java | 14 ++++ .../main/java/com/hai/entity/HighApprove.java | 18 ++++- .../com/hai/entity/HighApproveExample.java | 70 +++++++++++++++++++ .../com/hai/service/HighApproveService.java | 8 +++ .../service/impl/HighApproveServiceImpl.java | 28 ++++++++ 8 files changed, 218 insertions(+), 19 deletions(-) diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighApproveController.java b/hai-bweb/src/main/java/com/bweb/controller/HighApproveController.java index 6b187c29..0ba4b71a 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighApproveController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighApproveController.java @@ -1,6 +1,8 @@ package com.bweb.controller; import com.alibaba.fastjson.JSONObject; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; @@ -9,12 +11,15 @@ import com.hai.common.security.UserCenter; import com.hai.common.utils.DateUtil; import com.hai.common.utils.ResponseMsgUtil; import com.hai.entity.HighApprove; +import com.hai.entity.HighCoupon; import com.hai.entity.HighCouponHandsel; import com.hai.entity.HighMerchant; +import com.hai.enum_type.ApproveType; import com.hai.model.HighCouponModel; import com.hai.model.ResponseData; import com.hai.model.UserInfoModel; import com.hai.service.HighApproveService; +import com.hai.service.HighCouponService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; @@ -22,14 +27,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; -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.ResponseBody; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.util.Date; +import java.util.HashMap; +import java.util.Map; /** * @ClassName HighApproveController @@ -50,6 +54,9 @@ public class HighApproveController { @Resource private HighApproveService highApproveService; + @Resource + private HighCouponService highCouponService; + @RequestMapping(value="/approveProcessed",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "审批") @@ -91,4 +98,56 @@ public class HighApproveController { return ResponseMsgUtil.exception(e); } } + + @RequestMapping(value="/getApproveDetail",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "查询审批详情") + public ResponseData getApproveDetail(@RequestParam(name = "approveId", required = true) Long approveId) { + try { + // 查询审批记录 + HighApprove approve = highApproveService.getApproveById(approveId); + if (approve == null) { + log.error("HighCouponController -> getApproveDetail() error!","未找到审批记录"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_APPROVE, ""); + } + Map map = new HashMap<>(); + map.put("approve", approve); + + if (approve.getObjectType() == ApproveType.UP_SHELF_APPROVE.getType()) { + map.put("object", highCouponService.getCouponById(approve.getObjectId())); + } + + return ResponseMsgUtil.success(map); + + } catch (Exception e) { + log.error("HighCouponController -> getApproveDetail() error!",e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/getApproveList",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "查询审批列表") + public ResponseData getApproveList(@RequestParam(name = "approveSerialNo", required = false) String approveSerialNo, + @RequestParam(name = "objectType", required = false) Integer objectType, + @RequestParam(name = "objectId", required = false) Long objectId, + @RequestParam(name = "objectName", required = false) String objectName, + @RequestParam(name = "pageNum", required = true) Integer pageNum, + @RequestParam(name = "pageSize", required = true) Integer pageSize) { + try { + + Map map = new HashMap<>(); + map.put("approveSerialNo", approveSerialNo); + map.put("objectType", approveSerialNo); + map.put("objectId", approveSerialNo); + map.put("objectName", approveSerialNo); + + PageHelper.startPage(pageNum, pageSize); + return ResponseMsgUtil.success(new PageInfo<>(highApproveService.getApproveList(map))); + + } catch (Exception e) { + log.error("HighCouponController -> getApproveDetail() error!",e); + return ResponseMsgUtil.exception(e); + } + } } diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java b/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java index de037112..1d15f56b 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java @@ -209,6 +209,7 @@ public class HighCouponController { HighApprove approve = new HighApprove(); approve.setObjectType(ApproveType.UP_SHELF_APPROVE.getType()); approve.setObjectId(id); + approve.setObjectName(coupon.getCouponName()); approve.setApproveSerialNo(DateUtil.date2String(new Date(), "MMddhhmmss") + ((Math.random()*9+1)*10000)); approve.setStatus(1); approve.setCreateTime(new Date()); diff --git a/hai-service/src/main/java/com/hai/dao/HighApproveMapper.java b/hai-service/src/main/java/com/hai/dao/HighApproveMapper.java index 5bb37437..1af2b2d2 100644 --- a/hai-service/src/main/java/com/hai/dao/HighApproveMapper.java +++ b/hai-service/src/main/java/com/hai/dao/HighApproveMapper.java @@ -40,19 +40,19 @@ public interface HighApproveMapper extends HighApproveMapperExt { @Insert({ "insert into high_approve (object_type, object_id, ", - "approve_serial_no, remarks, ", - "`status`, create_time, ", - "update_time, submit_operator_id, ", - "submit_operator_name, approve_operator_id, ", - "approve_operator_name, ext_1, ", - "ext_2, ext_3)", + "object_name, approve_serial_no, ", + "remarks, `status`, ", + "create_time, update_time, ", + "submit_operator_id, submit_operator_name, ", + "approve_operator_id, approve_operator_name, ", + "ext_1, ext_2, ext_3)", "values (#{objectType,jdbcType=INTEGER}, #{objectId,jdbcType=BIGINT}, ", - "#{approveSerialNo,jdbcType=VARCHAR}, #{remarks,jdbcType=VARCHAR}, ", - "#{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ", - "#{updateTime,jdbcType=TIMESTAMP}, #{submitOperatorId,jdbcType=BIGINT}, ", - "#{submitOperatorName,jdbcType=VARCHAR}, #{approveOperatorId,jdbcType=BIGINT}, ", - "#{approveOperatorName,jdbcType=VARCHAR}, #{ext1,jdbcType=VARCHAR}, ", - "#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" + "#{objectName,jdbcType=VARCHAR}, #{approveSerialNo,jdbcType=VARCHAR}, ", + "#{remarks,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, ", + "#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, ", + "#{submitOperatorId,jdbcType=BIGINT}, #{submitOperatorName,jdbcType=VARCHAR}, ", + "#{approveOperatorId,jdbcType=BIGINT}, #{approveOperatorName,jdbcType=VARCHAR}, ", + "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" }) @Options(useGeneratedKeys=true,keyProperty="id") int insert(HighApprove record); @@ -66,6 +66,7 @@ public interface HighApproveMapper extends HighApproveMapperExt { @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="object_type", property="objectType", jdbcType=JdbcType.INTEGER), @Result(column="object_id", property="objectId", jdbcType=JdbcType.BIGINT), + @Result(column="object_name", property="objectName", jdbcType=JdbcType.VARCHAR), @Result(column="approve_serial_no", property="approveSerialNo", jdbcType=JdbcType.VARCHAR), @Result(column="remarks", property="remarks", jdbcType=JdbcType.VARCHAR), @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), @@ -83,8 +84,8 @@ public interface HighApproveMapper extends HighApproveMapperExt { @Select({ "select", - "id, object_type, object_id, approve_serial_no, remarks, `status`, create_time, ", - "update_time, submit_operator_id, submit_operator_name, approve_operator_id, ", + "id, object_type, object_id, object_name, approve_serial_no, remarks, `status`, ", + "create_time, update_time, submit_operator_id, submit_operator_name, approve_operator_id, ", "approve_operator_name, ext_1, ext_2, ext_3", "from high_approve", "where id = #{id,jdbcType=BIGINT}" @@ -93,6 +94,7 @@ public interface HighApproveMapper extends HighApproveMapperExt { @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="object_type", property="objectType", jdbcType=JdbcType.INTEGER), @Result(column="object_id", property="objectId", jdbcType=JdbcType.BIGINT), + @Result(column="object_name", property="objectName", jdbcType=JdbcType.VARCHAR), @Result(column="approve_serial_no", property="approveSerialNo", jdbcType=JdbcType.VARCHAR), @Result(column="remarks", property="remarks", jdbcType=JdbcType.VARCHAR), @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), @@ -121,6 +123,7 @@ public interface HighApproveMapper extends HighApproveMapperExt { "update high_approve", "set object_type = #{objectType,jdbcType=INTEGER},", "object_id = #{objectId,jdbcType=BIGINT},", + "object_name = #{objectName,jdbcType=VARCHAR},", "approve_serial_no = #{approveSerialNo,jdbcType=VARCHAR},", "remarks = #{remarks,jdbcType=VARCHAR},", "`status` = #{status,jdbcType=INTEGER},", diff --git a/hai-service/src/main/java/com/hai/dao/HighApproveSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighApproveSqlProvider.java index 1f751a57..1ad8c3ea 100644 --- a/hai-service/src/main/java/com/hai/dao/HighApproveSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/HighApproveSqlProvider.java @@ -36,6 +36,10 @@ public class HighApproveSqlProvider { sql.VALUES("object_id", "#{objectId,jdbcType=BIGINT}"); } + if (record.getObjectName() != null) { + sql.VALUES("object_name", "#{objectName,jdbcType=VARCHAR}"); + } + if (record.getApproveSerialNo() != null) { sql.VALUES("approve_serial_no", "#{approveSerialNo,jdbcType=VARCHAR}"); } @@ -96,6 +100,7 @@ public class HighApproveSqlProvider { } sql.SELECT("object_type"); sql.SELECT("object_id"); + sql.SELECT("object_name"); sql.SELECT("approve_serial_no"); sql.SELECT("remarks"); sql.SELECT("`status`"); @@ -137,6 +142,10 @@ public class HighApproveSqlProvider { sql.SET("object_id = #{record.objectId,jdbcType=BIGINT}"); } + if (record.getObjectName() != null) { + sql.SET("object_name = #{record.objectName,jdbcType=VARCHAR}"); + } + if (record.getApproveSerialNo() != null) { sql.SET("approve_serial_no = #{record.approveSerialNo,jdbcType=VARCHAR}"); } @@ -196,6 +205,7 @@ public class HighApproveSqlProvider { sql.SET("id = #{record.id,jdbcType=BIGINT}"); sql.SET("object_type = #{record.objectType,jdbcType=INTEGER}"); sql.SET("object_id = #{record.objectId,jdbcType=BIGINT}"); + sql.SET("object_name = #{record.objectName,jdbcType=VARCHAR}"); sql.SET("approve_serial_no = #{record.approveSerialNo,jdbcType=VARCHAR}"); sql.SET("remarks = #{record.remarks,jdbcType=VARCHAR}"); sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); @@ -226,6 +236,10 @@ public class HighApproveSqlProvider { sql.SET("object_id = #{objectId,jdbcType=BIGINT}"); } + if (record.getObjectName() != null) { + sql.SET("object_name = #{objectName,jdbcType=VARCHAR}"); + } + if (record.getApproveSerialNo() != null) { sql.SET("approve_serial_no = #{approveSerialNo,jdbcType=VARCHAR}"); } diff --git a/hai-service/src/main/java/com/hai/entity/HighApprove.java b/hai-service/src/main/java/com/hai/entity/HighApprove.java index fa5edbe0..daa7334e 100644 --- a/hai-service/src/main/java/com/hai/entity/HighApprove.java +++ b/hai-service/src/main/java/com/hai/entity/HighApprove.java @@ -19,7 +19,7 @@ public class HighApprove implements Serializable { private Long id; /** - * 审批对象 1:卡券上架审批 + * 审批对象 1:卡券上架审批 2:卡卷价格审批 */ private Integer objectType; @@ -28,6 +28,11 @@ public class HighApprove implements Serializable { */ private Long objectId; + /** + * 审批对象名称 + */ + private String objectName; + /** * 审批流水号 */ @@ -105,6 +110,14 @@ public class HighApprove implements Serializable { this.objectId = objectId; } + public String getObjectName() { + return objectName; + } + + public void setObjectName(String objectName) { + this.objectName = objectName; + } + public String getApproveSerialNo() { return approveSerialNo; } @@ -216,6 +229,7 @@ public class HighApprove implements Serializable { return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) && (this.getObjectType() == null ? other.getObjectType() == null : this.getObjectType().equals(other.getObjectType())) && (this.getObjectId() == null ? other.getObjectId() == null : this.getObjectId().equals(other.getObjectId())) + && (this.getObjectName() == null ? other.getObjectName() == null : this.getObjectName().equals(other.getObjectName())) && (this.getApproveSerialNo() == null ? other.getApproveSerialNo() == null : this.getApproveSerialNo().equals(other.getApproveSerialNo())) && (this.getRemarks() == null ? other.getRemarks() == null : this.getRemarks().equals(other.getRemarks())) && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) @@ -237,6 +251,7 @@ public class HighApprove implements Serializable { result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); result = prime * result + ((getObjectType() == null) ? 0 : getObjectType().hashCode()); result = prime * result + ((getObjectId() == null) ? 0 : getObjectId().hashCode()); + result = prime * result + ((getObjectName() == null) ? 0 : getObjectName().hashCode()); result = prime * result + ((getApproveSerialNo() == null) ? 0 : getApproveSerialNo().hashCode()); result = prime * result + ((getRemarks() == null) ? 0 : getRemarks().hashCode()); result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); @@ -261,6 +276,7 @@ public class HighApprove implements Serializable { sb.append(", id=").append(id); sb.append(", objectType=").append(objectType); sb.append(", objectId=").append(objectId); + sb.append(", objectName=").append(objectName); sb.append(", approveSerialNo=").append(approveSerialNo); sb.append(", remarks=").append(remarks); sb.append(", status=").append(status); diff --git a/hai-service/src/main/java/com/hai/entity/HighApproveExample.java b/hai-service/src/main/java/com/hai/entity/HighApproveExample.java index bf2a9012..8bdb2317 100644 --- a/hai-service/src/main/java/com/hai/entity/HighApproveExample.java +++ b/hai-service/src/main/java/com/hai/entity/HighApproveExample.java @@ -305,6 +305,76 @@ public class HighApproveExample { return (Criteria) this; } + public Criteria andObjectNameIsNull() { + addCriterion("object_name is null"); + return (Criteria) this; + } + + public Criteria andObjectNameIsNotNull() { + addCriterion("object_name is not null"); + return (Criteria) this; + } + + public Criteria andObjectNameEqualTo(String value) { + addCriterion("object_name =", value, "objectName"); + return (Criteria) this; + } + + public Criteria andObjectNameNotEqualTo(String value) { + addCriterion("object_name <>", value, "objectName"); + return (Criteria) this; + } + + public Criteria andObjectNameGreaterThan(String value) { + addCriterion("object_name >", value, "objectName"); + return (Criteria) this; + } + + public Criteria andObjectNameGreaterThanOrEqualTo(String value) { + addCriterion("object_name >=", value, "objectName"); + return (Criteria) this; + } + + public Criteria andObjectNameLessThan(String value) { + addCriterion("object_name <", value, "objectName"); + return (Criteria) this; + } + + public Criteria andObjectNameLessThanOrEqualTo(String value) { + addCriterion("object_name <=", value, "objectName"); + return (Criteria) this; + } + + public Criteria andObjectNameLike(String value) { + addCriterion("object_name like", value, "objectName"); + return (Criteria) this; + } + + public Criteria andObjectNameNotLike(String value) { + addCriterion("object_name not like", value, "objectName"); + return (Criteria) this; + } + + public Criteria andObjectNameIn(List values) { + addCriterion("object_name in", values, "objectName"); + return (Criteria) this; + } + + public Criteria andObjectNameNotIn(List values) { + addCriterion("object_name not in", values, "objectName"); + return (Criteria) this; + } + + public Criteria andObjectNameBetween(String value1, String value2) { + addCriterion("object_name between", value1, value2, "objectName"); + return (Criteria) this; + } + + public Criteria andObjectNameNotBetween(String value1, String value2) { + addCriterion("object_name not between", value1, value2, "objectName"); + return (Criteria) this; + } + public Criteria andApproveSerialNoIsNull() { addCriterion("approve_serial_no is null"); return (Criteria) this; diff --git a/hai-service/src/main/java/com/hai/service/HighApproveService.java b/hai-service/src/main/java/com/hai/service/HighApproveService.java index 142f1460..07fe8c39 100644 --- a/hai-service/src/main/java/com/hai/service/HighApproveService.java +++ b/hai-service/src/main/java/com/hai/service/HighApproveService.java @@ -3,6 +3,7 @@ package com.hai.service; import com.hai.entity.HighApprove; import java.util.List; +import java.util.Map; /** * @Auther: 胡锐 @@ -40,4 +41,11 @@ public interface HighApproveService { **/ void approveProcessed(HighApprove highApprove); + /** + * @Author 胡锐 + * @Description 审批列表 + * @Date 2021/3/16 19:39 + **/ + List getApproveList(Map map); + } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighApproveServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighApproveServiceImpl.java index d4292ccc..486b760d 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighApproveServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighApproveServiceImpl.java @@ -5,17 +5,21 @@ import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.dao.HighApproveMapper; import com.hai.entity.HighApprove; +import com.hai.entity.HighApproveExample; import com.hai.entity.HighCoupon; import com.hai.enum_type.ApproveType; import com.hai.model.HighCouponModel; import com.hai.service.HighApproveService; import com.hai.service.HighCouponService; +import org.apache.commons.collections4.MapUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.Date; +import java.util.List; +import java.util.Map; import java.util.Objects; /** @@ -54,4 +58,28 @@ public class HighApproveServiceImpl implements HighApproveService { highCouponService.upShelfApproveResult(highApprove); } } + + @Override + public List getApproveList(Map map) { + HighApproveExample example = new HighApproveExample(); + HighApproveExample.Criteria criteria = example.createCriteria(); + + if (MapUtils.getString(map, "approveSerialNo") != null) { + criteria.andApproveSerialNoEqualTo(MapUtils.getString(map, "approveSerialNo")); + } + + if (MapUtils.getInteger(map, "objectType") != null) { + criteria.andObjectTypeEqualTo(MapUtils.getInteger(map, "objectType")); + } + + if (MapUtils.getInteger(map, "objectId") != null) { + criteria.andObjectTypeEqualTo(MapUtils.getInteger(map, "objectId")); + } + + if (MapUtils.getString(map, "objectName") != null) { + criteria.andObjectNameLike("%" + MapUtils.getString(map, "objectName") + "%"); + } + + return highApproveMapper.selectByExample(example); + } }