Browse Source

申购单

caozj 2 năm trước cách đây
mục cha
commit
f4392f3c34
20 tập tin đã thay đổi với 972 bổ sung1 xóa
  1. 18 0
      bladex/blade-common/src/main/java/org/springblade/common/utils/CodeUtil.java
  2. 55 0
      bladex/blade-common/src/main/java/org/springblade/common/utils/DateUtil.java
  3. 92 0
      hx-saas-project/saas-entity/src/main/java/com/fjhx/subscribe/entity/ApplyPurchase.java
  4. 66 0
      hx-saas-project/saas-entity/src/main/java/com/fjhx/subscribe/entity/ApplyPurchasedetail.java
  5. 69 0
      hx-saas-project/saas-entity/src/main/java/com/fjhx/subscribe/enums/ApplyPurchaseStatusEnum.java
  6. 66 0
      hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/controller/ApplyPurchaseController.java
  7. 45 0
      hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/controller/ApplyPurchaseFlowController.java
  8. 64 0
      hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/controller/ApplyPurchasedetailController.java
  9. 33 0
      hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/mapper/ApplyPurchaseMapper.java
  10. 24 0
      hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/mapper/ApplyPurchaseMapper.xml
  11. 31 0
      hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/mapper/ApplyPurchasedetailMapper.java
  12. 19 0
      hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/mapper/ApplyPurchasedetailMapper.xml
  13. 51 0
      hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/service/IApplyPurchaseFlowService.java
  14. 31 0
      hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/service/IApplyPurchaseService.java
  15. 31 0
      hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/service/IApplyPurchasedetailService.java
  16. 208 0
      hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/service/impl/ApplyPurchaseFlowServiceImpl.java
  17. 34 0
      hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/service/impl/ApplyPurchaseServiceImpl.java
  18. 34 0
      hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/service/impl/ApplyPurchasedetailServiceImpl.java
  19. 0 1
      hx-saas-project/saas-storage/src/main/java/com/fjhx/supplier/mapper/SupplierMapper.xml
  20. 1 0
      hx-service/storage/src/main/java/com/fjhx/supplier/mapper/SupplierMapper.xml

+ 18 - 0
bladex/blade-common/src/main/java/org/springblade/common/utils/CodeUtil.java

@@ -1,6 +1,10 @@
 package org.springblade.common.utils;
 
+import io.undertow.util.DateUtils;
+
 import java.text.DecimalFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 
 /**
  * 编码生成工具类
@@ -21,4 +25,18 @@ public class CodeUtil {
         String k=decimalFormat.format(i);
         return "C"+k;
     }
+
+    /**
+     * 生成申购单编码
+     * @param code
+     * @return
+     */
+    public static String generateSubscribeCode(String code){
+        String date = new SimpleDateFormat("yyyyMMdd").format(new Date());
+        DecimalFormat decimalFormat=new DecimalFormat("0000");
+        String codenew=code.substring(1);
+        int i=Integer.parseInt(codenew)+1;
+        String k=decimalFormat.format(i);
+        return "PR-"+date+"-"+k;
+    }
 }

+ 55 - 0
bladex/blade-common/src/main/java/org/springblade/common/utils/DateUtil.java

