Browse Source

Merge branch 'dev' of ssh://10.10.100.21/source/saas-platform into dev

rainco 7 years ago
parent
commit
3da7fe4a0a
17 changed files with 650 additions and 9 deletions
  1. 1 0
      applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/exception/BizExceptionCode.java
  2. 3 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/PaybalanceServiceImpl.java
  3. 3 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/RecbalanceServiceImpl.java
  4. 66 0
      applications/sale/sale-dto/src/main/java/com/usoftchina/saas/sale/dto/PurchaseDTO.java
  5. 62 0
      applications/sale/sale-dto/src/main/java/com/usoftchina/saas/sale/dto/PurchaseDetailDTO.java
  6. 156 0
      applications/sale/sale-dto/src/main/java/com/usoftchina/saas/sale/dto/PurchaseListDTO.java
  7. 7 1
      applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/controller/SaleController.java
  8. 8 0
      applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/mapper/SaleMapper.java
  9. 2 0
      applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/service/SaleService.java
  10. 58 3
      applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/service/impl/SaleServiceImpl.java
  11. 242 0
      applications/sale/sale-server/src/main/resources/mapper/SaleMapper.xml
  12. 2 2
      base-servers/account/account-server/src/main/resources/mapper/AccountRoleMapper.xml
  13. 1 0
      frontend/saas-web/app/view/auth/CompanyPicker.scss
  14. 2 1
      frontend/saas-web/app/view/auth/LoginController.js
  15. 10 1
      frontend/saas-web/app/view/sale/sale/FormPanel.js
  16. 26 1
      frontend/saas-web/app/view/sale/sale/FormPanelController.js
  17. 1 0
      frontend/saas-web/app/view/viewport/ViewportController.js

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

