获取指定日期的采购销售量

product
chuang 2 years ago
parent bfddcfd8c1
commit 0bff634f0b

@ -21,6 +21,8 @@ import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -48,6 +50,36 @@ public class MessageCenterController {
@Autowired
private MessageCenterService messageCenterService;
/**
*
*/
@GetMapping(value = "/getSaleQuantityData")
public ActionResult getSaleQuantityData(String dateNow) throws Exception {
// public void exportBillInfo(HttpServletResponse response) throws Exception {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
long lt = new Long(dateNow);
//将时间戳转换为时间
Date date = new Date(lt);
System.out.println("时间为:"+simpleDateFormat.format(date));
Map saleQuantityData = messageCenterService.getSaleQuantityData(date);
return ActionResult.success(saleQuantityData);
}
/**
*
*/
@GetMapping(value = "/getPurchasedAmountData")
public ActionResult getPurchasedAmountData(String dateNow) throws Exception {
// public void exportBillInfo(HttpServletResponse response) throws Exception {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
long lt = new Long(dateNow);
//将时间戳转换为时间
Date date = new Date(lt);
System.out.println("时间为:"+simpleDateFormat.format(date));
Map saleQuantityData = messageCenterService.getPurchasedAmountData(date);
return ActionResult.success(saleQuantityData);
}
/**
*

@ -3,7 +3,9 @@ package jnpf.messageCenter.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import jnpf.messageCenter.entity.MessageCenterEntity;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -34,4 +36,7 @@ public interface MessageCenterMapper extends BaseMapper<MessageCenterEntity> {
* @return
*/
List<MessageCenterEntity> getInventoryWarningData();
List<Map> getSaleQuantity(@Param("inpDate")Date inpDate);
List<Map> getPurchasedAmount(@Param("inpDate")Date inpDate);
}

@ -39,4 +39,18 @@ public interface MessageCenterService extends IService<MessageCenterEntity> {
// 子表方法
//列表子表数据方法
/**
*
* @param inpDate
* @return
*/
Map getSaleQuantityData(Date inpDate);
/**
*
* @param inpDate
* @return
*/
Map getPurchasedAmountData(Date inpDate);
}