@@ -0,0 +1,55 @@
+package org.springblade.common.utils;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ * @Author:caozj
+ * @DATE:2022/7/14 17:23
+ */
+public class DateUtil {
+    /**
+     * 时间添加或减少
+     *
+     * @param str
+     * @param day
+     * @return
+     */
+    public static String dateMinusMonth(String str, int day) {
+        try {
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+            Date dt = null;//将字符串生成Date
+            dt = sdf.parse(str);
+            Calendar rightNow = Calendar.getInstance();
+            rightNow.setTime(dt);//使用给定的 Date 设置此 Calendar 的时间。
+            rightNow.add(Calendar.DAY_OF_MONTH, day);
+            Date dt1 = rightNow.getTime();//返回一个表示此 Calendar 时间值的 Date 对象。
+            String reStr = sdf.format(dt1);//将给定的 Date 格式化为日期/时间字符串,并将结果添加到给定的 StringBuffer。
+            return reStr;
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    /**
+     * 判断日期距离现在多少天
+     * @param date
+     * @return
+     * @throws ParseException
+     */
+    public static String differenceDate(String date) throws ParseException {
+        SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");//指定格式时间转换
+        Date d=simpleDateFormat.parse(date);//转换成日期
+        long datetime=d.getTime();//时间转换成毫秒值
+        long todaytime=new Date().getTime();//获取当前日期毫秒值
+        long Difference=todaytime-datetime;//差值
+        return String.valueOf(Difference/1000/60/60/24);
+    }
+
+    public static void main(String[] args) throws ParseException {
+
+    }
+}

+ 92 - 0
hx-saas-project/saas-entity/src/main/java/com/fjhx/subscribe/entity/ApplyPurchase.java

@@ -0,0 +1,92 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.fjhx.subscribe.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.time.LocalDateTime;
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+import com.fjhx.base.BaseStockEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * 申购单实体类
+ *
+ * @author BladeX
+ * @since 2022-07-26
+ */
+@Data
+@TableName("stock_apply_purchase")
+@ApiModel(value = "ApplyPurchase对象", description = "申购单")
+public class ApplyPurchase extends BaseStockEntity {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	* 申购单号
+	*/
+	@ApiModelProperty(value = "申购单号")
+	private String applyBillNo;
+	/**
+	* 申购部门
+	*/
+	@ApiModelProperty(value = "申购部门")
+	private String departName;
+	/**
+	* 申请时间
+	*/
+	@ApiModelProperty(value = "申请时间")
+	private Date applyTime;
+	/**
+	* 申购说明
+	*/
+	@ApiModelProperty(value = "申购说明")
+	private String applyAccount;
+	/**
+	* 申购类型 (枚举定义:0=物料,1=行政)
+	*/
+	@ApiModelProperty(value = "申购类型 (枚举定义:0=物料,1=行政)")
+	private Integer applyPurType;
+	/**
+	* 申购内容
+	*/
+	@ApiModelProperty(value = "申购内容")
+	private String purchaseContent;
+	/**
+	* 审批状态 (枚举定义:0=待审批,1=审批中,2=已审批,3=已驳回,4=已撤回)
+	*/
+	@ApiModelProperty(value = "审批状态 (枚举定义:0=待审批,1=审批中,2=已审批,3=已驳回,4=已撤回)")
+	private Integer approveBillState;
+	/**
+	* 审核时间
+	*/
+	@ApiModelProperty(value = "审核时间")
+	private Date approvalTime;
+	/**
+	* 安全库存自动生成
+	*/
+	@ApiModelProperty(value = "安全库存自动生成")
+	private Boolean safetyStockCreate;
+
+
+	private List<ApplyPurchasedetail> purchasedetailList;
+}

+ 66 - 0
hx-saas-project/saas-entity/src/main/java/com/fjhx/subscribe/entity/ApplyPurchasedetail.java

@@ -0,0 +1,66 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.fjhx.subscribe.entity;
+
+import java.math.BigDecimal;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.time.LocalDateTime;
+import java.io.Serializable;
+
+import com.fjhx.base.BaseStockEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * 申购单明细实体类
+ *
+ * @author BladeX
+ * @since 2022-07-26
+ */
+@Data
+@TableName("stock_apply_purchasedetail")
+@ApiModel(value = "ApplyPurchasedetail对象", description = "申购单明细")
+public class ApplyPurchasedetail extends BaseStockEntity {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	* 申购ID
+	*/
+	@ApiModelProperty(value = "申购ID")
+	private String applyPurchaseId;
+	/**
+	* 物料Code
+	*/
+	@ApiModelProperty(value = "物料Code")
+	private String materialId;
+	/**
+	* 申购数量
+	*/
+	@ApiModelProperty(value = "申购数量")
+	private BigDecimal purchaseQty;
+	/**
+	* 用途
+	*/
+	@ApiModelProperty(value = "用途")
+	private String purpose;
+
+
+}

+ 69 - 0
hx-saas-project/saas-entity/src/main/java/com/fjhx/subscribe/enums/ApplyPurchaseStatusEnum.java

@@ -0,0 +1,69 @@
+package com.fjhx.subscribe.enums;
+
+import org.apache.commons.collections4.MapUtils;
+import org.springblade.core.tool.utils.StringPool;
+
+import java.util.LinkedHashMap;
+
+/**
+ * 申购单状态
+ * 枚举定义:0=待审批,1=审批中,2=已审批,3=已驳回,4=已撤回)
+ */
+public enum ApplyPurchaseStatusEnum {
+
+    APPLY_PURCHASE_STATUS_0(0, "待审批"),
+    APPLY_PURCHASE_STATUS_1(1, "审批中"),
+    APPLY_PURCHASE_STATUS_2(2, "已审批"),
+    APPLY_PURCHASE_STATUS_3(3, "已驳回"),
+    APPLY_PURCHASE_STATUS_4(4, "已撤回"),
+    ;
+
+    private int key;
+
+    private String value;
+
+    private static LinkedHashMap<Integer, String> map = new LinkedHashMap<>();
+
+    ApplyPurchaseStatusEnum(int key, String value) {
+        this.key = key;
+        this.value = value;
+    }
+
+    /**
+     * 获取枚举map
+     *
+     * @return
+     */
+    public static LinkedHashMap<Integer, String> getMap() {
+        if (MapUtils.isNotEmpty(map)) {
+            return map;
+        }
+        for (ApplyPurchaseStatusEnum ms : values()) {
+            map.put(ms.key, ms.value);
+        }
+        return map;
+    }
+
+    /**
+     * 通过key获取名称
+     *
+     * @param key
+     * @return
+     */
+    public static String getNameByKey(Integer key) {
+        if (key == null || key < 0) {
+            return "";
+        }
+        LinkedHashMap<Integer, String> map = getMap();
+        return map.getOrDefault(key, StringPool.EMPTY);
+    }
+
+    public int getKey() {
+        return key;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+}

+ 66 - 0
hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/controller/ApplyPurchaseController.java

@@ -0,0 +1,66 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.fjhx.subscribe.controller;
+
+import com.fjhx.subscribe.entity.ApplyPurchase;
+import com.fjhx.subscribe.service.IApplyPurchaseService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.AllArgsConstructor;
+import javax.validation.Valid;
+
+import org.springblade.common.constant.ApiConstant;
+import org.springblade.core.mp.support.Condition;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
+import org.springframework.web.bind.annotation.*;
+import org.springblade.core.boot.ctrl.BladeController;
+
+/**
+ * 申购单 控制器
+ *
+ * @author BladeX
+ * @since 2022-07-26
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping(ApiConstant.Project.SAAS_STORAGE_REQUEST_PREFIX+"/applypurchase")
+@Api(value = "申购单", tags = "申购单接口")
+public class ApplyPurchaseController extends BladeController {
+
+	private final IApplyPurchaseService applyPurchaseService;
+
+	/**
+	 * 详情
+	 */
+	@GetMapping("/detail")
+	public R<ApplyPurchase> detail(ApplyPurchase applyPurchase) {
+		ApplyPurchase detail = applyPurchaseService.getOne(Condition.getQueryWrapper(applyPurchase));
+		return R.data(detail);
+	}
+	
+	/**
+	 * 删除 申购单
+	 */
+	@PostMapping("/remove")
+	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
+		return R.status(applyPurchaseService.removeByIds(Func.toLongList(ids)));
+	}
+
+	
+}

+ 45 - 0
hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/controller/ApplyPurchaseFlowController.java

@@ -0,0 +1,45 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.fjhx.subscribe.controller;
+
+import com.fjhx.subscribe.entity.ApplyPurchase;
+import com.fjhx.subscribe.service.IApplyPurchaseService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiParam;
+import lombok.AllArgsConstructor;
+import org.springblade.common.constant.ApiConstant;
+import org.springblade.core.boot.ctrl.BladeController;
+import org.springblade.core.mp.support.Condition;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 申购单流程 控制器
+ *
+ * @author BladeX
+ * @since 2022-07-26
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping(ApiConstant.Project.SAAS_STORAGE_REQUEST_PREFIX+"/applypurchase/flow")
+@Api(value = "申购单流程", tags = "申购单接口")
+public class ApplyPurchaseFlowController extends BladeController {
+
+	private final IApplyPurchaseService applyPurchaseService;
+	
+}

+ 64 - 0
hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/controller/ApplyPurchasedetailController.java

@@ -0,0 +1,64 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.fjhx.subscribe.controller;
+
+import com.fjhx.subscribe.entity.ApplyPurchasedetail;
+import com.fjhx.subscribe.service.IApplyPurchasedetailService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiParam;
+import lombok.AllArgsConstructor;
+
+import org.springblade.common.constant.ApiConstant;
+import org.springblade.core.mp.support.Condition;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
+import org.springframework.web.bind.annotation.*;
+import org.springblade.core.boot.ctrl.BladeController;
+
+/**
+ * 申购单明细 控制器
+ *
+ * @author BladeX
+ * @since 2022-07-26
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping(ApiConstant.Project.SAAS_STORAGE_REQUEST_PREFIX+"/applypurchasedetail")
+@Api(value = "申购单明细", tags = "申购单明细接口")
+public class ApplyPurchasedetailController extends BladeController {
+
+	private final IApplyPurchasedetailService applyPurchasedetailService;
+
+	/**
+	 * 详情
+	 */
+	@GetMapping("/detail")
+	public R<ApplyPurchasedetail> detail(ApplyPurchasedetail applyPurchasedetail) {
+		ApplyPurchasedetail detail = applyPurchasedetailService.getOne(Condition.getQueryWrapper(applyPurchasedetail));
+		return R.data(detail);
+	}
+
+	/**
+	 * 删除 申购单明细
+	 */
+	@PostMapping("/remove")
+	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
+		return R.status(applyPurchasedetailService.removeByIds(Func.toLongList(ids)));
+	}
+
+	
+}

