统计查询
This commit is contained in:
parent
8205c8eaa7
commit
648bf33b9a
|
|
@ -20,6 +20,11 @@ public class ProPlanInfoVo extends PageInfo {
|
|||
*/
|
||||
private int recordNum;
|
||||
|
||||
/**
|
||||
* 出库单量
|
||||
*/
|
||||
private int recordNum2;
|
||||
|
||||
/**
|
||||
* 需用数量
|
||||
*/
|
||||
|
|
@ -29,6 +34,11 @@ public class ProPlanInfoVo extends PageInfo {
|
|||
*/
|
||||
private int outNum;
|
||||
|
||||
/**
|
||||
* 出库量
|
||||
*/
|
||||
private int outNum2;
|
||||
|
||||
/**
|
||||
* 出库量
|
||||
*/
|
||||
|
|
@ -52,6 +62,8 @@ public class ProPlanInfoVo extends PageInfo {
|
|||
private String proName;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
package com.bonus.gzgqj.business.plan.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class StatisticsVo {
|
||||
|
||||
/**
|
||||
* 需要数量
|
||||
*/
|
||||
private int neeNum;
|
||||
/**
|
||||
* 发货数量
|
||||
*/
|
||||
private int fhNum;
|
||||
/**
|
||||
* 待发货数量
|
||||
*/
|
||||
private int dfhNum;
|
||||
|
||||
/**
|
||||
* 待发货数量
|
||||
*/
|
||||
private int num;
|
||||
}
|
||||
|
|
@ -86,4 +86,16 @@ public interface PlanOutMapper {
|
|||
* @param data
|
||||
*/
|
||||
void updatePriPlanInfo(ProPlanInfoVo data);
|
||||
|
||||
/**
|
||||
* 查询发货统计
|
||||
* @return
|
||||
*/
|
||||
List<StatisticsVo> getStatistics();
|
||||
|
||||
/**
|
||||
* 超出 库存数量
|
||||
* @return
|
||||
*/
|
||||
StatisticsVo getOverNum();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,20 +133,23 @@ public class PlanOutServiceImpl implements PlanOutService{
|
|||
if(num>0){
|
||||
//计算 本次全部发货数量及整改数量 最后同步到 工程 -计划-发货统计表中
|
||||
int allFhNum=0;
|
||||
//非计划发货数量
|
||||
int allFhNum2=0;
|
||||
//非计划发货次数
|
||||
int count=0;
|
||||
int allTzNum=0;
|
||||
int excNum=0;
|
||||
//处理 发货单
|
||||
boolean a= planOutInfo(list,vo,allFhNum,allTzNum,excNum);
|
||||
boolean a= planOutInfo(list,vo,allFhNum,allTzNum);
|
||||
if(!a){
|
||||
return ServerResponse.createErroe("发货失败");
|
||||
}
|
||||
//处理新增发货单
|
||||
boolean b=addOutPlanInfo(addList,vo,allFhNum);
|
||||
boolean b=addOutPlanInfo(addList,vo,allFhNum2,count);
|
||||
if(!b){
|
||||
return ServerResponse.createErroe("发货失败");
|
||||
}
|
||||
//处理 发货后 统计及 详情数据
|
||||
boolean c= updateProPlan(vo,allFhNum,allTzNum);
|
||||
boolean c= updateProPlan(vo,allFhNum,allTzNum,allFhNum2,count);
|
||||
if(!c){
|
||||
return ServerResponse.createErroe("发货失败");
|
||||
}
|
||||
|
|
@ -162,19 +165,30 @@ public class PlanOutServiceImpl implements PlanOutService{
|
|||
|
||||
@Override
|
||||
public ServerResponse getStatistics() {
|
||||
Map<String,Integer> map= Maps.newHashMap();
|
||||
try{
|
||||
Map<String,String> map= Maps.newHashMap();
|
||||
|
||||
|
||||
|
||||
List<StatisticsVo> list=mapper.getStatistics();
|
||||
StatisticsVo data=mapper.getOverNum();
|
||||
map.put("neeNum",list.get(0).getNeeNum());
|
||||
map.put("dfhNum",list.get(0).getDfhNum());
|
||||
map.put("fhNum",list.get(0).getFhNum());
|
||||
map.put("overNum",data.getNum());
|
||||
//不在计划内的数量
|
||||
map.put("noPlanNum",list.get(1).getFhNum());
|
||||
|
||||
}catch (Exception e){
|
||||
map.put("neeNum",0);
|
||||
map.put("dfhNum",0);
|
||||
map.put("fhNum",0);
|
||||
map.put("overNum",0);
|
||||
//不在计划内的数量
|
||||
map.put("noPlanNum",0);
|
||||
log.error(e.toString(),e);
|
||||
}
|
||||
return ServerResponse.createSuccess();
|
||||
return ServerResponse.createSuccess(map);
|
||||
}
|
||||
|
||||
public boolean planOutInfo(List<ProOutDetail> list,ProOutInfoVo vo,int allFhNum, int allTzNum,int excNum){
|
||||
public boolean planOutInfo(List<ProOutDetail> list,ProOutInfoVo vo,int allFhNum, int allTzNum){
|
||||
try {
|
||||
for (ProOutDetail details:list){
|
||||
allFhNum=allFhNum+details.getFhNum();
|
||||
|
|
@ -186,9 +200,6 @@ public class PlanOutServiceImpl implements PlanOutService{
|
|||
return false;
|
||||
}else{
|
||||
//需要的数量
|
||||
int needNum=data.getNeedNum();
|
||||
|
||||
|
||||
ProNeedInfo insertObj=new ProNeedInfo();
|
||||
BeanUtils.copyProperties(insertObj,data);
|
||||
insertObj.setOutId(vo.getId());
|
||||
|
|
@ -206,6 +217,7 @@ public class PlanOutServiceImpl implements PlanOutService{
|
|||
int tzNum2=details.getFhNum();
|
||||
data.setFhNum(fhNum+fhNum2);
|
||||
data.setTzNum(tzNum+tzNum2);
|
||||
|
||||
mapper.updateNeedInfo(data);
|
||||
return true;
|
||||
}else {
|
||||
|
|
@ -222,12 +234,13 @@ public class PlanOutServiceImpl implements PlanOutService{
|
|||
|
||||
/**
|
||||
* 更新工程 -统计数据
|
||||
* @param allTzNum
|
||||
* @param allTzNum 全部调整数量
|
||||
* @param vo
|
||||
* @param allFhNum
|
||||
* @param allFhNum 全部发货数量
|
||||
* @param allFhNum 超出需求数量
|
||||
* @return
|
||||
*/
|
||||
public Boolean updateProPlan( ProOutInfoVo vo,int allFhNum, int allTzNum){
|
||||
public Boolean updateProPlan( ProOutInfoVo vo,int allFhNum, int allTzNum ,int allFhNum2,int count ){
|
||||
try {
|
||||
//更新工程 总数据信息
|
||||
ProPlanInfoVo data= mapper.getProPlanInfo(vo);
|
||||
|
|
@ -248,6 +261,10 @@ public class PlanOutServiceImpl implements PlanOutService{
|
|||
data.setStatus(2);
|
||||
}
|
||||
data.setLastDay(vo.getCreateDay());
|
||||
//非计划发货数量
|
||||
data.setOutNum2(allFhNum2);
|
||||
//非计划发货次数 .
|
||||
data.setRecordNum2(count);
|
||||
//更新 工程-计划 -统计表
|
||||
mapper.updatePriPlanInfo(data);
|
||||
return true;
|
||||
|
|
@ -261,12 +278,14 @@ public class PlanOutServiceImpl implements PlanOutService{
|
|||
* 传入
|
||||
* 新增集合、发货单、发货数量
|
||||
*/
|
||||
public Boolean addOutPlanInfo(List<ProAddInfoDetails> addList, ProOutInfoVo vo,int allFhNum){
|
||||
public Boolean addOutPlanInfo(List<ProAddInfoDetails> addList, ProOutInfoVo vo,int allFhNum,int count){
|
||||
try {
|
||||
//是否有 新增
|
||||
if(StringUtils.isNotEmpty(addList)){
|
||||
count=count+1;
|
||||
//全部新增发货清单
|
||||
for (ProAddInfoDetails details:addList){
|
||||
|
||||
allFhNum=allFhNum+details.getFhNum();
|
||||
ProNeedInfo insertObj=new ProNeedInfo();
|
||||
insertObj.setOutId(vo.getId());
|
||||
|
|
@ -301,9 +320,5 @@ public class PlanOutServiceImpl implements PlanOutService{
|
|||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
String suffx= IDUtils.getSuffix("/C/SSSK4555.PNG");
|
||||
System.err.println(suffx);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
<!--更新 统计数量-->
|
||||
<update id="updatePriPlanInfo">
|
||||
update t_pro_plan_info set record_num=#{recordNum},out_num=#{outNum},tz_num=#{tzNum},last_day=#{lastDay},
|
||||
status=#{status}
|
||||
status=#{status},out2_num=#{outNum2},record2_num=#{recordNum}
|
||||
where pro_id=#{proId}
|
||||
</update>
|
||||
<delete id="deleteProOut">
|
||||
|
|
@ -87,11 +87,26 @@
|
|||
select
|
||||
ppi.pro_id proId, ppi.need_num needNum,
|
||||
ppi.plan_num planNum,ppi.record_num recordNum,
|
||||
ppi.out_num outNum, ppi.status,
|
||||
ppi.out_num outNum, ppi.status,out2_num outNum2,record2_num recordNum2,
|
||||
ppi.last_day lastDay
|
||||
from t_pro_plan_info ppi
|
||||
where ppi.pro_id=#{proId}
|
||||
</select>
|
||||
|
||||
<select id="getStatistics" resultType="com.bonus.gzgqj.business.plan.entity.StatisticsVo">
|
||||
select sum(need_num) needNum ,sum(fh_num) fhNum,SUM(IF(need_num>=fh_num,need_num-fh_num,0)) dfhNum
|
||||
from t_pro_need_info
|
||||
WHERE need_type=1
|
||||
UNION
|
||||
select IFNULL( sum(need_num),0) needNum ,IFNULL(sum(fh_num),0) fhNum,IFNULL(SUM(IF(need_num>=fh_num,need_num-fh_num,0)),0) dfhNum
|
||||
from t_pro_need_info
|
||||
WHERE need_type=2
|
||||
</select>
|
||||
<!--超出 数量-->
|
||||
<select id="getOverNum" resultType="com.bonus.gzgqj.business.plan.entity.StatisticsVo">
|
||||
SELECT IFNULL(SUM(pni.need_num-mt.NUM),0) num
|
||||
from t_pro_need_info pni
|
||||
left join mm_type mt on pni.module_id=mt.id
|
||||
where pni.need_type=1
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue