Browse Source

公出最大工时发起修改

anderx 1 year ago
parent
commit
03d9de3f1d

+ 1 - 1
src/main/java/com/goafanti/common/dao/TOrderPublicReleaseCountMapper.java

@@ -10,7 +10,7 @@ import java.util.List;
  * 订单公出信息表(TOrderPublicReleaseCount)表数据库访问层
  *
  * @author makejava
- * @since 2024-09-20 15:22:04
+ * @since 2024-09-23 17:14:13
  */
 public interface TOrderPublicReleaseCountMapper {
 

+ 46 - 16
src/main/java/com/goafanti/common/mapper/TOrderPublicReleaseCountMapper.xml

@@ -11,10 +11,11 @@
         <result property="maxDuration" column="max_duration" jdbcType="NUMERIC"/>
         <result property="maxProcess" column="max_process" jdbcType="INTEGER"/>
         <result property="maxType" column="max_type" jdbcType="INTEGER"/>
+        <result property="maxStatus" column="max_status" jdbcType="INTEGER"/>
     </resultMap>
 
     <sql id="TOrderPublicReleaseCountAllSql">
-        id, order_no, actual_duration, people_count, frequency, create_time, max_duration, max_process, max_type
+        id, order_no, actual_duration, people_count, frequency, create_time, max_duration, max_process, max_type, max_status
     </sql>
 
     <!--查询单个-->
@@ -59,6 +60,9 @@
             <if test="maxType != null">
                 and max_type = #{maxType}
             </if>
+            <if test="maxStatus != null">
+                and max_status = #{maxStatus}
+            </if>
         </where>
         <if test="page_sql != null">
             ${page_sql}
@@ -97,34 +101,37 @@
             <if test="maxType != null">
                 and max_type = #{maxType}
             </if>
+            <if test="maxStatus != null">
+                and max_status = #{maxStatus}
+            </if>
         </where>
     </select>
 
     <!--新增所有列-->
     <insert id="insert" keyProperty="id" useGeneratedKeys="true">
         insert into t_order_public_release_count(order_no, actual_duration, people_count, frequency, create_time,
-                                                 max_duration, max_process, max_type)
+                                                 max_duration, max_process, max_type, max_status)
         values (#{orderNo}, #{actualDuration}, #{peopleCount}, #{frequency}, #{createTime}, #{maxDuration},
-                #{maxProcess}, #{maxType})
+                #{maxProcess}, #{maxType}, #{maxStatus})
     </insert>
 
     <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
         insert into t_order_public_release_count(order_no, actual_duration, people_count, frequency, create_time,
-        max_duration, max_process, max_type)
+        max_duration, max_process, max_type, max_status)
         values
         <foreach collection="entities" item="entity" separator=",">
             (#{entity.orderNo}, #{entity.actualDuration}, #{entity.peopleCount}, #{entity.frequency},
-            #{entity.createTime}, #{entity.maxDuration}, #{entity.maxProcess}, #{entity.maxType})
+            #{entity.createTime}, #{entity.maxDuration}, #{entity.maxProcess}, #{entity.maxType}, #{entity.maxStatus})
         </foreach>
     </insert>
 
     <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
         insert into t_order_public_release_count(order_no, actual_duration, people_count, frequency, create_time,
-        max_duration, max_process, max_type)
+        max_duration, max_process, max_type, max_status)
         values
         <foreach collection="entities" item="entity" separator=",">
             (#{entity.orderNo}, #{entity.actualDuration}, #{entity.peopleCount}, #{entity.frequency},
-            #{entity.createTime}, #{entity.maxDuration}, #{entity.maxProcess}, #{entity.maxType})
+            #{entity.createTime}, #{entity.maxDuration}, #{entity.maxProcess}, #{entity.maxType}, #{entity.maxStatus})
         </foreach>
         on duplicate key update
         order_no = values(order_no),
@@ -134,7 +141,8 @@
         create_time = values(create_time),
         max_duration = values(max_duration),
         max_process = values(max_process),
-        max_type = values(max_type)
+        max_type = values(max_type),
+        max_status = values(max_status)
     </insert>
 
     <!--通过主键修改数据-->
@@ -165,6 +173,9 @@
             <if test="maxType != null">
                 max_type = #{maxType},
             </if>
+            <if test="maxStatus != null">
+                max_status = #{maxStatus},
+            </if>
         </set>
         where id = #{id}
     </update>
@@ -179,19 +190,38 @@
 
     <update id="updateByOrderNo">
         update t_order_public_release_count
-        set
-            actual_duration =  #{actualDuration,jdbcType=DOUBLE},
-            people_count =  #{peopleCount,jdbcType=INTEGER},
-            frequency =  #{frequency,jdbcType=INTEGER},
-            max_duration = #{maxDuration},
-            max_process = #{maxProcess},
-            max_type = #{maxType}
+        <set>
+            <if test="actualDuration != null">
+                actual_duration = #{actualDuration},
+            </if>
+            <if test="peopleCount != null">
+                people_count = #{peopleCount},
+            </if>
+            <if test="frequency != null">
+                frequency = #{frequency},
+            </if>
+            <if test="createTime != null">
+                create_time = #{createTime},
+            </if>
+            <if test="maxDuration != null">
+                max_duration = #{maxDuration},
+            </if>
+            <if test="maxProcess != null">
+                max_process = #{maxProcess},
+            </if>
+            <if test="maxType != null">
+                max_type = #{maxType},
+            </if>
+            <if test="maxStatus != null">
+                max_status = #{maxStatus},
+            </if>
+        </set>
         where   order_no =  #{orderNo,jdbcType=VARCHAR}
     </update>
 
     <select id="selectByOrderNo"  resultMap="TOrderPublicReleaseCountMap">
         select
-            id, order_no, actual_duration, people_count, frequency, create_time,max_duration, max_process,max_type
+        <include refid="TOrderPublicReleaseCountAllSql"/>
         from t_order_public_release_count
         where  order_no =  #{orderNo,jdbcType=VARCHAR}
     </select>

+ 14 - 2
src/main/java/com/goafanti/common/model/TOrderPublicReleaseCount.java

@@ -8,10 +8,10 @@ import java.util.Date;
  * 订单公出信息表(TOrderPublicReleaseCount)实体类
  *
  * @author makejava
- * @since 2024-09-20 15:22:04
+ * @since 2024-09-23 17:14:13
  */
 public class TOrderPublicReleaseCount implements Serializable {
-    private static final long serialVersionUID = -56144493896307473L;
+    private static final long serialVersionUID = 655526116471477610L;
 
     private Integer id;
     /**
@@ -46,6 +46,10 @@ public class TOrderPublicReleaseCount implements Serializable {
      * 最大分类 0=不能公出,1=时间内公出,2=未设置公出
      */
     private Integer maxType;
+    /**
+     * 最大状态 0=未修改,1=已修改
+     */
+    private Integer maxStatus;
 
 
     public Integer getId() {
@@ -120,5 +124,13 @@ public class TOrderPublicReleaseCount implements Serializable {
         this.maxType = maxType;
     }
 
+    public Integer getMaxStatus() {
+        return maxStatus;
+    }
+
+    public void setMaxStatus(Integer maxStatus) {
+        this.maxStatus = maxStatus;
+    }
+
 }
 

+ 2 - 2
src/main/java/com/goafanti/weChat/controller/AdminReleaseApiController.java

@@ -549,7 +549,7 @@ public class AdminReleaseApiController extends CertifyApiController{
 	 * 修改最大公出
 	 */
 	@RequestMapping(value = "/updateMaxDuration",method = RequestMethod.POST)
-	public Result updateMaxDuration (String orderNo,Double maxDuration,String remarks){
+	public Result updateMaxDuration (String orderNo, Double maxDuration, String remarks){
 		Result res =new Result();
 		if (StringUtils.isEmpty(orderNo)){
 			return res().error(buildError(ErrorConstants.PARAM_ERROR,"订单编号"));
@@ -562,7 +562,7 @@ public class AdminReleaseApiController extends CertifyApiController{
 	}
 
 	/**
-	 * 修改最大公出
+	 * 审核最大公出
 	 */
 	@RequestMapping(value = "/examineMaxDuration",method = RequestMethod.POST)
 	public Result examineMaxDuration (String orderNo,Integer status,String remarks){

+ 25 - 4
src/main/java/com/goafanti/weChat/service/impl/PublicReleaseServiceImpl.java

@@ -1195,10 +1195,22 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 	@Override
 	public Object updateMaxDuration(String orderNo, Double maxDuration,String remarks) {
 		TOrderPublicReleaseCount in =new TOrderPublicReleaseCount();
+		TOrderPublicReleaseCount use = tOrderPublicReleaseCountMapper.selectByOrderNo(orderNo);
+		if (use.getMaxProcess()==1||use.getMaxProcess()==2){
+			throw new BusinessException("该最大公出已经是待审核的状态。");
+		}
 		in.setOrderNo(orderNo);
 		in.setMaxDuration(maxDuration);
 		in.setMaxProcess(1);
 		addOrderPublicReleaseLog(orderNo,0,0,remarks);
+		List<Admin> admins = adminMapper.selectAdminByRoleType(AFTConstants.TECH_ADMIN);
+		TOrderNewBo order = tOrderNewMapper.getSaleIdByOno(orderNo);
+		StringBuilder str=new StringBuilder();
+		str.append("合同编号[").append(order.getContractNo()).append("]最大公出限制审核");
+		str.append("需要审核,请尽快审核。");
+		admins.forEach(e->{
+			addNoticeAndEmail(e.getId(),NoticeStatus.PUBLIC_MAX_DURATION.getCode(), str.toString());
+		});
 		tOrderPublicReleaseCountMapper.updateByOrderNo(in);
 		return 1;
 	}
@@ -1206,18 +1218,27 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 	@Override
 	public Object pushExamineMaxDuration(String orderNo,Integer status, String remarks) {
 		TOrderPublicReleaseCount in =new TOrderPublicReleaseCount();
+		TOrderPublicReleaseCount use = tOrderPublicReleaseCountMapper.selectByOrderNo(orderNo);
 		in.setOrderNo(orderNo);
-		int examine =0;
+		Integer examine =null;
 		int process =0;
 		if (TokenManager.hasRole(AFTConstants.TECH_ADMIN)&&TokenManager.hasRole(AFTConstants.FINANCE_ADMIN)){
 			process=4;
 			examine=0;
 		}else if (TokenManager.hasRole(AFTConstants.TECH_ADMIN)){
+			if (use.getMaxProcess()!=1){
+				throw new BusinessException("审核人错误,必须是技术管理员才能审核。");
+			}
 			examine=1;
 			process=2;
 		}else if (TokenManager.hasRole(AFTConstants.FINANCE_ADMIN)){
+			if (use.getMaxProcess()!=2){
+				throw new BusinessException("审核人错误,必须是财务管理员才能审核。");
+			}
 			examine=2;
 			process=4;
+		}else {
+			throw new BusinessException("审核人错误,必须是技术/财务管理员才能审核。");
 		}
 		TOrderNewBo order = tOrderNewMapper.getSaleIdByOno(orderNo);
 		StringBuilder str=new StringBuilder();
@@ -1232,10 +1253,10 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 			}else if (examine==1){
 				addOrderPublicReleaseLog(orderNo,status,examine,remarks);
 				if (examine==1){
-					List<Admin> admins = adminMapper.selectAdminByRoleType(AFTConstants.TECH_ADMIN);
+					List<Admin> admins = adminMapper.selectAdminByRoleType(AFTConstants.FINANCE_ADMIN);
 					str.append("需要审核,请尽快审核。");
 					admins.forEach(e->{
-						addNoticeAndEmail(order.getSalesmanId(),NoticeStatus.PUBLIC_MAX_DURATION_YES.getCode(), str.toString());
+						addNoticeAndEmail(e.getId(),NoticeStatus.PUBLIC_MAX_DURATION_YES.getCode(), str.toString());
 					});
 
 				}
@@ -1245,7 +1266,7 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 			str.append("已驳回。");
 			addNoticeAndEmail(order.getSalesmanId(),NoticeStatus.PUBLIC_MAX_DURATION_YES.getCode(), str.toString());
 		}
-		return tOrderPublicReleaseCountMapper.update(in);
+		return tOrderPublicReleaseCountMapper.updateByOrderNo(in);
 	}
 
 	private void addNoticeAndEmail(String aid, Integer noticeStatus, String remarks) {