+ 33 - 0
hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/mapper/ApplyPurchaseMapper.java

@@ -0,0 +1,33 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.fjhx.subscribe.mapper;
+
+import com.fjhx.subscribe.entity.ApplyPurchase;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import java.util.List;
+
+/**
+ * 申购单 Mapper 接口
+ *
+ * @author BladeX
+ * @since 2022-07-26
+ */
+public interface ApplyPurchaseMapper extends BaseMapper<ApplyPurchase> {
+
+
+}

+ 24 - 0
hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/mapper/ApplyPurchaseMapper.xml

@@ -0,0 +1,24 @@
+<?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.fjhx.subscribe.mapper.ApplyPurchaseMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="applyPurchaseResultMap" type="com.fjhx.subscribe.entity.ApplyPurchase">
+        <id column="id" property="id"/>
+        <result column="is_delete" property="isDelete"/>
+        <result column="create_time" property="createTime"/>
+        <result column="update_time" property="updateTime"/>
+        <result column="create_user" property="createUser"/>
+        <result column="update_user" property="updateUser"/>
+        <result column="apply_bill_no" property="applyBillNo"/>
+        <result column="depart_name" property="departName"/>
+        <result column="apply_time" property="applyTime"/>
+        <result column="apply_account" property="applyAccount"/>
+        <result column="apply_pur_type" property="applyPurType"/>
+        <result column="purchase_content" property="purchaseContent"/>
+        <result column="approve_bill_state" property="approveBillState"/>
+        <result column="approval_time" property="approvalTime"/>
+        <result column="safety_stock_create" property="safetyStockCreate"/>
+    </resultMap>
+
+</mapper>

