补发货修改
This commit is contained in:
parent
60c9839099
commit
adacebec13
|
|
@ -219,6 +219,17 @@ public class PurchaseController {
|
|||
return service.addPurchaseDataBySupplement(request, files);
|
||||
}
|
||||
|
||||
/**
|
||||
* 补发货接口---暂存
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("addPurchaseDataBySupplementAndTemporary")
|
||||
public ServerResponse addPurchaseDataBySupplementAndTemporary(HttpServletRequest request, @RequestParam(value = "file[]", required = false) MultipartFile[] files) {
|
||||
return service.addPurchaseDataBySupplementAndTemporary(request, files);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发货修改数据接口---暂存
|
||||
* @param
|
||||
|
|
|
|||
|
|
@ -97,6 +97,6 @@ public class OutPlanVoSupInfo {
|
|||
|
||||
private String createTime;
|
||||
|
||||
|
||||
private String status;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -238,4 +238,18 @@ public interface PurchaseMapper {
|
|||
* @return
|
||||
*/
|
||||
List<OutPlanVoDetails> getPurchaseDetailsListByBatch(OutPlanVoDetails details);
|
||||
|
||||
/**
|
||||
* 获取补充数据
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
List<OutPlanVoSupInfo> getPurchaseSupDetailsListBySupplement(OutPlanVoDetails vo);
|
||||
|
||||
/**
|
||||
* 删除补充数据
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
int delStPlanOutSupData(String id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,4 +130,12 @@ public interface PurchaseService {
|
|||
* @return
|
||||
*/
|
||||
List<OutPlanVoDetails> getPurchaseDetailsListBatch(OutPlanVo data);
|
||||
|
||||
/**
|
||||
* 新增补发货数据
|
||||
* @param request
|
||||
* @param files
|
||||
* @return
|
||||
*/
|
||||
ServerResponse addPurchaseDataBySupplementAndTemporary(HttpServletRequest request, MultipartFile[] files);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -817,6 +817,7 @@ public class PurchaseServiceImpl implements PurchaseService {
|
|||
details.setLkNum(Integer.toString(lkNum));
|
||||
}
|
||||
String createTime = DateTimeHelper.getNowTime();
|
||||
int delNum = mapper.delStPlanOutSupData(outPlanVo.getId());
|
||||
for (OutPlanVoDetails details : detailsList) {
|
||||
String detailId=details.getId();
|
||||
List<OutPlanVoSupInfo> supInfoList = details.getSupList();
|
||||
|
|
@ -831,6 +832,7 @@ public class PurchaseServiceImpl implements PurchaseService {
|
|||
outSup.setProId(outPlanVo.getProId());
|
||||
outSup.setDetailsId(detailId);
|
||||
outSup.setCreateTime(createTime);
|
||||
outSup.setStatus("1");
|
||||
int succ = mapper.insertStPlanOutSupData(outSup);
|
||||
if (succ < 1) {
|
||||
throw new Exception("添加数据失败");
|
||||
|
|
@ -898,6 +900,105 @@ public class PurchaseServiceImpl implements PurchaseService {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ServerResponse addPurchaseDataBySupplementAndTemporary(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();
|
||||
//删除所有暂存数据
|
||||
int delNum = mapper.delStPlanOutSupData(outPlanVo.getId());
|
||||
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);
|
||||
outSup.setStatus("0");
|
||||
int succ = mapper.insertStPlanOutSupData(outSup);
|
||||
if (succ < 1) {
|
||||
throw new Exception("添加数据失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
return ServerResponse.createSuccess("保存成功", outPlanVo);
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
}
|
||||
return ServerResponse.createErroe("保存失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult deleteDetail(Long id) {
|
||||
try {
|
||||
|
|
@ -1307,7 +1408,7 @@ public class PurchaseServiceImpl implements PurchaseService {
|
|||
list = mapper.getPurchaseDetailsListBySupplement(param);
|
||||
if (StringUtils.isNotEmpty(list)) {
|
||||
list.forEach(vo -> {
|
||||
List<OutPlanVoSupInfo> outPlanVoSupInfoList = mapper.getPurchaseSupDetailsList(vo);
|
||||
List<OutPlanVoSupInfo> outPlanVoSupInfoList = mapper.getPurchaseSupDetailsListBySupplement(vo);
|
||||
if (outPlanVoSupInfoList.size()>0){
|
||||
List<OutPlanVoSupInfo> supList = new ArrayList<>();
|
||||
supList.add(outPlanVoSupInfoList.get(0));
|
||||
|
|
|
|||
|
|
@ -30,6 +30,11 @@
|
|||
from st_plan_out
|
||||
WHERE apply_id=#{id}
|
||||
</delete>
|
||||
<delete id="delStPlanOutSupData">
|
||||
delete
|
||||
from st_plan_out_sup
|
||||
WHERE out_id= #{id} and status='0'
|
||||
</delete>
|
||||
|
||||
<!--查询详情数据-->
|
||||
<insert id="insertPurchaseDetailsData" useGeneratedKeys="true" keyProperty="id">
|
||||
|
|
@ -56,9 +61,17 @@
|
|||
</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)
|
||||
sup_id, model_id, cg_num, lk_num, sup_name, cc_day, jy_day, remark,
|
||||
<if test="status!=null and status!=''">
|
||||
status,
|
||||
</if>
|
||||
create_time)
|
||||
values (#{contractId}, #{outId}, #{proId}, #{detailsId}, #{supId},
|
||||
#{modelId}, #{cgNum}, #{lkNum}, #{supName}, #{ccDay}, #{jyDay}, #{remark},#{createTime})
|
||||
#{modelId}, #{cgNum}, #{lkNum}, #{supName}, #{ccDay}, #{jyDay}, #{remark},
|
||||
<if test="status!=null and status!=''">
|
||||
#{status},
|
||||
</if>
|
||||
#{createTime})
|
||||
</insert>
|
||||
|
||||
<update id="updatePurchaseDetailsSupData">
|
||||
|
|
@ -257,12 +270,23 @@
|
|||
</select>
|
||||
<select id="getPurchaseSupDetailsList"
|
||||
resultType="com.bonus.aqgqj.business.backstage.entity.OutPlanVoSupInfo">
|
||||
select pos.cg_num*sct.price money,sct.price,pos.sup_name supName,pos.cc_day ccDay,pos.jy_day jyDay,pos.remark ,pos.contract_id as contractId,
|
||||
pos.cg_num cgNum,pos.lk_num lkNum,pos.lk_num historyLkNum ,pos.id,pos.sup_id supId
|
||||
from st_plan_out_sup pos
|
||||
left join st_contract_type sct on pos.sup_id=sct.supplier_id and
|
||||
pos.model_id=sct.model_id and pos.contract_id=sct.contract_id
|
||||
where pos.details_id=#{id}
|
||||
select pos.cg_num * sct.price money,
|
||||
sct.price,
|
||||
pos.sup_name supName,
|
||||
pos.cc_day ccDay,
|
||||
pos.jy_day jyDay,
|
||||
pos.remark,
|
||||
pos.contract_id as contractId,
|
||||
pos.cg_num cgNum,
|
||||
pos.lk_num lkNum,
|
||||
pos.lk_num historyLkNum,
|
||||
pos.id,
|
||||
pos.sup_id supId
|
||||
from st_plan_out_sup pos
|
||||
left join st_contract_type sct on pos.sup_id = sct.supplier_id and
|
||||
pos.model_id = sct.model_id and pos.contract_id = sct.contract_id
|
||||
where pos.details_id = #{id}
|
||||
and pos.status = '1'
|
||||
</select>
|
||||
<!--按照发货单进行 统计-->
|
||||
<select id="getTypeList" resultType="com.bonus.aqgqj.business.backstage.entity.OutPlanVoDetails">
|
||||
|
|
@ -321,7 +345,7 @@
|
|||
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
|
||||
LEFT JOIN st_plan_out_sup spos on spos.details_id=spod.id and spos.status='1'
|
||||
WHERE
|
||||
spod.out_id=#{id}
|
||||
GROUP BY
|
||||
|
|
@ -388,8 +412,33 @@
|
|||
LEFT JOIN st_plan_out_details spod on spos.details_id=spod.id
|
||||
WHERE
|
||||
spos.out_id=#{outId}
|
||||
and spos.status='1'
|
||||
<if test="createTime!=null and createTime!=''">
|
||||
and spos.create_time=#{createTime}
|
||||
</if>
|
||||
</select>
|
||||
<select id="getPurchaseSupDetailsListBySupplement"
|
||||
resultType="com.bonus.aqgqj.business.backstage.entity.OutPlanVoSupInfo">
|
||||
select pos.cg_num * sct.price money,
|
||||
sct.price,
|
||||
pos.sup_name supName,
|
||||
pos.cc_day ccDay,
|
||||
pos.jy_day jyDay,
|
||||
pos.remark,
|
||||
pos.contract_id as contractId,
|
||||
pos.cg_num cgNum,
|
||||
pos.lk_num lkNum,
|
||||
pos.lk_num historyLkNum,
|
||||
pos.id,
|
||||
pos.sup_id supId,
|
||||
case
|
||||
when pos.status = '0' then '暂存'
|
||||
when pos.status = '1' then '已提交'
|
||||
end status
|
||||
from st_plan_out_sup pos
|
||||
left join st_contract_type sct on pos.sup_id = sct.supplier_id and
|
||||
pos.model_id = sct.model_id and pos.contract_id = sct.contract_id
|
||||
where pos.details_id = #{id}
|
||||
ORDER BY pos.status
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue