Browse Source

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

zhuth 7 years ago
parent
commit
c2b930a3f0

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

@@ -30,6 +30,7 @@ import com.usoftchina.saas.document.service.WarehouseService;
 import com.usoftchina.saas.exception.BizException;
 import com.usoftchina.saas.page.PageRequest;
 import com.usoftchina.saas.utils.CollectionUtils;
+import com.usoftchina.saas.utils.DateUtils;
 import com.usoftchina.saas.utils.RegexpUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -241,7 +242,10 @@ public class ProductServiceImpl extends CommonBaseServiceImpl<ProductMapper, Pro
             String inoutCode = maxnumberService.getMaxnumber("StorageInit", true).getData();
             prodInOut.setPi_inoutno(inoutCode);     //出入库单号
             prodInOut.setPi_class("库存初始化");
-            prodInOut.setPi_date(new Date());
+
+            Calendar calendar = Calendar.getInstance();
+            calendar.set(Calendar.DAY_OF_MONTH, 1);
+            prodInOut.setPi_date(calendar.getTime());   //赋值为当月第一天
             //prodInOut.setPi_total();            //含税金额
             prodInOut.setPi_status(Status.UNAUDITED.getDisplay());
             prodInOut.setPi_statuscode(Status.UNAUDITED.name());

+ 11 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/ProfitdetailMapper.java

@@ -0,0 +1,11 @@
+package com.usoftchina.saas.money.mapper;
+
+import com.usoftchina.saas.money.po.Profitpresent;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface ProfitdetailMapper {
+    List<Profitpresent> selectByCondition(@Param("con") String con, @Param("companyId") Long companyId);
+    String selectCalculateFields(@Param("fields") String fields, @Param("con") String con, @Param("companyId") Long companyId);
+}

+ 2 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/VerificationMapper.java

@@ -40,4 +40,6 @@ public interface VerificationMapper extends CommonBaseMapper<Verification> {
     String validateResAudit(@Param("id") Long id);
 
     int validateSetAcount(@Param("detno") int detno,@Param("companyid")Long companyid);
+
+    void updateAuditMsg (@Param("id") Long id,@Param("userName")String userName);
 }

+ 109 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/po/Profitpresent.java

@@ -0,0 +1,109 @@
+package com.usoftchina.saas.money.po;
+
+import java.util.Date;
+
+/**
+ * @author heqw
+ * @date 2018/12/10 10:45
+ **/
+public class Profitpresent {
+    private Date pi_date;
+    private Integer pi_ym;
+    private String pi_custcode;
+    private String pi_custname;
+    private String cu_sellername;
+    private Double saamount;
+    private Double netamount;
+    private Double costamount;
+    private Double profit;
+    private Double profitpresent;
+    private String cu_type;
+
+    public String getCu_type() {
+        return cu_type;
+    }
+
+    public void setCu_type(String cu_type) {
+        this.cu_type = cu_type;
+    }
+
+    public Date getPi_date() {
+        return pi_date;
+    }
+
+    public void setPi_date(Date pi_date) {
+        this.pi_date = pi_date;
+    }
+
+    public Integer getPi_ym() {
+        return pi_ym;
+    }
+
+    public void setPi_ym(Integer pi_ym) {
+        this.pi_ym = pi_ym;
+    }
+
+    public String getPi_custcode() {
+        return pi_custcode;
+    }
+
+    public void setPi_custcode(String pi_custcode) {
+        this.pi_custcode = pi_custcode;
+    }
+
+    public String getPi_custname() {
+        return pi_custname;
+    }
+
+    public void setPi_custname(String pi_custname) {
+        this.pi_custname = pi_custname;
+    }
+
+    public String getCu_sellername() {
+        return cu_sellername;
+    }
+
+    public void setCu_sellername(String cu_sellername) {
+        this.cu_sellername = cu_sellername;
+    }
+
+    public Double getSaamount() {
+        return saamount;
+    }
+
+    public void setSaamount(Double saamount) {
+        this.saamount = saamount;
+    }
+
+    public Double getNetamount() {
+        return netamount;
+    }
+
+    public void setNetamount(Double netamount) {
+        this.netamount = netamount;
+    }
+
+    public Double getCostamount() {
+        return costamount;
+    }
+
+    public void setCostamount(Double costamount) {
+        this.costamount = costamount;
+    }
+
+    public Double getProfit() {
+        return profit;
+    }
+
+    public void setProfit(Double profit) {
+        this.profit = profit;
+    }
+
+    public Double getProfitpresent() {
+        return profitpresent;
+    }
+
+    public void setProfitpresent(Double profitpresent) {
+        this.profitpresent = profitpresent;
+    }
+}

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