+ 31 - 0
hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/mapper/ApplyPurchasedetailMapper.java

@@ -0,0 +1,31 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.fjhx.subscribe.mapper;
+
+import com.fjhx.subscribe.entity.ApplyPurchasedetail;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+/**
+ * 申购单明细 Mapper 接口
+ *
+ * @author BladeX
+ * @since 2022-07-26
+ */
+public interface ApplyPurchasedetailMapper extends BaseMapper<ApplyPurchasedetail> {
+
+}

+ 19 - 0
hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/mapper/ApplyPurchasedetailMapper.xml

@@ -0,0 +1,19 @@
+<?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.fjhx.subscribe.mapper.ApplyPurchasedetailMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="applyPurchasedetailResultMap" type="com.fjhx.subscribe.entity.ApplyPurchasedetail">
+        <id column="ID" property="id"/>
+        <result column="is_delete" property="isDelete"/>
+        <result column="create_time" property="createTime"/>
+        <result column="update_time" property="updateTime"/>
+        <result column="create_user" property="createUser"/>
+        <result column="update_user" property="updateUser"/>
+        <result column="apply_purchase_id" property="applyPurchaseId"/>
+        <result column="material_id" property="materialId"/>
+        <result column="purchase_qty" property="purchaseQty"/>
+        <result column="purpose" property="purpose"/>
+    </resultMap>
+
+</mapper>