@@ -77,6 +77,7 @@ public enum BizExceptionCode implements BaseExceptionCode {
     RECALANCE_OUTNOWBALANCE(74003,"本次核销金额不能大于未核销金额"),
     BEFORE_UNAUDIT(74006, "单据:<u>%s</u>未审核,无法反审核"),
     BANK_AMOUNT_NOTENOUGH(74004, "资金账号不足"),
+    SUBLEDGER_NOT_EXIS(74005,"来源单据不存在"),
 
 
 

+ 3 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/PaybalanceServiceImpl.java

@@ -137,6 +137,9 @@ public class PaybalanceServiceImpl extends CommonBaseServiceImpl<PaybalanceMappe
             Double namount = new Double(0);
             if(sourceId!=0){
                 Subledger subledger = subledgerMapper.selectByPrimaryKey(sourceId);
+                if (subledger == null){
+                    throw new BizException(500, BizExceptionCode.SUBLEDGER_NOT_EXIS.getMessage());
+                }
                 namount = subledger.getSl_namount();
             }
             //本次核销金额不能大于未核销金额

+ 3 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/RecbalanceServiceImpl.java

@@ -135,6 +135,9 @@ public class RecbalanceServiceImpl extends CommonBaseServiceImpl<RecbalanceMappe
             Double namount = new Double(0);
             if(sourceId!=0){
                 Subledger subledger = subledgerMapper.selectByPrimaryKey(sourceId);
+                if (subledger == null){
+                    throw new BizException(500, BizExceptionCode.SUBLEDGER_NOT_EXIS.getMessage());
+                }
                 namount = subledger.getSl_namount()==null?new Double(0):subledger.getSl_namount();
             }
             //本次核销金额不能大于未核销金额

+ 66 - 0
applications/sale/sale-dto/src/main/java/com/usoftchina/saas/sale/dto/PurchaseDTO.java

@@ -0,0 +1,66 @@
+package com.usoftchina.saas.sale.dto;
+
+import com.usoftchina.saas.base.entity.CommonBaseEntity;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+@Data
+public class PurchaseDTO extends CommonBaseEntity implements Serializable {
+
+    private String pu_code;
+
+    private Date pu_date;
+
+    private Integer pu_vendid;
+
+    private String pu_vendcode;
+
+    private String pu_vendname;
+
+    private Integer pu_buyerid;
+
+    private String pu_buyercode;
+
+    private String pu_buyername;
+
+    private Date pu_delivery;
+
+    private Double pu_taxtotal;
+
+    private Double pu_total;
+
+    private String pu_remark;
+
+    private String pu_totalupper;
+
+    private String pu_printstatus;
+
+    private String pu_printstatuscode;
+
+    private String pu_acceptstatuscode;
+
+    private String pu_acceptstatus;
+
+    private String pu_statuscode;
+
+    private String pu_status;
+
+    private String pu_text1;
+
+    private String pu_text2;
+
+    private String pu_text3;
+
+    private String pu_text4;
+
+    private String pu_text5;
+
+    private String pu_shipaddresscode;
+
+    private String pu_auditman;
+
+    private Date pu_auditdate;
+
+}

+ 62 - 0
applications/sale/sale-dto/src/main/java/com/usoftchina/saas/sale/dto/PurchaseDetailDTO.java

@@ -0,0 +1,62 @@
+package com.usoftchina.saas.sale.dto;
+
+import com.usoftchina.saas.base.entity.CommonBaseEntity;
+import com.usoftchina.saas.document.dto.ProductDTO;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+@Data
+public class PurchaseDetailDTO extends CommonBaseEntity implements Serializable {
+
+    private  Long pd_puid;
+
+    private String pd_code;
+
+    private Integer pd_detno;
+
+    private Long pd_prodid;
+
+    private String pd_prodcode;
+
+    private String pd_unit;
+
+    private Double pd_qty;
+
+    private Double pd_price;
+
+    private Double pd_taxprice;
+
+    private Double pd_total;
+
+    private Double pd_taxrate;
+
+    private Double pd_taxtotal;
+
+    private Double pd_acceptqty;
+
+    private Date pd_delivery;
+
+    private String pd_salecode;
+
+    private Integer pd_saledetno;
+
+    private Integer pd_sdid;
+
+    private String pd_text1;
+
+    private String pd_text2;
+
+    private String pd_text3;
+
+    private String pd_text4;
+
+    private String pd_text5;
+
+    private Double pd_yqty;
+
+    private  String pd_remark;
+
+    private ProductDTO productDTO;
+}

+ 156 - 0
applications/sale/sale-dto/src/main/java/com/usoftchina/saas/sale/dto/PurchaseListDTO.java

@@ -0,0 +1,156 @@
+package com.usoftchina.saas.sale.dto;
+
+
+import com.usoftchina.saas.base.entity.CommonBaseEntity;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @author: guq
+ * @create: 2018-10-10 16:42
+ **/
+@Data
+public class PurchaseListDTO extends CommonBaseEntity implements Serializable {
+
+    //主表信息
+    private  Integer pu_id;
+
+    private String pu_code;
+
+    private Date pu_date;
+
+    private Integer pu_vendid;
+
+    private String pu_vendcode;
+
+    private String pu_vendname;
+
+    private Integer pu_buyerid;
+
+    private String pu_buyercode;
+
+    private String pu_buyername;
+
+    private Date pu_delivery;
+
+    private Double pu_taxtotal;
+
+    private Double pu_total;
+
+    private String pu_remark;
+
+    private String pu_totalupper;
+
+    private String pu_printstatus;
+
+    private String pu_printstatuscode;
+
+    private String pu_acceptstatuscode;
+
+    private String pu_acceptstatus;
+
+    private String pu_statuscode;
+
+    private String pu_status;
+
+    private String pu_text1;
+
+    private String pu_text2;
+
+    private String pu_text3;
+
+    private String pu_text4;
+
+    private String pu_text5;
+
+    private String pu_shipaddresscode;
+
+    private Date pu_auditdate;
+
+    private String pu_auditman;
+
+    //从表字段
+    private Long pd_id;
+
+    private  Long pd_puid;
+
+    private String pd_code;
+
+    private Integer pd_detno;
+
+    private Integer pd_prodid;
+
+    private String pd_prodcode;
+
+    private String pd_unit;
+
+    private Double pd_qty;
+
+    private Double pd_price;
+
+    private Double pd_taxprice;
+
+    private Double pd_total;
+
+    private Double pd_taxrate;
+
+    private Double pd_taxtotal;
+
+    private Double pd_acceptqty;
+
+    private Date pd_delivery;
+
+    private String pd_salecode;
+
+    private Integer pd_saledetno;
+
+    private Integer pd_sdid;
+
+    private String pd_text1;
+
+    private String pd_text2;
+
+    private String pd_text3;
+
+    private String pd_text4;
+
+    private String pd_text5;
+
+    private Double pd_yqty;
+
+    private String pd_remark;
+
+    private String pd_ordercode;
+
+    //private ProductDTO productDTO;
+    private Long pr_id;
+    private String pr_code;
+    private String pr_detail;
+    private String pr_spec;
+    private String pr_unit;
+    private String pr_kind;
+    private String pr_orispeccode;
+    private long pr_whid;
+    private String pr_whcode;
+    private String pr_whname;
+    private long pr_zxbzs;
+    private long pr_leadtime;
+    private String pr_brand;
+    private String pr_standardprice;
+    private String pr_purcprice;
+    private String pr_saleprice;
+    private long pr_vendid;
+    private String pr_vendname;
+    private String pr_vendcode;
+    private Date pr_docdate;
+    private long pr_recordmanid;
+    private String pr_recordman;
+    private String pr_status;
+    private String pr_statuscode;
+    private String pr_text1;
+    private String pr_text2;
+    private String pr_text3;
+    private String pr_text4;
+}

+ 7 - 1
applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/controller/SaleController.java

@@ -186,7 +186,13 @@ public class SaleController {
        return Result.success();
     }
 
-    @GetMapping("/test")
+    @PostMapping("/saleTurnPurchase/{id}")
+    public Result saleTurnPurchase(@PathVariable("id") Long id){
+        DocBaseDTO baseDTO = saleService.saleTurnPurchase(id);
+        return Result.success(baseDTO);
+    }
+
+  @GetMapping("/test")
     public String test() {
         return "配置构建success-1";
     }

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

@@ -2,6 +2,8 @@ package com.usoftchina.saas.sale.mapper;
 
 import com.usoftchina.saas.base.mapper.CommonBaseMapper;
 import com.usoftchina.saas.commons.dto.DocBaseDTO;
+import com.usoftchina.saas.sale.dto.PurchaseDTO;
+import com.usoftchina.saas.sale.dto.PurchaseDetailDTO;
 import com.usoftchina.saas.sale.po.Sale;
 import java.util.List;
 import org.apache.ibatis.annotations.Param;
@@ -42,4 +44,10 @@ public interface SaleMapper extends CommonBaseMapper<Sale> {
     Integer checkSendStatus(Long id);
 
     void updateCreator(@Param("userId") Long userId, @Param("userName") String userName, @Param("id") Long id);
+
+    void turnPurchase(PurchaseDTO purchase);
+
+    void turnPurchaseDetail(List<PurchaseDetailDTO> list);
+
+    Integer selectPurchaseId(@Param("code") String code,@Param("companyid") Long companyid);
 }

+ 2 - 0
applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/service/SaleService.java

@@ -44,4 +44,6 @@ public interface SaleService {
     void batchClose(BatchDealBaseDTO baseDTOs);
 
     void batchOpen(BatchDealBaseDTO baseDTOs);
+
+    DocBaseDTO saleTurnPurchase(Long id);
 }

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

@@ -2,6 +2,7 @@ package com.usoftchina.saas.sale.service.impl;
 
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.usoftchina.saas.base.Result;
 import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
 import com.usoftchina.saas.commons.api.CommonService;
 import com.usoftchina.saas.commons.api.MaxnumberService;
@@ -14,12 +15,11 @@ import com.usoftchina.saas.commons.po.BillCodeSeq;
 import com.usoftchina.saas.commons.po.Operation;
 import com.usoftchina.saas.commons.po.Status;
 import com.usoftchina.saas.context.BaseContextHolder;
+import com.usoftchina.saas.document.entities.Product;
 import com.usoftchina.saas.exception.BizException;
 import com.usoftchina.saas.page.PageDefault;
 import com.usoftchina.saas.page.PageRequest;
-import com.usoftchina.saas.sale.dto.SaleDTO;
-import com.usoftchina.saas.sale.dto.SaleDetailDTO;
-import com.usoftchina.saas.sale.dto.SaleFormDTO;
+import com.usoftchina.saas.sale.dto.*;
 import com.usoftchina.saas.sale.mapper.*;
 import com.usoftchina.saas.sale.po.Sale;
 import com.usoftchina.saas.sale.po.SaleDetail;
@@ -524,6 +524,61 @@ public class SaleServiceImpl implements SaleService{
 
     }
 
+    @Override
+    public DocBaseDTO saleTurnPurchase(Long id) {
+        Sale sale = saleMapper.selectByPrimaryKey(id);
+        List<SaleList> dateilList = saleListMapper.selectSaleListByCondition("sa_id="+id,BaseContextHolder.getCompanyId());
+
+        PurchaseDTO purchase = new PurchaseDTO();
+        List<PurchaseDetailDTO> listPurchaseDetail = new ArrayList<PurchaseDetailDTO>();
+
+        //销售主表转采购主表
+        Result<String> result = maxnumberService.getMaxnumber(BillCodeSeq.PURCHASE.getCaller(),false);
+        purchase.setPu_code(result.getData());
+        purchase.setPu_status(Status.UNAUDITED.getDisplay());
+        purchase.setPu_statuscode(Status.UNAUDITED.toString());
+        purchase.setCompanyId(BaseContextHolder.getCompanyId());
+        purchase.setCreatorId(BaseContextHolder.getUserId());
+        purchase.setCreateTime(new Date());
+        purchase.setCreatorName(BaseContextHolder.getUserName());
+        saleMapper.turnPurchase(purchase);
+
+        Long purchaseId = purchase.getId();
+        for (SaleList detail : dateilList){
+            PurchaseDetailDTO purchaseDetailDTO = new PurchaseDetailDTO();
+            Double taxPrice = detail.getPr_purcprice()==null?new Double(0):Double.valueOf(detail.getPr_purcprice());
+            Double taxrate = detail.getSd_taxrate()==null?new Double(0):detail.getSd_taxrate();
+            Double qty = detail.getSd_qty()==null?new Double(0):detail.getSd_qty();
+            purchaseDetailDTO.setPd_prodid(Long.valueOf(String.valueOf(detail.getSd_prodid())));
+            purchaseDetailDTO.setPd_prodcode(detail.getSd_prodcode());
+            purchaseDetailDTO.setPd_detno(detail.getSd_detno());
+            purchaseDetailDTO.setPd_qty(detail.getSd_qty());
+            purchaseDetailDTO.setPd_price(taxPrice/(1+taxrate));
+            purchaseDetailDTO.setPd_salecode(sale.getSa_code());
+            purchaseDetailDTO.setPd_saledetno(detail.getSd_detno());
+            purchaseDetailDTO.setPd_taxrate(taxrate);
+            purchaseDetailDTO.setPd_taxprice(taxPrice);
+            purchaseDetailDTO.setPd_taxtotal(taxPrice*qty);
+            purchaseDetailDTO.setCompanyId(BaseContextHolder.getCompanyId());
+            purchaseDetailDTO.setCreatorId(BaseContextHolder.getUserId());
+            purchaseDetailDTO.setCreateTime(new Date());
+            purchaseDetailDTO.setCreatorName(BaseContextHolder.getUserName());
+            purchaseDetailDTO.setPd_puid(purchaseId);
+            purchaseDetailDTO.setPd_code(result.getData());
+            listPurchaseDetail.add(purchaseDetailDTO);
+        }
+
+        saleMapper.turnPurchaseDetail(listPurchaseDetail);
+
+
+
+        DocBaseDTO baseDTO = new DocBaseDTO();
+        baseDTO.setCode(result.getData());
+        baseDTO.setId(Long.valueOf(String.valueOf(purchaseId)));
+        baseDTO.setName(BillCodeSeq.PURCHASE.getName());
+        return baseDTO;
+    }
+
     //更新最新销售总额
     private void updateTotal(Long id) {
         if (null == id) {

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

@@ -421,4 +421,246 @@
   <update id="updateCreator">
     update sale set creatorId = #{userId} , creatorName=#{userName} where sa_id=#{id}
   </update>
+  
+  
+  
+  <!-- 销售订单转采购单-->
+  <insert id="turnPurchase" parameterType="com.usoftchina.saas.sale.dto.PurchaseDTO" >
+    <selectKey resultType="java.lang.Long" keyProperty="id">
+      SELECT LAST_INSERT_ID() AS ID
+    </selectKey>
+    insert into purchase
+    <trim prefix="(" suffix=")" suffixOverrides="," >
+      <if test="pu_code != null" >
+        pu_code,
+      </if>
+      <if test="pu_date != null" >
+        pu_date,
+      </if>
+      <if test="pu_vendid != null" >
+        pu_vendid,
+      </if>
+      <if test="pu_vendcode != null" >
+        PU_VENDCODE,
+      </if>
+      <if test="pu_vendname != null" >
+        PU_VENDNAME,
+      </if>
+      <if test="pu_buyerid != null" >
+        PU_BUYERID,
+      </if>
+      <if test="pu_buyercode != null" >
+        PU_BUYERCODE,
+      </if>
+      <if test="pu_buyername != null" >
+        PU_BUYERNAME,
+      </if>
+      <if test="pu_delivery != null" >
+        PU_DELIVERY,
+      </if>
+      <if test="pu_taxtotal != null" >
+        PU_TAXTOTAL,
+      </if>
+      <if test="pu_total != null" >
+        PU_TOTAL,
+      </if>
+      <if test="pu_remark != null" >
+        PU_REMARK,
+      </if>
+      <if test="pu_totalupper != null" >
+        PU_TOTALUPPER,
+      </if>
+      <if test="pu_printstatus != null" >
+        PU_PRINTSTATUS,
+      </if>
+      <if test="pu_printstatuscode != null" >
+        PU_PRINTSTATUSCODE,
+      </if>
+      <if test="pu_acceptstatuscode != null" >
+        PU_ACCEPTSTATUSCODE,
+      </if>
+      <if test="pu_acceptstatus != null" >
+        PU_ACCEPTSTATUS,
+      </if>
+      <if test="pu_statuscode != null" >
+        PU_STATUSCODE,
+      </if>
+      <if test="pu_status != null" >
+        PU_STATUS,
+      </if>
+      <if test="companyId != null" >
+        companyid,
+      </if>
+      <if test="updaterId != null" >
+        updaterId,
+      </if>
+      <if test="updaterName != null" >
+        updaterName,
+      </if>
+      <if test="updateTime != null" >
+        updateTime,
+      </if>
+      <if test="creatorId != null" >
+        creatorId,
+      </if>
+      <if test="creatorName != null" >
+        creatorName,
+      </if>
+      <if test="createTime != null" >
+        createTime,
+      </if>
+      <if test="pu_text1 != null" >
+        pu_text1,
+      </if>
+      <if test="pu_text2 != null" >
+        pu_text2,
+      </if>
+      <if test="pu_text3 != null" >
+        pu_text3,
+      </if>
+      <if test="pu_text4 != null" >
+        pu_text4,
+      </if>
+      <if test="pu_text5 != null" >
+        pu_text5,
+      </if>
+      <if test="pu_shipaddresscode != null" >
+        PU_SHIPADDRESSCODE,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
+      <if test="pu_code != null" >
+        #{pu_code,jdbcType=VARCHAR},
+      </if>
+      <if test="pu_date != null" >
+        #{pu_date,jdbcType=TIMESTAMP},
+      </if>
+      <if test="pu_vendid != null" >
+        #{pu_vendid,jdbcType=INTEGER},
+      </if>
+      <if test="pu_vendcode != null" >
+        #{pu_vendcode,jdbcType=VARCHAR},
+      </if>
+      <if test="pu_vendname != null" >
+        #{pu_vendname,jdbcType=VARCHAR},
+      </if>
+      <if test="pu_buyerid != null" >
+        #{pu_buyerid,jdbcType=INTEGER},
+      </if>
+      <if test="pu_buyercode != null" >
+        #{pu_buyercode,jdbcType=VARCHAR},
+      </if>
+      <if test="pu_buyername != null" >
+        #{pu_buyername,jdbcType=VARCHAR},
+      </if>
+      <if test="pu_delivery != null" >
+        #{pu_delivery,jdbcType=TIMESTAMP},
+      </if>
+      <if test="pu_taxtotal != null" >
+        #{pu_taxtotal,jdbcType=DOUBLE},
+      </if>
+      <if test="pu_total != null" >
+        #{pu_total,jdbcType=DOUBLE},
+      </if>
+      <if test="pu_remark != null" >
+        #{pu_remark,jdbcType=VARCHAR},
+      </if>
+      <if test="pu_totalupper != null" >
+        #{pu_totalupper,jdbcType=VARCHAR},
+      </if>
+      <if test="pu_printstatus != null" >
+        #{pu_printstatus,jdbcType=VARCHAR},
+      </if>
+      <if test="pu_printstatuscode != null" >
+        #{pu_printstatuscode,jdbcType=VARCHAR},
+      </if>
+      <if test="pu_acceptstatuscode != null" >
+        #{pu_acceptstatuscode,jdbcType=VARCHAR},
+      </if>
+      <if test="pu_acceptstatus != null" >
+        #{pu_acceptstatus,jdbcType=VARCHAR},
+      </if>
+      <if test="pu_statuscode != null" >
+        #{pu_statuscode,jdbcType=VARCHAR},
+      </if>
+      <if test="pu_status != null" >
+        #{pu_status,jdbcType=VARCHAR},
+      </if>
+      <if test="companyId != null" >
+        #{companyId,jdbcType=INTEGER},
+      </if>
+      <if test="updaterId != null" >
+        #{updaterId,jdbcType=INTEGER},
+      </if>
+      <if test="updaterName != null" >
+        #{updaterName,jdbcType=VARCHAR},
+      </if>
+      <if test="updateTime != null" >
+        #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="creatorId != null" >
+        #{creatorId,jdbcType=INTEGER},
+      </if>
+      <if test="creatorName != null" >
+        #{creatorName,jdbcType=VARCHAR},
+      </if>
+      <if test="createTime != null" >
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="pu_text1 != null" >
+        #{pu_text1,jdbcType=VARCHAR},
+      </if>
+      <if test="pu_text2 != null" >
+        #{pu_text2,jdbcType=VARCHAR},
+      </if>
+      <if test="pu_text3 != null" >
+        #{pu_text3,jdbcType=VARCHAR},
+      </if>
+      <if test="pu_text4 != null" >
+        #{pu_text4,jdbcType=VARCHAR},
+      </if>
+      <if test="pu_text5 != null" >
+        #{pu_text5,jdbcType=VARCHAR},
+      </if>
+      <if test="pu_shipaddresscode != null" >
+        #{pu_shipaddresscode,jdbcType=LONGVARCHAR},
+      </if>
+    </trim>
+  </insert>
+
+  <insert id="turnPurchaseDetail" parameterType="java.util.List" >
+    insert into purchasedetail ( PD_PUID, PD_CODE,
+    PD_DETNO, PD_PRODID, PD_PRODCODE,
+    PD_UNIT, PD_QTY, PD_PRICE,PD_TAXPRICE,
+    PD_TOTAL,PD_TAXRATE, PD_TAXTOTAL, PD_ACCEPTQTY,
+    PD_DELIVERY, PD_SALECODE, PD_SALEDETNO,
+    PD_SDID, companyId, updaterId,
+    updateTime, pd_text1, pd_text2,
+    pd_text3, pd_text4, pd_text5,
+    pd_yqty,pd_remark)
+    values
+    <foreach collection="list" item="item" index="index" open="" close="" separator=",">
+      (
+      #{item.pd_puid,jdbcType=INTEGER}, #{item.pd_code,jdbcType=VARCHAR},
+      #{item.pd_detno,jdbcType=INTEGER}, #{item.pd_prodid,jdbcType=INTEGER}, #{item.pd_prodcode,jdbcType=VARCHAR},
+      #{item.pd_unit,jdbcType=VARCHAR}, #{item.pd_qty,jdbcType=DOUBLE}, #{item.pd_price,jdbcType=DOUBLE},#{item.pd_taxprice,jdbcType=DOUBLE},
+      #{item.pd_total,jdbcType=DOUBLE},#{item.pd_taxrate,jdbcType=DOUBLE}, #{item.pd_taxtotal,jdbcType=DOUBLE}, #{item.pd_acceptqty,jdbcType=DOUBLE},
+      #{item.pd_delivery,jdbcType=DOUBLE}, #{item.pd_salecode,jdbcType=VARCHAR}, #{item.pd_saledetno,jdbcType=INTEGER},
+      #{item.pd_sdid,jdbcType=INTEGER}, #{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_yqty,jdbcType=DOUBLE}, #{item.pd_remark,jdbcType=VARCHAR}
+      )
+    </foreach>
+  </insert>
+  <select id="selectPurchaseId" resultType="int">
+    select pu_id from purchase where
+    <if test="code !=null">
+      pu_code=#{code}
+    </if> and
+    <if test="companyid !=null">
+      companyid=#{companyid}
+    </if>
+
+  </select>
 </mapper>

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

@@ -20,8 +20,8 @@
         SELECT a.id id,a.username,a.realname,a.email,a.mobile,GROUP_CONCAT(c.name) roleNames,GROUP_CONCAT(c.id) roleIds
         FROM ac_account a
         left join ac_account_company d on a.id = d.account_id
-        left join ac_account_role b on a.id=b.account_id
-        left join ac_role c  on b.role_id = c.id
+        left join ac_account_role b on a.id=b.account_id and d.company_id = b.company_id
+        left join ac_role c  on b.role_id = c.id and b.company_id = c.company_id
         <where>
             <if test="condition!=null">
                 ${condition}

+ 1 - 0
frontend/saas-web/app/view/auth/CompanyPicker.scss

@@ -18,6 +18,7 @@
         overflow: hidden;
         border-top: 1px solid transparent;
         cursor: pointer;
+        border-radius: 4px;
 
         img {
             margin-bottom: 10px;

+ 2 - 1
frontend/saas-web/app/view/auth/LoginController.js

@@ -65,7 +65,8 @@ Ext.define('saas.view.auth.LoginController', {
             })
             .then(function() {
                 view.isMasked() && view.unmask();
+                view.close();
                 view.ownerCt.destroy();
-            });        
+            });
     }
 });