@@ -43,6 +43,8 @@ public class MoneyReportServiceImpl implements MoneyReportService {
     private CustmonthMapper custmonthMapper;
     @Autowired
     private BanksubledgerMapper banksubledgerMapper;
+    @Autowired
+    private ProfitdetailMapper profitdetailMapper;
 
     @Override
     public Map<String, Object> vendorCheck(PageRequest page, ListReqDTO req) {
@@ -278,6 +280,11 @@ public class MoneyReportServiceImpl implements MoneyReportService {
             if (!StringUtils.isEmpty(calculateFieldsSql)) {
                 res = banksubledgerMapper.selectCalculateFields(calculateFieldsSql, con, companyId);
             }
+        }else if("profitdetails".equals(type)){
+            list = profitdetailMapper.selectByCondition(con, companyId);
+            if (!StringUtils.isEmpty(calculateFieldsSql)) {
+                res = profitdetailMapper.selectCalculateFields(calculateFieldsSql, con, companyId);
+            }
         }
 
         try {

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

@@ -543,8 +543,6 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
         formData.getMain().setVc_auditdate(new Date());
         baseDTO = this.saveFormData(formData);
         Long id = baseDTO.getId();
-
-
             VerificationDTO verificationDTO = formData.getMain();
             Subledger subledger = changSubledgerUntil(verificationDTO);
             subledgerMapper.insertSelective(subledger);
@@ -573,7 +571,8 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
 
         //更新出入库状态
         this.updateProdInoutStatus(id);
-
+        //更新审核人和审核日期
+        verificationMapper.updateAuditMsg(id,BaseContextHolder.getUserName());
         baseDTO.setId(id);
         baseDTO.setName(BillCodeSeq.VERIFICATION.getCaller());
         baseDTO.setCode(formData.getMain().getVc_code());

+ 123 - 0
applications/money/money-server/src/main/resources/mapper/ProfitdetailMapper.xml

@@ -0,0 +1,123 @@
+<?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.money.mapper.ProfitdetailMapper" >
+  <resultMap id="BaseResultMap" type="com.usoftchina.saas.money.po.Profitpresent" >
+    <result column="pi_ym" property="pi_ym" jdbcType="INTEGER" />
+    <result column="pi_custcode" property="pi_custcode" jdbcType="VARCHAR" />
+    <result column="pi_custname" property="pi_custname" jdbcType="VARCHAR" />
+	  <result column="cu_type" property="cu_type" jdbcType="VARCHAR" />
+    <result column="cu_sellername" property="cu_sellername" jdbcType="VARCHAR" />
+    <result column="saamount" property="saamount" jdbcType="DOUBLE" />
+    <result column="netamount" property="netamount" jdbcType="DOUBLE" />
+    <result column="costamount" property="costamount" jdbcType="DOUBLE" />
+    <result column="profit" property="profit" jdbcType="DOUBLE" />
+    <result column="profitpresent" property="profitpresent" jdbcType="DOUBLE" />
+    <result column="pi_date" property="pi_date" jdbcType="TIMESTAMP" />
+  </resultMap>
+  <sql id="Base_Column_List" >
+    cu_type, pi_custcode, pi_custname, cu_sellername, saamount, netamount, costamount, profit,
+    profitpresent
+  </sql>
+
+  <select id="selectByCondition" parameterType="java.lang.Long" resultMap="BaseResultMap">
+   SELECT
+	a.pi_custcode,
+	a.pi_custname,
+	a.cu_type,
+	a.cu_sellername,
+	a.saamount,
+	a.netamount,
+	a.costamount,
+SUM(a.netamount - a.costamount) as profit,
+(SUM(a.netamount - a.costamount)/IFNULL(netamount,SUM(netamount - costamount))) as profitpresent
+
+FROM
+	(
+		SELECT
+			pi_custcode,
+			pi_custname,
+	        cu_type,
+			cu_sellername,
+			SUM(
+				pd_sendprice * (pd_outqty - pd_inqty)
+			) AS saamount,
+			SUM(
+				pd_netprice * (pd_outqty - pd_inqty)
+			) AS netamount,
+			SUM(
+				pd_price * (pd_outqty - pd_inqty)
+			) AS costamount
+		FROM
+			prodinout,
+			prodiodetail,
+			customer
+    <where>
+      <if test="con != null">
+        ${con}
+      </if>
+      <if test="companyId != null">
+        and  prodinout.companyid = #{companyId}
+      </if>
+    </where>
+		and	pi_id = pd_piid
+		AND pi_custid = cu_id and
+prodinout.companyid= prodiodetail.companyid and prodiodetail.companyid = prodinout.companyid
+		GROUP BY
+			pi_custcode,
+			pi_custname,
+	        cu_type,
+			cu_sellername
+	) a GROUP BY
+			a.pi_custcode,
+			a.pi_custname,
+	        a.cu_type,
+			a.cu_sellername
+	  ORDER BY a.pi_custname asc,a.pi_custname desc
+  </select>
+
+	<select id="selectCalculateFields" resultType="string">
+		SELECT ${fields}
+		FROM
+		(
+		SELECT
+		pi_custcode,
+		pi_custname,
+		cu_type,
+		cu_sellername,
+		SUM(
+		pd_sendprice * (pd_outqty - pd_inqty)
+		) AS saamount,
+		SUM(
+		pd_netprice * (pd_outqty - pd_inqty)
+		) AS netamount,
+		SUM(
+		pd_price * (pd_outqty - pd_inqty)
+		) AS costamount
+		FROM
+		prodinout,
+		prodiodetail,
+		customer
+		<where>
+			<if test="con != null">
+				${con}
+			</if>
+			<if test="companyId != null">
+				and  prodinout.companyid = #{companyId}
+			</if>
+		</where>
+		and	pi_id = pd_piid
+		AND pi_custid = cu_id and
+		prodinout.companyid= prodiodetail.companyid and prodiodetail.companyid = prodinout.companyid
+		GROUP BY
+		pi_custcode,
+		pi_custname,
+		cu_type,
+		cu_sellername
+		) a GROUP BY
+		a.pi_custcode,
+		a.pi_custname,
+		a.cu_type,
+		a.cu_sellername
+	</select>
+
+</mapper>

+ 3 - 3
applications/money/money-server/src/main/resources/mapper/VerificationMapper.xml

@@ -619,7 +619,7 @@
     select count(1) from periodsdetail where pd_detno = #{detno} and IFNULL(pd_status,0)=99
     and companyid= #{companyid}
   </select>
-  <select id="checkStatus" resultType="int">
-    select count(1) from Verification where ifnull(vc_statuscode,'')='AUDITED' and vc_id= #{id,jdbcType=INTEGER}
-  </select>
+  <update id="updateAuditMsg">
+    update verification set vc_auditman  = #{userName},vc_auditdate = NOW() where vc_id = #{id}
+  </update>
 </mapper>

+ 2 - 0
applications/sale/sale-server/src/main/java/com/usoftchina/saas/sale/po/report/SaleProfitView.java

@@ -58,4 +58,6 @@ public class SaleProfitView {
     private Double pd_profitpresent;
 
     private Double pw_costprice;
+
+    private Date pi_date;
 }

+ 2 - 1
applications/sale/sale-server/src/main/resources/mapper/SaleProfitViewMapper.xml

@@ -7,6 +7,7 @@
     <result column="sa_sellercode" property="sa_sellercode" jdbcType="VARCHAR" />
     <result column="sa_seller" property="sa_seller" jdbcType="VARCHAR" />
     <result column="sa_date" property="sa_date" jdbcType="TIMESTAMP" />
+    <result column="pi_date" property="pi_date" jdbcType="TIMESTAMP" />
     <result column="pd_inoutno" property="pd_inoutno" jdbcType="VARCHAR" />
     <result column="pd_piclass" property="pd_piclass" jdbcType="VARCHAR" />
     <result column="pr_kind" property="pr_kind" jdbcType="VARCHAR" />
@@ -37,7 +38,7 @@
         and  companyId = #{companyId}
       </if>
     </where>
-    order by sa_date desc
+    order by pi_date desc
   </select>
 
   <select id="selectCalculateFields" resultType="string">

+ 0 - 1
applications/storage/storage-server/src/main/resources/mapper/ProdInOutReportMapper.xml

@@ -55,7 +55,6 @@
         and  companyid = #{companyId}
       </if>
     </where>
-    order by pi_date desc
   </select>
 
 

+ 51 - 20
frontend/saas-web/app/view/money/report/ProfitDetail.js

@@ -11,60 +11,91 @@ Ext.define('saas.view.money.report.ProfitDetail', {
     viewName: 'money-report-profitdetail',
 
     groupField: null,
-    listUrl: '/api/money/report/recDetail',
+    listUrl: '/api/money/report/profitdetails',
     defaultCondition: null,
     reportTitle: '毛利润分析表',
-    QueryWidth: 0.25,
+    QueryWidth: 0.2,
     searchItems: [{
         xtype: 'customerDbfindTrigger',
         name: 'pi_custname',
-        fieldLabel: '客户名称',
-        columnWidth: 0.25
+        emptyText: '客户',
+        columnWidth: 0.15,
+        dbfinds:[
+            {
+                from:'cu_name',to:'pi_custname'
+            }]
     }, {
         xtype : "remotecombo", 
         storeUrl:'/api/document/customerkind/getCombo',
         name : "cu_type", 
         emptyText : "客户类型", 
-        columnWidth: 0.25,
+        columnWidth: 0.15,
         hiddenBtn:true
     }, {
         xtype: 'condatefield',
-        name: 'rb_date',
+        name: 'pi_date',
         fieldLabel: '日期',
-        columnWidth: 0.25
+        columnWidth: 0.5
     }],
 
-    reportColumns: [{
-        text: '客户编号',
-        dataIndex: 'pi_inoutno',
-        width: 200
-    }, {
+    reportColumns: [
+        {
+            text: '客户',
+            dataIndex: 'pi_custname',
+            width: 200,
+        },{
         text: '客户类型',
-        dataIndex: 'pi_custcode',
+        dataIndex: 'cu_type',
         width: 200,
     }, {
         text: '业务员',
-        dataIndex: 'pi_custname',
+        dataIndex: 'cu_sellername',
         width: 200,
     }, {
         text: '销售总额',
-        dataIndex: 'pi_class',
-        width: 150
+        dataIndex: 'saamount',
+        width: 150,
+            renderer : function(v) {
+                var arr = (v + '.').split('.');
+                var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0');
+                var format = '0,000.' + xr.join();
+                return Ext.util.Format.number(v, format);
+            },
+            summaryType: 'sum',
+            summaryRenderer: function(v) {
+                var arr = (v + '.').split('.');
+                var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0');
+                var format = '0,000.' + xr.join();
+                return Ext.util.Format.number(v, format);
+            }
     }, {
         text: '不含税金额',
-        dataIndex: 'pu_buyername',
+        dataIndex: 'netamount',
         width: 150
     }, {
         text: '成本金额',
-        dataIndex: 'rb_date',
+        dataIndex: 'costamount',
         width: 150
     }, {
         text: '毛利润',
-        dataIndex: 'pd_pdno',
+        dataIndex: 'profit',
         width: 150,
+            renderer : function(v) {
+                var arr = (v + '.').split('.');
+                var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0');
+                var format = '0,000.' + xr.join();
+                return Ext.util.Format.number(v, format);
+            },
+            summaryType: 'sum',
+            summaryRenderer: function(v) {
+                var arr = (v + '.').split('.');
+                var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0');
+                var format = '0,000.' + xr.join();
+                return Ext.util.Format.number(v, format);
+            }
     }, {
         text: '毛利率',
-        dataIndex: 'cu_beginaramount',
+        dataIndex: 'profitpresent',
         width: 150
     }]
 });

+ 4 - 0
frontend/saas-web/resources/json/navigation.json

@@ -71,6 +71,10 @@
             "text": "销售利润表",
             "viewType": "sale-report-saleprofit"
         }, {
+            "text": "毛利润分析表",
+            "id": "monry-report-profitdetail",
+            "viewType":"monry-report-profitdetail"
+        },{
             "text": "客户对账单",
             "id": "monry-report-customercheck",
             "viewType":"monry-report-customercheck"