+ 51 - 0
hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/service/IApplyPurchaseFlowService.java

@@ -0,0 +1,51 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.fjhx.subscribe.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.fjhx.flow.entity.FlowParam;
+import com.fjhx.subscribe.entity.ApplyPurchase;
+
+/**
+ * 申购单流程 服务类
+ *
+ * @author BladeX
+ * @since 2022-07-26
+ */
+public interface IApplyPurchaseFlowService extends IService<ApplyPurchase> {
+
+    /**
+     * 开始流程
+     *
+     * @param applyPurchase
+     */
+    void start(ApplyPurchase applyPurchase);
+
+    /**
+     * 审核
+     *
+     * @param condition
+     */
+    void examine(FlowParam condition);
+
+    /**
+     * 驳回
+     *
+     * @param condition
+     */
+    void reject(FlowParam condition);
+}

+ 31 - 0
hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/service/IApplyPurchaseService.java

@@ -0,0 +1,31 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.fjhx.subscribe.service;
+
+import com.fjhx.subscribe.entity.ApplyPurchase;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+/**
+ * 申购单 服务类
+ *
+ * @author BladeX
+ * @since 2022-07-26
+ */
+public interface IApplyPurchaseService extends IService<ApplyPurchase> {
+
+}

+ 31 - 0
hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/service/IApplyPurchasedetailService.java

@@ -0,0 +1,31 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.fjhx.subscribe.service;
+
+import com.fjhx.subscribe.entity.ApplyPurchasedetail;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+/**
+ * 申购单明细 服务类
+ *
+ * @author BladeX
+ * @since 2022-07-26
+ */
+public interface IApplyPurchasedetailService extends IService<ApplyPurchasedetail> {
+
+}

+ 208 - 0
hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/service/impl/ApplyPurchaseFlowServiceImpl.java

