标段管理-客户利润统计

product
chuang 2 years ago
parent 88959e1113
commit c8d10f28fa

@ -94,6 +94,26 @@ public class CustomerVOController {
return ActionResult.success(vo);
}
/**
*
*
* @param customerPagination
* @return
*/
@PostMapping("/getMobileList")
public ActionResult mobileList(@RequestBody CustomerPagination customerPagination)throws IOException{
List<CustomerMobileListVo> list= customerService.getMObileList(customerPagination);
//处理id字段转名称若无需转或者为空可删除
PageListVO vo=new PageListVO();
vo.setList(list);
PaginationVO page=JsonUtil.getJsonToBean(customerPagination,PaginationVO.class);
vo.setPagination(page);
return ActionResult.success(vo);
}
/**
*

@ -7,6 +7,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jnpf.customer.entity.CustomerEntity;
import jnpf.customer.entity.CustomerMobileEntity;
import jnpf.customer.model.customer.CustomerMobileListVo;
import jnpf.customer.model.customer.CustomerMobileVO;
import org.apache.ibatis.annotations.Param;
/**
@ -19,6 +21,6 @@ import org.apache.ibatis.annotations.Param;
*/
public interface CustomerVMapper extends BaseMapper<CustomerEntity> {
IPage<CustomerMobileEntity> getMobileList(@Param("page")Page<CustomerMobileEntity> page, @Param("ew") Wrapper<CustomerEntity> queryWrapper);
IPage<CustomerMobileEntity> getCustomerMobileVOList(@Param("page")Page<CustomerMobileEntity> page, @Param("ew") Wrapper<CustomerEntity> queryWrapper);
IPage<CustomerMobileEntity> getMobileCustomerVOList(@Param("page")Page<CustomerMobileEntity> page, @Param("ew") Wrapper<CustomerEntity> queryWrapper);
IPage<CustomerMobileVO> getCustomerMobileVOList(@Param("page")Page<CustomerMobileEntity> page, @Param("ew") Wrapper<CustomerEntity> queryWrapper);
IPage<CustomerMobileListVo> getMoblieDataDD(@Param("page")Page<CustomerMobileEntity> page, @Param("ew") Wrapper<CustomerEntity> queryWrapper);
}

@ -26,5 +26,5 @@ public class CustomerMobileListVo {
/*总利润:所有客户 总利润 的汇总*/
private BigDecimal profit;
/*客户统计信息*/
private List<CustomerMobileVO> customerMobileVOS;
private List<CustomerMobileVO> customerMobileVOSList;
}

