Просмотр исходного кода

Merge remote-tracking branch 'origin/dev' into dev

heqinwei 7 лет назад
Родитель
Сommit
984e7072d3
100 измененных файлов с 3617 добавлено и 374 удалено
  1. 1 1
      applications/commons/commons-api/src/main/java/com/usoftchina/saas/commons/api/MaxnumberService.java
  2. 2 1
      applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/exception/BizExceptionCode.java
  3. 7 5
      applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/po/Status.java
  4. 6 4
      applications/document/document-api/src/main/java/com/usoftchina/saas/document/api/WarehouseApi.java
  5. 148 0
      applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/Bom.java
  6. 136 0
      applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/BomDetail.java
  7. 26 0
      applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/BomList.java
  8. 1 13
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/DocumentApplication.java
  9. 41 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/BomController.java
  10. 53 12
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/CustomerController.java
  11. 1 1
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/FundinouttypeController.java
  12. 4 4
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/VendorController.java
  13. 4 4
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/WarehouseController.java
  14. 26 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/BomDetailMapper.java
  15. 25 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/BomMapper.java
  16. 48 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/BomService.java
  17. 10 2
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/CustomerService.java
  18. 1 1
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/VendorService.java
  19. 0 1
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/AddressServiceImpl.java
  20. 124 0
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/BomServiceImpl.java
  21. 83 2
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/CustomerServiceImpl.java
  22. 15 2
      applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/VendorServiceImpl.java
  23. 0 1
      applications/document/document-server/src/main/resources/application.yml
  24. 396 0
      applications/document/document-server/src/main/resources/mapper/BomDetailMapper.xml
  25. 251 0
      applications/document/document-server/src/main/resources/mapper/BomMapper.xml
  26. 1 1
      applications/document/document-server/src/main/resources/mapper/CustomeraddressMapper.xml
  27. 1 1
      applications/document/document-server/src/main/resources/mapper/CustomercontactMapper.xml
  28. 1 1
      applications/document/document-server/src/main/resources/mapper/VendorMapper.xml
  29. 51 0
      applications/document/document-server/src/test/java/com/usoftchina/saas/document/mapper/CustomerMapperTest.java
  30. 8 0
      applications/money/money-server/pom.xml
  31. 4 4
      applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/controller/ProdInOutController.java
  32. 0 4
      applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/mapper/ProdIODetailMapper.java
  33. 0 5
      applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/mapper/ProdInOutMapper.java
  34. 1 2
      applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/service/ProdInOutService.java
  35. 17 17
      applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/service/impl/ProdInOutServiceImpl.java
  36. 1 58
      applications/purchase/purchase-server/src/main/resources/mapper/ProdIODetailMapper.xml
  37. 0 24
      applications/purchase/purchase-server/src/main/resources/mapper/ProdInOutMapper.xml
  38. 4 11
      applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/SaleApplication.java
  39. 3 2
      applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/controller/ProdInOutController.java
  40. 4 0
      applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/mapper/ProdInOutMapper.java
  41. 4 0
      applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/mapper/SaleMapper.java
  42. 56 10
      applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/service/ProdInOutService.java
  43. 124 75
      applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/service/impl/ProdInOutServiceImpl.java
  44. 37 4
      applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/service/impl/SaleServiceImpl.java
  45. 3 1
      applications/sale/sale-server/src/main/resources/mapper/ProdInOutListMapper.xml
  46. 14 1
      applications/sale/sale-server/src/main/resources/mapper/ProdInOutMapper.xml
  47. 11 0
      applications/sale/sale-server/src/main/resources/mapper/SaleMapper.xml
  48. 8 2
      applications/storage/storage-dto/src/main/java/com/usoftchina/saas/storage/po/ProdInOut.java
  49. 177 0
      applications/storage/storage-dto/src/main/java/com/usoftchina/saas/storage/po/ProdInOutExample.java
  50. 6 0
      applications/storage/storage-dto/src/main/java/com/usoftchina/saas/storage/po/ProdInOutList.java
  51. 28 0
      base-servers/account/README.md
  52. 4 0
      base-servers/account/account-dto/pom.xml
  53. 48 0
      base-servers/account/account-dto/src/main/java/com/usoftchina/saas/account/constant/ResourceClassify.java
  54. 26 0
      base-servers/account/account-dto/src/main/java/com/usoftchina/saas/account/constant/RoleType.java
  55. 100 0
      base-servers/account/account-dto/src/main/java/com/usoftchina/saas/account/dto/ResourceDTO.java
  56. 169 0
      base-servers/account/account-dto/src/main/java/com/usoftchina/saas/account/dto/ResourceGroupDTO.java
  57. 49 0
      base-servers/account/account-dto/src/main/java/com/usoftchina/saas/account/dto/ResourceModuleDTO.java
  58. 0 10
      base-servers/account/account-dto/src/main/java/com/usoftchina/saas/account/dto/ResourcesDTO.java
  59. 75 0
      base-servers/account/account-dto/src/main/java/com/usoftchina/saas/account/dto/RoleDTO.java
  60. 57 0
      base-servers/account/account-dto/src/main/java/com/usoftchina/saas/account/dto/RoleSaveDTO.java
  61. 67 0
      base-servers/account/account-dto/src/main/java/com/usoftchina/saas/account/dto/RoleUpdateDTO.java
  62. 57 0
      base-servers/account/account-dto/src/main/java/com/usoftchina/saas/account/dto/UrlResourceDTO.java
  63. 5 5
      base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/controller/AccountController.java
  64. 47 5
      base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/controller/CompanyController.java
  65. 0 8
      base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/controller/ResourceController.java
  66. 56 0
      base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/controller/ResourcesController.java
  67. 115 1
      base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/controller/RoleController.java
  68. 12 2
      base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/mapper/AccountCompanyMapper.java
  69. 7 0
      base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/mapper/AccountRoleMapper.java
  70. 33 0
      base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/mapper/CompanyAppMapper.java
  71. 10 0
      base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/mapper/CompanyMapper.java
  72. 21 0
      base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/mapper/ResourceGroupMapper.java
  73. 29 0
      base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/mapper/ResourceMapper.java
  74. 20 0
      base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/mapper/ResourceModuleMapper.java
  75. 0 11
      base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/mapper/ResourcesMapper.java
  76. 10 1
      base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/mapper/RoleResourceMapper.java
  77. 31 36
      base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/po/Resource.java
  78. 40 0
      base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/po/ResourceGroup.java
  79. 40 0
      base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/po/ResourceModule.java
  80. 13 0
      base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/po/Role.java
  81. 24 0
      base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/service/CompanyService.java
  82. 29 0
      base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/service/ResourceService.java
  83. 28 0
      base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/service/RoleService.java
  84. 2 0
      base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/service/impl/AccountServiceImpl.java
  85. 27 0
      base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/service/impl/CompanyServiceImpl.java
  86. 104 0
      base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/service/impl/ResourceServiceImpl.java
  87. 58 0
      base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/service/impl/RoleServiceImpl.java
  88. 17 2
      base-servers/account/account-server/src/main/resources/application.yml
  89. 3 0
      base-servers/account/account-server/src/main/resources/mapper/AccountCompanyMapper.xml
  90. 3 0
      base-servers/account/account-server/src/main/resources/mapper/AccountRoleMapper.xml
  91. 13 0
      base-servers/account/account-server/src/main/resources/mapper/CompanyAppMapper.xml
  92. 7 4
      base-servers/account/account-server/src/main/resources/mapper/CompanyMapper.xml
  93. 15 0
      base-servers/account/account-server/src/main/resources/mapper/ResourceGroupMapper.xml
  94. 24 0
      base-servers/account/account-server/src/main/resources/mapper/ResourceMapper.xml
  95. 15 0
      base-servers/account/account-server/src/main/resources/mapper/ResourceModuleMapper.xml
  96. 0 4
      base-servers/account/account-server/src/main/resources/mapper/ResourcesMapper.xml
  97. 98 1
      base-servers/account/account-server/src/main/resources/mapper/RoleMapper.xml
  98. 3 0
      base-servers/account/account-server/src/main/resources/mapper/RoleResourceMapper.xml
  99. 1 2
      base-servers/account/account-server/src/test/java/com/usoftchina/saas/account/controller/AccountControllerTest.java
  100. 32 5
      base-servers/account/account-server/src/test/java/com/usoftchina/saas/account/controller/CompanyControllerTest.java

+ 1 - 1
applications/commons/commons-api/src/main/java/com/usoftchina/saas/commons/api/MaxnumberService.java

@@ -28,6 +28,6 @@ public interface MaxnumberService {
      * @Author: guq
      * @Date: 2018/10/22
      */
-    @PostMapping("/numnber/getMaxnumber")
+    @PostMapping("/number/getMaxnumber")
     public Result<String> getMaxnumber(@RequestParam("caller") String caller, @RequestParam("update") boolean update);
 }

+ 2 - 1
applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/exception/BizExceptionCode.java