@@ -0,0 +1,208 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.fjhx.subscribe.service.impl;
+
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fjhx.flow.entity.Flow;
+import com.fjhx.flow.entity.FlowParam;
+import com.fjhx.myapp.application.feign.IFlowApi;
+import com.fjhx.subscribe.entity.ApplyPurchase;
+import com.fjhx.subscribe.entity.ApplyPurchasedetail;
+import com.fjhx.subscribe.enums.ApplyPurchaseStatusEnum;
+import com.fjhx.subscribe.mapper.ApplyPurchaseMapper;
+import com.fjhx.subscribe.service.IApplyPurchaseFlowService;
+import com.fjhx.subscribe.service.IApplyPurchaseService;
+import com.fjhx.subscribe.service.IApplyPurchasedetailService;
+import com.fjhx.supplier.entity.Supplier;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springblade.common.utils.CodeUtil;
+import org.springblade.core.log.exception.ServiceException;
+import org.springblade.core.secure.utils.AuthUtil;
+import org.springblade.core.tool.utils.ObjectUtil;
+import org.springblade.core.tool.utils.StringUtil;
+import org.springblade.system.user.entity.User;
+import org.springblade.system.user.feign.IUserClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * 申购单流程 服务实现类
+ *
+ * @author BladeX
+ * @since 2022-07-26
+ */
+@Service
+public class ApplyPurchaseFlowServiceImpl extends ServiceImpl<ApplyPurchaseMapper, ApplyPurchase> implements IApplyPurchaseFlowService {
+
+    @Autowired
+    private IFlowApi flowApi;
+    @Autowired
+    private IUserClient userClient;
+    @Autowired
+    private IApplyPurchasedetailService iApplyPurchasedetailService;
+    /**
+     * 发起流程
+     * @param applyPurchase
+     */
+    @Override
+    public void start(ApplyPurchase applyPurchase) {
+        //状态=审批中
+        applyPurchase.setApproveBillState(ApplyPurchaseStatusEnum.APPLY_PURCHASE_STATUS_1.getKey());
+        User user = userClient.infoUser(AuthUtil.getUserIdStr());
+        if(StringUtils.isEmpty(applyPurchase.getApplyBillNo())){
+            //生成code
+            ApplyPurchase sCode = getOne(Wrappers.<ApplyPurchase>query().lambda().orderByDesc(ApplyPurchase::getApplyBillNo).last("limit 1"));
+            String date = new SimpleDateFormat("yyyyMMdd").format(new Date());
+            String code = "PR-"+date+"-0001";
+            if(ObjectUtil.isEmpty(sCode)){
+                applyPurchase.setApplyBillNo(code);
+            }else{
+                applyPurchase.setApplyBillNo(sCode.getApplyBillNo()==null?code: CodeUtil.generateSubscribeCode(sCode.getApplyBillNo()));
+            }
+        }
+        //发起审批
+        String title = user.getName() + " 在" + LocalDate.now() + "日发起了 申购单审批流程(单号" + applyPurchase.getApplyBillNo() + ")";
+        if (StringUtils.isBlank(applyPurchase.getId())) {
+            saveApplyPurchase(applyPurchase);
+        }else{
+            updateApplyPurchase(applyPurchase);
+        }
+        //发起流程
+        FlowParam param = setValue(title,null,null,"subscribe",null);
+        try {
+            flowApi.startFlow(param);
+        }catch (Exception e){
+            throw new ServiceException("流程异常");
+        }
+    }
+
+    /**
+     * 审批
+     * @param condition
+     */
+    @Override
+    public void examine(FlowParam condition) {
+        if (StringUtils.isAnyBlank(condition.getBusinessId(), condition.getProInstantsId())) {
+            throw new ServiceException("参数缺失");
+        }
+        //查询申购单信息
+        ApplyPurchase applyPurchase = this.getById(condition.getBusinessId());
+        if (applyPurchase == null) {
+            throw new ServiceException("申购单不存在");
+        }
+        try {
+            Boolean flowResult = flowApi.examineFlow(condition);
+            if(flowResult){//流程结束
+                ApplyPurchase update = new ApplyPurchase();
+                update.setId(condition.getBusinessId());
+                update.setApprovalTime(new Date());
+                update.setApproveBillState(ApplyPurchaseStatusEnum.APPLY_PURCHASE_STATUS_2.getKey());
+                this.updateById(update);
+            }
+        }catch (Exception e){
+            throw new ServiceException("流程异常");
+        }
+    }
+
+    /**
+     * 驳回
+     * @param condition
+     */
+    @Override
+    public void reject(FlowParam condition) {
+        if (StringUtils.isAnyBlank(condition.getBusinessId(), condition.getProInstantsId())) {
+            throw new ServiceException("参数缺失");
+        }
+        try {
+            Boolean flowResult = flowApi.rejectFlow(condition);//驳回完后判断流程是否结束。还是转交到上一个节点
+            if(flowResult){//流程结束
+                ApplyPurchase update = new ApplyPurchase();
+                update.setId(condition.getBusinessId());
+                update.setApproveBillState(ApplyPurchaseStatusEnum.APPLY_PURCHASE_STATUS_3.getKey());
+                this.updateById(update);
+            }
+        }catch (Exception e){
+            throw new ServiceException("流程异常");
+        }
+    }
+
+    /**
+     * 设置流程属性
+     * @param title
+     * @param common
+     * @param businessId
+     * @param flowIdentifying
+     * @param proInstantsId
+     * @return
+     */
+    private FlowParam setValue(String title,String common,String businessId,String flowIdentifying,String proInstantsId){
+        FlowParam param = new FlowParam();
+        param.setCommon(common);
+        param.setBusinessId(businessId);
+        param.setFlowIdentifying(flowIdentifying);
+        param.setTitle(title);
+        return param;
+    }
+
+    /**
+     * 新增
+     * @param applyPurchase
+     */
+    private void saveApplyPurchase(ApplyPurchase applyPurchase){
+        applyPurchase.setCreate();
+        save(applyPurchase);
+        //申购明细保存
+        List<ApplyPurchasedetail> applyPurchasedetailList = applyPurchase.getPurchasedetailList();
+        if(CollectionUtils.isNotEmpty(applyPurchasedetailList)){
+            for(ApplyPurchasedetail d:applyPurchasedetailList){
+                d.setCreate();
+                d.setApplyPurchaseId(applyPurchase.getId());
+            }
+            iApplyPurchasedetailService.saveBatch(applyPurchasedetailList);
+        }
+    }
+
+    /**
+     * 修改
+     * @param applyPurchase
+     */
+    private void updateApplyPurchase(ApplyPurchase applyPurchase){
+        applyPurchase.setUpdate();
+        updateById(applyPurchase);
+        //申购明细修改
+        List<ApplyPurchasedetail> applyPurchasedetailList = applyPurchase.getPurchasedetailList();
+        if(CollectionUtils.isNotEmpty(applyPurchasedetailList)){
+            //清空申购明细
+            iApplyPurchasedetailService.remove(Wrappers.<ApplyPurchasedetail>query().lambda().eq(ApplyPurchasedetail::getApplyPurchaseId,applyPurchase.getId()));
+            for(ApplyPurchasedetail d:applyPurchasedetailList){
+                d.setCreate();
+                d.setApplyPurchaseId(applyPurchase.getId());
+            }
+            iApplyPurchasedetailService.saveBatch(applyPurchasedetailList);
+        }
+
+    }
+}