@ -10,8 +10,10 @@ import jnpf.messageCenter.entity.MessageCenterEntity;
import jnpf.messageCenter.mapper.MessageCenterMapper;
import jnpf.messageCenter.model.messagecenter.MessageCenterPagination;
import jnpf.messageCenter.service.MessageCenterService;
import jnpf.mobilePort.utils.BigDecimalUtil;
import jnpf.permission.model.authorize.AuthorizeConditionModel;
import jnpf.permission.service.AuthorizeService;
import jnpf.util.DateUtil;
import jnpf.util.ServletUtil;
import jnpf.util.StringUtil;
import jnpf.util.UserProvider;
@ -20,9 +22,10 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* messageCenter
@ -346,6 +349,88 @@ public class MessageCenterServiceImpl extends ServiceImpl<MessageCenterMapper, M
return messageCenterMapper.getHomePageData();
}
/**
*
* @param inpDate
* @return
*/
@Override
public Map getSaleQuantityData(Date inpDate) {
List<Map> saleQuantity = messageCenterMapper.getSaleQuantity(inpDate);
ArrayList<String> xData = new ArrayList<>();
ArrayList<BigDecimal> data = new ArrayList<>();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
for (int i = 7; i > 0; i--) {
Date frontDay = DateUtil.getFrontDay(inpDate,i - 1);
xData.add(simpleDateFormat.format(frontDay));
Boolean isExist=true;
for (int i1 = 0; i1 < saleQuantity.size(); i1++) {
Map map = saleQuantity.get(i1);
if (!String.valueOf(map.get("outputDate")).equals("null")){
Date outputDate = (Date)map.get("outputDate");
int i2 = 0;
try {
i2 = DateUtil.dateCompare(simpleDateFormat.parse(simpleDateFormat.format(frontDay)), outputDate);
} catch (ParseException e) {
throw new RuntimeException(e);
}
if (i2==0){
isExist=false;
data.add(BigDecimalUtil.getBigDecimal(map.get("salesVolumeToday")));
}
}
}
if (isExist){
data.add(new BigDecimal("0"));
}
}
HashMap<String, Object> hashMap = new HashMap<>();
hashMap.put("xData",xData);
hashMap.put("data",data);
return hashMap;
}
/**
*
* @param inpDate
* @return
*/
@Override
public Map getPurchasedAmountData(Date inpDate) {
List<Map> saleQuantity = messageCenterMapper.getPurchasedAmount(inpDate);
ArrayList<String> xData = new ArrayList<>();
ArrayList<BigDecimal> data = new ArrayList<>();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
for (int i = 7; i > 0; i--) {
Date frontDay = DateUtil.getFrontDay(inpDate,i - 1);
xData.add(simpleDateFormat.format(frontDay));
Boolean isExist=true;
for (int i1 = 0; i1 < saleQuantity.size(); i1++) {
Map map = saleQuantity.get(i1);
if (!String.valueOf(map.get("inputDate")).equals("null")){
Date outputDate = (Date)map.get("inputDate");
int i2 = 0;
try {
i2 = DateUtil.dateCompare(simpleDateFormat.parse(simpleDateFormat.format(frontDay)), outputDate);
} catch (ParseException e) {
throw new RuntimeException(e);
}
if (i2==0){
isExist=false;
data.add(BigDecimalUtil.getBigDecimal(map.get("todayPurchasePrice")));
}
}
}
if (isExist){
data.add(new BigDecimal("0"));
}
}
HashMap<String, Object> hashMap = new HashMap<>();
hashMap.put("xData",xData);
hashMap.put("data",data);
return hashMap;
}
@Override
public void delete(MessageCenterEntity entity) {
if (entity != null) {

@ -1,5 +1,6 @@
package jnpf.mobilePort.controller;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jnpf.base.ActionResult;
@ -15,6 +16,7 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
@Slf4j
@ -26,6 +28,8 @@ public class MobilePortController {
@Resource
private PurchaseorderitemService purchaseorderitemService;
/**
*
* @param response

@ -0,0 +1,36 @@
package jnpf.mobilePort.utils;
import java.math.BigDecimal;
import java.math.BigInteger;
/**
* @Author: WangChuang
* @Date: 23/3/2023 11:30
* @Description //注释:
* @Version 1.0
*/
public class BigDecimalUtil {
/**
* ObjectBigDecimal
*
* @param value object
* @return BigDecimal
*/
public static BigDecimal getBigDecimal(Object value) {
BigDecimal ret = null;
if (value != null) {
if (value instanceof BigDecimal) {
ret = (BigDecimal) value;
} else if (value instanceof String) {
ret = new BigDecimal((String) value);
} else if (value instanceof BigInteger) {
ret = new BigDecimal((BigInteger) value);
} else if (value instanceof Number) {
ret = new BigDecimal(((Number) value).doubleValue());
} else {
throw new ClassCastException("Not possible to coerce [" + value + "] from class " + value.getClass() + " into a BigDecimal.");
}
}
return ret;
}
}

@ -384,4 +384,56 @@
a.areaname
) aaa
</select>
<resultMap id="getPurchasedAmountMap" type="map">
<result property="todayPurchasePrice" column="todayPurchasePrice"/>
<result property="inputDate" column="input_date"/>
</resultMap>
<select id="getPurchasedAmount" resultMap="getPurchasedAmountMap">
SELECT
*
FROM
(
SELECT
ROUND( IFNULL( SUM( IFNULL( a.settlement, 0 )), 0 ), 6 ) todayPurchasePrice ,
a.input_date
FROM
jg_poundlist a
WHERE
a.delete_mark = '0'
AND TO_DAYS( #{inpDate}) - TO_DAYS( a.input_date )>=0
AND TO_DAYS( #{inpDate}) - TO_DAYS( a.input_date ) <![CDATA[ < ]]> 7
GROUP BY a.input_date
ORDER BY a.input_date asc
) aaa
</select>
<resultMap id="getSaleQuantityMap" type="map">
<result property="salesVolumeToday" column="salesVolumeToday"/>
<result property="outputDate" column="output_date"/>
</resultMap>
<select id="getSaleQuantity" resultMap="getSaleQuantityMap">
SELECT
*
FROM
(
SELECT
ROUND( IFNULL( SUM( IFNULL( a.settlement, 0 )), 0 ), 6 ) salesVolumeToday,
a.output_date
FROM
jg_poundlist a
WHERE
a.delete_mark = '0'
AND TO_DAYS( #{inpDate} ) - TO_DAYS( a.output_date )>= 0
AND TO_DAYS( #{inpDate} ) - TO_DAYS( a.output_date ) <![CDATA[ < ]]> 7
GROUP BY
a.output_date
ORDER BY
a.output_date ASC
) aaa
</select>
</mapper>

Loading…
Cancel
Save