@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import jnpf.customer.entity.CustomerEntity;
import jnpf.customer.entity.CustomerMobileEntity;
import jnpf.customer.model.customer.CustomerMobileListVo;
import jnpf.customer.model.customer.CustomerPagination;
import java.util.List;
@ -36,6 +37,8 @@ public interface CustomerService extends IService<CustomerEntity> {
void create(CustomerEntity entity);
boolean update( String id, CustomerEntity entity);
/**获取移动端的数据 **/
List<CustomerMobileListVo> getMObileList(CustomerPagination customerPagination);
// 子表方法

@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jnpf.customer.entity.CustomerEntity;
import jnpf.customer.entity.CustomerMobileEntity;
import jnpf.customer.mapper.CustomerVMapper;
import jnpf.customer.model.customer.CustomerMobileListVo;
import jnpf.customer.model.customer.CustomerPagination;
import jnpf.customer.service.CustomerService;
import jnpf.permission.model.authorize.AuthorizeConditionModel;
@ -245,6 +246,102 @@ public class CustomerVOServiceImpl extends ServiceImpl<CustomerVMapper, Customer
entity.setId(id);
return this.updateById(entity);
}
/**
* @TODO
* @param customerPagination
* @return
*/
@Override
public List<CustomerMobileListVo> getMObileList(CustomerPagination customerPagination) {
String userId=userProvider.get().getUserId();
List<String> AllIdList =new ArrayList();
int total=0;
int customerNum =0;
QueryWrapper<CustomerEntity> customerQueryWrapper=new QueryWrapper<>();
boolean pcPermission = true;
boolean appPermission = true;
boolean isPc = ServletUtil.getHeader("jnpf-origin").equals("pc");
if(isPc && pcPermission){
if (!userProvider.get().getIsAdministrator()){
Object customerObj=authorizeService.getCondition(new AuthorizeConditionModel(customerQueryWrapper,customerPagination.getMenuId(),"customer"));
if (ObjectUtil.isEmpty(customerObj)){
return new ArrayList<>();
} else {
customerQueryWrapper = (QueryWrapper<CustomerEntity>)customerObj;
customerNum++;
}
}
}
if(!isPc && appPermission){
if (!userProvider.get().getIsAdministrator()){
Object customerObj=authorizeService.getCondition(new AuthorizeConditionModel(customerQueryWrapper,customerPagination.getMenuId(),"customer"));
if (ObjectUtil.isEmpty(customerObj)){
return new ArrayList<>();
} else {
customerQueryWrapper = (QueryWrapper<CustomerEntity>)customerObj;
customerNum++;
}
}
}
if(StringUtil.isNotEmpty(customerPagination.getSupplierCd())){
customerNum++;
customerQueryWrapper.lambda().like(CustomerEntity::getSupplierCd,customerPagination.getSupplierCd());
}
if(StringUtil.isNotEmpty(customerPagination.getSupplierNm())){
customerNum++;
customerQueryWrapper.lambda().like(CustomerEntity::getSupplierNm,customerPagination.getSupplierNm());
}
if(StringUtil.isNotEmpty(customerPagination.getVatRegistrationNum())){
customerNum++;
customerQueryWrapper.lambda().like(CustomerEntity::getVatRegistrationNum,customerPagination.getVatRegistrationNum());
}
if(StringUtil.isNotEmpty(customerPagination.getContactName())){
customerNum++;
customerQueryWrapper.lambda().like(CustomerEntity::getContactName,customerPagination.getContactName());
}
if(StringUtil.isNotEmpty(customerPagination.getKeyword())){
customerNum++;
customerQueryWrapper.lambda().and(wq -> {
// 拼接sql
wq.like(CustomerEntity::getSupplierNm,customerPagination.getKeyword())
.or()
.like(CustomerEntity::getSupplierCd,customerPagination.getKeyword());
});
}
if(AllIdList.size()>0){
customerQueryWrapper.lambda().in(CustomerEntity::getId, AllIdList);
}
//排序
if(StringUtil.isEmpty(customerPagination.getSidx())){
customerQueryWrapper.lambda().orderByDesc(CustomerEntity::getCreatorTime);
}else{
try {
String sidx = customerPagination.getSidx();
CustomerEntity customerEntity = new CustomerEntity();
Field declaredField = customerEntity.getClass().getDeclaredField(sidx);
declaredField.setAccessible(true);
String value = declaredField.getAnnotation(TableField.class).value();
customerQueryWrapper="asc".equals(customerPagination.getSort().toLowerCase())?customerQueryWrapper.orderByAsc(value):customerQueryWrapper.orderByDesc(value);
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
}
if((total>0 && AllIdList.size()>0) || total==0){
Page<CustomerMobileEntity> page=new Page<>(customerPagination.getCurrentPage(), customerPagination.getPageSize());
IPage<CustomerMobileListVo> userIPage= customerVMapper.getMoblieDataDD(page, customerQueryWrapper);
return customerPagination.setData(userIPage.getRecords(),userIPage.getTotal());
}else{
List<CustomerMobileListVo> list = new ArrayList();
return customerPagination.setData(list, list.size());
}
}
@Override
public void delete(CustomerEntity entity){
if(entity!=null){

@ -94,7 +94,7 @@
<select id="getMobileCustomerVOList" resultMap="customerMobileMap">
<select id="getMobileCustomerVOList" >
SELECT
*
FROM
@ -195,16 +195,7 @@
) aaa
</select>
<resultMap id="customerMobileMap" type="jnpf.customer.model.customer.CustomerMobileListVo">
<result property="invoiceNum" column="invoiceNum"/>
<result property="noInvoiceNum" column="noInvoiceNum"/>
<result property="fundNum" column="fundNum"/>
<result property="noFundNum" column="noFundNum"/>
<result property="noPayCollectionNum" column="noPayCollectionNum"/>
<result property="profit" column="profit"/>
<result property="profit" column="profit"/>
<collection property="customerMobileVOS" select="jnpf.customer.mapper.CustomerVMapper.getCustomerMobileVOList" fetchType="eager" column="{page=#{page},ew=#{ew}"></collection>
</resultMap>
<select id="getCustomerMobileVOList" resultMap="getCustomerMobileVOMap" >
SELECT
@ -350,4 +341,255 @@
<result property="amountSum" column="amountSum"/>
<result property="profit" column="profit"/>
</resultMap>
<select id="getMoblieDataDD" resultMap="getMobiieMap">
SELECT
*
FROM
(
SELECT
a.*,
(
SELECT
IFNULL( SUM( b.settlement ), 0 )
FROM
jg_poundlist b
WHERE
a.id = b.customer_id
AND b.is_expense = '1'
AND b.pound_status = '0'
AND (
b.sales_status != '99'
OR ISNULL( b.sales_status ))
AND (
b.sales_status != '0'
OR ISNULL( b.sales_status ))
AND b.delete_mark = '0'
) invoiceNum,
(
SELECT
IFNULL( SUM( c.settlement ), 0 )
FROM
jg_poundlist c
WHERE
a.id = c.customer_id
AND c.is_expense = '0'
AND c.pound_status = '0'
AND (
c.sales_status != '99'
OR ISNULL( c.sales_status ))
AND (
c.sales_status != '0'
OR ISNULL( c.sales_status ))
AND c.delete_mark = '0'
) noInvoiceNum,
(
SELECT
ROUND( IFNULL( SUM( d.sales_price * d.settlement ), 0 ), 6 )
FROM
jg_poundlist d
WHERE
a.id = d.customer_id
AND d.advance = '1'
AND d.pound_status = '0'
AND (
d.sales_status != '99'
OR ISNULL( d.sales_status ))
AND (
d.sales_status != '0'
OR ISNULL( d.sales_status ))
AND d.delete_mark = '0'
) fundNum,
(
SELECT
ROUND( IFNULL( SUM( e.sales_price * e.settlement ), 0 ), 6 )
FROM
jg_poundlist e
WHERE
a.id = e.customer_id
AND e.advance = '0'
AND e.pound_status = '0'
AND (
e.sales_status != '99'
OR ISNULL( e.sales_status ))
AND (
e.sales_status != '0'
OR ISNULL( e.sales_status ))
AND e.delete_mark = '0'
) noFundNum,
@pDataA :=(
SELECT
ROUND( IFNULL( SUM( f.sales_price * f.settlement ), 0 ), 6 )
FROM
jg_poundlist f
WHERE
a.id = f.customer_id
AND f.is_collection = '1'
AND f.pound_status = '0'
AND (
f.sales_status != '99'
OR ISNULL( f.sales_status ))
AND (
f.sales_status != '0'
OR ISNULL( f.sales_status ))
AND f.delete_mark = '0'
) payCollectionNum,
@pDataB :=(
SELECT
ROUND( IFNULL( SUM( g.sales_price * g.settlement ), 0 ), 6 )
FROM
jg_poundlist g
WHERE
a.id = g.customer_id
AND g.is_collection = '0'
AND g.pound_status = '0'
AND (
g.sales_status != '99'
OR ISNULL( g.sales_status ))
AND (
g.sales_status != '0'
OR ISNULL( g.sales_status ))
AND g.delete_mark = '0'
) noPayCollectionNum,
ROUND( @pDataA + @pDataB, 6 ) amountSum,
(
SELECT
ROUND( IFNULL( SUM(( h.sales_price - h.purchase_price )* h.settlement ), 0 ), 6 )
FROM
jg_poundlist h
WHERE
a.id = h.customer_id
AND h.pound_status = '0'
AND (
h.sales_status != '99'
OR ISNULL( h.sales_status ))
AND (
h.sales_status != '0'
OR ISNULL( h.sales_status ))
AND h.delete_mark = '0'
) profit
FROM
jg_customer a
WHERE
a.delete_mark = '0'
) aaa,
(
SELECT
(
SELECT
SUM( a.settlement )
FROM
jg_poundlist a
WHERE
a.is_expense = '1'
AND a.pound_status = '0'
AND (
a.sales_status != '99'
OR ISNULL( a.sales_status ))
AND (
a.sales_status != '0'
OR ISNULL( a.sales_status ))
AND a.delete_mark = '0'
) invoiceNumM,(
SELECT
SUM( a.settlement )
FROM
jg_poundlist a
WHERE
a.is_expense = '0'
AND a.pound_status = '0'
AND (
a.sales_status != '99'
OR ISNULL( a.sales_status ))
AND (
a.sales_status != '0'
OR ISNULL( a.sales_status ))
AND a.delete_mark = '0'
) noInvoiceNumM,(
SELECT
ROUND( SUM( a.sales_price * a.settlement ), 6 )
FROM
jg_poundlist a
WHERE
a.advance = '1'
AND a.pound_status = '0'
AND (
a.sales_status != '99'
OR ISNULL( a.sales_status ))
AND (
a.sales_status != '0'
OR ISNULL( a.sales_status ))
AND a.delete_mark = '0'
) fundNumM,(
SELECT
ROUND( SUM( a.sales_price * a.settlement ), 6 )
FROM
jg_poundlist a
WHERE
a.advance = '0'
AND a.pound_status = '0'
AND (
a.sales_status != '99'
OR ISNULL( a.sales_status ))
AND (
a.sales_status != '0'
OR ISNULL( a.sales_status ))
AND a.delete_mark = '0'
) noFundNumM,(
SELECT
ROUND( SUM( a.sales_price * a.settlement ), 6 )
FROM
jg_poundlist a
WHERE
a.is_collection = '0'
AND a.pound_status = '0'
AND (
a.sales_status != '99'
OR ISNULL( a.sales_status ))
AND (
a.sales_status != '0'
OR ISNULL( a.sales_status ))
AND a.delete_mark = '0'
) noPayCollectionNumM,(
SELECT
ROUND( SUM(( a.sales_price - a.purchase_price )* a.settlement ), 6 )
FROM
jg_poundlist a
WHERE
a.pound_status = '0'
AND (
a.sales_status != '99'
OR ISNULL( a.sales_status ))
AND (
a.sales_status != '0'
OR ISNULL( a.sales_status ))
AND a.delete_mark = '0'
) profitM
FROM
DUAL
) bbb ${ew.customSqlSegment}
</select>
<resultMap id="getMobiieMap" type="jnpf.customer.model.customer.CustomerMobileListVo">
<result property="invoiceNum" column="invoiceNumM"/>
<result property="noInvoiceNum" column="noInvoiceNumM"/>
<result property="fundNum" column="fundNumM"/>
<result property="noFundNum" column="noFundNumM"/>
<result property="noPayCollectionNum" column="noPayCollectionNumM"/>
<result property="profit" column="profitM"/>
<collection property="customerMobileVOSList" ofType="jnpf.customer.model.customer.CustomerMobileVO" javaType="list">
<result property="supplierNm" column="supplier_nm"/>
<result property="invoiceNum" column="invoiceNum"/>
<result property="noInvoiceNum" column="noInvoiceNum"/>
<result property="fundNum" column="fundNum"/>
<result property="noFundNum" column="noFundNum"/>
<result property="payCollectionNum" column="payCollectionNum"/>
<result property="noPayCollectionNum" column="noPayCollectionNum"/>
<result property="amountSum" column="amountSum"/>
<result property="profit" column="profit"/>
</collection>
</resultMap>
</mapper>

Loading…
Cancel
Save