+ 34 - 0
hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/service/impl/ApplyPurchaseServiceImpl.java

@@ -0,0 +1,34 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.fjhx.subscribe.service.impl;
+
+import com.fjhx.subscribe.entity.ApplyPurchase;
+import com.fjhx.subscribe.mapper.ApplyPurchaseMapper;
+import com.fjhx.subscribe.service.IApplyPurchaseService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 申购单 服务实现类
+ *
+ * @author BladeX
+ * @since 2022-07-26
+ */
+@Service
+public class ApplyPurchaseServiceImpl extends ServiceImpl<ApplyPurchaseMapper, ApplyPurchase> implements IApplyPurchaseService {
+
+}

+ 34 - 0
hx-saas-project/saas-storage/src/main/java/com/fjhx/subscribe/service/impl/ApplyPurchasedetailServiceImpl.java

@@ -0,0 +1,34 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.fjhx.subscribe.service.impl;
+
+import com.fjhx.subscribe.entity.ApplyPurchasedetail;
+import com.fjhx.subscribe.mapper.ApplyPurchasedetailMapper;
+import com.fjhx.subscribe.service.IApplyPurchasedetailService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 申购单明细 服务实现类
+ *
+ * @author BladeX
+ * @since 2022-07-26
+ */
+@Service
+public class ApplyPurchasedetailServiceImpl extends ServiceImpl<ApplyPurchasedetailMapper, ApplyPurchasedetail> implements IApplyPurchasedetailService {
+
+}

+ 0 - 1
hx-saas-project/saas-storage/src/main/java/com/fjhx/supplier/mapper/SupplierMapper.xml

@@ -96,7 +96,6 @@
     <sql id="list_condition">
         <where>
             t1.is_delete = 0
-            AND t1.CategoryCode NOT IN ("02.","02.003.")
             <if test="search neq null and search neq '' ">
                 AND ((INSTR(t1.`name`, #{search}) > 0) OR (INSTR(t1.`code`, #{search}) > 0) )
             </if>

+ 1 - 0
hx-service/storage/src/main/java/com/fjhx/supplier/mapper/SupplierMapper.xml

@@ -262,6 +262,7 @@
     <sql id="list_condition">
         <where>
             t1.IsDelete = 0
+            AND t1.CategoryCode NOT IN ("02.","02.003.")
             <if test="search neq null and search neq '' ">
                 AND ((INSTR(t1.`Name`, #{search}) > 0) OR (INSTR(t1.`Code`, #{search}) > 0) )
             </if>