Merge remote-tracking branch 'origin/main' into main
This commit is contained in:
commit
8434b530d8
|
|
@ -178,6 +178,18 @@ public class PurchaseController {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发货数据新增接口---暂存
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("addPurchaseDataTemporary")
|
||||
public ServerResponse addPurchaseDataTemporary(HttpServletRequest request, @RequestParam(value = "file[]", required = false) MultipartFile[] files) {
|
||||
return service.addPurchaseDataTemporary(request, files);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("addUnplannedPurchaseData")
|
||||
public ServerResponse addUnplannedPurchaseData(HttpServletRequest request, @RequestParam(value = "file[]", required = false) MultipartFile[] files) {
|
||||
return service.addUnplannedPurchaseData(request, files);
|
||||
|
|
@ -195,6 +207,16 @@ public class PurchaseController {
|
|||
return service.updatePurchaseData(request, files);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发货修改数据接口---暂存
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("updatePurchaseDataTemporary")
|
||||
public ServerResponse updatePurchaseDataTemporary(HttpServletRequest request, @RequestParam(value = "file[]", required = false) MultipartFile[] files) {
|
||||
return service.updatePurchaseDataTemporary(request, files);
|
||||
}
|
||||
|
||||
/**
|
||||
* 采购详情查看
|
||||
*
|
||||
|
|
|
|||
|
|
@ -110,4 +110,9 @@ public class OutPlanVo extends ParentVo {
|
|||
|
||||
|
||||
private String resultData2;
|
||||
|
||||
/**
|
||||
* 状态 0-暂存,1-提交
|
||||
*/
|
||||
private int editStatus;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,4 +92,20 @@ public interface PurchaseService {
|
|||
|
||||
|
||||
AjaxResult deleteDetail(Long id);
|
||||
|
||||
/**
|
||||
* 新增临时数据
|
||||
* @param request
|
||||
* @param files
|
||||
* @return
|
||||
*/
|
||||
ServerResponse addPurchaseDataTemporary(HttpServletRequest request, MultipartFile[] files);
|
||||
|
||||
/**
|
||||
* 修改临时数据
|
||||
* @param request
|
||||
* @param files
|
||||
* @return
|
||||
*/
|
||||
ServerResponse updatePurchaseDataTemporary(HttpServletRequest request, MultipartFile[] files);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import com.bonus.aqgqj.manager.webResult.AjaxResult;
|
|||
import com.bonus.aqgqj.manager.webResult.ServerResponse;
|
||||
import com.google.common.collect.Maps;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
|
@ -173,12 +174,17 @@ public class PurchaseServiceImpl implements PurchaseService {
|
|||
try {
|
||||
list = mapper.getProApplyList(data);
|
||||
final int[] xh = {1};
|
||||
if (StringUtils.isNotEmpty(list)) {
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
list.forEach(vo -> {
|
||||
vo.setXh(xh[0]);
|
||||
xh[0]++;
|
||||
String money = mapper.outPlanMoney(vo);
|
||||
vo.setMoney(money);
|
||||
|
||||
// 判断status为"已发货"且editStatus为0,修改status为"暂存"
|
||||
if ("已发货".equals(vo.getStatus()) && 0 == vo.getEditStatus()) {
|
||||
vo.setStatus("暂存");
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
|
@ -354,6 +360,7 @@ public class PurchaseServiceImpl implements PurchaseService {
|
|||
maTypeMapper.updateMatype(maTypeVo);
|
||||
}
|
||||
//跟新计划
|
||||
outPlanVo.setEditStatus(1);
|
||||
mapper.updatePlanData(outPlanVo);
|
||||
//修改成功后返回数据
|
||||
outPlanVo.setResultData(outPlanVo.getDetailsList().size() + "");
|
||||
|
|
@ -732,6 +739,7 @@ public class PurchaseServiceImpl implements PurchaseService {
|
|||
|
||||
}
|
||||
//跟新计划
|
||||
outPlanVo.setEditStatus(1);
|
||||
mapper.updatePlanData(outPlanVo);
|
||||
//修改成功后返回数据
|
||||
outPlanVo.setResultData(outPlanVo.getDetailsList().size() + "");
|
||||
|
|
@ -755,6 +763,344 @@ public class PurchaseServiceImpl implements PurchaseService {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ServerResponse addPurchaseDataTemporary(HttpServletRequest request, MultipartFile[] files) {
|
||||
try {
|
||||
String params = request.getParameter("params");
|
||||
if (StringHelper.isEmpty(params)) {
|
||||
return ServerResponse.createErroe("请求参数缺失");
|
||||
}
|
||||
String userId = UserUtil.getLoginUser().getUserId() + "";
|
||||
String userName = UserUtil.getLoginUser().getUsername();
|
||||
OutPlanVo outPlanVo = JSON.parseObject(params, OutPlanVo.class);
|
||||
|
||||
outPlanVo.setUserName(userName);
|
||||
outPlanVo.setUpdater(userId);
|
||||
outPlanVo.setCreator(userId);
|
||||
if (StringHelper.isEmpty(outPlanVo.getPlanId())) {
|
||||
return ServerResponse.createErroe("请选择需求计划");
|
||||
}
|
||||
if (StringHelper.isEmpty(outPlanVo.getFhDay())) {
|
||||
return ServerResponse.createErroe("发货时间不能为空");
|
||||
}
|
||||
if (StringHelper.isEmpty(outPlanVo.getJbUser())) {
|
||||
return ServerResponse.createErroe("请填写经办人");
|
||||
}
|
||||
if (StringHelper.isEmpty(outPlanVo.getAddress())) {
|
||||
outPlanVo.setAddress("无");
|
||||
}
|
||||
|
||||
List<OutPlanVoDetails> detailsList = outPlanVo.getDetailsList();
|
||||
|
||||
int allCkNum = 0;
|
||||
int allLkNum = 0;
|
||||
SupplierVo supp = new SupplierVo();
|
||||
for (OutPlanVoDetails details : detailsList) {
|
||||
List<OutPlanVoSupInfo> supInfoList = details.getSupList();
|
||||
|
||||
// 采购和利库都是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("该单子已被结算、不允许再次发货");
|
||||
}
|
||||
String needNum = details.getNeedNum();
|
||||
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));
|
||||
allCkNum += ckNum;
|
||||
allLkNum += lkNum;
|
||||
}
|
||||
outPlanVo.setCgNum(allCkNum);
|
||||
outPlanVo.setLkNum(allLkNum);
|
||||
int successNum = mapper.insertPurchaseData(outPlanVo);
|
||||
if (successNum != 1) {
|
||||
throw new RuntimeException("新增数据异常,请稍后重试");
|
||||
}
|
||||
if (files != null && files.length > 0) {
|
||||
List<FileUploadVo> fileList = uploadService.uploadImage(files, outPlanVo.getId(), "st_plan_out", "采购发货附件");
|
||||
if (fileList.size() != files.length) {
|
||||
throw new RuntimeException("文件上传失败!");
|
||||
}
|
||||
}
|
||||
for (OutPlanVoDetails details : detailsList) {
|
||||
details.setOutId(outPlanVo.getId());
|
||||
int num = mapper.insertPurchaseDetailsData(details);
|
||||
if (num != 1) {
|
||||
throw new RuntimeException("新增失败数据异常,请稍后重试");
|
||||
}
|
||||
List<OutPlanVoSupInfo> supInfoList = details.getSupList();
|
||||
// 没有采购的模拟一条假数据
|
||||
for (OutPlanVoSupInfo info : supInfoList) {
|
||||
if (info.getCgNum() <= 0) {
|
||||
info.setContractId("10086");
|
||||
info.setSupId("10086");
|
||||
info.setSupName("库存发出");
|
||||
}
|
||||
if (StringHelper.isEmpty(info.getContractId()) || StringHelper.isEmpty(info.getSupId())){
|
||||
//暂存时未选,暂时置为0
|
||||
info.setContractId("0");
|
||||
info.setSupId("0");
|
||||
}
|
||||
}
|
||||
int succ = mapper.insertPurchaseDetailsSupData(details, supInfoList);
|
||||
if (succ != supInfoList.size()) {
|
||||
throw new RuntimeException("新增失败数据异常,请稍后重试");
|
||||
}
|
||||
//更新需求
|
||||
mapper.updatePlanDetails(details);
|
||||
//更新库存
|
||||
MaTypeVo maTypeVo = new MaTypeVo();
|
||||
maTypeVo.setModelId(details.getModelId());
|
||||
int nowNum = maTypeMapper.maTypeCheck(maTypeVo);
|
||||
if (StringHelper.isEmpty(details.getLkNum())){
|
||||
details.setLkNum("0");
|
||||
}
|
||||
if (nowNum - Integer.parseInt(details.getLkNum()) > 0) {
|
||||
maTypeVo.setStorageNum(nowNum - Integer.parseInt(details.getLkNum()) + "");
|
||||
} else {
|
||||
maTypeVo.setStorageNum("0");
|
||||
}
|
||||
maTypeMapper.updateMatype(maTypeVo);
|
||||
}
|
||||
//跟新计划
|
||||
mapper.updatePlanData(outPlanVo);
|
||||
//修改成功后返回数据
|
||||
outPlanVo.setResultData(outPlanVo.getDetailsList().size() + "");
|
||||
outPlanVo.setResultData2(allCkNum + "");
|
||||
return ServerResponse.createSuccess("保存成功", outPlanVo);
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
}
|
||||
return ServerResponse.createErroe("保存失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ServerResponse updatePurchaseDataTemporary(HttpServletRequest request, MultipartFile[] files) {
|
||||
try {
|
||||
String params = request.getParameter("params");
|
||||
if (StringHelper.isEmpty(params)) {
|
||||
return ServerResponse.createErroe("请求参数缺失");
|
||||
}
|
||||
String userId = UserUtil.getLoginUser().getUserId() + "";
|
||||
String userName = UserUtil.getLoginUser().getUsername();
|
||||
OutPlanVo outPlanVo = JSON.parseObject(params, OutPlanVo.class);
|
||||
outPlanVo.setUserName(userName);
|
||||
outPlanVo.setUpdater(userId);
|
||||
if (StringHelper.isEmpty(outPlanVo.getPlanId())) {
|
||||
return ServerResponse.createErroe("请选择需求计划");
|
||||
}
|
||||
if (StringHelper.isEmpty(outPlanVo.getFhDay())) {
|
||||
return ServerResponse.createErroe("发货时间不能为空");
|
||||
}
|
||||
if (StringHelper.isEmpty(outPlanVo.getJbUser())) {
|
||||
return ServerResponse.createErroe("请填写经办人");
|
||||
}
|
||||
if (StringHelper.isEmpty(outPlanVo.getAddress())) {
|
||||
outPlanVo.setAddress("无");
|
||||
}
|
||||
|
||||
List<OutPlanVoDetails> detailsList = outPlanVo.getDetailsList();
|
||||
|
||||
int allCkNum = 0;
|
||||
int allLkNum = 0;
|
||||
for (OutPlanVoDetails details : detailsList) {
|
||||
List<OutPlanVoSupInfo> supInfoList = details.getSupList();
|
||||
// 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) {
|
||||
throw new RuntimeException("同一型号厂商不能一致");
|
||||
}
|
||||
details.setProId(outPlanVo.getProId());
|
||||
details.setPlanId(details.getPlanId());
|
||||
int ckNum = 0;
|
||||
int lkNum = 0;
|
||||
int hisNum = 0;
|
||||
//三级
|
||||
int applyNum = mapper.getJsData(outPlanVo.getPlanId());
|
||||
if (applyNum > 0) {
|
||||
throw new RuntimeException("该发货单已被结算、不允许再次发货");
|
||||
}
|
||||
String needNum = details.getNeedNum();
|
||||
//三级
|
||||
for (OutPlanVoSupInfo supInfo : supInfoList) {
|
||||
ckNum += supInfo.getCgNum();
|
||||
lkNum += supInfo.getLkNum();
|
||||
hisNum += supInfo.getHistoryLkNum();
|
||||
supInfo.setPlanId(outPlanVo.getPlanId());
|
||||
supInfo.setProId(outPlanVo.getProId());
|
||||
supInfo.setModelId(details.getModelId());
|
||||
//shu数据校验
|
||||
SupplierVo supp = new SupplierVo();
|
||||
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 (hisNum < ckNum) {
|
||||
if (lkNum - hisNum > num) {
|
||||
return ServerResponse.createErroe(details.getModel() + "-型号设备的利库量大于库存量,库存不足!");
|
||||
}
|
||||
}
|
||||
details.setHisNum(hisNum);
|
||||
details.setCgNum(Integer.toString(ckNum));
|
||||
details.setLkNum(Integer.toString(lkNum));
|
||||
allCkNum += ckNum;
|
||||
allLkNum += lkNum;
|
||||
}
|
||||
outPlanVo.setCgNum(allCkNum);
|
||||
outPlanVo.setLkNum(allLkNum);
|
||||
if (StringHelper.isEmpty(outPlanVo.getId())) {
|
||||
throw new RuntimeException("发货单id不能为空");
|
||||
}
|
||||
int successNum = mapper.updatePurchaseData(outPlanVo);
|
||||
if (successNum != 1) {
|
||||
throw new RuntimeException("修改失败数据异常,请稍后重试");
|
||||
}
|
||||
if (StringHelper.isNotEmpty(outPlanVo.getDelFileId())) {
|
||||
boolean isc = uploadService.deleteFile(outPlanVo.getDelFileId());
|
||||
if (!isc) {
|
||||
throw new RuntimeException("文件删除失败");
|
||||
}
|
||||
}
|
||||
if (StringHelper.isNotEmpty(outPlanVo.getDelSupId())) {
|
||||
List<String> ids = Arrays.asList(outPlanVo.getDelSupId().split("@"));
|
||||
int suc = mapper.deleteSupId(ids);
|
||||
if (suc != ids.size()) {
|
||||
throw new RuntimeException("厂商删除失败!");
|
||||
}
|
||||
}
|
||||
if (files != null && files.length > 0) {
|
||||
List<FileUploadVo> fileList = uploadService.uploadImage(files, outPlanVo.getId(), "st_plan_out", "采购发货附件");
|
||||
if (fileList.size() != files.length) {
|
||||
throw new RuntimeException("文件上传失败!");
|
||||
}
|
||||
}
|
||||
//
|
||||
for (OutPlanVoDetails details : detailsList) {
|
||||
details.setOutId(outPlanVo.getId());
|
||||
int num = mapper.updatePurchaseDetailsData(details);
|
||||
if (num != 1) {
|
||||
throw new RuntimeException("修改失败数据异常,请稍后重试");
|
||||
}
|
||||
List<OutPlanVoSupInfo> supInfoList = details.getSupList();
|
||||
//出入库
|
||||
for (OutPlanVoSupInfo outSup : supInfoList) {
|
||||
if (outSup.getCgNum() <= 0) {
|
||||
outSup.setContractId("10086");
|
||||
outSup.setSupId("10086");
|
||||
outSup.setSupName("库存发出");
|
||||
}
|
||||
if (StringHelper.isEmpty(outSup.getContractId()) || StringHelper.isEmpty(outSup.getSupId())){
|
||||
//暂存时未选,暂时置为0
|
||||
outSup.setContractId("0");
|
||||
outSup.setSupId("0");
|
||||
}
|
||||
// 是空的就需要新增
|
||||
if (StringHelper.isEmpty(outSup.getId()) || "undefined".equals(outSup.getId())) {
|
||||
List<OutPlanVoSupInfo> addList = new ArrayList<>();
|
||||
addList.add(outSup);
|
||||
int succ = mapper.insertPurchaseDetailsSupData(details, addList);
|
||||
if (succ != supInfoList.size()) {
|
||||
throw new RuntimeException("新增厂商异常,请稍后重试");
|
||||
}
|
||||
} else {
|
||||
int succ = mapper.updatePurchaseDetailsSupData(outSup);
|
||||
if (succ != 1) {
|
||||
throw new RuntimeException("修改厂商异常,请稍后重试");
|
||||
}
|
||||
}
|
||||
}
|
||||
mapper.updatePlanDetails(details);
|
||||
//更新库存
|
||||
MaTypeVo maTypeVo = new MaTypeVo();
|
||||
maTypeVo.setModelId(details.getModelId());
|
||||
int nowNum = maTypeMapper.maTypeCheck(maTypeVo);
|
||||
int hisNum = details.getHisNum();
|
||||
int lkNum = Integer.parseInt(details.getLkNum());
|
||||
if (hisNum >= lkNum) {
|
||||
int now = hisNum - lkNum;
|
||||
maTypeVo.setStorageNum(nowNum + now + "");
|
||||
} else {
|
||||
int now = lkNum - hisNum;
|
||||
if (nowNum >= now) {
|
||||
maTypeVo.setStorageNum(nowNum - now + "");
|
||||
} else {
|
||||
maTypeVo.setStorageNum("0");
|
||||
}
|
||||
}
|
||||
maTypeMapper.updateMatype(maTypeVo);
|
||||
|
||||
}
|
||||
//跟新计划
|
||||
mapper.updatePlanData(outPlanVo);
|
||||
//修改成功后返回数据
|
||||
outPlanVo.setResultData(outPlanVo.getDetailsList().size() + "");
|
||||
outPlanVo.setResultData2(allCkNum + "");
|
||||
return ServerResponse.createSuccess("保存成功", outPlanVo);
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
}
|
||||
return ServerResponse.createErroe("保存失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看想数据
|
||||
*
|
||||
|
|
|
|||
|
|
@ -70,7 +70,14 @@
|
|||
</update>
|
||||
<!--计划数据-->
|
||||
<update id="updatePlanData">
|
||||
update st_plan_apply set ck_num=#{cgNum},lk_num=#{lkNum},fh_day=#{fhDay} where id=#{planId}
|
||||
update st_plan_apply
|
||||
set ck_num=#{cgNum},
|
||||
lk_num=#{lkNum},
|
||||
<if test="editStatus!=null">
|
||||
edit_status=#{editStatus},
|
||||
</if>
|
||||
fh_day=#{fhDay}
|
||||
where id = #{planId}
|
||||
</update>
|
||||
<update id="updateDetail">
|
||||
update st_plan_apply
|
||||
|
|
@ -155,7 +162,7 @@
|
|||
</if>
|
||||
</select>
|
||||
<select id="getProApplyList" resultType="com.bonus.aqgqj.business.backstage.entity.OutPlanVo">
|
||||
SELECT spa.code planCode,spa.project_id proId,spa.need_time needTime,spa.creator,spa.remark,spa.id ,
|
||||
SELECT spa.code planCode,spa.project_id proId,spa.need_time needTime,spa.creator,spa.remark,spa.id ,spa.edit_status as editStatus,
|
||||
if(spa.ck_num+spa.lk_num>0,'已发货','未发货') status,DATE_FORMAT(spa.create_time, '%Y-%m-%d') applyTime,spa.creator userName,
|
||||
DATE_FORMAT(spa.create_time, '%Y-%m-%d') createTime ,spa.need_num needNum,spa.ck_num cgNum,spa.lk_num lkNum
|
||||
from st_plan_apply spa
|
||||
|
|
|
|||
Loading…
Reference in New Issue