@@ -21,7 +21,8 @@ public enum BizExceptionCode implements BaseExceptionCode {
     NULL_CODERULE(79100, "单据规则不存在,请先确定单据生成规则"),
     CODE_EXISTS(79200, "单据编号已存在"),
     BIZ_CLOSE(79301, "只能关闭已审核的单据"),
-    BIZ_OPEN(79002, "只能打开已关闭的单据"),
+    BIZ_OPEN(79302, "只能打开已关闭的单据"),
+    BOM_SAVE(79401, "产品编号+版本号已存在"),
     NO_DATA(79998, "未找到数据"),
     ILLEGAL_ID(79999, "id不正确"),
 

+ 7 - 5
applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/po/Status.java

@@ -11,6 +11,12 @@ public enum Status {
      */
     CLOSE("已关闭"),
 
+    /**
+     * 已开启
+     */
+    OPEN("已开启"),
+
+
     /**
      * 已审核
      */
@@ -44,12 +50,8 @@ public enum Status {
     /**
      * 未出库
      */
-    UNTURNOUT("未出库"),
+    UNTURNOUT("未出库");
 
-    /**
-     * 开启
-     */
-    OPEN("开启")
 
     ;
     private String display;

+ 6 - 4
applications/document/document-api/src/main/java/com/usoftchina/saas/document/api/WarehouseApi.java

@@ -3,16 +3,18 @@ package com.usoftchina.saas.document.api;
 import com.usoftchina.saas.base.Result;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 
 import java.util.Map;
 
 @FeignClient(name = "document-server")
 public interface WarehouseApi {
 
-    @GetMapping("/warehouse/post")
-    public Result post(Map<String, Object> param);
+    @PostMapping("/warehouse/post")
+    public Result post(@RequestBody Map<String, Object> map);
 
-    @GetMapping("/warehouse/unPost")
-    public Result unPost(Map<String, Object> param);
+    @PostMapping("/warehouse/unPost")
+    public Result unPost(@RequestBody Map<String, Object> map);
 
 }

+ 148 - 0
applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/Bom.java

@@ -0,0 +1,148 @@
+package com.usoftchina.saas.document.entities;
+
+import com.usoftchina.saas.base.entity.CommonBaseEntity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+public class Bom extends CommonBaseEntity implements Serializable {
+    private Integer bo_motherid;
+
+    private String bo_mothercode;
+
+    private String bo_mothername;
+
+    private String bo_version;
+
+    private String bo_status;
+
+    private String bo_statuscode;
+
+    private Integer bo_recorderid;
+
+    private String bo_recorder;
+
+    private Date bo_recorddate;
+
+    private String bo_text1;
+
+    private String bo_text2;
+
+    private String bo_text3;
+
+    private String bo_text4;
+
+    private String bo_text5;
+
+    public Integer getBo_motherid() {
+        return bo_motherid;
+    }
+
+    public void setBo_motherid(Integer bo_motherid) {
+        this.bo_motherid = bo_motherid;
+    }
+
+    public String getBo_mothercode() {
+        return bo_mothercode;
+    }
+
+    public void setBo_mothercode(String bo_mothercode) {
+        this.bo_mothercode = bo_mothercode == null ? null : bo_mothercode.trim();
+    }
+
+    public String getBo_mothername() {
+        return bo_mothername;
+    }
+
+    public void setBo_mothername(String bo_mothername) {
+        this.bo_mothername = bo_mothername == null ? null : bo_mothername.trim();
+    }
+
+    public String getBo_version() {
+        return bo_version;
+    }
+
+    public void setBo_version(String bo_version) {
+        this.bo_version = bo_version == null ? null : bo_version.trim();
+    }
+
+    public String getBo_status() {
+        return bo_status;
+    }
+
+    public void setBo_status(String bo_status) {
+        this.bo_status = bo_status == null ? null : bo_status.trim();
+    }
+
+    public String getBo_statuscode() {
+        return bo_statuscode;
+    }
+
+    public void setBo_statuscode(String bo_statuscode) {
+        this.bo_statuscode = bo_statuscode == null ? null : bo_statuscode.trim();
+    }
+
+    public Integer getBo_recorderid() {
+        return bo_recorderid;
+    }
+
+    public void setBo_recorderid(Integer bo_recorderid) {
+        this.bo_recorderid = bo_recorderid;
+    }
+
+    public String getBo_recorder() {
+        return bo_recorder;
+    }
+
+    public void setBo_recorder(String bo_recorder) {
+        this.bo_recorder = bo_recorder == null ? null : bo_recorder.trim();
+    }
+
+    public Date getBo_recorddate() {
+        return bo_recorddate;
+    }
+
+    public void setBo_recorddate(Date bo_recorddate) {
+        this.bo_recorddate = bo_recorddate;
+    }
+
+    public String getBo_text1() {
+        return bo_text1;
+    }
+
+    public void setBo_text1(String bo_text1) {
+        this.bo_text1 = bo_text1 == null ? null : bo_text1.trim();
+    }
+
+    public String getBo_text2() {
+        return bo_text2;
+    }
+
+    public void setBo_text2(String bo_text2) {
+        this.bo_text2 = bo_text2 == null ? null : bo_text2.trim();
+    }
+
+    public String getBo_text3() {
+        return bo_text3;
+    }
+
+    public void setBo_text3(String bo_text3) {
+        this.bo_text3 = bo_text3 == null ? null : bo_text3.trim();
+    }
+
+    public String getBo_text4() {
+        return bo_text4;
+    }
+
+    public void setBo_text4(String bo_text4) {
+        this.bo_text4 = bo_text4 == null ? null : bo_text4.trim();
+    }
+
+    public String getBo_text5() {
+        return bo_text5;
+    }
+
+    public void setBo_text5(String bo_text5) {
+        this.bo_text5 = bo_text5 == null ? null : bo_text5.trim();
+    }
+}

+ 136 - 0
applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/BomDetail.java

@@ -0,0 +1,136 @@
+package com.usoftchina.saas.document.entities;
+
+import com.usoftchina.saas.base.entity.CommonBaseEntity;
+import java.io.Serializable;
+
+public class BomDetail extends CommonBaseEntity implements Serializable {
+    private Long bd_bomid;
+
+    private Integer bd_detno;
+
+    private Integer bd_sonid;
+
+    private String bd_soncode;
+
+    private String bd_unit;
+
+    private Integer bd_baseqty;
+
+    private String bd_replace;
+
+    private String bd_remark;
+
+    private String bd_text1;
+
+    private String bd_text2;
+
+    private String bd_text3;
+
+    private String bd_text4;
+
+    private String bd_text5;
+
+    public Long getBd_bomid() {
+        return bd_bomid;
+    }
+
+    public void setBd_bomid(Long bd_bomid) {
+        this.bd_bomid = bd_bomid;
+    }
+
+    public Integer getBd_detno() {
+        return bd_detno;
+    }
+
+    public void setBd_detno(Integer bd_detno) {
+        this.bd_detno = bd_detno;
+    }
+
+    public Integer getBd_sonid() {
+        return bd_sonid;
+    }
+
+    public void setBd_sonid(Integer bd_sonid) {
+        this.bd_sonid = bd_sonid;
+    }
+
+    public String getBd_soncode() {
+        return bd_soncode;
+    }
+
+    public void setBd_soncode(String bd_soncode) {
+        this.bd_soncode = bd_soncode == null ? null : bd_soncode.trim();
+    }
+
+    public String getBd_unit() {
+        return bd_unit;
+    }
+
+    public void setBd_unit(String bd_unit) {
+        this.bd_unit = bd_unit == null ? null : bd_unit.trim();
+    }
+
+    public Integer getBd_baseqty() {
+        return bd_baseqty;
+    }
+
+    public void setBd_baseqty(Integer bd_baseqty) {
+        this.bd_baseqty = bd_baseqty;
+    }
+
+    public String getBd_text1() {
+        return bd_text1;
+    }
+
+    public void setBd_text1(String bd_text1) {
+        this.bd_text1 = bd_text1 == null ? null : bd_text1.trim();
+    }
+
+    public String getBd_text2() {
+        return bd_text2;
+    }
+
+    public void setBd_text2(String bd_text2) {
+        this.bd_text2 = bd_text2 == null ? null : bd_text2.trim();
+    }
+
+    public String getBd_text3() {
+        return bd_text3;
+    }
+
+    public void setBd_text3(String bd_text3) {
+        this.bd_text3 = bd_text3 == null ? null : bd_text3.trim();
+    }
+
+    public String getBd_text4() {
+        return bd_text4;
+    }
+
+    public void setBd_text4(String bd_text4) {
+        this.bd_text4 = bd_text4 == null ? null : bd_text4.trim();
+    }
+
+    public String getBd_text5() {
+        return bd_text5;
+    }
+
+    public void setBd_text5(String bd_text5) {
+        this.bd_text5 = bd_text5 == null ? null : bd_text5.trim();
+    }
+
+    public String getBd_replace() {
+        return bd_replace;
+    }
+
+    public void setBd_replace(String bd_replace) {
+        this.bd_replace = bd_replace;
+    }
+
+    public String getBd_remark() {
+        return bd_remark;
+    }
+
+    public void setBd_remark(String bd_remark) {
+        this.bd_remark = bd_remark;
+    }
+}

+ 26 - 0
applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/BomList.java

@@ -0,0 +1,26 @@
+package com.usoftchina.saas.document.entities;
+
+import java.io.Serializable;
+import java.util.List;
+
+public class BomList implements Serializable {
+
+    private Bom main;
+    private List<BomDetail> items;
+
+    public Bom getMain() {
+        return main;
+    }
+
+    public void setMain(Bom main) {
+        this.main = main;
+    }
+
+    public List<BomDetail> getItems() {
+        return items;
+    }
+
+    public void setItems(List<BomDetail> items) {
+        this.items = items;
+    }
+}

+ 1 - 13
applications/document/document-server/src/main/java/com/usoftchina/saas/document/DocumentApplication.java

@@ -6,8 +6,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
 import org.springframework.cloud.openfeign.EnableFeignClients;
 import org.springframework.transaction.annotation.EnableTransactionManagement;
-import org.springframework.web.servlet.config.annotation.CorsRegistry;
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
 
 @SpringBootApplication
 @EnableEurekaClient
@@ -15,19 +13,9 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
 @EnableTransactionManagement
 @EnableFeignClients("com.usoftchina.saas")
 @MapperScan("com.usoftchina.saas.document.mapper")
-public class DocumentApplication extends WebMvcConfigurerAdapter {
+public class DocumentApplication {
 
     public static void main(String[] args) {
         SpringApplication.run(DocumentApplication.class);
     }
-
-    @Override
-    public void addCorsMappings(CorsRegistry registry) {
-        registry.addMapping("/**")
-                .allowCredentials(true)
-                .allowedHeaders("*")
-                .allowedOrigins("*")
-                .allowedMethods("*");
-    }
-
 }

+ 41 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/BomController.java

@@ -0,0 +1,41 @@
+package com.usoftchina.saas.document.controller;
+
+import com.usoftchina.saas.base.Result;
+import com.usoftchina.saas.commons.dto.ListReqDTO;
+import com.usoftchina.saas.document.entities.BomList;
+import com.usoftchina.saas.document.service.BomService;
+import com.usoftchina.saas.page.PageRequest;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.print.Doc;
+
+@RestController
+@RequestMapping("/bom")
+public class BomController {
+
+    @Autowired
+    private BomService bomService;
+
+    @PostMapping("/save")
+    public Result saveData(@RequestBody BomList bomList){
+        return Result.success(bomService.saveData(bomList));
+    }
+
+    @PostMapping("/delete/{id}")
+    public Result delete(@PathVariable("id") Long id){
+        bomService.delete(id);
+        return Result.success();
+    }
+
+    @GetMapping("/list")
+    public Result getListDataByCondition(PageRequest page, ListReqDTO listReqDTO){
+        return Result.success(bomService.getListDataByCondition(page, listReqDTO));
+    }
+
+    @GetMapping("/getDataById")
+    public Result getDataByCondition(@PathVariable("id") Long id){
+        return Result.success(bomService.getDataById(id));
+    }
+
+}

+ 53 - 12
applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/CustomerController.java

@@ -66,14 +66,38 @@ public class CustomerController {
      * @param id
      * @return
      */
-    @GetMapping("/delete/{id}")
+    @PostMapping("/delete/{id}")
     public Result delete(@PathVariable("id") Long id) {
         customerService.delete(id);
         return Result.success();
     }
 
     /**
-     * 采购订单批量删除
+     * 客户联系人删除
+     *
+     * @param id
+     * @return
+     */
+    @PostMapping("/deletecontact/{id}")
+    public Result deletecontact(@PathVariable("id") Long id) {
+        customerService.deletecontact(id);
+        return Result.success();
+    }
+
+    /**
+     * 客户地址删除
+     *
+     * @param id
+     * @return
+     */
+    @PostMapping("/deleteaddress/{id}")
+    public Result deleteaddress(@PathVariable("id") Long id) {
+        customerService.deleteaddress(id);
+        return Result.success();
+    }
+
+    /**
+     * 客户资料批量删除
      *
      * @param baseDTOs
      * @return
@@ -92,7 +116,20 @@ public class CustomerController {
      */
     @PostMapping("/close/{id}")
     public Result close(@PathVariable(value = "id") long id){
-        customerService.close(id);
+        DocBaseDTO close = customerService.close(id);
+        return Result.success(close);
+    }
+
+
+    /**
+     * 客户资料批量删除
+     *
+     * @param baseDTOs
+     * @return
+     */
+    @PostMapping("/batchClose")
+    public Result batchClose(@RequestBody BatchDealBaseDTO baseDTOs) {
+        customerService.batchClose(baseDTOs);
         return Result.success();
     }
 
@@ -104,16 +141,20 @@ public class CustomerController {
      */
     @PostMapping("/open/{id}")
     public Result open(@PathVariable(value = "id") long id){
-        customerService.open(id);
-        return Result.success();
+        DocBaseDTO open = customerService.open(id);
+        return Result.success(open);
     }
 
-
-
-
-
-
-
-
+    /**
+     * 客户资料批量启用
+     *
+     * @param baseDTOs
+     * @return
+     */
+    @PostMapping("/batchOpen")
+    public Result batchOpen(@RequestBody BatchDealBaseDTO baseDTOs) {
+        customerService.batchOpen(baseDTOs);
+        return Result.success();
+    }
 
 }

+ 1 - 1
applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/FundinouttypeController.java

@@ -9,7 +9,7 @@ import org.springframework.web.bind.annotation.*;
 import java.util.List;
 
 @RestController
-@RequestMapping("/fundinoutType")
+@RequestMapping("/fundinouttype")
 public class FundinouttypeController {
 
     @Autowired

+ 4 - 4
applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/VendorController.java

@@ -40,7 +40,7 @@ public class VendorController {
      * @param id
      * @return
      */
-    @GetMapping("/getListById/{id}")
+    @GetMapping("/getDataById/{id}")
     public Result<VendorListDTO> getDataById(@PathVariable("id") Long id){
         VendorListDTO vendorListDTO = vendorService.getListById(id);
         return Result.success(vendorListDTO);
@@ -51,9 +51,9 @@ public class VendorController {
      * @param listReqDTO
      * @return
      */
-    @GetMapping("/getListDataByCondition")
-    public Result<List<VendorList>> getListDataByCondition(ListReqDTO listReqDTO){
-        return Result.success(vendorService.getListDataByCondition(listReqDTO));
+    @GetMapping("/list")
+    public Result<PageInfo<VendorList>> getListDataByCondition(PageRequest page, ListReqDTO listReqDTO){
+        return Result.success(vendorService.getListDataByCondition(page, listReqDTO));
     }
 
     /**

+ 4 - 4
applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/WarehouseController.java

@@ -23,8 +23,8 @@ public class WarehouseController {
      * 过账
      * @return
      */
-    @GetMapping("/post")
-    public Result post(Map<String, Object> map){
+    @PostMapping("/post")
+    public Result post(@RequestBody Map<String, Object> map){
         warehouseService.post(map);
         return Result.success(map.get("result"));
     }
@@ -34,8 +34,8 @@ public class WarehouseController {
      * @param map
      * @return
      */
-    @GetMapping("/unPost")
-    public Result unPost(Map<String, Object> map){
+    @PostMapping("/unPost")
+    public Result unPost(@RequestBody Map<String, Object> map){
         warehouseService.unPost(map);
         return Result.success();
     }

+ 26 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/BomDetailMapper.java

@@ -0,0 +1,26 @@
+package com.usoftchina.saas.document.mapper;
+
+import com.usoftchina.saas.base.mapper.CommonBaseMapper;
+import com.usoftchina.saas.document.entities.BomDetail;
+
+import java.util.List;
+
+public interface BomDetailMapper extends CommonBaseMapper<BomDetail> {
+    int deleteByPrimaryKey(Long bd_id);
+
+    int insert(BomDetail record);
+
+    int insertSelective(BomDetail record);
+
+    BomDetail selectByPrimaryKey(Long bd_id);
+
+    int updateByPrimaryKeySelective(BomDetail record);
+
+    int updateByPrimaryKey(BomDetail record);
+
+    void batchInsert(List<BomDetail> bomDetailList);
+
+    void batchUpdate(List<BomDetail> bomDetailList);
+
+    void deleteByFK(Long id);
+}

+ 25 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/BomMapper.java

@@ -0,0 +1,25 @@
+package com.usoftchina.saas.document.mapper;
+
+import com.usoftchina.saas.base.mapper.CommonBaseMapper;
+import com.usoftchina.saas.document.entities.Bom;
+import org.apache.ibatis.annotations.Param;
+
+public interface BomMapper extends CommonBaseMapper<Bom> {
+    int deleteByPrimaryKey(Long bo_id);
+
+    int insert(Bom record);
+
+    int insertSelective(Bom record);
+
+    Bom selectByPrimaryKey(Long bo_id);
+
+    int updateByPrimaryKeySelective(Bom record);
+
+    int updateByPrimaryKey(Bom record);
+
+    int validCodeAndVersion(@Param("code") String code, @Param("version") String version, @Param("companyId") Long companyId);
+
+    int validateCodeWhenInsert(@Param("code") String code, @Param("companyId") Long companyId);
+
+    int validateCodeWhenUpdate(@Param("code") String code, @Param("id") Long id, @Param("companyId") Long company);
+}

+ 48 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/BomService.java

@@ -0,0 +1,48 @@
+package com.usoftchina.saas.document.service;
+
+import com.usoftchina.saas.base.service.CommonBaseService;
+import com.usoftchina.saas.commons.dto.DocBaseDTO;
+import com.usoftchina.saas.commons.dto.ListReqDTO;
+import com.usoftchina.saas.document.entities.Bom;
+import com.usoftchina.saas.document.entities.BomList;
+import com.usoftchina.saas.document.mapper.BomMapper;
+import com.usoftchina.saas.page.PageRequest;
+
+import java.util.List;
+
+public interface BomService extends CommonBaseService<BomMapper, Bom> {
+
+    /**
+     * 保存、更新BOM资料主从表数据
+     * @param bomList
+     * @return
+     */
+    DocBaseDTO saveData(BomList bomList);
+
+    /**
+     * 删除
+     * @param id
+     */
+    void delete(Long id);
+
+    /**
+     * BOM资料复制
+     * @param id
+     */
+    void copy(Long id);
+
+    /**
+     * 获取列表数据
+     * @param pageRequest   分页对象
+     * @param listReqDTO    条件对象
+     * @return
+     */
+    List<BomList> getListDataByCondition(PageRequest pageRequest, ListReqDTO listReqDTO);
+
+    /**
+     * 通过ID获取主从表数据
+     * @param id
+     * @return
+     */
+    BomList getDataById(Long id);
+}

+ 10 - 2
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/CustomerService.java

@@ -24,9 +24,17 @@ public interface CustomerService extends CommonBaseService<CustomerMapper, Custo
 
     void delete(Long id);
 
-    void close(long id);
+    DocBaseDTO close(long id);
 
-    void open(long id);
+    DocBaseDTO open(long id);
 
     void batchDelete(BatchDealBaseDTO baseDTOs);
+
+    void deletecontact(Long id);
+
+    void deleteaddress(Long id);
+
+    void batchClose(BatchDealBaseDTO baseDTOs);
+
+    void batchOpen(BatchDealBaseDTO baseDTOs);
 }

+ 1 - 1
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/VendorService.java

@@ -38,7 +38,7 @@ public interface VendorService extends CommonBaseService<VendorMapper, Vendor>{
      * @param listReqDTO  条件对象
      * @return List<VendorList>
      */
-    List<VendorList> getListDataByCondition(ListReqDTO listReqDTO);
+    PageInfo<VendorList> getListDataByCondition(PageRequest page, ListReqDTO listReqDTO);
 
     /**
      * 保存主从表数据

+ 0 - 1
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/AddressServiceImpl.java

@@ -3,7 +3,6 @@ package com.usoftchina.saas.document.service.impl;
 import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
 import com.usoftchina.saas.commons.api.MessageLogService;
 import com.usoftchina.saas.commons.dto.DocBaseDTO;
-import com.usoftchina.saas.commons.po.Messagelog;
 import com.usoftchina.saas.context.BaseContextHolder;
 import com.usoftchina.saas.document.entities.Address;
 import com.usoftchina.saas.document.mapper.AddressMapper;

+ 124 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/BomServiceImpl.java

@@ -0,0 +1,124 @@
+package com.usoftchina.saas.document.service.impl;
+
+import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
+import com.usoftchina.saas.commons.api.MaxnumberService;
+import com.usoftchina.saas.commons.api.MessageLogService;
+import com.usoftchina.saas.commons.dto.DocBaseDTO;
+import com.usoftchina.saas.commons.dto.ListReqDTO;
+import com.usoftchina.saas.commons.exception.BizExceptionCode;
+import com.usoftchina.saas.commons.po.BillCodeSeq;
+import com.usoftchina.saas.context.BaseContextHolder;
+import com.usoftchina.saas.document.entities.Bom;
+import com.usoftchina.saas.document.entities.BomDetail;
+import com.usoftchina.saas.document.entities.BomList;
+import com.usoftchina.saas.document.mapper.BomDetailMapper;
+import com.usoftchina.saas.document.mapper.BomMapper;
+import com.usoftchina.saas.document.service.BomService;
+import com.usoftchina.saas.exception.BizException;
+import com.usoftchina.saas.page.PageRequest;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class BomServiceImpl extends CommonBaseServiceImpl<BomMapper, Bom> implements BomService {
+
+    @Autowired
+    private MaxnumberService maxnumberService;
+    @Autowired
+    private BomDetailMapper bomDetailMapper;
+    @Autowired
+    private MessageLogService messageLogService;
+
+    @Override
+    public DocBaseDTO saveData(BomList bomList) {
+        Long id = bomList.getMain().getId();
+        Long companyId = BaseContextHolder.getCompanyId();
+        Bom bom = bomList.getMain();
+        List<BomDetail> bomDetailList = bomList.getItems();
+        DocBaseDTO docBaseDTO = null;
+        if(id == 0){
+            //校验编号和版本 是否已存在
+            int count = getMapper().validCodeAndVersion(bom.getBo_mothercode(), bom.getBo_version(), companyId);
+            if(count == 0){
+                String code = pushMaxnubmer(bom.getBo_mothercode(), bom.getId());
+                bom.setBo_mothercode(code);
+                bom.setCompanyId(companyId);
+                //保存BOM
+                getMapper().insertSelective(bom);
+                //赋值BD_BOMID
+                for (BomDetail bomDetail : bomDetailList){
+                    bomDetail.setBd_bomid(bom.getId());
+                    bomDetail.setCompanyId(companyId);
+                }
+                bomDetailMapper.batchInsert(bomDetailList);
+                docBaseDTO = generateMsgObj(bom.getId());
+                //记录LOG
+                messageLogService.save(docBaseDTO);
+            }else{
+                throw new BizException(BizExceptionCode.BOM_SAVE);
+            }
+        }else{
+            //校验编号和版本 是否已存在
+            int count = getMapper().validCodeAndVersion(bom.getBo_mothercode(), bom.getBo_version(), companyId);
+            //更新主表
+            getMapper().updateByPrimaryKeySelective(bom);
+            //更新从表
+            bomDetailMapper.batchUpdate(bomDetailList);
+            //记录LOG
+            messageLogService.update(generateMsgObj(bom.getId()));
+        }
+        return docBaseDTO;
+    }
+
+    @Override
+    public void delete(Long id) {
+        if(id == null || id <= 0){
+            throw new BizException(BizExceptionCode.ILLEGAL_ID);
+        }
+        getMapper().deleteByPrimaryKey(id);
+        bomDetailMapper.deleteByFK(id);
+    }
+
+    @Override
+    public void copy(Long id) {
+
+    }
+
+    @Override
+    public List<BomList> getListDataByCondition(PageRequest pageRequest, ListReqDTO listReqDTO) {
+        return null;
+    }
+
+    @Override
+    public BomList getDataById(Long id) {
+        return null;
+    }
+
+    /**
+     * 构造日记记录对象
+     * @param id
+     * @return
+     */
+    private DocBaseDTO generateMsgObj(Long id){
+        return new DocBaseDTO(id, "", "Bom");
+    }
+
+    /**
+     * @Description: 检验获取并更新单号
+     * @Param: [code, id]
+     * @return: java.lang.String
+     * @Author: guq
+     * @Date: 2018/10/19
+     */
+    private String pushMaxnubmer(String code, Long id) {
+        if (null == code) {
+            throw new BizException(BizExceptionCode.NULL_CODE);
+        }
+        Long companyId = BaseContextHolder.getCompanyId();
+        Integer count = "0".equals(String.valueOf(id)) ? getMapper().validateCodeWhenInsert(code, companyId) :
+                getMapper().validateCodeWhenUpdate(code, id, companyId);
+        return maxnumberService.pushMaxnubmer(count, code, BillCodeSeq.PURCHASE.getCaller()).getData();
+    }
+}

+ 83 - 2
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/CustomerServiceImpl.java

@@ -6,6 +6,8 @@ import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
 import com.usoftchina.saas.commons.dto.BatchDealBaseDTO;
 import com.usoftchina.saas.commons.dto.DocBaseDTO;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
+import com.usoftchina.saas.commons.exception.BizExceptionCode;
+import com.usoftchina.saas.commons.po.Status;
 import com.usoftchina.saas.context.BaseContextHolder;
 import com.usoftchina.saas.document.dto.CustomerDTO;
 import com.usoftchina.saas.document.dto.CustomerFormDTO;
@@ -238,15 +240,90 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
     }
 
     @Override
-    public void close(long id) {
+    public void deletecontact(Long id) {
+        customercontactMapper.deleteByPrimaryKey(id);
+        DocBaseDTO docBaseDTO = getBaseDTOById(id);
+        //日志
+//        messageLogService.deleteDetail(docBaseDTO);
+    }
 
+    @Override
+    public void deleteaddress(Long id) {
+        customeraddressMapper.deleteByPrimaryKey(id);
+        DocBaseDTO docBaseDTO = getBaseDTOById(id);
+        //日志
+//        messageLogService.deleteDetail(docBaseDTO);
     }
 
+    private DocBaseDTO singleClose(Long id) {
+        DocBaseDTO docBaseDTO = null;
+        if (null!=id) {
+            Customer customer = getMapper().selectByPrimaryKey(id);
+            if(Status.CLOSE.name().equals(customer.getCu_statuscode())){
+                throw new BizException(BizExceptionCode.BIZ_CLOSE);
+            }
+            customer.setCu_statuscode(Status.CLOSE.name());
+            customer.setCu_status(Status.CLOSE.getDisplay());
+            getMapper().updateByPrimaryKeySelective(customer);
+            docBaseDTO = getBaseDTOById(id);
+            //日志
+//        messageLogService.close(docBaseDTO);
+        }
+        return docBaseDTO;
+    }
+
+
     @Override
-    public void open(long id) {
+    public DocBaseDTO close(long id) {
+        return singleClose(id);
+    }
 
+    @Override
+    public void batchClose(BatchDealBaseDTO baseDTOs) {
+        if (null == baseDTOs || null == baseDTOs.getBaseDTOs() ||
+                baseDTOs.getBaseDTOs().size() == 0) {
+            return;
+        }
+        for (DocBaseDTO base : baseDTOs.getBaseDTOs()) {
+            singleClose(base.getId());
+        }
     }
 
+    private DocBaseDTO singleOpen(Long id) {
+        DocBaseDTO docBaseDTO = null;
+        if (null!=id) {
+            Customer customer = getMapper().selectByPrimaryKey(id);
+            if(Status.OPEN.name().equals(customer.getCu_statuscode())){
+                throw new BizException(BizExceptionCode.BIZ_OPEN);
+            }
+            customer.setCu_statuscode(Status.OPEN.name());
+            customer.setCu_status(Status.OPEN.getDisplay());
+            getMapper().updateByPrimaryKeySelective(customer);
+            docBaseDTO = getBaseDTOById(id);
+            //日志
+//        messageLogService.close(docBaseDTO);
+        }
+        return docBaseDTO;
+    }
+
+
+    @Override
+    public DocBaseDTO open(long id) {
+        return singleOpen(id);
+    }
+
+    @Override
+    public void batchOpen(BatchDealBaseDTO baseDTOs) {
+        if (null == baseDTOs || null == baseDTOs.getBaseDTOs() ||
+                baseDTOs.getBaseDTOs().size() == 0) {
+            return;
+        }
+        for (DocBaseDTO base : baseDTOs.getBaseDTOs()) {
+            singleOpen(base.getId());
+        }
+    }
+
+
     private List<CustomerList> getListByMode(ListReqDTO req) {
         List<CustomerList> list = null;
         Long companyId = BaseContextHolder.getCompanyId();
@@ -278,4 +355,8 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
         return baseDTO;
     }
 
+
+
+
+
 }

+ 15 - 2
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/VendorServiceImpl.java

@@ -71,9 +71,19 @@ public class VendorServiceImpl extends CommonBaseServiceImpl<VendorMapper, Vendo
      * 返回列表数据
      * @return
      */
-    public List<VendorList> getListDataByCondition(ListReqDTO listReqDTO){
+    public PageInfo<VendorList> getListDataByCondition(PageRequest page, ListReqDTO listReqDTO){
+        //设置分页
+        if (null == page || page.getSize() == 0 || page.getNumber() == 0) {
+            page = new PageRequest();
+            page.setNumber(1);
+            page.setSize(10);
+        }
+        PageHelper.startPage(page.getNumber(), page.getSize());
+        //取分页信息
         String condition = listReqDTO.getFinalCondition();
-        return getMapper().getListDataByCondition(condition, BaseContextHolder.getCompanyId());
+        List<VendorList> list = getMapper().getListDataByCondition(condition, BaseContextHolder.getCompanyId());
+        PageInfo<VendorList> pageInfo = new PageInfo<VendorList>(list);
+        return pageInfo;
     }
 
     /**
@@ -82,6 +92,9 @@ public class VendorServiceImpl extends CommonBaseServiceImpl<VendorMapper, Vendo
      */
     @Override
     public DocBaseDTO saveFormData(VendorListDTO vendorListDTO) {
+        if (null == vendorListDTO || null == vendorListDTO.getMain()){
+            throw new BizException(500, "数据为空,请填写后再保存");
+        }
         Vendor main = vendorListDTO.getMain();
         main.setCompanyId(BaseContextHolder.getCompanyId());
         List<Vendorcontact> items = vendorListDTO.getItems();

+ 0 - 1
applications/document/document-server/src/main/resources/application.yml

@@ -48,7 +48,6 @@ eureka:
     registryFetchIntervalSeconds: 5
     serviceUrl:
       defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@192.168.0.181:8510/eureka/
-#      defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@192.168.253.31:8510/eureka/
 server:
   port: 9480
   tomcat:

+ 396 - 0
applications/document/document-server/src/main/resources/mapper/BomDetailMapper.xml

@@ -0,0 +1,396 @@
+<?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.usoftchina.saas.document.mapper.BomDetailMapper" >
+  <resultMap id="BaseResultMap" type="com.usoftchina.saas.document.entities.BomDetail" >
+    <id column="bd_id" property="id" jdbcType="INTEGER" />
+    <result column="bd_bomid" property="bd_bomid" jdbcType="INTEGER" />
+    <result column="bd_detno" property="bd_detno" jdbcType="INTEGER" />
+    <result column="bd_sonid" property="bd_sonid" jdbcType="INTEGER" />
+    <result column="bd_soncode" property="bd_soncode" jdbcType="VARCHAR" />
+    <result column="bd_unit" property="bd_unit" jdbcType="VARCHAR" />
+    <result column="bd_baseqty" property="bd_baseqty" jdbcType="INTEGER" />
+    <result column="bd_replace" property="bd_replace" jdbcType="VARCHAR" />
+    <result column="bd_remark" property="bd_remark" jdbcType="VARCHAR" />
+    <result column="comapnyId" property="companyId" jdbcType="INTEGER" />
+    <result column="updaterId" property="updaterId" jdbcType="INTEGER" />
+    <result column="updateTime" property="updateTime" jdbcType="TIMESTAMP" />
+    <result column="bd_text1" property="bd_text1" jdbcType="VARCHAR" />
+    <result column="bd_text2" property="bd_text2" jdbcType="VARCHAR" />
+    <result column="bd_text3" property="bd_text3" jdbcType="VARCHAR" />
+    <result column="bd_text4" property="bd_text4" jdbcType="VARCHAR" />
+    <result column="bd_text5" property="bd_text5" jdbcType="VARCHAR" />
+  </resultMap>
+  <sql id="Base_Column_List" >
+    bd_id, bd_bomid, bd_detno, bd_sonid, bd_soncode, bd_unit, bd_baseqty, bd_replace, 
+    bd_remark, comapnyId, updaterId, updateTime, bd_text1, bd_text2, bd_text3, bd_text4, 
+    bd_text5
+  </sql>
+  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
+    select 
+    <include refid="Base_Column_List" />
+    from bomdetail
+    where bd_id = #{id}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
+    delete from bomdetail
+    where bd_id = #{id}
+  </delete>
+  <insert id="insert" parameterType="com.usoftchina.saas.document.entities.BomDetail" >
+    insert into bomdetail (bd_bomid, bd_detno,
+      bd_sonid, bd_soncode, bd_unit, 
+      bd_baseqty, bd_replace, bd_remark, 
+      comapnyId, updaterId, updateTime, 
+      bd_text1, bd_text2, bd_text3, 
+      bd_text4, bd_text5)
+    values ( #{bd_bomid,jdbcType=INTEGER}, #{bd_detno,jdbcType=INTEGER},
+      #{bd_sonid,jdbcType=INTEGER}, #{bd_soncode,jdbcType=VARCHAR}, #{bd_unit,jdbcType=VARCHAR}, 
+      #{bd_baseqty,jdbcType=INTEGER}, #{bd_replace,jdbcType=VARCHAR}, #{bd_remark,jdbcType=VARCHAR}, 
+      #{comapnyId,jdbcType=INTEGER}, #{updaterId,jdbcType=INTEGER}, #{updateTime,jdbcType=TIMESTAMP}, 
+      #{bd_text1,jdbcType=VARCHAR}, #{bd_text2,jdbcType=VARCHAR}, #{bd_text3,jdbcType=VARCHAR}, 
+      #{bd_text4,jdbcType=VARCHAR}, #{bd_text5,jdbcType=VARCHAR})
+  </insert>
+  <insert id="insertSelective" parameterType="com.usoftchina.saas.document.entities.BomDetail" >
+    insert into bomdetail
+    <trim prefix="(" suffix=")" suffixOverrides="," >
+      <if test="bd_bomid != null" >
+        bd_bomid,
+      </if>
+      <if test="bd_detno != null" >
+        bd_detno,
+      </if>
+      <if test="bd_sonid != null" >
+        bd_sonid,
+      </if>
+      <if test="bd_soncode != null" >
+        bd_soncode,
+      </if>
+      <if test="bd_unit != null" >
+        bd_unit,
+      </if>
+      <if test="bd_baseqty != null" >
+        bd_baseqty,
+      </if>
+      <if test="bd_replace != null" >
+        bd_replace,
+      </if>
+      <if test="bd_remark != null" >
+        bd_remark,
+      </if>
+      <if test="comapnyId != null" >
+        comapnyId,
+      </if>
+      <if test="updaterId != null" >
+        updaterId,
+      </if>
+      <if test="updateTime != null" >
+        updateTime,
+      </if>
+      <if test="bd_text1 != null" >
+        bd_text1,
+      </if>
+      <if test="bd_text2 != null" >
+        bd_text2,
+      </if>
+      <if test="bd_text3 != null" >
+        bd_text3,
+      </if>
+      <if test="bd_text4 != null" >
+        bd_text4,
+      </if>
+      <if test="bd_text5 != null" >
+        bd_text5,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
+      <if test="bd_bomid != null" >
+        #{bd_bomid,jdbcType=INTEGER},
+      </if>
+      <if test="bd_detno != null" >
+        #{bd_detno,jdbcType=INTEGER},
+      </if>
+      <if test="bd_sonid != null" >
+        #{bd_sonid,jdbcType=INTEGER},
+      </if>
+      <if test="bd_soncode != null" >
+        #{bd_soncode,jdbcType=VARCHAR},
+      </if>
+      <if test="bd_unit != null" >
+        #{bd_unit,jdbcType=VARCHAR},
+      </if>
+      <if test="bd_baseqty != null" >
+        #{bd_baseqty,jdbcType=INTEGER},
+      </if>
+      <if test="bd_replace != null" >
+        #{bd_replace,jdbcType=VARCHAR},
+      </if>
+      <if test="bd_remark != null" >
+        #{bd_remark,jdbcType=VARCHAR},
+      </if>
+      <if test="comapnyId != null" >
+        #{comapnyId,jdbcType=INTEGER},
+      </if>
+      <if test="updaterId != null" >
+        #{updaterId,jdbcType=INTEGER},
+      </if>
+      <if test="updateTime != null" >
+        #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="bd_text1 != null" >
+        #{bd_text1,jdbcType=VARCHAR},
+      </if>
+      <if test="bd_text2 != null" >
+        #{bd_text2,jdbcType=VARCHAR},
+      </if>
+      <if test="bd_text3 != null" >
+        #{bd_text3,jdbcType=VARCHAR},
+      </if>
+      <if test="bd_text4 != null" >
+        #{bd_text4,jdbcType=VARCHAR},
+      </if>
+      <if test="bd_text5 != null" >
+        #{bd_text5,jdbcType=VARCHAR},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.saas.document.entities.BomDetail" >
+    update bomdetail
+    <set >
+      <if test="bd_bomid != null" >
+        bd_bomid = #{bd_bomid,jdbcType=INTEGER},
+      </if>
+      <if test="bd_detno != null" >
+        bd_detno = #{bd_detno,jdbcType=INTEGER},
+      </if>
+      <if test="bd_sonid != null" >
+        bd_sonid = #{bd_sonid,jdbcType=INTEGER},
+      </if>
+      <if test="bd_soncode != null" >
+        bd_soncode = #{bd_soncode,jdbcType=VARCHAR},
+      </if>
+      <if test="bd_unit != null" >
+        bd_unit = #{bd_unit,jdbcType=VARCHAR},
+      </if>
+      <if test="bd_baseqty != null" >
+        bd_baseqty = #{bd_baseqty,jdbcType=INTEGER},
+      </if>
+      <if test="bd_replace != null" >
+        bd_replace = #{bd_replace,jdbcType=VARCHAR},
+      </if>
+      <if test="bd_remark != null" >
+        bd_remark = #{bd_remark,jdbcType=VARCHAR},
+      </if>
+      <if test="comapnyId != null" >
+        comapnyId = #{comapnyId,jdbcType=INTEGER},
+      </if>
+      <if test="updaterId != null" >
+        updaterId = #{updaterId,jdbcType=INTEGER},
+      </if>
+      <if test="updateTime != null" >
+        updateTime = #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="bd_text1 != null" >
+        bd_text1 = #{bd_text1,jdbcType=VARCHAR},
+      </if>
+      <if test="bd_text2 != null" >
+        bd_text2 = #{bd_text2,jdbcType=VARCHAR},
+      </if>
+      <if test="bd_text3 != null" >
+        bd_text3 = #{bd_text3,jdbcType=VARCHAR},
+      </if>
+      <if test="bd_text4 != null" >
+        bd_text4 = #{bd_text4,jdbcType=VARCHAR},
+      </if>
+      <if test="bd_text5 != null" >
+        bd_text5 = #{bd_text5,jdbcType=VARCHAR},
+      </if>
+    </set>
+    where bd_id = #{id}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.usoftchina.saas.document.entities.BomDetail" >
+    update bomdetail
+    set bd_bomid = #{bd_bomid,jdbcType=INTEGER},
+      bd_detno = #{bd_detno,jdbcType=INTEGER},
+      bd_sonid = #{bd_sonid,jdbcType=INTEGER},
+      bd_soncode = #{bd_soncode,jdbcType=VARCHAR},
+      bd_unit = #{bd_unit,jdbcType=VARCHAR},
+      bd_baseqty = #{bd_baseqty,jdbcType=INTEGER},
+      bd_replace = #{bd_replace,jdbcType=VARCHAR},
+      bd_remark = #{bd_remark,jdbcType=VARCHAR},
+      comapnyId = #{comapnyId,jdbcType=INTEGER},
+      updaterId = #{updaterId,jdbcType=INTEGER},
+      updateTime = #{updateTime,jdbcType=TIMESTAMP},
+      bd_text1 = #{bd_text1,jdbcType=VARCHAR},
+      bd_text2 = #{bd_text2,jdbcType=VARCHAR},
+      bd_text3 = #{bd_text3,jdbcType=VARCHAR},
+      bd_text4 = #{bd_text4,jdbcType=VARCHAR},
+      bd_text5 = #{bd_text5,jdbcType=VARCHAR}
+    where bd_id = #{id}
+  </update>
+  <insert id="batchInsert" parameterType="java.util.List">
+    <foreach collection="list" item="item" index="index" open="" close="" separator=",">
+      INSERT INTO BOMDETAIL
+      <trim prefix="(" suffix=")" suffixOverrides=",">
+        <if test="item.bd_bomid != null" >
+          bd_bomid,
+        </if>
+        <if test="item.bd_detno != null" >
+          bd_detno,
+        </if>
+        <if test="item.bd_sonid != null" >
+          bd_sonid,
+        </if>
+        <if test="item.bd_soncode != null" >
+          bd_soncode,
+        </if>
+        <if test="item.bd_unit != null" >
+          bd_unit,
+        </if>
+        <if test="item.bd_baseqty != null" >
+          bd_baseqty,
+        </if>
+        <if test="item.bd_replace != null" >
+          bd_replace,
+        </if>
+        <if test="item.bd_remark != null" >
+          bd_remark,
+        </if>
+        <if test="item.comapnyId != null" >
+          comapnyId,
+        </if>
+        <if test="item.updaterId != null" >
+          updaterId,
+        </if>
+        <if test="item.updateTime != null" >
+          updateTime,
+        </if>
+        <if test="item.bd_text1 != null" >
+          bd_text1,
+        </if>
+        <if test="item.bd_text2 != null" >
+          bd_text2,
+        </if>
+        <if test="item.bd_text3 != null" >
+          bd_text3,
+        </if>
+        <if test="item.bd_text4 != null" >
+          bd_text4,
+        </if>
+        <if test="item.bd_text5 != null" >
+          bd_text5,
+        </if>
+      </trim>
+      <trim prefix="values (" suffix=")" suffixOverrides="," >
+        <if test="item.bd_bomid != null" >
+          #{item.bd_bomid},
+        </if>
+        <if test="bd_detno != null" >
+          #{item.bd_detno,jdbcType=INTEGER},
+        </if>
+        <if test="bd_sonid != null" >
+          #{item.bd_sonid,jdbcType=INTEGER},
+        </if>
+        <if test="bd_soncode != null" >
+          #{item.bd_soncode,jdbcType=VARCHAR},
+        </if>
+        <if test="bd_unit != null" >
+          #{item.bd_unit,jdbcType=VARCHAR},
+        </if>
+        <if test="bd_baseqty != null" >
+          #{item.bd_baseqty,jdbcType=INTEGER},
+        </if>
+        <if test="bd_replace != null" >
+          #{item.bd_replace,jdbcType=VARCHAR},
+        </if>
+        <if test="bd_remark != null" >
+          #{item.bd_remark,jdbcType=VARCHAR},
+        </if>
+        <if test="comapnyId != null" >
+          #{item.comapnyId,jdbcType=INTEGER},
+        </if>
+        <if test="updaterId != null" >
+          #{item.updaterId,jdbcType=INTEGER},
+        </if>
+        <if test="updateTime != null" >
+          #{item.updateTime,jdbcType=TIMESTAMP},
+        </if>
+        <if test="bd_text1 != null" >
+          #{item.bd_text1,jdbcType=VARCHAR},
+        </if>
+        <if test="bd_text2 != null" >
+          #{item.bd_text2,jdbcType=VARCHAR},
+        </if>
+        <if test="bd_text3 != null" >
+          #{item.bd_text3,jdbcType=VARCHAR},
+        </if>
+        <if test="bd_text4 != null" >
+          #{item.bd_text4,jdbcType=VARCHAR},
+        </if>
+        <if test="bd_text5 != null" >
+          #{item.bd_text5,jdbcType=VARCHAR},
+        </if>
+      </trim>
+    </foreach>
+  </insert>
+
+  <update id="batchUpdate" parameterType="com.usoftchina.saas.document.entities.BomDetail">
+    <foreach collection="list" item="item" index="index" open="" close="" separator=";">
+      UPDATE BOMDETAIL
+      <set >
+        <if test="item.bd_bomid != null" >
+          bd_bomid = #{item.bd_bomid},
+        </if>
+        <if test="bd_detno != null" >
+          bd_detno = #{item.bd_detno,jdbcType=INTEGER},
+        </if>
+        <if test="bd_sonid != null" >
+          bd_sonid = #{item.bd_sonid,jdbcType=INTEGER},
+        </if>
+        <if test="bd_soncode != null" >
+          bd_soncode = #{item.bd_soncode,jdbcType=VARCHAR},
+        </if>
+        <if test="bd_unit != null" >
+          bd_unit = #{item.bd_unit,jdbcType=VARCHAR},
+        </if>
+        <if test="bd_baseqty != null" >
+          bd_baseqty = #{item.bd_baseqty,jdbcType=INTEGER},
+        </if>
+        <if test="bd_replace != null" >
+          bd_replace = #{item.bd_replace,jdbcType=VARCHAR},
+        </if>
+        <if test="bd_remark != null" >
+          bd_remark = #{item.bd_remark,jdbcType=VARCHAR},
+        </if>
+        <if test="comapnyId != null" >
+          comapnyId = #{item.comapnyId,jdbcType=INTEGER},
+        </if>
+        <if test="updaterId != null" >
+          updaterId = #{item.updaterId,jdbcType=INTEGER},
+        </if>
+        <if test="updateTime != null" >
+          updateTime = #{item.updateTime,jdbcType=TIMESTAMP},
+        </if>
+        <if test="bd_text1 != null" >
+          bd_text1 = #{item.bd_text1,jdbcType=VARCHAR},
+        </if>
+        <if test="bd_text2 != null" >
+          bd_text2 = #{item.bd_text2,jdbcType=VARCHAR},
+        </if>
+        <if test="bd_text3 != null" >
+          bd_text3 = #{item.bd_text3,jdbcType=VARCHAR},
+        </if>
+        <if test="bd_text4 != null" >
+          bd_text4 = #{item.bd_text4,jdbcType=VARCHAR},
+        </if>
+        <if test="bd_text5 != null" >
+          bd_text5 = #{item.bd_text5,jdbcType=VARCHAR},
+        </if>
+      </set>
+      where bd_id = #{item.id}
+    </foreach>
+  </update>
+
+  <delete id="deleteByFK" parameterType="java.lang.Long">
+    DELETE FROM BOMDETAIL
+    WHERE BD_BOMID=#{id}
+  </delete>
+</mapper>

+ 251 - 0
applications/document/document-server/src/main/resources/mapper/BomMapper.xml

@@ -0,0 +1,251 @@
+<?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.usoftchina.saas.document.mapper.BomMapper" >
+  <resultMap id="BaseResultMap" type="com.usoftchina.saas.document.entities.Bom" >
+    <id column="bo_id" property="id" jdbcType="INTEGER" />
+    <result column="bo_motherid" property="bo_motherid" jdbcType="INTEGER" />
+    <result column="bo_mothercode" property="bo_mothercode" jdbcType="VARCHAR" />
+    <result column="bo_mothername" property="bo_mothername" jdbcType="VARCHAR" />
+    <result column="bo_version" property="bo_version" jdbcType="VARCHAR" />
+    <result column="bo_status" property="bo_status" jdbcType="VARCHAR" />
+    <result column="bo_statuscode" property="bo_statuscode" jdbcType="VARCHAR" />
+    <result column="bo_recorderid" property="bo_recorderid" jdbcType="INTEGER" />
+    <result column="bo_recorder" property="bo_recorder" jdbcType="VARCHAR" />
+    <result column="bo_recorddate" property="bo_recorddate" jdbcType="TIMESTAMP" />
+    <result column="companyId" property="companyId" jdbcType="INTEGER" />
+    <result column="updaterId" property="updaterId" jdbcType="INTEGER" />
+    <result column="updateTime" property="updateTime" jdbcType="TIMESTAMP" />
+    <result column="bo_text1" property="bo_text1" jdbcType="VARCHAR" />
+    <result column="bo_text2" property="bo_text2" jdbcType="VARCHAR" />
+    <result column="bo_text3" property="bo_text3" jdbcType="VARCHAR" />
+    <result column="bo_text4" property="bo_text4" jdbcType="VARCHAR" />
+    <result column="bo_text5" property="bo_text5" jdbcType="VARCHAR" />
+  </resultMap>
+  <sql id="Base_Column_List" >
+    bo_id, bo_motherid, bo_mothercode, bo_mothername, bo_version, bo_status, bo_statuscode, 
+    bo_recorderid, bo_recorder, bo_recorddate, companyId, updaterId, updateTime, bo_text1, 
+    bo_text2, bo_text3, bo_text4, bo_text5
+  </sql>
+  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
+    select 
+    <include refid="Base_Column_List" />
+    from bom
+    where bo_id = #{id}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
+    delete from bom
+    where bo_id = #{id}
+  </delete>
+  <insert id="insert" parameterType="com.usoftchina.saas.document.entities.Bom" >
+    insert into bom (bo_motherid, bo_mothercode,
+      bo_mothername, bo_version, bo_status, 
+      bo_statuscode, bo_recorderid, bo_recorder, 
+      bo_recorddate, companyId, updaterId, 
+      updateTime, bo_text1, bo_text2, 
+      bo_text3, bo_text4, bo_text5
+      )
+    values (#{bo_motherid,jdbcType=INTEGER}, #{bo_mothercode,jdbcType=VARCHAR},
+      #{bo_mothername,jdbcType=VARCHAR}, #{bo_version,jdbcType=VARCHAR}, #{bo_status,jdbcType=VARCHAR}, 
+      #{bo_statuscode,jdbcType=VARCHAR}, #{bo_recorderid,jdbcType=INTEGER}, #{bo_recorder,jdbcType=VARCHAR}, 
+      #{bo_recorddate,jdbcType=TIMESTAMP}, #{companyId,jdbcType=INTEGER}, #{updaterId,jdbcType=INTEGER}, 
+      #{updateTime,jdbcType=TIMESTAMP}, #{bo_text1,jdbcType=VARCHAR}, #{bo_text2,jdbcType=VARCHAR}, 
+      #{bo_text3,jdbcType=VARCHAR}, #{bo_text4,jdbcType=VARCHAR}, #{bo_text5,jdbcType=VARCHAR}
+      )
+  </insert>
+  <insert id="insertSelective" parameterType="com.usoftchina.saas.document.entities.Bom" >
+    insert into bom
+    <trim prefix="(" suffix=")" suffixOverrides="," >
+      <if test="bo_motherid != null" >
+        bo_motherid,
+      </if>
+      <if test="bo_mothercode != null" >
+        bo_mothercode,
+      </if>
+      <if test="bo_mothername != null" >
+        bo_mothername,
+      </if>
+      <if test="bo_version != null" >
+        bo_version,
+      </if>
+      <if test="bo_status != null" >
+        bo_status,
+      </if>
+      <if test="bo_statuscode != null" >
+        bo_statuscode,
+      </if>
+      <if test="bo_recorderid != null" >
+        bo_recorderid,
+      </if>
+      <if test="bo_recorder != null" >
+        bo_recorder,
+      </if>
+      <if test="bo_recorddate != null" >
+        bo_recorddate,
+      </if>
+      <if test="companyId != null" >
+        companyId,
+      </if>
+      <if test="updaterId != null" >
+        updaterId,
+      </if>
+      <if test="updateTime != null" >
+        updateTime,
+      </if>
+      <if test="bo_text1 != null" >
+        bo_text1,
+      </if>
+      <if test="bo_text2 != null" >
+        bo_text2,
+      </if>
+      <if test="bo_text3 != null" >
+        bo_text3,
+      </if>
+      <if test="bo_text4 != null" >
+        bo_text4,
+      </if>
+      <if test="bo_text5 != null" >
+        bo_text5,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
+      <if test="bo_motherid != null" >
+        #{bo_motherid,jdbcType=INTEGER},
+      </if>
+      <if test="bo_mothercode != null" >
+        #{bo_mothercode,jdbcType=VARCHAR},
+      </if>
+      <if test="bo_mothername != null" >
+        #{bo_mothername,jdbcType=VARCHAR},
+      </if>
+      <if test="bo_version != null" >
+        #{bo_version,jdbcType=VARCHAR},
+      </if>
+      <if test="bo_status != null" >
+        #{bo_status,jdbcType=VARCHAR},
+      </if>
+      <if test="bo_statuscode != null" >
+        #{bo_statuscode,jdbcType=VARCHAR},
+      </if>
+      <if test="bo_recorderid != null" >
+        #{bo_recorderid,jdbcType=INTEGER},
+      </if>
+      <if test="bo_recorder != null" >
+        #{bo_recorder,jdbcType=VARCHAR},
+      </if>
+      <if test="bo_recorddate != null" >
+        #{bo_recorddate,jdbcType=TIMESTAMP},
+      </if>
+      <if test="companyId != null" >
+        #{companyId,jdbcType=INTEGER},
+      </if>
+      <if test="updaterId != null" >
+        #{updaterId,jdbcType=INTEGER},
+      </if>
+      <if test="updateTime != null" >
+        #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="bo_text1 != null" >
+        #{bo_text1,jdbcType=VARCHAR},
+      </if>
+      <if test="bo_text2 != null" >
+        #{bo_text2,jdbcType=VARCHAR},
+      </if>
+      <if test="bo_text3 != null" >
+        #{bo_text3,jdbcType=VARCHAR},
+      </if>
+      <if test="bo_text4 != null" >
+        #{bo_text4,jdbcType=VARCHAR},
+      </if>
+      <if test="bo_text5 != null" >
+        #{bo_text5,jdbcType=VARCHAR},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.saas.document.entities.Bom" >
+    update bom
+    <set >
+      <if test="bo_motherid != null" >
+        bo_motherid = #{bo_motherid,jdbcType=INTEGER},
+      </if>
+      <if test="bo_mothercode != null" >
+        bo_mothercode = #{bo_mothercode,jdbcType=VARCHAR},
+      </if>
+      <if test="bo_mothername != null" >
+        bo_mothername = #{bo_mothername,jdbcType=VARCHAR},
+      </if>
+      <if test="bo_version != null" >
+        bo_version = #{bo_version,jdbcType=VARCHAR},
+      </if>
+      <if test="bo_status != null" >
+        bo_status = #{bo_status,jdbcType=VARCHAR},
+      </if>
+      <if test="bo_statuscode != null" >
+        bo_statuscode = #{bo_statuscode,jdbcType=VARCHAR},
+      </if>
+      <if test="bo_recorderid != null" >
+        bo_recorderid = #{bo_recorderid,jdbcType=INTEGER},
+      </if>
+      <if test="bo_recorder != null" >
+        bo_recorder = #{bo_recorder,jdbcType=VARCHAR},
+      </if>
+      <if test="bo_recorddate != null" >
+        bo_recorddate = #{bo_recorddate,jdbcType=TIMESTAMP},
+      </if>
+      <if test="companyId != null" >
+        companyId = #{companyId,jdbcType=INTEGER},
+      </if>
+      <if test="updaterId != null" >
+        updaterId = #{updaterId,jdbcType=INTEGER},
+      </if>
+      <if test="updateTime != null" >
+        updateTime = #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="bo_text1 != null" >
+        bo_text1 = #{bo_text1,jdbcType=VARCHAR},
+      </if>
+      <if test="bo_text2 != null" >
+        bo_text2 = #{bo_text2,jdbcType=VARCHAR},
+      </if>
+      <if test="bo_text3 != null" >
+        bo_text3 = #{bo_text3,jdbcType=VARCHAR},
+      </if>
+      <if test="bo_text4 != null" >
+        bo_text4 = #{bo_text4,jdbcType=VARCHAR},
+      </if>
+      <if test="bo_text5 != null" >
+        bo_text5 = #{bo_text5,jdbcType=VARCHAR},
+      </if>
+    </set>
+    where bo_id = #{id}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.usoftchina.saas.document.entities.Bom" >
+    update bom
+    set bo_motherid = #{bo_motherid,jdbcType=INTEGER},
+      bo_mothercode = #{bo_mothercode,jdbcType=VARCHAR},
+      bo_mothername = #{bo_mothername,jdbcType=VARCHAR},
+      bo_version = #{bo_version,jdbcType=VARCHAR},
+      bo_status = #{bo_status,jdbcType=VARCHAR},
+      bo_statuscode = #{bo_statuscode,jdbcType=VARCHAR},
+      bo_recorderid = #{bo_recorderid,jdbcType=INTEGER},
+      bo_recorder = #{bo_recorder,jdbcType=VARCHAR},
+      bo_recorddate = #{bo_recorddate,jdbcType=TIMESTAMP},
+      companyId = #{companyId,jdbcType=INTEGER},
+      updaterId = #{updaterId,jdbcType=INTEGER},
+      updateTime = #{updateTime,jdbcType=TIMESTAMP},
+      bo_text1 = #{bo_text1,jdbcType=VARCHAR},
+      bo_text2 = #{bo_text2,jdbcType=VARCHAR},
+      bo_text3 = #{bo_text3,jdbcType=VARCHAR},
+      bo_text4 = #{bo_text4,jdbcType=VARCHAR},
+      bo_text5 = #{bo_text5,jdbcType=VARCHAR}
+    where bo_id = #{id}
+  </update>
+  <select id="validateCodeWhenInsert" resultType="int">
+    select count(*) from BOM where BO_MOTHERCODE = #{code} and companyId =#{companyId}
+  </select>
+  <select id="validateCodeWhenUpdate" resultType="int" >
+    select count(*) from BOM where BO_MOTHERCODE = #{code} and BO_ID != #{id} and companyId =#{companyId}
+  </select>
+  <select id="validCodeAndVersion" resultType="int">
+      SELECT COUNT(*) FROM BOM WHERE BO_MOTHERCODE = #{code} and BO_VERSION=#{version} and COMPANYID=#{companyId}
+  </select>
+</mapper>

+ 1 - 1
applications/document/document-server/src/main/resources/mapper/CustomeraddressMapper.xml

@@ -33,7 +33,7 @@
     from customeraddress
     where ca_id = #{ca_id,jdbcType=INTEGER}
   </select>
-  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
     delete from customeraddress
     where ca_id = #{ca_id,jdbcType=INTEGER}
   </delete>

+ 1 - 1
applications/document/document-server/src/main/resources/mapper/CustomercontactMapper.xml

@@ -29,7 +29,7 @@
     from customercontact
     where cc_id = #{cc_id,jdbcType=INTEGER}
   </select>
-  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
     delete from customercontact
     where cc_id = #{cc_id,jdbcType=INTEGER}
   </delete>

+ 1 - 1
applications/document/document-server/src/main/resources/mapper/VendorMapper.xml

@@ -89,7 +89,7 @@
     </resultMap>
 
     <select id="getListDataByCondition" resultMap="VendorListResultMapper">
-        SELECT * FROM VENDOR LEFT JOIN VENDORCONTACT ON VE_ID = VC_VEID
+        SELECT * FROM VENDOR LEFT JOIN VENDORCONTACT ON VE_ID = VC_VEID and vc_default = 1
         <where>
             <if test="condition!=null">
                 ${condition}

+ 51 - 0
applications/document/document-server/src/test/java/com/usoftchina/saas/document/mapper/CustomerMapperTest.java

@@ -0,0 +1,51 @@
+package com.usoftchina.saas.document.mapper;
+
+import com.usoftchina.saas.document.DocumentApplication;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+/**
+ * Created by zdw
+ * 2018-10-26 14:44.
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = DocumentApplication.class)
+@EnableAutoConfiguration
+public class CustomerMapperTest {
+    @Autowired
+    private CustomerMapper customerMapper;
+
+
+    @Test
+    public void deleteByPrimaryKey() throws Exception {
+    }
+
+    @Test
+    public void insertSelective() throws Exception {
+    }
+
+    @Test
+    public void selectByPrimaryKey() throws Exception {
+        System.out.println("---");
+        System.out.println(customerMapper.selectByPrimaryKey(new Long(24)).getCompanyId());
+
+
+    }
+
+    @Test
+    public void updateByPrimaryKeySelective() throws Exception {
+    }
+
+    @Test
+    public void updateByPrimaryKey() throws Exception {
+    }
+
+    @Test
+    public void selectCodeById() throws Exception {
+    }
+
+}

+ 8 - 0
applications/money/money-server/pom.xml

@@ -24,6 +24,14 @@
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-web</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.usoftchina.saas</groupId>
+            <artifactId>auth-client</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.usoftchina.saas</groupId>
+            <artifactId>server-starter</artifactId>
+        </dependency>
 
         <!-- db -->
         <dependency>

+ 4 - 4
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/controller/ProdInOutController.java

@@ -3,7 +3,7 @@ package com.usoftchina.saas.purchase.controller;
 import com.github.pagehelper.PageInfo;
 import com.usoftchina.saas.base.Result;
 import com.usoftchina.saas.commons.dto.BatchDealBaseDTO;
-import com.usoftchina.saas.commons.dto.DocSavedDTO;
+import com.usoftchina.saas.commons.dto.DocBaseDTO;
 import com.usoftchina.saas.page.PageRequest;
 import com.usoftchina.saas.purchase.dto.ProdInOutFormDTO;
 import com.usoftchina.saas.purchase.dto.ProdInOutReqDTO;
@@ -56,8 +56,8 @@ public class ProdInOutController {
      * @return
      */
     @PostMapping("/save")
-    public Result<DocSavedDTO> saveFormData(@RequestBody ProdInOutFormDTO data) {
-        DocSavedDTO savedDTO = prodInOutService.saveFormData(data,false);
+    public Result<DocBaseDTO> saveFormData(@RequestBody ProdInOutFormDTO data) {
+        DocBaseDTO savedDTO = prodInOutService.saveFormData(data);
         return Result.success(savedDTO);
     }
 
@@ -94,7 +94,7 @@ public class ProdInOutController {
      */
     @PostMapping("/audit")
     public Result audit(@RequestBody ProdInOutFormDTO formData) {
-        DocSavedDTO audit = prodInOutService.audit(formData);
+        DocBaseDTO audit = prodInOutService.audit(formData);
         return Result.success(audit);
     }
 

+ 0 - 4
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/mapper/ProdIODetailMapper.java

@@ -10,14 +10,10 @@ public interface ProdIODetailMapper extends CommonBaseMapper<ProdIODetail> {
 
     int deleteByPrimaryKey(Long pd_id);
 
-    int insert(ProdIODetail record);
-
     int insertSelective(ProdIODetail record);
 
-
     ProdIODetail selectByPrimaryKey(Integer pd_id);
 
-
     int updateByPrimaryKeySelective(ProdIODetail record);
 
     int updateByPrimaryKeyWithBLOBs(ProdIODetail record);

+ 0 - 5
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/mapper/ProdInOutMapper.java

@@ -8,15 +8,10 @@ public interface ProdInOutMapper extends CommonBaseMapper<ProdInOut> {
 
     int deleteByPrimaryKey(Long pi_id);
 
-    int insert(ProdInOut record);
-
     int insertSelective(ProdInOut record);
 
-
-
     ProdInOut selectByPrimaryKey(Long pi_id);
 
-
     int updateByPrimaryKeySelective(ProdInOut record);
 
     int updateByPrimaryKeyWithBLOBs(ProdInOut record);

+ 1 - 2
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/service/ProdInOutService.java

@@ -5,7 +5,6 @@ import com.usoftchina.saas.base.Result;
 import com.usoftchina.saas.base.service.CommonBaseService;
 import com.usoftchina.saas.commons.dto.BatchDealBaseDTO;
 import com.usoftchina.saas.commons.dto.DocBaseDTO;
-import com.usoftchina.saas.commons.dto.DocSavedDTO;
 import com.usoftchina.saas.page.PageRequest;
 import com.usoftchina.saas.purchase.dto.ProdInOutFormDTO;
 import com.usoftchina.saas.purchase.dto.ProdInOutReqDTO;
@@ -46,7 +45,7 @@ public interface ProdInOutService extends CommonBaseService<ProdInOutMapper, Pro
      * @param formData
      * @return
      */
-    DocSavedDTO audit(ProdInOutFormDTO formData);
+    DocBaseDTO audit(ProdInOutFormDTO formData);
 
     /**
      * 反审核出入库单

+ 17 - 17
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/service/impl/ProdInOutServiceImpl.java

@@ -7,7 +7,6 @@ import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
 import com.usoftchina.saas.commons.api.MaxnumberService;
 import com.usoftchina.saas.commons.dto.BatchDealBaseDTO;
 import com.usoftchina.saas.commons.dto.DocBaseDTO;
-import com.usoftchina.saas.commons.dto.DocSavedDTO;
 import com.usoftchina.saas.commons.exception.BizExceptionCode;
 import com.usoftchina.saas.context.BaseContextHolder;
 import com.usoftchina.saas.document.api.WarehouseApi;
@@ -19,7 +18,9 @@ import com.usoftchina.saas.purchase.dto.ProdInOutDTO;
 import com.usoftchina.saas.purchase.dto.ProdInOutFormDTO;
 import com.usoftchina.saas.purchase.dto.ProdInOutReqDTO;
 import com.usoftchina.saas.purchase.mapper.*;
-import com.usoftchina.saas.purchase.po.*;
+import com.usoftchina.saas.purchase.po.ProdIODetail;
+import com.usoftchina.saas.purchase.po.ProdInOut;
+import com.usoftchina.saas.purchase.po.ProdInOutList;
 import com.usoftchina.saas.purchase.service.ProdInOutService;
 import com.usoftchina.saas.utils.BeanMapper;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -96,7 +97,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
     }
 
     @Override
-    public DocSavedDTO saveFormData(ProdInOutFormDTO formdata,Boolean isbfaudit) {
+    public DocBaseDTO saveFormData(ProdInOutFormDTO formdata) {
         if (null == formdata || null == formdata.getMain()){
             throw new BizException(500, "数据为空,请填写后再保存");
         }
@@ -111,7 +112,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         List<ProdIODetail> insertDetails = new ArrayList<>();
         //更新从表数据
         List<ProdIODetail> updateDetails = new ArrayList<>();
-        DocSavedDTO saveDTO = new DocSavedDTO();
+        DocBaseDTO baseDTO = new DocBaseDTO();
         Long pi_id = main.getId();
         String pi_inoutno = main.getPi_inoutno();
         ProdInOut prodInOut = BeanMapper.map(main,ProdInOut.class);
@@ -124,7 +125,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         //编号获取
         pi_inoutno = pushMaxnubmer(pi_inoutno, pi_id);
         prodInOut.setPi_inoutno(pi_inoutno);
-        saveDTO.setCode(pi_inoutno);
+        baseDTO.setCode(pi_inoutno);
         //判断更新与保存动作
         if (StringUtils.isEmpty(pi_id) || "0".equals(pi_id.toString())){
             //插入操作
@@ -143,8 +144,8 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
             if (insertDetails.size()>0) {
                 prodIODetailMapper.batchInsert(insertDetails);
             }
-            saveDTO.setId(pi_id);
-            return saveDTO;
+            baseDTO.setId(pi_id);
+            return baseDTO;
         }
         //更新操作
         getMapper().updateByPrimaryKeySelective(prodInOut);
@@ -168,11 +169,10 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         if (updateDetails.size()>0) {
             prodIODetailMapper.batchUpdate(updateDetails);
         }
-        saveDTO.setId(pi_id);
+        baseDTO.setId(pi_id);
         //更新已转数
-        if (!isbfaudit)
-            updateYqty(prodInOut);
-        return saveDTO;
+        updateYqty(prodInOut);
+        return baseDTO;
     }
 
     @Override
@@ -195,19 +195,19 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
 
 
     @Override
-    public DocSavedDTO audit(ProdInOutFormDTO formData) {
+    public DocBaseDTO audit(ProdInOutFormDTO formData) {
         Long id = null;
-        DocSavedDTO savedDTO = new DocSavedDTO();
+        DocBaseDTO baseDTO = new DocBaseDTO();
         if (null != formData) {
             id = formData.getMain().getId();
             if (StringUtils.isEmpty(id)) {
-                DocSavedDTO saveDTO = saveFormData(formData,true);
-                id = saveDTO.getId();
+                baseDTO = saveFormData(formData);
+                id = baseDTO.getId();
             }
             singleAudit(formData.getMain());
         }
-        savedDTO.setId(id);
-        return savedDTO;
+        baseDTO.setId(id);
+        return baseDTO;
     }
 
     @Override

+ 1 - 58
applications/purchase/purchase-server/src/main/resources/mapper/ProdIODetailMapper.xml

@@ -97,37 +97,6 @@
     delete from prodiodetail
     where pd_id = #{pd_id,jdbcType=INTEGER}
   </delete>
-  <insert id="insert" parameterType="com.usoftchina.saas.purchase.po.ProdIODetail">
-    insert into prodiodetail (pd_id, pd_piid, pd_inoutno, 
-      pd_piclass, pd_pdno, pd_ordercode, 
-      pd_orderdetno, pd_prodid, pd_prodcode, 
-      pd_unit, pd_inqty, pd_outqty, 
-      pd_orderprice, pd_sendprice, pd_price, 
-      pd_total, pd_taxrate, pd_netprice, 
-      pd_nettotal, pd_whid, pd_whcode, 
-      pd_whname, pd_inwhid, pd_inwhcode, 
-      pd_inwhname, pd_orderid, pd_sdid, 
-      pd_status, companyid, updaterid, 
-      updatetime, pd_text1, pd_text2, 
-      pd_text3, pd_text4, pd_text5, 
-      pd_ym, pd_yqty, pd_remark,pd_ioid
-      )
-    values (#{pd_id,jdbcType=INTEGER}, #{pd_piid,jdbcType=INTEGER}, #{pd_inoutno,jdbcType=VARCHAR}, 
-      #{pd_piclass,jdbcType=VARCHAR}, #{pd_pdno,jdbcType=INTEGER}, #{pd_ordercode,jdbcType=VARCHAR}, 
-      #{pd_orderdetno,jdbcType=INTEGER}, #{pd_prodid,jdbcType=INTEGER}, #{pd_prodcode,jdbcType=VARCHAR}, 
-      #{pd_unit,jdbcType=VARCHAR}, #{pd_inqty,jdbcType=DOUBLE}, #{pd_outqty,jdbcType=DOUBLE},
-      #{pd_orderprice,jdbcType=DOUBLE}, #{pd_sendprice,jdbcType=DOUBLE}, #{pd_price,jdbcType=DOUBLE}, 
-      #{pd_total,jdbcType=DOUBLE}, #{pd_taxrate,jdbcType=DOUBLE}, #{pd_netprice,jdbcType=DOUBLE},
-      #{pd_nettotal,jdbcType=DOUBLE}, #{pd_whid,jdbcType=INTEGER}, #{pd_whcode,jdbcType=VARCHAR}, 
-      #{pd_whname,jdbcType=VARCHAR}, #{pd_inwhid,jdbcType=INTEGER}, #{pd_inwhcode,jdbcType=VARCHAR}, 
-      #{pd_inwhname,jdbcType=VARCHAR}, #{pd_orderid,jdbcType=INTEGER}, #{pd_sdid,jdbcType=INTEGER}, 
-      #{pd_status,jdbcType=INTEGER}, #{companyid,jdbcType=INTEGER}, #{updaterid,jdbcType=INTEGER}, 
-      #{updatetime,jdbcType=TIMESTAMP}, #{pd_text1,jdbcType=VARCHAR}, #{pd_text2,jdbcType=VARCHAR}, 
-      #{pd_text3,jdbcType=VARCHAR}, #{pd_text4,jdbcType=VARCHAR}, #{pd_text5,jdbcType=VARCHAR}, 
-      #{pd_ym,jdbcType=INTEGER}, #{pd_yqty,jdbcType=DOUBLE}, #{pd_remark,jdbcType=LONGVARCHAR},
-      #{pd_ioid,jdbcType=INTEGER}
-      )
-  </insert>
   <insert id="insertSelective" parameterType="com.usoftchina.saas.purchase.po.ProdIODetail">
     <selectKey resultType="java.lang.Long" keyProperty="id">
       SELECT LAST_INSERT_ID() AS ID
@@ -581,32 +550,6 @@
     where pd_id = #{pd_id,jdbcType=INTEGER}
   </update>
   <insert id="batchInsert" parameterType="java.util.List" >
-    insert into prodiodetail
-    (
-    pd_piid,pd_inoutno,pd_piclass,pd_pdno,pd_ordercode,
-    pd_orderdetno,pd_prodid,pd_prodcode,pd_unit,
-    pd_inqty,pd_outqty,pd_orderprice,pd_sendprice,pd_price,
-    pd_total,pd_taxrate,pd_netprice,pd_nettotal,
-    pd_whid,pd_whcode,pd_whname,pd_inwhid,pd_inwhcode,
-    pd_inwhname,pd_orderid,pd_sdid,pd_status,pd_remark,
-    companyid,updaterid,updatetime,pd_text1,pd_text2,
-    pd_text3,pd_text4,pd_text5,pd_ym,pd_yqty
-    )
-    values
-    <foreach collection="list" item="item" index="index" open="" close="" separator=",">
-      (
-      #{item.pd_piid,jdbcType=INTEGER},#{item.pd_inoutno,jdbcType=VARCHAR},#{item.pd_piclass,jdbcType=VARCHAR},#{item.pd_pdno,jdbcType=INTEGER},#{item.pd_ordercode,jdbcType=VARCHAR},
-      #{item.pd_orderdetno,jdbcType=INTEGER},#{item.pd_prodid,jdbcType=INTEGER},#{item.pd_prodcode,jdbcType=VARCHAR},#{item.pd_unit,jdbcType=VARCHAR},
-      #{item.pd_inqty,jdbcType=DOUBLE},#{item.pd_outqty,jdbcType=DOUBLE},#{item.pd_orderprice,jdbcType=DOUBLE},#{item.pd_sendprice,jdbcType=DOUBLE},#{item.pd_price,jdbcType=DOUBLE},
-      #{item.pd_total,jdbcType=DOUBLE},#{item.pd_taxrate,jdbcType=DOUBLE},#{item.pd_netprice,jdbcType=DOUBLE},#{item.pd_nettotal,jdbcType=DOUBLE},
-      #{item.pd_whid,jdbcType=INTEGER},#{item.pd_whcode,jdbcType=VARCHAR},#{item.pd_whname,jdbcType=VARCHAR},#{item.pd_inwhid,jdbcType=INTEGER},#{item.pd_inwhcode,jdbcType=VARCHAR},
-      #{item.pd_inwhname,jdbcType=VARCHAR},#{item.pd_orderid,jdbcType=INTEGER},#{item.pd_sdid,jdbcType=INTEGER},#{item.pd_status,jdbcType=VARCHAR},#{item.pd_remark,jdbcType=VARCHAR},
-      #{item.companyId,jdbcType=INTEGER},#{item.updaterId,jdbcType=INTEGER},#{item.updateTime,jdbcType=TIMESTAMP},#{item.pd_text1,jdbcType=VARCHAR},#{item.pd_text2,jdbcType=VARCHAR},
-      #{item.pd_text3,jdbcType=VARCHAR},#{item.pd_text4,jdbcType=VARCHAR},#{item.pd_text5,jdbcType=VARCHAR},#{item.pd_ym,jdbcType=INTEGER},#{item.pd_yqty,jdbcType=DOUBLE}
-      )
-    </foreach>
-  </insert>
-  <insert id="batchInsert1" parameterType="java.util.List" >
     <foreach collection="list" item="item" index="index" open="" close="" separator=",">
       insert into prodiodetail
       <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -847,9 +790,9 @@
           #{item.pd_ioid,jdbcType=INTEGER},
         </if>
       </trim>
-
     </foreach>
   </insert>
+
   <update id="batchUpdate" parameterType="com.usoftchina.saas.purchase.po.ProdIODetail" >
     <foreach collection="list" item="item" index="index" open="" close="" separator=";">
       update prodiodetail <set>

+ 0 - 24
applications/purchase/purchase-server/src/main/resources/mapper/ProdInOutMapper.xml

@@ -64,30 +64,6 @@
     where pi_id = #{pi_id,jdbcType=INTEGER}
   </delete>
 
-  <insert id="insert" parameterType="com.usoftchina.saas.purchase.po.ProdInOut">
-    insert into prodinout (pi_id, pi_inoutno, pi_class, 
-      pi_date, pi_vendid, pi_vendcode, 
-      pi_vendname, pi_custid, pi_custcode, 
-      pi_custname, pi_puid, pi_pucode, 
-      pi_said, pi_sacode, pi_total, 
-      pi_recordmanid, pi_recordman, pi_recorddate, 
-      pi_status, pi_statuscode, pi_printstatus, 
-      pi_printstatuscode, companyid, updaterid, 
-      updatetime, pi_text1, pi_text2, 
-      pi_text3, pi_text4, pi_text5,
-      pi_address)
-    values (#{pi_id,jdbcType=INTEGER}, #{pi_inoutno,jdbcType=VARCHAR}, #{pi_class,jdbcType=VARCHAR}, 
-      #{pi_date,jdbcType=TIMESTAMP}, #{pi_vendid,jdbcType=INTEGER}, #{pi_vendcode,jdbcType=VARCHAR}, 
-      #{pi_vendname,jdbcType=VARCHAR}, #{pi_custid,jdbcType=INTEGER}, #{pi_custcode,jdbcType=VARCHAR}, 
-      #{pi_custname,jdbcType=VARCHAR}, #{pi_puid,jdbcType=INTEGER}, #{pi_pucode,jdbcType=VARCHAR}, 
-      #{pi_said,jdbcType=INTEGER}, #{pi_sacode,jdbcType=VARCHAR}, #{pi_total,jdbcType=DOUBLE},
-      #{pi_recordmanid,jdbcType=INTEGER}, #{pi_recordman,jdbcType=VARCHAR}, #{pi_recorddate,jdbcType=TIMESTAMP}, 
-      #{pi_status,jdbcType=VARCHAR}, #{pi_statuscode,jdbcType=VARCHAR}, #{pi_printstatus,jdbcType=VARCHAR}, 
-      #{pi_printstatuscode,jdbcType=VARCHAR}, #{companyid,jdbcType=INTEGER}, #{updaterid,jdbcType=INTEGER}, 
-      #{updatetime,jdbcType=TIMESTAMP}, #{pi_text1,jdbcType=VARCHAR}, #{pi_text2,jdbcType=VARCHAR}, 
-      #{pi_text3,jdbcType=VARCHAR}, #{pi_text4,jdbcType=VARCHAR}, #{pi_text5,jdbcType=VARCHAR}, 
-      #{pi_address,jdbcType=LONGVARCHAR})
-  </insert>
   <insert id="insertSelective" parameterType="com.usoftchina.saas.purchase.po.ProdInOut">
     <selectKey resultType="java.lang.Long" keyProperty="id">
       SELECT LAST_INSERT_ID() AS ID

+ 4 - 11
applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/SaleApplication.java

@@ -4,8 +4,8 @@ import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
-import org.springframework.web.servlet.config.annotation.CorsRegistry;
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+
 
 /**
  * @author: guq
@@ -14,16 +14,9 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
 @SpringBootApplication
 @MapperScan("com.usoftchina.saas.sale.mapper")
 @EnableEurekaClient
-public class SaleApplication extends WebMvcConfigurerAdapter{
+@EnableFeignClients("com.usoftchina.saas")
+public class SaleApplication{
     public static void main(String[] args) {
         SpringApplication.run(SaleApplication.class, args);
     }
-    @Override
-    public void addCorsMappings(CorsRegistry registry) {
-        registry.addMapping("/**")
-                .allowCredentials(true)
-                .allowedHeaders("*")
-                .allowedOrigins("*")
-                .allowedMethods("*");
-    }
 }

+ 3 - 2
applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/controller/ProdInOutController.java

@@ -3,6 +3,7 @@ package com.usoftchina.saas.sale.controller;
 import com.github.pagehelper.PageInfo;
 import com.usoftchina.saas.base.Result;
 import com.usoftchina.saas.commons.dto.BatchDealBaseDTO;
+import com.usoftchina.saas.commons.dto.DocBaseDTO;
 import com.usoftchina.saas.commons.dto.DocSavedDTO;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
 import com.usoftchina.saas.page.PageRequest;
@@ -59,7 +60,7 @@ public class ProdInOutController {
      */
     @PostMapping("/save")
     public Result<DocSavedDTO> saveFormData(@RequestBody ProdInOutFormDTO data) {
-        DocSavedDTO savedDTO = prodInOutService.saveFormData(data,false);
+        DocBaseDTO savedDTO = prodInOutService.saveFormData(data);
         return Result.success(savedDTO);
     }
 
@@ -96,7 +97,7 @@ public class ProdInOutController {
      */
     @PostMapping("/audit")
     public Result audit(@RequestBody ProdInOutFormDTO formData) {
-        DocSavedDTO audit = prodInOutService.audit(formData);
+        DocBaseDTO audit = prodInOutService.audit(formData);
         return Result.success(audit);
     }
 

+ 4 - 0
applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/mapper/ProdInOutMapper.java

@@ -50,4 +50,8 @@ public interface ProdInOutMapper extends CommonBaseMapper<ProdInOut> {
     String validateAudit(List<DocBaseDTO> baseDTOs);
 
     String validateBatchUnAudit(List<DocBaseDTO> baseDTOs);
+
+    String validateBatchClose(List<DocBaseDTO> baseDTOs);
+
+    String validateBatchOpen(List<DocBaseDTO> baseDTOs);
 }

+ 4 - 0
applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/mapper/SaleMapper.java

@@ -33,4 +33,8 @@ public interface SaleMapper {
     Integer validateCodeWhenUpdate(@Param("code") String code, @Param("id") Long id, @Param("companyId") Long companyId);
 
     void updateTotal(Long id);
+
+    void updateTotalAndNetPrice(Long id);
+
+    void updateNetTotal(Long id);
 }

+ 56 - 10
applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/service/ProdInOutService.java

@@ -22,7 +22,6 @@ import com.usoftchina.saas.storage.po.ProdInOutList;
  */
 public interface ProdInOutService extends CommonBaseService<ProdInOutMapper, ProdInOut>  {
 
-
     /**
      * 获取出入单表单
      *
@@ -45,6 +44,19 @@ public interface ProdInOutService extends CommonBaseService<ProdInOutMapper, Pro
      */
     void delete(Long id);
 
+    /**
+     * 批量删除出入库单
+     * @param baseDTOs
+     */
+    void batchDelete(BatchDealBaseDTO baseDTOs);
+
+    /**
+     * 删除明细
+     * @param id
+     * @return
+     */
+    Integer deleteItem(Long id);
+
     /**
      * 审核出入库单
      * @param formData
@@ -52,25 +64,59 @@ public interface ProdInOutService extends CommonBaseService<ProdInOutMapper, Pro
      */
     DocBaseDTO audit(ProdInOutFormDTO formData);
 
+    /**
+     * 批量审核出入库
+     * @param baseDTOs
+     * @return
+     */
+    void batchAudit(BatchDealBaseDTO baseDTOs);
+
     /**
      * 反审核出入库单
      * @param id
      */
     Result unAudit(Long id);
 
-    void batchAudit(BatchDealBaseDTO baseDTOs);
-
-    Integer deleteItem(Long id);
+    /**
+     * 批量反审核出入库单
+     * @param baseDTOs
+     */
+    void batchUnAudit(BatchDealBaseDTO baseDTOs);
 
-    void batchDelete(BatchDealBaseDTO baseDTOs);
+    /**
+     * 启用出入库单
+     * @param id
+     */
+    Result open(Long id);
 
-    PageInfo<ProdInOutList> getListData(PageRequest page, ListReqDTO req);
+    /**
+     * 关闭出入库单
+     * @param
+     */
+    Result close(Long id);
 
-    Result turnProdin(Long id);
+    /**
+     * 批量启用出入库单
+     * @param baseDTOs
+     */
+    void batchOpen(BatchDealBaseDTO baseDTOs);
 
-    void batchUnAudit(BatchDealBaseDTO baseDTOs);
+    /**
+     * 批量关闭出入库单
+     * @param baseDTOs
+     */
+    void batchClose(BatchDealBaseDTO baseDTOs);
 
-    void open(Long id);
+    /**
+     * 获取列表信息
+     * @param page 分页
+     * @param req
+     */
+    PageInfo<ProdInOutList> getListData(PageRequest page, ListReqDTO req);
 
-    void close(Long id);
+    /**
+     * 出库单转退货单
+     * @param id
+     */
+    Result turnProdin(Long id);
 }

+ 124 - 75
applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/service/impl/ProdInOutServiceImpl.java

@@ -12,7 +12,6 @@ import com.usoftchina.saas.commons.dto.DocSavedDTO;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
 import com.usoftchina.saas.commons.exception.BizExceptionCode;
 import com.usoftchina.saas.commons.po.BillCodeSeq;
-import com.usoftchina.saas.commons.po.Maxnumbers;
 import com.usoftchina.saas.commons.po.Status;
 import com.usoftchina.saas.context.BaseContextHolder;
 import com.usoftchina.saas.document.api.WarehouseApi;
@@ -22,7 +21,6 @@ import com.usoftchina.saas.page.PageRequest;
 import com.usoftchina.saas.sale.dto.ProdIODetailDTO;
 import com.usoftchina.saas.sale.dto.ProdInOutDTO;
 import com.usoftchina.saas.sale.dto.ProdInOutFormDTO;
-import com.usoftchina.saas.sale.dto.ProdInOutReqDTO;
 import com.usoftchina.saas.sale.mapper.*;
 import com.usoftchina.saas.sale.service.ProdInOutService;
 import com.usoftchina.saas.storage.po.ProdIODetail;
@@ -56,7 +54,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
     public ProdInOutFormDTO getFormData(Long id) {
         ProdInOutFormDTO prodInOutFormDTO = new ProdInOutFormDTO();
         //查询主表
-        ProdInOut prodInOut = getMapper().selectByPrimaryKey(id);
+        ProdInOut prodInOut = checkAndReturnOrder(id);
         //将prodInOut实体对象转化为传输对象
         ProdInOutDTO main = BeanMapper.map(prodInOut,ProdInOutDTO.class);
         //查询从表
@@ -98,7 +96,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         prodInOut.setPi_date(new Date());
 
         //编号获取
-        pi_inoutno = pushMaxnubmer(pi_inoutno, pi_id,pi_class);
+        pi_inoutno = pushMaxnubmer(prodInOut);
         prodInOut.setPi_inoutno(pi_inoutno);
 
         prodInOut.setPi_class(main.getPi_class());
@@ -166,7 +164,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         singleDelete(id);
     }
     private void singleDelete(Long id) {
-        ProdInOut prodInOut = getMapper().selectByPrimaryKey(id);
+        ProdInOut prodInOut = checkAndReturnOrder(id);
         //从表删除
         prodIODetailMapper.deleteByForeignKey(id);
         //主表删除
@@ -175,8 +173,9 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         //更新已转数
         updateYqty(prodInOut);
         //日志
-        messageLogService.deleteDetail(docBaseDTO);
+       messageLogService.deleteDetail(docBaseDTO);
     }
+
     @Override
     @Transactional
     public DocBaseDTO audit(ProdInOutFormDTO formData) {
@@ -216,16 +215,14 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
             return "";
         }
     }
+
     @Override
     public Result unAudit(Long id) {
-        if (null == id) {
-            return Result.error(BizExceptionCode.SALE_NULL_BILL);
-        }
+        ProdInOut prodInOut = checkAndReturnOrder(id);
         String code = prodInOutMapper.validateUnAudit(id);
-        if (null != code) {
+        if (!prodInOut.getPi_statuscode().equals(Status.AUDITED.name())) {
             throw new BizException(BizExceptionCode.SALE_NULL_BILL);
         }
-        ProdInOut prodInOut = prodInOutMapper.selectByPrimaryKey(id);
         ProdInOutDTO prodInOutDTO = BeanMapper.map(prodInOut, ProdInOutDTO.class);
         String res =  singleUnAudit(prodInOutDTO);
         if(res!=null){
@@ -247,6 +244,13 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         if(result!=null){
             return result.toString();
         }else{
+            //更新状态为未审核
+            ProdInOut prodInOut = BeanMapper.map(prodInOutDTO, ProdInOut.class);
+            prodInOut.setPi_statuscode(Status.UNAUDITED.name());
+            prodInOut.setPi_status(Status.UNAUDITED.getDisplay());
+            prodInOut.setUpdateTime(new Date());
+            prodInOut.setUpdaterId(BaseContextHolder.getUserId());
+            getMapper().updateByPrimaryKeySelective(prodInOut);
             //记录日志
             DocBaseDTO docBaseDTO = getBaseDTOById(prodInOutDTO.getId(),pi_class);
             //日志
@@ -254,6 +258,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
             return "";
         }
     }
+
     @Override
     public void batchAudit(BatchDealBaseDTO baseDTOs) {
         if (null == baseDTOs || null == baseDTOs.getBaseDTOs() ||
@@ -271,7 +276,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
             ProdInOutDTO prodInOutDTO = BeanMapper.map(prodInOut,ProdInOutDTO.class);
             error+=singleAudit(prodInOutDTO);
         }
-        if(error!=null&&!error.equals("")){
+        if(!StringUtils.isEmpty(error)){
             new BizException(501,error);
         }
     }
@@ -294,7 +299,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
             ProdInOutDTO prodInOutDTO = BeanMapper.map(prodInOut,ProdInOutDTO.class);
             error+=singleUnAudit(prodInOutDTO);
         }
-        if(error!=null&&!error.equals("")){
+        if(!StringUtils.isEmpty(error)){
             new BizException(501,error);
         }
     }
@@ -302,15 +307,16 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
     @Override
     public Integer deleteItem(Long id) {
         ProdIODetail prodIODetail = prodIODetailMapper.selectByPrimaryKey(id);
-        ProdInOut prodInOut = prodInOutMapper.selectByPrimaryKey(prodIODetail.getPd_piid());
+        ProdInOut prodInOut = checkAndReturnOrder(prodIODetail.getPd_piid());
         Integer num = prodIODetailMapper.deleteByPrimaryKey(id);
         //更新已转数
         updateYqty(prodInOut);
         DocBaseDTO docBaseDTO = getBaseDTOById(id,prodInOut.getPi_class());
         //日志
-        messageLogService.deleteDetail(docBaseDTO);
+       messageLogService.deleteDetail(docBaseDTO);
         return num;
     }
+
     @Override
     public void batchDelete(BatchDealBaseDTO baseDTOs) {
         if (null == baseDTOs || null == baseDTOs.getBaseDTOs() ||
@@ -337,6 +343,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         PageInfo<ProdInOutList> pageInfo = new PageInfo<ProdInOutList>(lists);
         return pageInfo;
     }
+
     private List<ProdInOutList> getListByMode(ListReqDTO req) {
         List<ProdInOutList> list = null;
         Long companyId = BaseContextHolder.getCompanyId();
@@ -351,12 +358,13 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         }
         return list;
     }
+
     @Override
     public Result turnProdin(Long id) {
         Integer count=0;
         double pdOutqty=0;
         double pdYqty=0;
-        ProdInOut sourcePi = prodInOutMapper.selectByPrimaryKey(id);
+        ProdInOut sourcePi = checkAndReturnOrder(id);
         List<ProdIODetail> sourceDetails =prodIODetailMapper.selectByFK(id);
         if (null == sourcePi || StringUtils.isEmpty(sourcePi.getPi_inoutno()) || sourceDetails.size() == 0) {
             throw new BizException(BizExceptionCode.SALE_NULL_BILL);
@@ -383,7 +391,9 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         //插入销售退货单主表
         ProdInOut targetPi = new ProdInOut();
         //生成单号
-        String piInoutno =  maxnumberService.getMaxnumber(BillCodeSeq.SALEIN.getCaller(),true).getData();
+        String piInoutno =
+                //BillCodeSeq.SALEIN.getCaller() + Math.abs(Math.random()*100);
+                maxnumberService.getMaxnumber(BillCodeSeq.SALEIN.getCaller(),true).getData();
         targetPi.setPi_inoutno(piInoutno);
         targetPi.setPi_class(BillCodeSeq.SALEIN.getName());
         targetPi.setPi_date(new Date());
@@ -442,81 +452,96 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
 
     @Override
     @Transactional
-    public void close(Long id) {
-        if(id == null || id <= 0) {
-            throw new BizException(BizExceptionCode.ILLEGAL_ID);
-        }
-        ProdInOut prodInOut =  prodInOutMapper.selectByPrimaryKey(id);
-        if(prodInOut==null){
-            throw new BizException(BizExceptionCode.NO_DATA);
+    public Result close(Long id) {
+        String res = singleClose(id);
+        if(StringUtils.hasText(res)){
+            return Result.error(res);
+        }else{
+            return Result.success();
         }
+    }
+
+    private String singleClose(Long id){
+        ProdInOut prodInOut = checkAndReturnOrder(id);
+        //状态校验
         if(Status.CLOSE.name().equals(prodInOut.getPi_status())){
-            throw new BizException(BizExceptionCode.BIZ_CLOSE);
+            return BizExceptionCode.BIZ_CLOSE.getMessage();
         }
+        //更新状态
         prodInOut.setPi_status(Status.CLOSE.getDisplay());
         prodInOut.setPi_statuscode(Status.CLOSE.name());
 
         prodInOutMapper.updateByPrimaryKeySelective(prodInOut);
-        DocBaseDTO docBaseDTO = getBaseDTOById(id,prodInOut.getPi_class());
-        //日志
-        messageLogService.close(docBaseDTO);
+        //记录日志
+        DocBaseDTO docBaseDTO = getBaseDTOById(prodInOut.getId(),prodInOut.getPi_class());
+       messageLogService.close(docBaseDTO);
+        return "";
     }
 
     @Override
-    @Transactional
-    public void open(Long id){
-        ProdInOut prodInOut = prodInOutMapper.selectByPrimaryKey(id);
-        if(prodInOut==null){
-            throw new BizException(BizExceptionCode.NO_DATA);
+    public  void batchClose(BatchDealBaseDTO baseDTOs){
+        if (null == baseDTOs || null == baseDTOs.getBaseDTOs() ||
+                baseDTOs.getBaseDTOs().size() == 0) {
+            return;
         }
-        List<ProdIODetail> prodIODetailList = prodIODetailMapper.selectByFK(id);
-        //部分入库、全部入库
-        int partTurnCount = 0,turnCount = 0;
-        Double yqty=0.0,qty=0.0;
-        Boolean isIn = false;
-        if(BillCodeSeq.SALEIN.getName().equals(prodInOut.getPi_class())){
-            isIn=true;
-        }
-        if(prodIODetailList!=null&&prodIODetailList.size()>0){
-            for (ProdIODetail prodiodetail :prodIODetailList){
-                yqty = prodiodetail.getPd_yqty() ==null?0.0:prodiodetail.getPd_yqty();
-                if(isIn){
-                    qty = prodiodetail.getPd_inqty() ==null?0.0:prodiodetail.getPd_yqty();
-                }else{
-                    qty = prodiodetail.getPd_outqty() ==null?0.0:prodiodetail.getPd_outqty();
-                }
-                if(yqty >= qty){
-                    turnCount++;
-                }else if(yqty>0&&yqty<qty){
-                    partTurnCount++;
-                }
-            }
+        String validate = prodInOutMapper.validateBatchClose(baseDTOs.getBaseDTOs());
+        if (!StringUtils.isEmpty(validate)) {
+            throw new BizException(503, "存在非已审核单据,单据编号:" + validate);
         }
-        if(partTurnCount>0){
-            if(isIn){
-                prodInOut.setPi_status(Status.PART2IN.getDisplay());
-                prodInOut.setPi_statuscode(Status.PART2IN.name());
-            }else {
-                prodInOut.setPi_status(Status.PARTOUT.getDisplay());
-                prodInOut.setPi_statuscode(Status.PARTOUT.name());
-            }
-        }else if(turnCount == prodIODetailList.size()){
-            if(isIn){
-                prodInOut.setPi_status(Status.TURNIN.getDisplay());
-                prodInOut.setPi_statuscode(Status.TURNIN.name());
-            }else {
-                prodInOut.setPi_status(Status.TURNOUT.getDisplay());
-                prodInOut.setPi_statuscode(Status.TURNOUT.name());
-            }
+        String error = null;
+        for (DocBaseDTO base : baseDTOs.getBaseDTOs()) {
+            error+=singleClose(base.getId());
+        }
+        if(!StringUtils.isEmpty(error)){
+            new BizException(501,error);
+        }
+    }
+
+    @Override
+    @Transactional
+    public Result open(Long id){
+        String res = singleOpen(id);
+        if(StringUtils.hasText(res)){
+            return Result.error(res);
         }else{
-            prodInOut.setPi_status(Status.AUDITED.getDisplay());
-            prodInOut.setPi_statuscode(Status.AUDITED.getDisplay());
+            return Result.success();
         }
+    }
+
+    private String singleOpen(Long id){
+        ProdInOut prodInOut = checkAndReturnOrder(id);
+        String pi_statuscode = prodInOut.getPi_statuscode();
+        if(!StringUtils.isEmpty(pi_statuscode)&&!pi_statuscode.equals(Status.CLOSE.getDisplay())){
+            return BizExceptionCode.BIZ_OPEN.getMessage();
+        };
+        prodInOut.setPi_status(Status.AUDITED.getDisplay());
+        prodInOut.setPi_statuscode(Status.AUDITED.getDisplay());
         prodInOutMapper.updateByPrimaryKeySelective(prodInOut);
-        DocBaseDTO docBaseDTO = getBaseDTOById(id,prodInOut.getPi_class());
         //记录日志
+        DocBaseDTO docBaseDTO = getBaseDTOById(prodInOut.getId(),prodInOut.getPi_class());
         messageLogService.open(docBaseDTO);
+        return "";
     }
+
+    @Override
+    public void batchOpen(BatchDealBaseDTO baseDTOs){
+        if (null == baseDTOs || null == baseDTOs.getBaseDTOs() ||
+                baseDTOs.getBaseDTOs().size() == 0) {
+            return;
+        }
+        String validate = prodInOutMapper.validateBatchOpen(baseDTOs.getBaseDTOs());
+        if (!StringUtils.isEmpty(validate)) {
+            throw new BizException(503, "存在非已关闭单据,单据编号:" + validate);
+        }
+        String error = null;
+        for (DocBaseDTO base : baseDTOs.getBaseDTOs()) {
+            error+=singleOpen(base.getId());
+        }
+        if(!StringUtils.isEmpty(error)){
+            new BizException(501,error);
+        }
+    }
+
     /**
      * @Description: 检验获取并更新单号
      * @Param: [code, id]
@@ -524,7 +549,10 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
      * @Author: guq
      * @Date: 2018/10/19
      */
-    private String pushMaxnubmer(String code, Long id,String pi_class) {
+    private String pushMaxnubmer(ProdInOut prodInOut) {
+        String code = prodInOut.getPi_inoutno();
+        Long id = prodInOut.getId();
+        String pi_class = prodInOut.getPi_class();
         if (null == code) {
             throw new BizException(BizExceptionCode.NULL_CODE);
         }
@@ -537,7 +565,9 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
             caller = BillCodeSeq.SALEIN.getCaller();
         }
         return maxnumberService.pushMaxnubmer(count, code, caller).getData();
+        //return  caller+Math.abs(Math.random()*100);
     }
+
     /**
      * @Description: 更新已转数
      * @Param: [code, id]
@@ -573,6 +603,7 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         baseDTO.setName(caller);
         return baseDTO;
     }
+
     //更新最新明细总额
     private void getTotal(Long id,String pi_class) {
         if(BillCodeSeq.SALEOUT.getName().equals(pi_class)){
@@ -581,4 +612,22 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
             prodIODetailMapper.updatePDSaleIN(id);
         }
     }
+
+    /**
+     * @Description
+     * @Param: [id]
+     * @return: com.usoftchina.saas.commons.dto.DocBaseDTO
+     * @Author: wuyx
+     * @Date: 2018/10/25
+     * */
+    private ProdInOut checkAndReturnOrder (Long id){
+        if(id == null || id <= 0) {
+            throw new BizException(BizExceptionCode.ILLEGAL_ID);
+        }
+        ProdInOut prodInOut = getMapper().selectByPrimaryKey(id);
+        if(prodInOut==null){
+            throw new BizException(BizExceptionCode.NO_DATA);
+        }
+        return prodInOut;
+    }
 }

+ 37 - 4
applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/service/impl/SaleServiceImpl.java

@@ -137,7 +137,11 @@ public class SaleServiceImpl implements SaleService{
             }
             baseDTO = getBaseDTOById(sa_id);
             //更新销售金额
-            getTotal(sa_id);
+            updateTotal(sa_id);
+            //更新从表总额
+            updateTotalAndNetPrice(sa_id);
+            //更新从表不含税金额
+            updateNetTotal(sa_id);
             //日志记录
             messageLogService.save(baseDTO);
             return baseDTO;
@@ -165,7 +169,11 @@ public class SaleServiceImpl implements SaleService{
         }
         baseDTO = getBaseDTOById(sa_id);
         //更新销售金额
-        getTotal(sa_id);
+        updateTotal(sa_id);
+        //更新从表总额
+        updateTotalAndNetPrice(sa_id);
+        //更新从表不含税金额
+        updateNetTotal(sa_id);
         //日志
         messageLogService.update(baseDTO);
         return baseDTO;
@@ -252,7 +260,12 @@ public class SaleServiceImpl implements SaleService{
         sale.setUpdaterId(BaseContextHolder.getUserId());
         //更新存在字段
         saleMapper.updateByPrimaryKeySelective(sale);
-
+        //更新销售金额
+        updateTotal(id);
+        //更新从表总额
+        updateTotalAndNetPrice(id);
+        //更新从表不含税金额
+        updateNetTotal(id);
         DocBaseDTO docBaseDTO = getBaseDTOById(id);
         //日志
         messageLogService.audit(docBaseDTO);
@@ -489,11 +502,31 @@ public class SaleServiceImpl implements SaleService{
     }
 
     //更新最新销售总额
-    private void getTotal(Long id) {
+    private void updateTotal(Long id) {
         if (null == id) {
             return;
         }
         saleMapper.updateTotal(id);
     }
 
+    /**
+    * @Description: 更新从表总额与不含税单价
+    * @Param: [id]
+    * @return: void
+    * @Author: guq
+    * @Date: 2018/10/27
+    */
+    private void updateTotalAndNetPrice(Long id) {
+        if (null == id) {
+            return;
+        }
+        saleMapper.updateTotalAndNetPrice(id);
+    }
+
+    private void updateNetTotal(Long id) {
+        if (null == id) {
+            return;
+        }
+        saleMapper.updateNetTotal(id);
+    }
 }

+ 3 - 1
applications/sale/sale-server/src/main/resources/mapper/ProdInOutListMapper.xml

@@ -68,7 +68,9 @@
     <result column="pd_ym" jdbcType="INTEGER" property="pd_ym" />
     <result column="pd_yqty" jdbcType="INTEGER" property="pd_yqty" />
     <result column="pd_ioid" jdbcType="INTEGER" property="pd_ioid" />
-
+    <result column="pi_nettotal" jdbcType="DOUBLE" property="pi_nettotal" />
+    <result column="pi_auditdate" jdbcType="TIMESTAMP" property="pi_auditdate" />
+    <result column="pi_auditman" jdbcType="VARCHAR" property="pi_auditman" />
   </resultMap>
 
 

+ 14 - 1
applications/sale/sale-server/src/main/resources/mapper/ProdInOutMapper.xml

@@ -32,7 +32,8 @@
     <result column="pi_text3" jdbcType="VARCHAR" property="pi_text3" />
     <result column="pi_text4" jdbcType="VARCHAR" property="pi_text4" />
     <result column="pi_text5" jdbcType="VARCHAR" property="pi_text5" />
-
+    <result column="pi_auditdate" jdbcType="TIMESTAMP" property="pi_auditdate" />
+    <result column="pi_auditman" jdbcType="VARCHAR" property="pi_auditman" />
 
 
   </resultMap>
@@ -743,5 +744,17 @@
     </foreach>
   </select>
 
+  <select id="validateBatchClose" parameterType="com.usoftchina.saas.commons.dto.DocBaseDTO" resultType="java.lang.String">
+    select GROUP_CONCAT(pi_inoutno) from prodinout where pi_statuscode!='AUDITED' and pi_id in
+    <foreach collection="list" item="item" open="(" close=")" separator=",">
+      #{item.id}
+    </foreach>
+  </select>
 
+  <select id="validateBatchOpen" parameterType="com.usoftchina.saas.commons.dto.DocBaseDTO" resultType="java.lang.String">
+    select GROUP_CONCAT(pi_inoutno) from prodinout where pi_statuscode!='CLOSE' and pi_id in
+    <foreach collection="list" item="item" open="(" close=")" separator=",">
+      #{item.id}
+    </foreach>
+  </select>
 </mapper>

+ 11 - 0
applications/sale/sale-server/src/main/resources/mapper/SaleMapper.xml

@@ -364,4 +364,15 @@
   <update id="updateTotal" parameterType="long">
     	update sale a set sa_total=(select sum(sd_price*sd_qty) from saledetail b where b.sd_said=a.sa_id ) where sa_id=#{id};
   </update>
+
+  <update id="updateTotalAndNetPrice" parameterType="long">
+    update saledetail a set sd_total=sd_qty*sd_price,
+    sd_netprice=round(ifnull(sd_price,0)/(1+ifnull(sd_taxrate,0)/100),6)
+     where sd_said=#{id}
+  </update>
+
+  <update id="updateNetTotal" parameterType="long">
+    update saledetail a set sd_nettotal=round(ifnull(sd_netprice,0)*nvl(sd_qty,0),2)
+    where sd_said=#{id}
+  </update>
 </mapper>

+ 8 - 2
applications/storage/storage-dto/src/main/java/com/usoftchina/saas/storage/po/ProdInOut.java

@@ -37,6 +37,8 @@ public class ProdInOut extends CommonBaseEntity implements Serializable {
 
     private Double pi_total;
 
+    private String pi_address;
+
     private Integer pi_recordmanid;
 
     private String pi_recordman;
@@ -61,8 +63,12 @@ public class ProdInOut extends CommonBaseEntity implements Serializable {
 
     private String pi_text5;
 
-    private String pi_address;
-
     private Long pi_inid;
 
+    private Double pi_nettotal;
+
+    private Date pi_auditdate;
+
+    private String pi_auditman;
+
 }

+ 177 - 0
applications/storage/storage-dto/src/main/java/com/usoftchina/saas/storage/po/ProdInOutExample.java

@@ -2085,6 +2085,183 @@ public class ProdInOutExample {
             addCriterion("pi_text5 not between", value1, value2, "pi_text5");
             return (Criteria) this;
         }
+        public Criteria andPi_nettotalIsNull() {
+            addCriterion("Pi_nettotal is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andPi_nettotalIsNotNull() {
+            addCriterion("Pi_nettotal is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andPi_nettotalEqualTo(Integer value) {
+            addCriterion("Pi_nettotal =", value, "Pi_nettotal");
+            return (Criteria) this;
+        }
+
+        public Criteria andPi_nettotalNotEqualTo(Integer value) {
+            addCriterion("Pi_nettotal <>", value, "Pi_nettotal");
+            return (Criteria) this;
+        }
+
+        public Criteria andPi_nettotalGreaterThan(Integer value) {
+            addCriterion("Pi_nettotal >", value, "Pi_nettotal");
+            return (Criteria) this;
+        }
+
+        public Criteria andPi_nettotalGreaterThanOrEqualTo(Integer value) {
+            addCriterion("Pi_nettotal >=", value, "Pi_nettotal");
+            return (Criteria) this;
+        }
+
+        public Criteria andPi_nettotalLessThan(Integer value) {
+            addCriterion("Pi_nettotal <", value, "Pi_nettotal");
+            return (Criteria) this;
+        }
+
+        public Criteria andPi_nettotalLessThanOrEqualTo(Integer value) {
+            addCriterion("Pi_nettotal <=", value, "Pi_nettotal");
+            return (Criteria) this;
+        }
+
+        public Criteria andPi_nettotalIn(List<Integer> values) {
+            addCriterion("Pi_nettotal in", values, "Pi_nettotal");
+            return (Criteria) this;
+        }
+
+        public Criteria andPi_nettotalNotIn(List<Integer> values) {
+            addCriterion("Pi_nettotal not in", values, "Pi_nettotal");
+            return (Criteria) this;
+        }
+
+        public Criteria andPi_nettotalBetween(Integer value1, Integer value2) {
+            addCriterion("Pi_nettotal between", value1, value2, "Pi_nettotal");
+            return (Criteria) this;
+        }
+
+        public Criteria andPi_nettotalNotBetween(Integer value1, Integer value2) {
+            addCriterion("Pi_nettotal not between", value1, value2, "Pi_nettotal");
+            return (Criteria) this;
+        }
+        public Criteria andPi_auditdateIsNull() {
+            addCriterion("Pi_auditdate is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andPi_auditdateIsNotNull() {
+            addCriterion("Pi_auditdate is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andPi_auditdateEqualTo(Integer value) {
+            addCriterion("Pi_auditdate =", value, "Pi_auditdate");
+            return (Criteria) this;
+        }
+
+        public Criteria andPi_auditdateNotEqualTo(Integer value) {
+            addCriterion("Pi_auditdate <>", value, "Pi_auditdate");
+            return (Criteria) this;
+        }
+
+        public Criteria andPi_auditdateGreaterThan(Integer value) {
+            addCriterion("Pi_auditdate >", value, "Pi_auditdate");
+            return (Criteria) this;
+        }
+
+        public Criteria andPi_auditdateGreaterThanOrEqualTo(Integer value) {
+            addCriterion("Pi_auditdate >=", value, "Pi_auditdate");
+            return (Criteria) this;
+        }
+
+        public Criteria andPi_auditdateLessThan(Integer value) {
+            addCriterion("Pi_auditdate <", value, "Pi_auditdate");
+            return (Criteria) this;
+        }
+
+        public Criteria andPi_auditdateLessThanOrEqualTo(Integer value) {
+            addCriterion("Pi_auditdate <=", value, "Pi_auditdate");
+            return (Criteria) this;
+        }
+
+        public Criteria andPi_auditdateIn(List<Integer> values) {
+            addCriterion("Pi_auditdate in", values, "Pi_auditdate");
+            return (Criteria) this;
+        }
+
+        public Criteria andPi_auditdateNotIn(List<Integer> values) {
+            addCriterion("Pi_auditdate not in", values, "Pi_auditdate");
+            return (Criteria) this;
+        }
+
+        public Criteria andPi_auditdateBetween(Integer value1, Integer value2) {
+            addCriterion("Pi_auditdate between", value1, value2, "Pi_auditdate");
+            return (Criteria) this;
+        }
+
+        public Criteria andPi_auditdateNotBetween(Integer value1, Integer value2) {
+            addCriterion("Pi_auditdate not between", value1, value2, "Pi_auditdate");
+            return (Criteria) this;
+        }
+        public Criteria andPi_auditmanIsNull() {
+            addCriterion("Pi_auditman is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andPi_auditmanIsNotNull() {
+            addCriterion("Pi_auditman is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andPi_auditmanEqualTo(Integer value) {
+            addCriterion("Pi_auditman =", value, "Pi_auditman");
+            return (Criteria) this;
+        }
+
+        public Criteria andPi_auditmanNotEqualTo(Integer value) {
+            addCriterion("Pi_auditman <>", value, "Pi_auditman");
+            return (Criteria) this;
+        }
+
+        public Criteria andPi_auditmanGreaterThan(Integer value) {
+            addCriterion("Pi_auditman >", value, "Pi_auditman");
+            return (Criteria) this;
+        }
+
+        public Criteria andPi_auditmanGreaterThanOrEqualTo(Integer value) {
+            addCriterion("Pi_auditman >=", value, "Pi_auditman");
+            return (Criteria) this;
+        }
+
+        public Criteria andPi_auditmanLessThan(Integer value) {
+            addCriterion("Pi_auditman <", value, "Pi_auditman");
+            return (Criteria) this;
+        }
+
+        public Criteria andPi_auditmanLessThanOrEqualTo(Integer value) {
+            addCriterion("Pi_auditman <=", value, "Pi_auditman");
+            return (Criteria) this;
+        }
+
+        public Criteria andPi_auditmanIn(List<Integer> values) {
+            addCriterion("Pi_auditman in", values, "Pi_auditman");
+            return (Criteria) this;
+        }
+
+        public Criteria andPi_auditmanNotIn(List<Integer> values) {
+            addCriterion("Pi_auditman not in", values, "Pi_auditman");
+            return (Criteria) this;
+        }
+
+        public Criteria andPi_auditmanBetween(Integer value1, Integer value2) {
+            addCriterion("Pi_auditman between", value1, value2, "Pi_auditman");
+            return (Criteria) this;
+        }
+
+        public Criteria andPi_auditmanNotBetween(Integer value1, Integer value2) {
+            addCriterion("Pi_auditman not between", value1, value2, "Pi_auditman");
+            return (Criteria) this;
+        }
     }
 
     public static class Criteria extends GeneratedCriteria {

+ 6 - 0
applications/storage/storage-dto/src/main/java/com/usoftchina/saas/storage/po/ProdInOutList.java

@@ -140,4 +140,10 @@ public class ProdInOutList extends CommonBaseEntity{
 
     private Long pd_ioid;
 
+    private Double pi_nettotal;
+
+    private Date pi_auditdate;
+
+    private String pi_auditman;
+
 }

+ 28 - 0
base-servers/account/README.md

@@ -0,0 +1,28 @@
+
+> ac_resource_module 资源模块
+
+| 字段      |  说明 |
+| :----:   | ---------  |
+| id | 主键,自动生成  |
+| app_id | 所属应用:trade-app(贸易云), manufacture-app(制造云), solution-app(方案云) |
+| name | 名称,例如:采购、销售、库存、资金、资料 |
+
+> ac_resource_group 资源分组
+
+| 字段      |  说明 |
+| :----:   | ---------  |
+| id | 主键,自动生成  |
+| module_id | 资源模块ID,参考ac_resource_module表 |
+| name | 名称,例如:采购单、采购验收单 |
+
+> ac_resource 资源
+
+| 字段      |  说明 |
+| :----:   | ---------  |
+| id | 主键,自动生成  |
+| group_id | 资源分组ID,参考ac_resource_group、ac_resource_module表 |
+| name | 名称,统一叫法:查询、新增、修改、审核、反审核、删除、打印、(其它,字数≤5) |
+| type | 类型,MENU(Navigation的资源)、BUTTON (页面按钮资源)、API... |
+| url | 请求url |
+| method | http请求头方法:GET, POST, PUT, DELETE |
+| classify | 归类:QUERY, ADD, UPDATE, AUDIT, UNAUDIT, DELETE, PRINT, OTHER  |

+ 4 - 0
base-servers/account/account-dto/pom.xml

@@ -18,6 +18,10 @@
             <artifactId>springfox-swagger2</artifactId>
             <scope>compile</scope>
         </dependency>
+        <dependency>
+            <groupId>com.usoftchina.saas</groupId>
+            <artifactId>commons-dto</artifactId>
+        </dependency>
     </dependencies>
 
 </project>

+ 48 - 0
base-servers/account/account-dto/src/main/java/com/usoftchina/saas/account/constant/ResourceClassify.java

@@ -0,0 +1,48 @@
+package com.usoftchina.saas.account.constant;
+
+/**
+ * @author yingp
+ * @date 2018/10/26
+ */
+public enum ResourceClassify {
+    /**
+     * 查询
+     */
+    QUERY,
+    /**
+     * 新增
+     */
+    ADD,
+    /**
+     * 保存
+     */
+    UPDATE,
+    /**
+     * 删除
+     */
+    DELETE,
+    /**
+     * (批量)审批
+     */
+    AUDIT,
+    /**
+     * (批量)反审批
+     */
+    UNAUDIT,
+    /**
+     * 导入
+     */
+    IMPORT,
+    /**
+     * 导出
+     */
+    EXPORT,
+    /**
+     * 打印
+     */
+    PRINT,
+    /**
+     * 其它
+     */
+    OTHER
+}

+ 26 - 0
base-servers/account/account-dto/src/main/java/com/usoftchina/saas/account/constant/RoleType.java

@@ -0,0 +1,26 @@
+package com.usoftchina.saas.account.constant;
+
+/**
+ * @author yingp
+ * @date 2018/10/23
+ */
+public enum RoleType {
+    /**
+     * 管理角色
+     */
+    ADMIN(0),
+    /**
+     * 普通角色
+     */
+    NORMAL(1);
+
+    private final int type;
+
+    RoleType(int type) {
+        this.type = type;
+    }
+
+    public int getType() {
+        return type;
+    }
+}

+ 100 - 0
base-servers/account/account-dto/src/main/java/com/usoftchina/saas/account/dto/ResourceDTO.java

@@ -0,0 +1,100 @@
+package com.usoftchina.saas.account.dto;
+
+import java.io.Serializable;
+
+/**
+ * 用于资源权限分配
+ *
+ * @author yingp
+ * @date 2018/10/10
+ */
+public class ResourceDTO implements Serializable {
+    private Long id;
+    /**
+     * 名称
+     */
+    private String name;
+    /**
+     * 资源类型
+     * MENU - 菜单
+     * DIR - 目录
+     * BUTTON - 按钮
+     * URI - 页面上的url
+     * API - api
+     */
+    private String type;
+    /**
+     * url
+     */
+    private String url;
+
+    /**
+     * 资源请求方式 POST/GET/PUT/DELETE
+     */
+    private String method;
+    /**
+     * 资源分组
+     * @see com.usoftchina.saas.account.constant.ResourceClassify
+     */
+    private String classify;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getMethod() {
+        return method;
+    }
+
+    public void setMethod(String method) {
+        this.method = method;
+    }
+
+    public String getClassify() {
+        return classify;
+    }
+
+    public void setClassify(String classify) {
+        this.classify = classify;
+    }
+
+    @Override
+    public String toString() {
+        return "ResourceDTO{" +
+                "id=" + id +
+                ", name='" + name + '\'' +
+                ", type='" + type + '\'' +
+                ", url='" + url + '\'' +
+                ", method='" + method + '\'' +
+                ", classify='" + classify + '\'' +
+                '}';
+    }
+}

+ 169 - 0
base-servers/account/account-dto/src/main/java/com/usoftchina/saas/account/dto/ResourceGroupDTO.java

@@ -0,0 +1,169 @@
+package com.usoftchina.saas.account.dto;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 用于资源权限分配
+ *
+ * @author yingp
+ * @date 2018/10/26
+ */
+public class ResourceGroupDTO implements Serializable{
+    private Long id;
+    private String name;
+    /**
+     * 查询
+     */
+    private List<ResourceDTO> queries;
+    /**
+     * 新增
+     */
+    private List<ResourceDTO> adds;
+    /**
+     * 修改
+     */
+    private List<ResourceDTO> updates;
+    /**
+     * 删除
+     */
+    private List<ResourceDTO> deletes;
+    /**
+     * 审核
+     */
+    private List<ResourceDTO> audits;
+    /**
+     * 反审核
+     */
+    private List<ResourceDTO> unAudits;
+    /**
+     * 打印
+     */
+    private List<ResourceDTO> prints;
+    /**
+     * 导出
+     */
+    private List<ResourceDTO> exports;
+    /**
+     * 导入
+     */
+    private List<ResourceDTO> imports;
+    /**
+     * 其它
+     */
+    private List<ResourceDTO> others;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public List<ResourceDTO> getQueries() {
+        return queries;
+    }
+
+    public void setQueries(List<ResourceDTO> queries) {
+        this.queries = queries;
+    }
+
+    public List<ResourceDTO> getAdds() {
+        return adds;
+    }
+
+    public void setAdds(List<ResourceDTO> adds) {
+        this.adds = adds;
+    }
+
+    public List<ResourceDTO> getUpdates() {
+        return updates;
+    }
+
+    public void setUpdates(List<ResourceDTO> updates) {
+        this.updates = updates;
+    }
+
+    public List<ResourceDTO> getDeletes() {
+        return deletes;
+    }
+
+    public void setDeletes(List<ResourceDTO> deletes) {
+        this.deletes = deletes;
+    }
+
+    public List<ResourceDTO> getAudits() {
+        return audits;
+    }
+
+    public void setAudits(List<ResourceDTO> audits) {
+        this.audits = audits;
+    }
+
+    public List<ResourceDTO> getUnAudits() {
+        return unAudits;
+    }
+
+    public void setUnAudits(List<ResourceDTO> unAudits) {
+        this.unAudits = unAudits;
+    }
+
+    public List<ResourceDTO> getPrints() {
+        return prints;
+    }
+
+    public void setPrints(List<ResourceDTO> prints) {
+        this.prints = prints;
+    }
+
+    public List<ResourceDTO> getExports() {
+        return exports;
+    }
+
+    public void setExports(List<ResourceDTO> exports) {
+        this.exports = exports;
+    }
+
+    public List<ResourceDTO> getImports() {
+        return imports;
+    }
+
+    public void setImports(List<ResourceDTO> imports) {
+        this.imports = imports;
+    }
+
+    public List<ResourceDTO> getOthers() {
+        return others;
+    }
+
+    public void setOthers(List<ResourceDTO> others) {
+        this.others = others;
+    }
+
+    @Override
+    public String toString() {
+        return "ResourceGroupDTO{" +
+                "id=" + id +
+                ", name='" + name + '\'' +
+                ", queries=" + queries +
+                ", adds=" + adds +
+                ", updates=" + updates +
+                ", deletes=" + deletes +
+                ", audits=" + audits +
+                ", unAudits=" + unAudits +
+                ", prints=" + prints +
+                ", exports=" + exports +
+                ", imports=" + imports +
+                ", others=" + others +
+                '}';
+    }
+}

+ 49 - 0
base-servers/account/account-dto/src/main/java/com/usoftchina/saas/account/dto/ResourceModuleDTO.java

@@ -0,0 +1,49 @@
+package com.usoftchina.saas.account.dto;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 用于资源权限分配
+ *
+ * @author yingp
+ * @date 2018/10/26
+ */
+public class ResourceModuleDTO implements Serializable{
+    private Long id;
+    private String name;
+    private List<ResourceGroupDTO> groups;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public List<ResourceGroupDTO> getGroups() {
+        return groups;
+    }
+
+    public void setGroups(List<ResourceGroupDTO> groups) {
+        this.groups = groups;
+    }
+
+    @Override
+    public String toString() {
+        return "ResourceModuleDTO{" +
+                "id=" + id +
+                ", name='" + name + '\'' +
+                ", groups=" + groups +
+                '}';
+    }
+}

+ 0 - 10
base-servers/account/account-dto/src/main/java/com/usoftchina/saas/account/dto/ResourcesDTO.java

@@ -1,10 +0,0 @@
-package com.usoftchina.saas.account.dto;
-
-import java.io.Serializable;
-
-/**
- * @author yingp
- * @date 2018/10/10
- */
-public class ResourcesDTO implements Serializable{
-}

+ 75 - 0
base-servers/account/account-dto/src/main/java/com/usoftchina/saas/account/dto/RoleDTO.java

@@ -0,0 +1,75 @@
+package com.usoftchina.saas.account.dto;
+
+import com.usoftchina.saas.base.dto.CommonBaseDTO;
+
+import java.io.Serializable;
+
+/**
+ * @author yingp
+ * @date 2018/10/24
+ */
+public class RoleDTO extends CommonBaseDTO implements Serializable{
+    /**
+     * 公司
+     */
+    private Long companyId;
+    /**
+     * 角色编码
+     */
+    private String code;
+    /**
+     * 角色名称
+     */
+    private String name;
+    /**
+     * 描述
+     */
+    private String description;
+
+    public Long getCompanyId() {
+        return companyId;
+    }
+
+    public void setCompanyId(Long companyId) {
+        this.companyId = companyId;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    @Override
+    public String toString() {
+        return "RoleDTO{" +
+                "companyId=" + companyId +
+                ", code='" + code + '\'' +
+                ", name='" + name + '\'' +
+                ", description='" + description + '\'' +
+                ", id=" + id +
+                ", createTime=" + createTime +
+                ", creatorName='" + creatorName + '\'' +
+                ", updateTime=" + updateTime +
+                ", updaterName='" + updaterName + '\'' +
+                '}';
+    }
+}

+ 57 - 0
base-servers/account/account-dto/src/main/java/com/usoftchina/saas/account/dto/RoleSaveDTO.java

@@ -0,0 +1,57 @@
+package com.usoftchina.saas.account.dto;
+
+import java.io.Serializable;
+
+/**
+ * 角色新增 数据传输对象
+ *
+ * @author yingp
+ * @date 2018/10/24
+ */
+public class RoleSaveDTO implements Serializable {
+    /**
+     * 编号
+     */
+    private String code;
+    /**
+     * 名称
+     */
+    private String name;
+    /**
+     * 描述
+     */
+    private String description;
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    @Override
+    public String toString() {
+        return "RoleSaveDTO{" +
+                "code='" + code + '\'' +
+                ", name='" + name + '\'' +
+                ", description='" + description + '\'' +
+                '}';
+    }
+}

+ 67 - 0
base-servers/account/account-dto/src/main/java/com/usoftchina/saas/account/dto/RoleUpdateDTO.java

@@ -0,0 +1,67 @@
+package com.usoftchina.saas.account.dto;
+
+import java.io.Serializable;
+
+/**
+ * 角色修改 数据传输对象
+ *
+ * @author yingp
+ * @date 2018/10/24
+ */
+public class RoleUpdateDTO implements Serializable {
+    private Long id;
+    /**
+     * 编号
+     */
+    private String code;
+    /**
+     * 名称
+     */
+    private String name;
+    /**
+     * 描述
+     */
+    private String description;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    @Override
+    public String toString() {
+        return "RoleSaveDTO{" +
+                "id=" + id +
+                ", code='" + code + '\'' +
+                ", name='" + name + '\'' +
+                ", description='" + description + '\'' +
+                '}';
+    }
+}

+ 57 - 0
base-servers/account/account-dto/src/main/java/com/usoftchina/saas/account/dto/UrlResourceDTO.java

@@ -0,0 +1,57 @@
+package com.usoftchina.saas.account.dto;
+
+import java.io.Serializable;
+
+/**
+ * 用于url拦截判断的属性
+ *
+ * @author yingp
+ * @date 2018/10/26
+ */
+public class UrlResourceDTO implements Serializable{
+    /**
+     * 名称
+     */
+    private String name;
+    /**
+     * url
+     */
+    private String url;
+    /**
+     * 资源请求方式 POST/GET/PUT/DELETE
+     */
+    private String method;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getMethod() {
+        return method;
+    }
+
+    public void setMethod(String method) {
+        this.method = method;
+    }
+
+    @Override
+    public String toString() {
+        return "UrlResourceDTO{" +
+                "name='" + name + '\'' +
+                ", url='" + url + '\'' +
+                ", method='" + method + '\'' +
+                '}';
+    }
+}

+ 5 - 5
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/controller/AccountController.java

@@ -110,7 +110,7 @@ public class AccountController {
      * @param username
      * @return
      */
-    @GetMapping
+    @GetMapping("/read")
     public Result<AccountDTO> getAccount(@RequestParam(value = "username") String username) {
         Account account = getAccountByUsername(username);
         if (null == account) {
@@ -204,12 +204,12 @@ public class AccountController {
     /**
      * 账户删除
      *
-     * @param accountId
+     * @param id
      * @return
      */
-    @PostMapping("/delete")
-    public Result deleteAccount(@RequestParam long accountId) {
-        accountService.removeByPrimaryKey(accountId);
+    @PostMapping("/delete/{id}")
+    public Result deleteAccount(@PathVariable Long id) {
+        accountService.removeByPrimaryKey(id);
         return Result.success();
     }
 }

+ 47 - 5
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/controller/CompanyController.java

@@ -5,6 +5,7 @@ import com.usoftchina.saas.account.dto.CompanyRegDTO;
 import com.usoftchina.saas.account.po.Company;
 import com.usoftchina.saas.account.service.CompanyService;
 import com.usoftchina.saas.base.Result;
+import com.usoftchina.saas.context.BaseContextHolder;
 import com.usoftchina.saas.exception.ExceptionCode;
 import com.usoftchina.saas.utils.BeanMapper;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -51,7 +52,7 @@ public class CompanyController {
      * @param name
      * @return
      */
-    @GetMapping(params = "name")
+    @GetMapping(path = "/read", params = "name")
     public Result<CompanyDTO> getByName(@RequestParam String name) {
         Company company = companyService.findByName(name);
         if (null != company) {
@@ -67,7 +68,7 @@ public class CompanyController {
      * @param businessCode
      * @return
      */
-    @GetMapping(params = "businessCode")
+    @GetMapping(path = "/read", params = "businessCode")
     public Result<CompanyDTO> getByBusinessCode(@RequestParam String businessCode) {
         Company company = companyService.findByBusinessCode(businessCode);
         if (null != company) {
@@ -77,15 +78,56 @@ public class CompanyController {
         return Result.error(ExceptionCode.COMPANY_NOT_EXIST);
     }
 
+    /**
+     * 当前登录的公司的信息
+     *
+     * @return
+     */
+    @GetMapping(path = "/read/current")
+    public Result<CompanyDTO> getCurrentCompany() {
+        Company company = companyService.findByPrimaryKey(BaseContextHolder.getCompanyId());
+        if (null != company) {
+            CompanyDTO companyDTO = BeanMapper.map(company, CompanyDTO.class);
+            return Result.success(companyDTO);
+        }
+        return Result.error(ExceptionCode.COMPANY_NOT_EXIST);
+    }
+
     /**
      * 删除
      *
+     * @param id
+     * @return
+     */
+    @PostMapping("/delete/{id}")
+    public Result delete(@PathVariable Long id) {
+        companyService.removeByPrimaryKey(id);
+        return Result.success();
+    }
+
+    /**
+     * 公司绑定应用
+     *
+     * @param companyId
+     * @param appId
+     * @return
+     */
+    @PostMapping("/bind/app")
+    public Result bindApp(@RequestParam long companyId, @RequestParam String appId) {
+        companyService.bindApp(companyId, appId);
+        return Result.success();
+    }
+
+    /**
+     * 公司解除绑定应用
+     *
      * @param companyId
+     * @param appId
      * @return
      */
-    @PostMapping("/delete")
-    public Result delete(@RequestParam Long companyId) {
-        companyService.removeByPrimaryKey(companyId);
+    @PostMapping("/unbind/app")
+    public Result unbindApp(@RequestParam long companyId, @RequestParam String appId) {
+        companyService.unbindApp(companyId, appId);
         return Result.success();
     }
 }

+ 0 - 8
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/controller/ResourceController.java

@@ -1,8 +0,0 @@
-package com.usoftchina.saas.account.controller;
-
-/**
- * @author yingp
- * @date 2018/10/2
- */
-public class ResourceController {
-}

+ 56 - 0
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/controller/ResourcesController.java

@@ -0,0 +1,56 @@
+package com.usoftchina.saas.account.controller;
+
+import com.usoftchina.saas.account.dto.ResourceModuleDTO;
+import com.usoftchina.saas.account.dto.UrlResourceDTO;
+import com.usoftchina.saas.account.service.ResourceService;
+import com.usoftchina.saas.base.Result;
+import com.usoftchina.saas.context.BaseContextHolder;
+import com.usoftchina.saas.utils.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * @author yingp
+ * @date 2018/10/2
+ */
+@RestController
+@RequestMapping("/resource")
+public class ResourcesController {
+
+    @Autowired
+    private ResourceService resourcesService;
+
+    /**
+     * 查找应用分模块的全部资源
+     *
+     * @return
+     */
+    @GetMapping("/module/list")
+    public Result<List<ResourceModuleDTO>> getModulesByAppId(String appId) {
+        if (StringUtils.isEmpty(appId)) {
+            // 查找当前登录应用的全部资源
+            appId = BaseContextHolder.getAppId();
+        }
+        return Result.success(resourcesService.findModulesByAppId(appId));
+    }
+
+    /**
+     * 查找应用的全部url资源
+     *
+     * @param appId
+     * @return
+     */
+    @GetMapping("/url/list")
+    public Result<List<UrlResourceDTO>> getUrlResourcesByAppId(String appId) {
+        if (StringUtils.isEmpty(appId)) {
+            // 查找当前登录应用的全部资源
+            appId = BaseContextHolder.getAppId();
+        }
+        return Result.success(resourcesService.findUrlResourcesByAppId(appId));
+    }
+
+}

+ 115 - 1
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/controller/RoleController.java

@@ -1,8 +1,122 @@
 package com.usoftchina.saas.account.controller;
 
+import com.usoftchina.saas.account.dto.RoleDTO;
+import com.usoftchina.saas.account.dto.RoleSaveDTO;
+import com.usoftchina.saas.account.dto.RoleUpdateDTO;
+import com.usoftchina.saas.account.po.Role;
+import com.usoftchina.saas.account.service.RoleService;
+import com.usoftchina.saas.base.Result;
+import com.usoftchina.saas.commons.dto.DocBaseDTO;
+import com.usoftchina.saas.context.BaseContextHolder;
+import com.usoftchina.saas.exception.ExceptionCode;
+import com.usoftchina.saas.utils.BeanMapper;
+import com.usoftchina.saas.utils.CollectionUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
 /**
  * @author yingp
  * @date 2018/10/2
  */
+@RestController
+@RequestMapping("/role")
 public class RoleController {
-}
+
+    @Autowired
+    private RoleService roleService;
+
+    /**
+     * 保存
+     *
+     * @param roleSaveDTO
+     * @return
+     */
+    @PostMapping("/save")
+    public Result<DocBaseDTO> save(@RequestBody RoleSaveDTO roleSaveDTO) {
+        Role role = BeanMapper.map(roleSaveDTO, Role.class);
+        roleService.save(role);
+        return Result.success(BeanMapper.map(role, DocBaseDTO.class));
+    }
+
+    /**
+     * 修改
+     *
+     * @param roleUpdateDTO
+     * @return
+     */
+    @PostMapping("/update")
+    public Result update(@RequestBody RoleUpdateDTO roleUpdateDTO) {
+        Role role = BeanMapper.map(roleUpdateDTO, Role.class);
+        roleService.updateByPrimaryKey(role);
+        return Result.success();
+    }
+
+    /**
+     * 删除
+     *
+     * @param id
+     * @return
+     */
+    @PostMapping("/delete/{id}")
+    public Result delete(@PathVariable Long id) {
+        roleService.removeByPrimaryKey(id);
+        return Result.success();
+    }
+
+    /**
+     * 查找
+     *
+     * @param id
+     * @return
+     */
+    @GetMapping("/read/{id}")
+    public Result<RoleDTO> get(@PathVariable Long id) {
+        Role role = roleService.findByPrimaryKey(id);
+        if (null == role) {
+            return Result.error(ExceptionCode.ROLE_NOT_EXIST);
+        }
+        return Result.success(BeanMapper.map(role, RoleDTO.class));
+    }
+
+    /**
+     * 查找当前登录公司的全部角色
+     *
+     * @return
+     */
+    @GetMapping("/list")
+    public Result<List<RoleDTO>> getByCompany() {
+        List<Role> roles = roleService.findByCompanyId(BaseContextHolder.getCompanyId());
+        if (CollectionUtils.isEmpty(roles)) {
+            return Result.success();
+        }
+        return Result.success(BeanMapper.mapList(roles, RoleDTO.class));
+    }
+
+    /**
+     * 角色绑定资源
+     *
+     * @param roleId
+     * @param resourceId
+     * @return
+     */
+    @PostMapping("/bind/resource")
+    public Result bindResource(@RequestParam long roleId, @RequestParam long resourceId) {
+        roleService.bindResource(roleId, resourceId);
+        return Result.success();
+    }
+
+    /**
+     * 角色解除绑定资源
+     *
+     * @param roleId
+     * @param resourceId
+     * @return
+     */
+    @PostMapping("/unbind/resource")
+    public Result unbindResource(@RequestParam long roleId, @RequestParam long resourceId) {
+        roleService.unbindResource(roleId, resourceId);
+        return Result.success();
+    }
+}

+ 12 - 2
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/mapper/AccountCompanyMapper.java

@@ -22,13 +22,23 @@ public interface AccountCompanyMapper {
      *
      * @param accountId
      * @param companyId
+     * @return
      */
-    void delete(@Param("accountId") Long accountId, @Param("companyId") Long companyId);
+    int delete(@Param("accountId") Long accountId, @Param("companyId") Long companyId);
 
     /**
      * 按账户删除
      *
      * @param accountId
+     * @return
+     */
+    int deleteByAccountId(@Param("accountId") Long accountId);
+
+    /**
+     * 按公司删除
+     *
+     * @param companyId
+     * @return
      */
-    void deleteByAccountId(@Param("accountId") Long accountId);
+    int deleteByCompanyId(@Param("companyId") Long companyId);
 }

+ 7 - 0
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/mapper/AccountRoleMapper.java

@@ -30,4 +30,11 @@ public interface AccountRoleMapper {
      * @param accountId
      */
     void deleteByAccountId(@Param("accountId") Long accountId);
+
+    /**
+     * 按角色删除
+     *
+     * @param roleId
+     */
+    void deleteByRoleId(@Param("roleId") Long roleId);
 }

+ 33 - 0
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/mapper/CompanyAppMapper.java

@@ -0,0 +1,33 @@
+package com.usoftchina.saas.account.mapper;
+
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * @author yingp
+ * @date 2018/10/24
+ */
+public interface CompanyAppMapper {
+    /**
+     * 新增
+     *
+     * @param companyId
+     * @param appId
+     * @return
+     */
+    int insert(@Param("companyId") Long companyId, @Param("appId") String appId);
+
+    /**
+     * 删除
+     *
+     * @param companyId
+     * @param appId
+     */
+    void delete(@Param("companyId") Long companyId, @Param("appId") String appId);
+    /**
+     * 按公司删除
+     *
+     * @param companyId
+     * @return
+     */
+    int deleteByCompanyId(@Param("companyId") Long companyId);
+}

+ 10 - 0
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/mapper/CompanyMapper.java

@@ -27,6 +27,14 @@ public interface CompanyMapper {
      */
     int insertSelective(Company record);
 
+    /**
+     * 按主键查询
+     *
+     * @param id
+     * @return
+     */
+    Company selectByPrimaryKey(@Param("id") Long id);
+
     /**
      * 按名称查询
      *
@@ -58,4 +66,6 @@ public interface CompanyMapper {
      * @return
      */
     int deleteByPrimaryKey(@Param("id") Long id);
+
+
 }

+ 21 - 0
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/mapper/ResourceGroupMapper.java

@@ -0,0 +1,21 @@
+package com.usoftchina.saas.account.mapper;
+
+import com.usoftchina.saas.account.po.ResourceGroup;
+import com.usoftchina.saas.account.po.ResourceModule;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * @author yingp
+ * @date 2018/10/26
+ */
+public interface ResourceGroupMapper {
+    /**
+     * 按资源模块查找
+     *
+     * @param moduleId
+     * @return
+     */
+    List<ResourceGroup> selectByModuleId(@Param("moduleId") Long moduleId);
+}

+ 29 - 0
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/mapper/ResourceMapper.java

@@ -0,0 +1,29 @@
+package com.usoftchina.saas.account.mapper;
+
+import com.usoftchina.saas.account.po.Resource;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * @author yingp
+ * @date 2018/10/2
+ */
+public interface ResourceMapper {
+
+    /**
+     * 按资源组查找
+     *
+     * @param groupId
+     * @return
+     */
+    List<Resource> selectByGroupId(@Param("groupId") Long groupId);
+
+    /**
+     * 按应用查找
+     *
+     * @param appId
+     * @return
+     */
+    List<Resource> selectByAppId(@Param("appId") String appId);
+}

+ 20 - 0
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/mapper/ResourceModuleMapper.java

@@ -0,0 +1,20 @@
+package com.usoftchina.saas.account.mapper;
+
+import com.usoftchina.saas.account.po.ResourceModule;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * @author yingp
+ * @date 2018/10/26
+ */
+public interface ResourceModuleMapper {
+    /**
+     * 按应用查找
+     *
+     * @param appId
+     * @return
+     */
+    List<ResourceModule> selectByAppId(@Param("appId") String appId);
+}

+ 0 - 11
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/mapper/ResourcesMapper.java

@@ -1,11 +0,0 @@
-package com.usoftchina.saas.account.mapper;
-
-import com.usoftchina.saas.account.po.Resources;
-import com.usoftchina.saas.base.mapper.CommonBaseMapper;
-
-/**
- * @author yingp
- * @date 2018/10/2
- */
-public interface ResourcesMapper extends CommonBaseMapper<Resources> {
-}

+ 10 - 1
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/mapper/RoleResourceMapper.java

@@ -21,6 +21,15 @@ public interface RoleResourceMapper {
      *
      * @param roleId
      * @param resourceId
+     * @return
+     */
+    int delete(@Param("roleId") Long roleId, @Param("resourceId") Long resourceId);
+
+    /**
+     * 按角色删除
+     *
+     * @param roleId
+     * @return
      */
-    void delete(@Param("roleId") Long roleId, @Param("resourceId") Long resourceId);
+    int deleteByRoleId(@Param("roleId") Long roleId);
 }

+ 31 - 36
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/po/Resources.java → base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/po/Resource.java

@@ -1,7 +1,5 @@
 package com.usoftchina.saas.account.po;
 
-import com.usoftchina.saas.base.entity.CommonBaseEntity;
-
 import java.io.Serializable;
 
 /**
@@ -10,15 +8,12 @@ import java.io.Serializable;
  * @author yingp
  * @date 2018/10/2
  */
-public class Resources extends CommonBaseEntity implements Serializable {
+public class Resource implements Serializable {
+    private Long id;
     /**
-     * 编号
+     * 资源组
      */
-    private String code;
-    /**
-     * 名称
-     */
-    private String name;
+    private Long groupId;
     /**
      * 资源类型
      * MENU - 菜单
@@ -28,6 +23,11 @@ public class Resources extends CommonBaseEntity implements Serializable {
      * API - api
      */
     private String type;
+    /**
+     * 资源分类
+     * @see com.usoftchina.saas.account.constant.ResourceClassify
+     */
+    private String classify;
     /**
      * url
      */
@@ -39,29 +39,16 @@ public class Resources extends CommonBaseEntity implements Serializable {
     private String method;
 
     /**
-     * 排序
-     */
-    private Integer orderNum;
-
-    /**
-     * 描述
+     * 名称
      */
-    private String description;
-
-    public String getCode() {
-        return code;
-    }
-
-    public void setCode(String code) {
-        this.code = code;
-    }
+    private String name;
 
-    public String getName() {
-        return name;
+    public Long getId() {
+        return id;
     }
 
-    public void setName(String name) {
-        this.name = name;
+    public void setId(Long id) {
+        this.id = id;
     }
 
     public String getType() {
@@ -72,6 +59,14 @@ public class Resources extends CommonBaseEntity implements Serializable {
         this.type = type;
     }
 
+    public String getClassify() {
+        return classify;
+    }
+
+    public void setClassify(String classify) {
+        this.classify = classify;
+    }
+
     public String getUrl() {
         return url;
     }
@@ -88,19 +83,19 @@ public class Resources extends CommonBaseEntity implements Serializable {
         this.method = method;
     }
 
-    public Integer getOrderNum() {
-        return orderNum;
+    public String getName() {
+        return name;
     }
 
-    public void setOrderNum(Integer orderNum) {
-        this.orderNum = orderNum;
+    public void setName(String name) {
+        this.name = name;
     }
 
-    public String getDescription() {
-        return description;
+    public Long getGroupId() {
+        return groupId;
     }
 
-    public void setDescription(String description) {
-        this.description = description;
+    public void setGroupId(Long groupId) {
+        this.groupId = groupId;
     }
 }

+ 40 - 0
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/po/ResourceGroup.java

@@ -0,0 +1,40 @@
+package com.usoftchina.saas.account.po;
+
+import java.io.Serializable;
+
+/**
+ * 资源组
+ * 可以按单据分组
+ *
+ * @author yingp
+ * @date 2018/10/25
+ */
+public class ResourceGroup implements Serializable {
+    private Long id;
+    private Long moduleId;
+    private String name;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getModuleId() {
+        return moduleId;
+    }
+
+    public void setModuleId(Long moduleId) {
+        this.moduleId = moduleId;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}

+ 40 - 0
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/po/ResourceModule.java

@@ -0,0 +1,40 @@
+package com.usoftchina.saas.account.po;
+
+import java.io.Serializable;
+
+/**
+ * 资源模块
+ * 按采购、销售、资金...分模块
+ *
+ * @author yingp
+ * @date 2018/10/25
+ */
+public class ResourceModule implements Serializable {
+    private Long id;
+    private String appId;
+    private String name;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+
+    public void setAppId(String appId) {
+        this.appId = appId;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}

+ 13 - 0
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/po/Role.java

@@ -24,6 +24,11 @@ public class Role extends CommonBaseEntity implements Serializable {
      */
     private String description;
 
+    /**
+     * 角色类型:0 - 管理员角色, 1 - 普通角色
+     */
+    private Integer type;
+
     public String getCode() {
         return code;
     }
@@ -47,4 +52,12 @@ public class Role extends CommonBaseEntity implements Serializable {
     public void setDescription(String description) {
         this.description = description;
     }
+
+    public Integer getType() {
+        return type;
+    }
+
+    public void setType(Integer type) {
+        this.type = type;
+    }
 }

+ 24 - 0
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/service/CompanyService.java

@@ -34,6 +34,14 @@ public interface CompanyService {
      */
     Company findByBusinessCode(String businessCode);
 
+    /**
+     * 按ID查找
+     *
+     * @param id
+     * @return
+     */
+    Company findByPrimaryKey(Long id);
+
     /**
      * 按个人账户查找全部绑定企业
      *
@@ -49,4 +57,20 @@ public interface CompanyService {
      * @return
      */
     boolean removeByPrimaryKey(Long id);
+
+    /**
+     * 公司绑定应用
+     *
+     * @param companyId
+     * @param appId
+     */
+    void bindApp(long companyId, String appId);
+
+    /**
+     * 公司解除绑定应用
+     *
+     * @param companyId
+     * @param appId
+     */
+    void unbindApp(long companyId, String appId);
 }

+ 29 - 0
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/service/ResourceService.java

@@ -0,0 +1,29 @@
+package com.usoftchina.saas.account.service;
+
+import com.usoftchina.saas.account.dto.ResourceModuleDTO;
+import com.usoftchina.saas.account.dto.UrlResourceDTO;
+import com.usoftchina.saas.account.po.Resource;
+
+import java.util.List;
+
+/**
+ * @author yingp
+ * @date 2018/10/24
+ */
+public interface ResourceService {
+    /**
+     * 按应用查找资源模块,以及模块下的资源分组 + 资源
+     *
+     * @param appId
+     * @return
+     */
+    List<ResourceModuleDTO> findModulesByAppId(String appId);
+
+    /**
+     * 按应用查找资源的url属性
+     *
+     * @param appId
+     * @return
+     */
+    List<UrlResourceDTO> findUrlResourcesByAppId(String appId);
+}

+ 28 - 0
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/service/RoleService.java

@@ -0,0 +1,28 @@
+package com.usoftchina.saas.account.service;
+
+import com.usoftchina.saas.account.mapper.RoleMapper;
+import com.usoftchina.saas.account.po.Role;
+import com.usoftchina.saas.base.service.CommonBaseService;
+
+/**
+ * @author yingp
+ * @date 2018/10/24
+ */
+public interface RoleService extends CommonBaseService<RoleMapper, Role>{
+
+    /**
+     * 角色绑定资源
+     *
+     * @param roleId
+     * @param resourceId
+     */
+    void bindResource(long roleId, long resourceId);
+
+    /**
+     * 角色解除绑定资源
+     *
+     * @param roleId
+     * @param resourceId
+     */
+    void unbindResource(long roleId, long resourceId);
+}

+ 2 - 0
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/service/impl/AccountServiceImpl.java

@@ -7,6 +7,7 @@ import com.usoftchina.saas.account.po.Account;
 import com.usoftchina.saas.account.service.AccountService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.DigestUtils;
 
 /**
@@ -82,6 +83,7 @@ public class AccountServiceImpl implements AccountService {
         accountRoleMapper.delete(accountId, roleId);
     }
 
+    @Transactional(rollbackFor = Exception.class)
     @Override
     public boolean removeByPrimaryKey(Long id) {
         accountRoleMapper.deleteByAccountId(id);

+ 27 - 0
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/service/impl/CompanyServiceImpl.java

@@ -1,5 +1,7 @@
 package com.usoftchina.saas.account.service.impl;
 
+import com.usoftchina.saas.account.mapper.AccountCompanyMapper;
+import com.usoftchina.saas.account.mapper.CompanyAppMapper;
 import com.usoftchina.saas.account.mapper.CompanyMapper;
 import com.usoftchina.saas.account.po.Company;
 import com.usoftchina.saas.account.service.CompanyService;
@@ -7,6 +9,7 @@ import com.usoftchina.saas.account.vo.CompanyBaseVO;
 import com.usoftchina.saas.context.BaseContextHolder;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.Date;
 import java.util.List;
@@ -21,6 +24,12 @@ public class CompanyServiceImpl implements CompanyService{
     @Autowired
     private CompanyMapper companyMapper;
 
+    @Autowired
+    private AccountCompanyMapper accountCompanyMapper;
+
+    @Autowired
+    private CompanyAppMapper companyAppMapper;
+
     @Override
     public boolean save(Company company) {
         Date nowDate = new Date();
@@ -42,13 +51,31 @@ public class CompanyServiceImpl implements CompanyService{
         return companyMapper.selectByBusinessCode(businessCode);
     }
 
+    @Override
+    public Company findByPrimaryKey(Long id) {
+        return companyMapper.selectByPrimaryKey(id);
+    }
+
     @Override
     public List<CompanyBaseVO> findBaseByAccountId(Long accountId) {
         return companyMapper.selectBaseByAccountId(accountId);
     }
 
+    @Transactional(rollbackFor = Exception.class)
     @Override
     public boolean removeByPrimaryKey(Long id) {
+        accountCompanyMapper.deleteByCompanyId(id);
+        companyAppMapper.deleteByCompanyId(id);
         return companyMapper.deleteByPrimaryKey(id) > 0;
     }
+
+    @Override
+    public void bindApp(long companyId, String appId) {
+        companyAppMapper.insert(companyId, appId);
+    }
+
+    @Override
+    public void unbindApp(long companyId, String appId) {
+        companyAppMapper.delete(companyId, appId);
+    }
 }

+ 104 - 0
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/service/impl/ResourceServiceImpl.java

@@ -0,0 +1,104 @@
+package com.usoftchina.saas.account.service.impl;
+
+import com.usoftchina.saas.account.constant.ResourceClassify;
+import com.usoftchina.saas.account.dto.ResourceDTO;
+import com.usoftchina.saas.account.dto.ResourceGroupDTO;
+import com.usoftchina.saas.account.dto.ResourceModuleDTO;
+import com.usoftchina.saas.account.dto.UrlResourceDTO;
+import com.usoftchina.saas.account.mapper.ResourceGroupMapper;
+import com.usoftchina.saas.account.mapper.ResourceMapper;
+import com.usoftchina.saas.account.mapper.ResourceModuleMapper;
+import com.usoftchina.saas.account.po.Resource;
+import com.usoftchina.saas.account.po.ResourceGroup;
+import com.usoftchina.saas.account.po.ResourceModule;
+import com.usoftchina.saas.account.service.ResourceService;
+import com.usoftchina.saas.utils.BeanMapper;
+import com.usoftchina.saas.utils.CollectionUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author yingp
+ * @date 2018/10/24
+ */
+@Service
+public class ResourceServiceImpl implements ResourceService {
+
+    @Autowired
+    private ResourceMapper resourceMapper;
+
+    @Autowired
+    private ResourceModuleMapper resourceModuleMapper;
+
+    @Autowired
+    private ResourceGroupMapper resourceGroupMapper;
+
+    @Override
+    public List<ResourceModuleDTO> findModulesByAppId(String appId) {
+        List<ResourceModule> modules = resourceModuleMapper.selectByAppId(appId);
+        if (!CollectionUtils.isEmpty(modules)) {
+            List<ResourceModuleDTO> moduleDTOS = BeanMapper.mapList(modules, ResourceModuleDTO.class);
+            moduleDTOS.parallelStream().forEach(moduleDTO -> {
+                moduleDTO.setGroups(findGroupsByModuleId(moduleDTO.getId()));
+            });
+            return moduleDTOS;
+        }
+        return null;
+    }
+
+    /**
+     * 模块下的资源分组
+     *
+     * @param moduleId
+     * @return
+     */
+    private List<ResourceGroupDTO> findGroupsByModuleId(Long moduleId) {
+        List<ResourceGroup> groups = resourceGroupMapper.selectByModuleId(moduleId);
+        if (!CollectionUtils.isEmpty(groups)) {
+            List<ResourceGroupDTO> groupDTOS = BeanMapper.mapList(groups, ResourceGroupDTO.class);
+            groupDTOS.parallelStream().forEach(groupDTO -> {
+                List<ResourceDTO> resources = findResourcesByGroupId(groupDTO.getId());
+                // 分类(分类后,方便快速设置)
+                Map<String, List<ResourceDTO>> map = CollectionUtils.groupBy(resources, ResourceDTO::getClassify);
+                groupDTO.setQueries(map.get(ResourceClassify.QUERY.name()));
+                groupDTO.setAdds(map.get(ResourceClassify.ADD.name()));
+                groupDTO.setUpdates(map.get(ResourceClassify.UPDATE.name()));
+                groupDTO.setDeletes(map.get(ResourceClassify.DELETE.name()));
+                groupDTO.setAudits(map.get(ResourceClassify.AUDIT.name()));
+                groupDTO.setUnAudits(map.get(ResourceClassify.UNAUDIT.name()));
+                groupDTO.setExports(map.get(ResourceClassify.EXPORT.name()));
+                groupDTO.setImports(map.get(ResourceClassify.IMPORT.name()));
+                groupDTO.setPrints(map.get(ResourceClassify.PRINT.name()));
+                groupDTO.setOthers(map.get(ResourceClassify.OTHER.name()));
+            });
+            return groupDTOS;
+        }
+        return null;
+    }
+
+    /**
+     * 资源组下的资源
+     *
+     * @param groupId
+     * @return
+     */
+    private List<ResourceDTO> findResourcesByGroupId(Long groupId) {
+        List<Resource> resources = resourceMapper.selectByGroupId(groupId);
+        if (!CollectionUtils.isEmpty(resources)) {
+            return BeanMapper.mapList(resources, ResourceDTO.class);
+        }
+        return null;
+    }
+
+    @Override
+    public List<UrlResourceDTO> findUrlResourcesByAppId(String appId) {
+        List<Resource> resources = resourceMapper.selectByAppId(appId);
+        if (!CollectionUtils.isEmpty(resources)) {
+            return BeanMapper.mapList(resources, UrlResourceDTO.class);
+        }
+        return null;
+    }
+}

+ 58 - 0
base-servers/account/account-server/src/main/java/com/usoftchina/saas/account/service/impl/RoleServiceImpl.java

@@ -0,0 +1,58 @@
+package com.usoftchina.saas.account.service.impl;
+
+import com.usoftchina.saas.account.constant.RoleType;
+import com.usoftchina.saas.account.mapper.AccountRoleMapper;
+import com.usoftchina.saas.account.mapper.RoleMapper;
+import com.usoftchina.saas.account.mapper.RoleResourceMapper;
+import com.usoftchina.saas.account.po.Role;
+import com.usoftchina.saas.account.service.RoleService;
+import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
+import com.usoftchina.saas.utils.StringUtils;
+import org.apache.commons.lang.RandomStringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * @author yingp
+ * @date 2018/10/24
+ */
+@Service
+public class RoleServiceImpl extends CommonBaseServiceImpl<RoleMapper, Role> implements RoleService{
+
+    private static final String ROLE_CODE_PREFIX = "ROLE_";
+
+    @Autowired
+    private RoleResourceMapper roleResourceMapper;
+
+    @Autowired
+    private AccountRoleMapper accountRoleMapper;
+
+    @Override
+    public boolean save(Role role) {
+        if (StringUtils.isEmpty(role.getCode())) {
+            role.setCode(ROLE_CODE_PREFIX + RandomStringUtils.randomAlphabetic(8));
+        }
+        // 新增的都是普通角色
+        role.setType(RoleType.NORMAL.getType());
+        return super.save(role);
+    }
+
+    @Override
+    public void bindResource(long roleId, long resourceId) {
+        roleResourceMapper.insert(roleId, resourceId);
+    }
+
+    @Override
+    public void unbindResource(long roleId, long resourceId) {
+        roleResourceMapper.delete(roleId, resourceId);
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public boolean removeByPrimaryKey(Long id) {
+        accountRoleMapper.deleteByRoleId(id);
+        roleResourceMapper.deleteByRoleId(id);
+        return super.removeByPrimaryKey(id);
+    }
+}

+ 17 - 2
base-servers/account/account-server/src/main/resources/application.yml

@@ -7,8 +7,23 @@ spring:
     user:
       name: admin
       password: select111***
+  rabbitmq:
+    host: 192.168.0.176
+    port: 5672
+    virtual-host: dev
+    username: saas
+    password: select123***
+  zipkin:
+    sender:
+      type: rabbit
+    locator:
+      discovery:
+        enabled: true
+  sleuth:
+    sampler:
+      probability: 1.0
   datasource:
-    driver-class-name: com.mysql.jdbc.Driver
+    driver-class-name: com.mysql.cj.jdbc.Driver
     url: jdbc:mysql://192.168.253.12:3306/saas_account?characterEncoding=utf-8&useSSL=false
     username: root
     password: select111***
@@ -31,7 +46,7 @@ eureka:
   client:
     registryFetchIntervalSeconds: 5
     serviceUrl:
-      defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@192.168.0.181:8500/eureka/
+      defaultZone: http://${spring.security.user.name}:${spring.security.user.password}@192.168.0.181:8510/eureka/
 server:
   port: 8580
   tomcat:

+ 3 - 0
base-servers/account/account-server/src/main/resources/mapper/AccountCompanyMapper.xml

@@ -10,4 +10,7 @@
     <delete id="deleteByAccountId" parameterType="java.lang.Long">
         delete from ac_account_company where account_id=#{accountId}
     </delete>
+    <delete id="deleteByCompanyId" parameterType="java.lang.Long">
+        delete from ac_account_company where company_id=#{companyId}
+    </delete>
 </mapper>

+ 3 - 0
base-servers/account/account-server/src/main/resources/mapper/AccountRoleMapper.xml

@@ -10,4 +10,7 @@
     <delete id="deleteByAccountId" parameterType="java.lang.Long">
         delete from ac_account_role where account_id=#{accountId}
     </delete>
+    <delete id="deleteByRoleId" parameterType="java.lang.Long">
+        delete from ac_account_role where role_id=#{roleId}
+    </delete>
 </mapper>

+ 13 - 0
base-servers/account/account-server/src/main/resources/mapper/CompanyAppMapper.xml

@@ -0,0 +1,13 @@
+<?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.usoftchina.saas.account.mapper.CompanyAppMapper">
+    <insert id="insert">
+        insert into ac_company_app(company_id,app_id) values (#{companyId,jdbcType=BIGINT}, #{appId,jdbcType=VARCHAR})
+    </insert>
+    <delete id="delete">
+        delete from ac_company_app where company_id=#{companyId,jdbcType=BIGINT} and app_id=#{appId,jdbcType=VARCHAR}
+    </delete>
+    <delete id="deleteByCompanyId" parameterType="java.lang.Long">
+        delete from ac_company_app where company_id=#{companyId}
+    </delete>
+</mapper>

+ 7 - 4
base-servers/account/account-server/src/main/resources/mapper/CompanyMapper.xml

@@ -80,17 +80,20 @@
             </if>
         </trim>
     </insert>
+    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="FullResultMap">
+        select <include refid="baseColumns"/> from ac_company where id=#{id,jdbcType=BIGINT}
+    </select>
     <select id="selectByName" parameterType="java.lang.String" resultMap="FullResultMap">
-        select <include refid="baseColumns"/> from ac_company where name=#{name}
+        select <include refid="baseColumns"/> from ac_company where name=#{name,jdbcType=VARCHAR}
     </select>
     <select id="selectByBusinessCode" parameterType="java.lang.String" resultMap="FullResultMap">
-        select <include refid="baseColumns"/> from ac_company where business_code=#{businessCode}
+        select <include refid="baseColumns"/> from ac_company where business_code=#{businessCode,jdbcType=VARCHAR}
     </select>
     <select id="selectBaseByAccountId" parameterType="java.lang.Long" resultMap="BaseResultMap">
         select ac_company.id,ac_company.name,ac_company.logo_url from ac_account_company,ac_company
-        where ac_account_company.company_id=ac_company.id and ac_account_company.account_id=#{accountId}
+        where ac_account_company.company_id=ac_company.id and ac_account_company.account_id=#{accountId,jdbcType=BIGINT}
     </select>
     <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
-        delete from ac_company where id=#{id}
+        delete from ac_company where id=#{id,jdbcType=BIGINT}
     </delete>
 </mapper>

+ 15 - 0
base-servers/account/account-server/src/main/resources/mapper/ResourceGroupMapper.xml

@@ -0,0 +1,15 @@
+<?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.usoftchina.saas.account.mapper.ResourceGroupMapper">
+    <resultMap id="BaseResultMap" type="com.usoftchina.saas.account.po.ResourceGroup">
+        <id column="id" jdbcType="BIGINT" property="id"/>
+        <result column="name" jdbcType="VARCHAR" property="name"/>
+        <result column="module_id" jdbcType="BIGINT" property="moduleId"/>
+    </resultMap>
+    <sql id="baseColumns">
+        id,name,module_id
+    </sql>
+    <select id="selectByModuleId" parameterType="java.lang.Long" resultMap="BaseResultMap">
+        select <include refid="baseColumns"/> from ac_resource_group where module_id=#{moduleId,jdbcType=VARCHAR} order by id
+    </select>
+</mapper>

+ 24 - 0
base-servers/account/account-server/src/main/resources/mapper/ResourceMapper.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.usoftchina.saas.account.mapper.ResourceMapper">
+    <resultMap id="BaseResultMap" type="com.usoftchina.saas.account.po.Resource">
+        <id column="id" jdbcType="BIGINT" property="id"/>
+        <result column="name" jdbcType="VARCHAR" property="name"/>
+        <result column="group_id" jdbcType="BIGINT" property="groupId"/>
+        <result column="type" jdbcType="VARCHAR" property="type"/>
+        <result column="url" jdbcType="VARCHAR" property="url"/>
+        <result column="method" jdbcType="VARCHAR" property="method"/>
+        <result column="classify" jdbcType="VARCHAR" property="classify"/>
+    </resultMap>
+    <sql id="baseColumns">
+        ac_resource.id,ac_resource.name,ac_resource.group_id,ac_resource.type,ac_resource.url,ac_resource.method,ac_resource.classify
+    </sql>
+    <select id="selectByGroupId" parameterType="java.lang.Long" resultMap="BaseResultMap">
+        select <include refid="baseColumns"/> from ac_resource where group_id=#{groupId,jdbcType=BIGINT}
+    </select>
+    <select id="selectByAppId" parameterType="java.lang.String" resultMap="BaseResultMap">
+        select <include refid="baseColumns"/> from ac_resource,ac_resource_module,ac_resource_group where
+        ac_resource_module.id=ac_resource_group.module_id and ac_resource_group.id=ac_resource.group_id
+        and ac_resource_module.app_id=#{appId,jdbcType=VARCHAR}
+    </select>
+</mapper>

+ 15 - 0
base-servers/account/account-server/src/main/resources/mapper/ResourceModuleMapper.xml

@@ -0,0 +1,15 @@
+<?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.usoftchina.saas.account.mapper.ResourceModuleMapper">
+    <resultMap id="BaseResultMap" type="com.usoftchina.saas.account.po.ResourceModule">
+        <id column="id" jdbcType="BIGINT" property="id"/>
+        <result column="name" jdbcType="VARCHAR" property="name"/>
+        <result column="app_id" jdbcType="VARCHAR" property="appId"/>
+    </resultMap>
+    <sql id="baseColumns">
+        id,name,app_id
+    </sql>
+    <select id="selectByAppId" parameterType="java.lang.String" resultMap="BaseResultMap">
+        select <include refid="baseColumns"/> from ac_resource_module where app_id=#{appId,jdbcType=VARCHAR} order by id
+    </select>
+</mapper>

+ 0 - 4
base-servers/account/account-server/src/main/resources/mapper/ResourcesMapper.xml

@@ -1,4 +0,0 @@
-<?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.usoftchina.saas.account.mapper.ResourcesMapper">
-</mapper>

+ 98 - 1
base-servers/account/account-server/src/main/resources/mapper/RoleMapper.xml

@@ -1,5 +1,102 @@
 <?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.usoftchina.saas.account.mapper.RoleMapper">
-
+    <resultMap id="BaseResultMap" type="com.usoftchina.saas.account.po.Role">
+        <id column="id" jdbcType="BIGINT" property="id"/>
+        <result column="code" jdbcType="VARCHAR" property="code"/>
+        <result column="name" jdbcType="VARCHAR" property="name"/>
+        <result column="description" jdbcType="VARCHAR" property="description"/>
+        <result column="type" jdbcType="INTEGER" property="type"/>
+        <result column="company_id" jdbcType="BIGINT" property="companyId"/>
+        <result column="creator_id" jdbcType="BIGINT" property="creatorId"/>
+        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
+        <result column="updater_id" jdbcType="BIGINT" property="updaterId"/>
+        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
+    </resultMap>
+    <sql id="baseColumns">
+        id,code,name,description,type,company_id,creator_id,create_time,updater_id,update_time
+    </sql>
+    <insert id="insert" parameterType="com.usoftchina.saas.account.po.Role"
+            useGeneratedKeys="true" keyProperty="id">
+        insert into ac_role(code,name,description,type,company_id,creator_id,create_time,updater_id,update_time)
+        values (#{code,jdbcType=VARCHAR},#{name,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, #{companyId,jdbcType=BIGINT},
+        #{creatorId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, #{updaterId,jdbcType=BIGINT}, #{updateTime,jdbcType=TIMESTAMP})
+    </insert>
+    <insert id="insertSelective" parameterType="com.usoftchina.saas.account.po.Role"
+            useGeneratedKeys="true" keyProperty="id">
+        insert into ac_role
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="code != null">
+                code,
+            </if>
+            <if test="name != null">
+                name,
+            </if>
+            <if test="description != null">
+                description,
+            </if>
+            <if test="type != null">
+                type,
+            </if>
+            <if test="companyId != null">
+                company_id,
+            </if>
+            <if test="creatorId != null">
+                creator_id,
+            </if>
+            <if test="createTime != null">
+                create_time,
+            </if>
+            <if test="updaterId != null">
+                updater_id,
+            </if>
+            <if test="updateTime != null">
+                update_time,
+            </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="code != null">
+                #{code,jdbcType=VARCHAR},
+            </if>
+            <if test="name != null">
+                #{name,jdbcType=VARCHAR},
+            </if>
+            <if test="description != null">
+                #{description,jdbcType=VARCHAR},
+            </if>
+            <if test="type != null">
+                #{type,jdbcType=INTEGER},
+            </if>
+            <if test="companyId != null">
+                #{companyId,jdbcType=BIGINT},
+            </if>
+            <if test="creatorId != null">
+                #{creatorId,jdbcType=BIGINT},
+            </if>
+            <if test="createTime != null">
+                #{createTime,jdbcType=TIMESTAMP},
+            </if>
+            <if test="updaterId != null">
+                #{updaterId,jdbcType=BIGINT},
+            </if>
+            <if test="updateTime != null">
+                #{updateTime,jdbcType=TIMESTAMP},
+            </if>
+        </trim>
+    </insert>
+    <update id="updateByPrimaryKey" parameterType="com.usoftchina.saas.account.po.Role">
+        update ac_role set code=#{code,jdbcType=VARCHAR},name=#{name,jdbcType=VARCHAR},
+        description=#{description,jdbcType=VARCHAR},type=#{type,jdbcType=INTEGER},company_id=#{companyId,jdbcType=BIGINT},
+        creator_id=#{creatorId,jdbcType=BIGINT},create_time=#{createTime,jdbcType=TIMESTAMP},
+        updater_id=#{updaterId,jdbcType=BIGINT},update_time=#{updateTime,jdbcType=TIMESTAMP} where id=#{id,jdbcType=BIGINT}
+    </update>
+    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
+        delete from ac_role where id=#{id,jdbcType=BIGINT}
+    </delete>
+    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
+        select <include refid="baseColumns"/> from ac_role where id=#{id,jdbcType=BIGINT}
+    </select>
+    <select id="selectByCompanyId" parameterType="java.lang.Long" resultMap="BaseResultMap">
+        select <include refid="baseColumns"/> from ac_role where company_id=#{companyId,jdbcType=BIGINT}
+    </select>
 </mapper>

+ 3 - 0
base-servers/account/account-server/src/main/resources/mapper/RoleResourceMapper.xml

@@ -7,4 +7,7 @@
     <delete id="delete">
         delete from ac_role_resource where role_id=#{roleId} and resource_id=#{resourceId}
     </delete>
+    <delete id="deleteByRoleId" parameterType="java.lang.Long">
+        delete from ac_role_resource where role_id=#{roleId}
+    </delete>
 </mapper>

+ 1 - 2
base-servers/account/account-server/src/test/java/com/usoftchina/saas/account/controller/AccountControllerTest.java

@@ -111,8 +111,7 @@ public class AccountControllerTest extends BaseControllerTest {
     @Test
     public void testI_deleteAccount() throws Exception {
         AccountDTO accountDTO = getAccountDTO();
-        mockMvc.perform(post("/account/delete")
-                .param("accountId", String.valueOf(accountDTO.getId())))
+        mockMvc.perform(post("/account/delete/{id}", accountDTO.getId()))
                 .andExpect(isSuccess());
     }
 }

+ 32 - 5
base-servers/account/account-server/src/test/java/com/usoftchina/saas/account/controller/CompanyControllerTest.java

@@ -3,6 +3,7 @@ package com.usoftchina.saas.account.controller;
 import com.usoftchina.saas.account.dto.CompanyDTO;
 import com.usoftchina.saas.base.Result;
 import com.usoftchina.saas.test.BaseControllerTest;
+import com.usoftchina.saas.test.TestConstant;
 import org.junit.Assert;
 import org.junit.FixMethodOrder;
 import org.junit.Test;
@@ -39,7 +40,7 @@ public class CompanyControllerTest extends BaseControllerTest {
     }
 
     private CompanyDTO getByName() throws Exception {
-        MvcResult mvcResult = mockMvc.perform(get("/company")
+        MvcResult mvcResult = mockMvc.perform(get("/company/read")
                 .param("name", name))
                 .andExpect(isSuccess())
                 .andReturn();
@@ -49,7 +50,7 @@ public class CompanyControllerTest extends BaseControllerTest {
     }
 
     private CompanyDTO getByBusinessCode() throws Exception {
-        MvcResult mvcResult = mockMvc.perform(get("/company")
+        MvcResult mvcResult = mockMvc.perform(get("/company/read")
                 .param("businessCode", businessCode))
                 .andExpect(isSuccess())
                 .andReturn();
@@ -65,10 +66,36 @@ public class CompanyControllerTest extends BaseControllerTest {
     }
 
     @Test
-    public void testD_delete() throws Exception {
+    public void testD_getCurrentCompany() throws Exception {
+        MvcResult mvcResult = mockMvc.perform(get("/company/read/current"))
+                .andExpect(isSuccess())
+                .andReturn();
+        Result<CompanyDTO> result = result(mvcResult, CompanyDTO.class);
+        System.out.println(result.getData());
+    }
+
+    @Test
+    public void testE_bindApp() throws Exception {
+        CompanyDTO companyDTO = getByName();
+        mockMvc.perform(post("/company/bind/app")
+                .param("companyId", String.valueOf(companyDTO.getId()))
+                .param("appId", TestConstant.DEFAULT_APP_ID))
+                .andExpect(isSuccess());
+    }
+
+    @Test
+    public void testF_unbindApp() throws Exception {
+        CompanyDTO companyDTO = getByName();
+        mockMvc.perform(post("/company/unbind/app")
+                .param("companyId", String.valueOf(companyDTO.getId()))
+                .param("appId", TestConstant.DEFAULT_APP_ID))
+                .andExpect(isSuccess());
+    }
+
+    @Test
+    public void testG_delete() throws Exception {
         CompanyDTO companyDTO = getByName();
-        mockMvc.perform(post("/company/delete")
-                .param("companyId", String.valueOf(companyDTO.getId())))
+        mockMvc.perform(post("/company/delete/{id}", companyDTO.getId()))
                 .andExpect(isSuccess());
     }
 

Некоторые файлы не были показаны из-за большого количества измененных файлов