+ 10 - 1
frontend/saas-web/app/view/sale/sale/FormPanel.js

@@ -21,7 +21,8 @@ Ext.define('saas.view.sale.sale.FormPanel', {
      _auditUrl:'/api/sale/sale/audit/',
      _unAuditUrl: '/api/sale/sale/unAudit/',
      _deleteUrl:'/api/sale/sale/delete/',
-     _turnOutUrl:'/api/sale/sale/turnProdOut/', 
+     _turnOutUrl:'/api/sale/sale/turnProdOut/',
+     _turnPurchase:'/api/sale/sale/saleTurnPurchase/',
      initId:0,
  
      toolBtns: [{
@@ -32,6 +33,14 @@ Ext.define('saas.view.sale.sale.FormPanel', {
          bind: {
              hidden: '{sa_statuscode!="AUDITED"}'
          }
+     },{
+         xtype: 'button',
+         text: '转采购单',
+         hidden: true,
+         handler: 'turnPurchase',
+         bind: {
+             hidden: '{sa_statuscode!="AUDITED"}'
+         }
      }],
 
     defaultItems: [{

+ 26 - 1
frontend/saas-web/app/view/sale/sale/FormPanelController.js

@@ -82,5 +82,30 @@ Ext.define('saas.view.sale.sale.FormPanelController', {
             console.error(res);
             saas.util.BaseUtil.showToast('转单失败: ' + res.message);
         });
-     }
+     },
+    turnPurchase : function(){
+        var me = this,
+            form = me.getView(),
+            id = form.getForm().findField(form._idField);
+        saas.util.BaseUtil.request({
+            url: form._turnPurchase+id.value,
+            method: 'POST',
+        })
+            .then(function(localJson) {
+                if(localJson.success){
+                    var intValue = localJson.data.id,
+                        codeValue= localJson.data.code,
+                        name = localJson.data.name;
+                    saas.util.BaseUtil.openTab('purchase-purchase-formpanel',name+"("+codeValue+")",codeValue+intValue, {
+                        initId: intValue
+                    });
+                    saas.util.BaseUtil.showToast('转单成功');
+                    saas.util.FormUtil.loadData(form);
+                }
+            })
+            .catch(function(res) {
+                console.error(res);
+                saas.util.BaseUtil.showToast('转单失败: ' + res.message);
+            });
+    }
 });

+ 1 - 0
frontend/saas-web/app/view/viewport/ViewportController.js

@@ -168,6 +168,7 @@ Ext.define('saas.view.viewport.ViewportController', {
                 })
                 .then(function() {
                     view.isMasked() && view.unmask();
+                    window.location.reload();
                 }); 
         }        
     }