补发货修改
This commit is contained in:
parent
8434b530d8
commit
2ca1f6fb9c
|
|
@ -207,6 +207,17 @@ public class PurchaseController {
|
|||
return service.updatePurchaseData(request, files);
|
||||
}
|
||||
|
||||
/**
|
||||
* 补发货接口
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("addPurchaseDataBySupplement")
|
||||
public ServerResponse addPurchaseDataBySupplement(HttpServletRequest request, @RequestParam(value = "file[]", required = false) MultipartFile[] files) {
|
||||
return service.addPurchaseDataBySupplement(request, files);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发货修改数据接口---暂存
|
||||
* @param
|
||||
|
|
@ -248,6 +259,33 @@ public class PurchaseController {
|
|||
return ServerResponse.createSuccess(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发货详情查看---分批次
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("getPurchaseDetailsListBatch")
|
||||
@DecryptAndVerify(decryptedClass = OutPlanVo.class)
|
||||
public ServerResponse getPurchaseDetailsListBatch(EncryptedReq<OutPlanVo> dto) {
|
||||
List<OutPlanVoDetails> list = service.getPurchaseDetailsListBatch(dto.getData());
|
||||
return ServerResponse.createSuccess(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 采购详情查看---补发货专用
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("getPurchaseDetailsListBySupplement")
|
||||
@DecryptAndVerify(decryptedClass = OutPlanVo.class)
|
||||
public ServerResponse getPurchaseDetailsListBySupplement(EncryptedReq<OutPlanVo> dto) {
|
||||
List<OutPlanVoDetails> list = service.getPurchaseDetailsListBySupplement(dto.getData());
|
||||
return ServerResponse.createSuccess(list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 二维码详情查看
|
||||
|
|
|
|||
|
|
@ -88,6 +88,17 @@ public class OutPlanVoDetails {
|
|||
*/
|
||||
private int hisNum;
|
||||
|
||||
private String num;
|
||||
|
||||
/**
|
||||
* 批次详情
|
||||
*/
|
||||
private List<OutPlanVoDetails> batchList;
|
||||
|
||||
private String createTime;
|
||||
|
||||
private String supName;
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -95,6 +95,8 @@ public class OutPlanVoSupInfo {
|
|||
|
||||
private int historyLkNum;
|
||||
|
||||
private String createTime;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -175,4 +175,67 @@ public interface PurchaseMapper {
|
|||
int deleteDetail(Long id);
|
||||
|
||||
int updateDetail(Long id);
|
||||
|
||||
/**
|
||||
* 获取补充数据
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
List<OutPlanVoDetails> getPurchaseDetailsListBySupplement(OutPlanVo data);
|
||||
|
||||
/**
|
||||
* 添加补充数据
|
||||
* @param outSup
|
||||
* @return
|
||||
*/
|
||||
int insertStPlanOutSupData(OutPlanVoSupInfo outSup);
|
||||
|
||||
/**
|
||||
* 获取补充数据
|
||||
* @param details
|
||||
* @return
|
||||
*/
|
||||
OutPlanVoSupInfo getStPlanOutSupData(OutPlanVoDetails details);
|
||||
|
||||
/**
|
||||
* 修改补充数据
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
int updateStPlanOutDetailsData(OutPlanVoSupInfo bean);
|
||||
|
||||
/**
|
||||
* 获取补充数据
|
||||
* @param outPlanVo
|
||||
* @return
|
||||
*/
|
||||
OutPlanVoDetails getStPlanOutDetailsData(OutPlanVo outPlanVo);
|
||||
|
||||
/**
|
||||
* 修改补充数据
|
||||
* @param outPlanVoDetails
|
||||
* @return
|
||||
*/
|
||||
int updateStPlanOutData(OutPlanVoDetails outPlanVoDetails);
|
||||
|
||||
/**
|
||||
* 获取补充数据
|
||||
* @param outPlanVoDetails
|
||||
* @return
|
||||
*/
|
||||
int updateStPlanApplyData(OutPlanVoDetails outPlanVoDetails);
|
||||
|
||||
/**
|
||||
* 获取补充数据
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
List<OutPlanVoDetails> getPurchaseDetailsListBatch(OutPlanVo data);
|
||||
|
||||
/**
|
||||
* 获取补充数据
|
||||
* @param details
|
||||
* @return
|
||||
*/
|
||||
List<OutPlanVoDetails> getPurchaseDetailsListByBatch(OutPlanVoDetails details);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,6 +74,13 @@ public interface PurchaseService {
|
|||
*/
|
||||
List<OutPlanVoDetails> getPurchaseDetailsList(OutPlanVo data);
|
||||
|
||||
/**
|
||||
* 采购详情列表清单
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
List<OutPlanVoDetails> getPurchaseDetailsListBySupplement(OutPlanVo data);
|
||||
|
||||
/**
|
||||
* 查询二维码导出
|
||||
* @param data
|
||||
|
|
@ -108,4 +115,19 @@ public interface PurchaseService {
|
|||
* @return
|
||||
*/
|
||||
ServerResponse updatePurchaseDataTemporary(HttpServletRequest request, MultipartFile[] files);
|
||||
|
||||
/**
|
||||
* 新增补发货数据
|
||||
* @param request
|
||||
* @param files
|
||||
* @return
|
||||
*/
|
||||
ServerResponse addPurchaseDataBySupplement(HttpServletRequest request, MultipartFile[] files);
|
||||
|
||||
/**
|
||||
* 批量查询采购详情列表清单
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
List<OutPlanVoDetails> getPurchaseDetailsListBatch(OutPlanVo data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -600,14 +600,14 @@ public class PurchaseServiceImpl implements PurchaseService {
|
|||
if (StringUtils.isEmpty(detailsList)) {
|
||||
return ServerResponse.createErroe("厂商数据不能为空");
|
||||
}
|
||||
boolean hasDuplicates = supInfoList.stream()
|
||||
.collect(Collectors.groupingBy(OutPlanVoSupInfo::getSupId))
|
||||
.entrySet()
|
||||
.stream()
|
||||
.anyMatch(e -> e.getValue().size() > 1);
|
||||
if (hasDuplicates) {
|
||||
return ServerResponse.createErroe("同一型号厂商不能一致");
|
||||
}
|
||||
// boolean hasDuplicates = supInfoList.stream()
|
||||
// .collect(Collectors.groupingBy(OutPlanVoSupInfo::getSupId))
|
||||
// .entrySet()
|
||||
// .stream()
|
||||
// .anyMatch(e -> e.getValue().size() > 1);
|
||||
// if (hasDuplicates) {
|
||||
// return ServerResponse.createErroe("同一型号厂商不能一致");
|
||||
// }
|
||||
details.setProId(outPlanVo.getProId());
|
||||
details.setPlanId(details.getPlanId());
|
||||
int ckNum = 0;
|
||||
|
|
@ -751,6 +751,153 @@ public class PurchaseServiceImpl implements PurchaseService {
|
|||
return ServerResponse.createErroe("修改失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ServerResponse addPurchaseDataBySupplement(HttpServletRequest request, MultipartFile[] files) {
|
||||
try {
|
||||
String params = request.getParameter("params");
|
||||
if (StringHelper.isEmpty(params)) {
|
||||
return ServerResponse.createErroe("请求参数缺失");
|
||||
}
|
||||
OutPlanVo outPlanVo = JSON.parseObject(params, OutPlanVo.class);
|
||||
List<OutPlanVoDetails> detailsList = outPlanVo.getDetailsList();
|
||||
SupplierVo supp = new SupplierVo();
|
||||
for (OutPlanVoDetails details : detailsList) {
|
||||
List<OutPlanVoSupInfo> supInfoList = details.getSupList();
|
||||
if (StringUtils.isEmpty(detailsList)) {
|
||||
return ServerResponse.createErroe("厂商数据不能为空");
|
||||
}
|
||||
// 采购和利库都是0的数量就不处理
|
||||
if (supInfoList.get(0).getCgNum() == 0 && supInfoList.get(0).getLkNum() == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean hasDuplicates = supInfoList.stream()
|
||||
.collect(Collectors.groupingBy(OutPlanVoSupInfo::getSupId))
|
||||
.entrySet()
|
||||
.stream()
|
||||
.anyMatch(e -> e.getValue().size() > 1);
|
||||
if (hasDuplicates) {
|
||||
return ServerResponse.createErroe("同一型号厂商不能一致");
|
||||
}
|
||||
details.setProId(outPlanVo.getProId());
|
||||
details.setPlanId(details.getPlanId());
|
||||
int ckNum = 0;
|
||||
int lkNum = 0;
|
||||
//三级
|
||||
int applyNum = mapper.getJsData(outPlanVo.getPlanId());
|
||||
if (applyNum > 0) {
|
||||
return ServerResponse.createErroe("该单子已被结算、不允许再次发货");
|
||||
}
|
||||
for (OutPlanVoSupInfo supInfo : supInfoList) {
|
||||
ckNum += supInfo.getCgNum();
|
||||
lkNum += supInfo.getLkNum();
|
||||
supInfo.setPlanId(outPlanVo.getPlanId());
|
||||
supInfo.setProId(outPlanVo.getProId());
|
||||
supInfo.setModelId(details.getModelId());
|
||||
//shu数据校验
|
||||
supp.setContractId(supInfo.getContractId());
|
||||
supp.setModelId(details.getModelId());
|
||||
supp.setSupId(supInfo.getSupId());
|
||||
//验证数据
|
||||
int num = supplierMapper.supCheck(supp);
|
||||
// 只有采购才需要选择供应商
|
||||
if (num < 1 && supInfo.getCgNum() > 0) {
|
||||
return ServerResponse.createErroe(supInfo.getSupName() + "-厂家合同内无此-" + details.getModel() + "-型号设备");
|
||||
}
|
||||
}
|
||||
//数据校验
|
||||
MaTypeVo maTypeVo = new MaTypeVo();
|
||||
maTypeVo.setModelId(details.getModelId());
|
||||
int num = maTypeMapper.maTypeCheck(maTypeVo);
|
||||
if (lkNum > num) {
|
||||
return ServerResponse.createErroe(details.getModel() + "-型号设备的利库量大于库存量,库存不足!");
|
||||
}
|
||||
details.setCgNum(Integer.toString(ckNum));
|
||||
details.setLkNum(Integer.toString(lkNum));
|
||||
}
|
||||
String createTime = DateTimeHelper.getNowTime();
|
||||
for (OutPlanVoDetails details : detailsList) {
|
||||
String detailId=details.getId();
|
||||
List<OutPlanVoSupInfo> supInfoList = details.getSupList();
|
||||
for (OutPlanVoSupInfo outSup : supInfoList) {
|
||||
if (outSup.getCgNum() <= 0) {
|
||||
outSup.setContractId("10086");
|
||||
outSup.setSupId("10086");
|
||||
outSup.setSupName("库存发出");
|
||||
}
|
||||
//新增st_plan_out_sup数据
|
||||
outSup.setOutId(outPlanVo.getId());
|
||||
outSup.setProId(outPlanVo.getProId());
|
||||
outSup.setDetailsId(detailId);
|
||||
outSup.setCreateTime(createTime);
|
||||
int succ = mapper.insertStPlanOutSupData(outSup);
|
||||
if (succ < 1) {
|
||||
throw new Exception("添加数据失败");
|
||||
}
|
||||
}
|
||||
//先查询st_plan_out_sup的数据
|
||||
//修改st_plan_out_details数据
|
||||
OutPlanVoSupInfo outSup = mapper.getStPlanOutSupData(details);
|
||||
if (outSup != null && outSup.getId() != null){
|
||||
OutPlanVoSupInfo bean = new OutPlanVoSupInfo();
|
||||
bean.setId(detailId);
|
||||
bean.setCgNum(outSup.getCgNum());
|
||||
bean.setLkNum(outSup.getLkNum());
|
||||
int re = mapper.updateStPlanOutDetailsData(bean);
|
||||
if (re < 1) {
|
||||
throw new Exception("修改数据失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
//先查询st_plan_out_details的数据
|
||||
//修改st_plan_out数据
|
||||
OutPlanVoDetails outPlanVoDetails = mapper.getStPlanOutDetailsData(outPlanVo);
|
||||
if (outPlanVoDetails != null && outPlanVoDetails.getId() != null){
|
||||
int re = mapper.updateStPlanOutData(outPlanVoDetails);
|
||||
if (re < 1) {
|
||||
throw new Exception("修改数据失败");
|
||||
}
|
||||
//更新st_plan_apply
|
||||
int res = mapper.updateStPlanApplyData(outPlanVoDetails);
|
||||
}
|
||||
|
||||
return ServerResponse.createSuccess("发货成功", outPlanVo);
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
}
|
||||
return ServerResponse.createErroe("发货失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OutPlanVoDetails> getPurchaseDetailsListBatch(OutPlanVo data) {
|
||||
List<OutPlanVoDetails> list = new ArrayList<>();
|
||||
try {
|
||||
//先查询批次
|
||||
// list = mapper.getPurchaseDetailsListBatch(data);
|
||||
// if (list.size()>0){
|
||||
// for (OutPlanVoDetails details : list) {
|
||||
// //根据批次查询对应数据
|
||||
// List<OutPlanVoDetails> detailsList = mapper.getPurchaseDetailsListByBatch(details);
|
||||
// details.setBatchList(detailsList);
|
||||
// }
|
||||
// } else {
|
||||
//分批发货前的数据
|
||||
OutPlanVo outPlanVo = mapper.getPurchaseDetails(data);
|
||||
OutPlanVoDetails details = new OutPlanVoDetails();
|
||||
details.setOutId(outPlanVo.getId());
|
||||
List<OutPlanVoDetails> detailsList = mapper.getPurchaseDetailsListByBatch(details);
|
||||
details.setBatchList(detailsList);
|
||||
list.add(details);
|
||||
// }
|
||||
return list;
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult deleteDetail(Long id) {
|
||||
try {
|
||||
|
|
@ -1150,6 +1297,30 @@ public class PurchaseServiceImpl implements PurchaseService {
|
|||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OutPlanVoDetails> getPurchaseDetailsListBySupplement(OutPlanVo data) {
|
||||
List<OutPlanVoDetails> list = new ArrayList<>();
|
||||
try {
|
||||
OutPlanVo outPlanVo = mapper.getPurchaseDetails(data);
|
||||
OutPlanVo param = new OutPlanVo();
|
||||
param.setId(outPlanVo.getId());
|
||||
list = mapper.getPurchaseDetailsListBySupplement(param);
|
||||
if (StringUtils.isNotEmpty(list)) {
|
||||
list.forEach(vo -> {
|
||||
List<OutPlanVoSupInfo> outPlanVoSupInfoList = mapper.getPurchaseSupDetailsList(vo);
|
||||
if (outPlanVoSupInfoList.size()>0){
|
||||
List<OutPlanVoSupInfo> supList = new ArrayList<>();
|
||||
supList.add(outPlanVoSupInfoList.get(0));
|
||||
vo.setSupList(supList);
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询二维码集合数据
|
||||
*
|
||||
|
|
|
|||
|
|
@ -54,6 +54,12 @@
|
|||
#{item.modelId},#{item.cgNum},#{item.lkNum},#{item.supName},#{item.ccDay},#{item.jyDay},#{item.remark})
|
||||
</foreach>
|
||||
</insert>
|
||||
<insert id="insertStPlanOutSupData">
|
||||
insert into st_plan_out_sup(contract_id, out_id, pro_id, details_id,
|
||||
sup_id, model_id, cg_num, lk_num, sup_name, cc_day, jy_day, remark,create_time)
|
||||
values (#{contractId}, #{outId}, #{proId}, #{detailsId}, #{supId},
|
||||
#{modelId}, #{cgNum}, #{lkNum}, #{supName}, #{ccDay}, #{jyDay}, #{remark},#{createTime})
|
||||
</insert>
|
||||
|
||||
<update id="updatePurchaseDetailsSupData">
|
||||
update st_plan_out_sup set contract_id=#{contractId},sup_id=#{supId},
|
||||
|
|
@ -87,6 +93,20 @@
|
|||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateStPlanOutDetailsData">
|
||||
update st_plan_out_details
|
||||
set cg_num= #{cgNum},
|
||||
lk_num= #{lkNum}
|
||||
where id = #{id}
|
||||
</update>
|
||||
<update id="updateStPlanOutData">
|
||||
update st_plan_out set cg_num=#{cgNum},lk_num= #{lkNum} where id = #{id}
|
||||
</update>
|
||||
<update id="updateStPlanApplyData">
|
||||
update st_plan_apply
|
||||
set cg_num=#{cgNum},lk_num= #{lkNum} where id = #{planId}
|
||||
</update>
|
||||
|
||||
|
||||
<select id="getProPurchaseList" resultType="com.bonus.aqgqj.business.backstage.entity.PurchaseVo">
|
||||
select count(1) planNum,pro.name proName,bc.`NAME` as companyName,SUM(spa.need_num) needNum , SUM(ck_num) ckNum,sum(lk_num) lkNum ,
|
||||
|
|
@ -287,4 +307,89 @@
|
|||
from st_slt_details
|
||||
where plan_id=#{planId}
|
||||
</select>
|
||||
<select id="getPurchaseDetailsListBySupplement"
|
||||
resultType="com.bonus.aqgqj.business.backstage.entity.OutPlanVoDetails">
|
||||
SELECT
|
||||
spod.id,
|
||||
spod.out_id outId,
|
||||
spod.type,
|
||||
spod.NAME,
|
||||
spod.model,
|
||||
spod.model_id modelId,
|
||||
spod.unit,
|
||||
spod.need_num needNum,
|
||||
SUM(spos.cg_num+spos.lk_num) as num
|
||||
FROM
|
||||
st_plan_out_details spod
|
||||
LEFT JOIN st_plan_out_sup spos on spos.details_id=spod.id
|
||||
WHERE
|
||||
spod.out_id=#{id}
|
||||
GROUP BY
|
||||
spos.details_id
|
||||
HAVING needNum-num >0
|
||||
</select>
|
||||
<select id="getStPlanOutSupData" resultType="com.bonus.aqgqj.business.backstage.entity.OutPlanVoSupInfo">
|
||||
SELECT
|
||||
id,
|
||||
SUM(IFNULL(cg_num,0)) as cgNum,
|
||||
SUM(IFNULL(lk_num,0)) as lkNum
|
||||
FROM
|
||||
st_plan_out_sup
|
||||
WHERE
|
||||
details_id=#{id}
|
||||
GROUP BY details_id
|
||||
</select>
|
||||
<select id="getStPlanOutDetailsData"
|
||||
resultType="com.bonus.aqgqj.business.backstage.entity.OutPlanVoDetails">
|
||||
SELECT
|
||||
out_id as id,
|
||||
plan_detail_id as planId,
|
||||
SUM(IFNULL(cg_num,0)) as cgNum,
|
||||
SUM(IFNULL(lk_num,0)) as lkNum
|
||||
FROM
|
||||
st_plan_out_details
|
||||
WHERE
|
||||
out_id=#{id}
|
||||
GROUP BY out_id
|
||||
</select>
|
||||
<select id="getPurchaseDetailsListBatch"
|
||||
resultType="com.bonus.aqgqj.business.backstage.entity.OutPlanVoDetails">
|
||||
SELECT
|
||||
spos.out_id as outId,
|
||||
spos.create_time as createTime
|
||||
FROM
|
||||
st_plan_out_sup spos
|
||||
LEFT JOIN st_plan_out_details spod on spos.out_id=spod.out_id
|
||||
WHERE
|
||||
spod.plan_detail_id=#{id}
|
||||
and spos.create_time is not null
|
||||
GROUP BY spos.create_time
|
||||
</select>
|
||||
<select id="getPurchaseDetailsListByBatch"
|
||||
resultType="com.bonus.aqgqj.business.backstage.entity.OutPlanVoDetails">
|
||||
SELECT
|
||||
spod.id,
|
||||
spod.out_id outId,
|
||||
spod.type,
|
||||
spod.NAME,
|
||||
spod.model,
|
||||
spod.model_id modelId,
|
||||
spod.unit,
|
||||
spod.need_num as needNum,
|
||||
spos.cg_num cgNum,
|
||||
spos.lk_num lkNum,
|
||||
spos.sup_id supId,
|
||||
spos.sup_name supName,
|
||||
spos.cc_day ccDay,
|
||||
spos.jy_day jyDay,
|
||||
spos.remark
|
||||
FROM
|
||||
st_plan_out_sup spos
|
||||
LEFT JOIN st_plan_out_details spod on spos.details_id=spod.id
|
||||
WHERE
|
||||
spos.out_id=#{outId}
|
||||
<if test="createTime!=null and createTime!=''">
|
||||
and spos.create_time=#{createTime}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue