Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张雷
/
skboot-zhongye
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
构建
提交
问题看板
文件
提交
网络
比较
分支
标签
831cef07
由
康伟
编写于
2024-09-25 16:59:29 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
kangwei : 采购计划统计接口
1 个父辈
6c8e9266
隐藏空白字符变更
内嵌
并排
正在显示
18 个修改的文件
包含
347 行增加
和
26 行删除
sk-module-biz/src/main/java/com/skua/modules/erp/controller/ErpCommonController.java
sk-module-biz/src/main/java/com/skua/modules/erp/controller/PurchaseContractController.java
sk-module-biz/src/main/java/com/skua/modules/erp/entity/ERPPurchaseContract.java
sk-module-biz/src/main/java/com/skua/modules/erp/mapper/xml/PurchasePlanMapper.xml
sk-module-biz/src/main/java/com/skua/modules/erp/service/IEROPurchaseContractService.java
sk-module-biz/src/main/java/com/skua/modules/erp/service/impl/ERPPurchaseContractServiceImpl.java
sk-module-biz/src/main/java/com/skua/modules/erp/vo/MaterialSearchVO.java
sk-module-biz/src/main/java/com/skua/modules/safe/controller/DangerLevelManageController.java
sk-module-biz/src/main/java/com/skua/modules/safe/controller/app/APPDangerInspectionRecordController.java
sk-module-equipment/src/main/java/com/skua/modules/equipment/controller/EquipmentInController.java
sk-module-equipment/src/main/java/com/skua/modules/equipment/entity/EquipmentIn.java
sk-module-equipment/src/main/java/com/skua/modules/equipment/service/IEquipmentInService.java
sk-module-equipment/src/main/java/com/skua/modules/equipment/service/impl/EquipmentInServiceImpl.java
sk-module-equipment/src/main/java/com/skua/modules/supplies/entity/EquipmentSparepartSupplies.java
sk-module-equipment/src/main/java/com/skua/modules/supplies/mapper/EquipmentSparepartSuppliesMapper.java
sk-module-equipment/src/main/java/com/skua/modules/supplies/mapper/xml/EquipmentSparepartSuppliesMapper.xml
sk-module-equipment/src/main/java/com/skua/modules/supplies/service/IEquipmentSparepartSuppliesService.java
sk-module-equipment/src/main/java/com/skua/modules/supplies/service/impl/EquipmentSparepartSuppliesServiceImpl.java
sk-module-biz/src/main/java/com/skua/modules/erp/controller/ErpCommonController.java
查看文件 @
831cef0
...
...
@@ -12,6 +12,7 @@ import com.skua.modules.erp.entity.ApproveRecord;
import
com.skua.modules.erp.entity.PurchaseMaterial
;
import
com.skua.modules.erp.service.IDistributMaterialService
;
import
com.skua.modules.erp.service.IPurchaseMaterialService
;
import
com.skua.modules.erp.vo.MaterialSearchVO
;
import
com.skua.modules.supplies.entity.EquipmentSparepartSupplies
;
import
com.skua.modules.supplies.service.IEquipmentSparepartSuppliesService
;
import
com.skua.modules.system.entity.SysUser
;
...
...
@@ -36,16 +37,17 @@ public class ErpCommonController {
@Autowired
private
IDistributMaterialService
distributMaterialService
;
@AutoLog
(
value
=
"ERP-物料列表"
)
@ApiOperation
(
value
=
"ERP-
物料列表"
,
notes
=
"ERP
-物料列表"
)
@AutoLog
(
value
=
"ERP-
采购计划--
物料列表"
)
@ApiOperation
(
value
=
"ERP-
采购计划--物料列表"
,
notes
=
"ERP-采购计划-
-物料列表"
)
@RequestMapping
(
value
=
"/sparepartList"
,
method
=
RequestMethod
.
GET
)
public
Result
<
IPage
<
EquipmentSparepartSupplies
>>
sparepartList
(
@RequestParam
(
name
=
"pageNo"
,
defaultValue
=
"1"
)
Integer
pageNo
,
@RequestParam
(
name
=
"pageSize"
,
defaultValue
=
"10"
)
Integer
pageSize
,
HttpServletRequest
req
)
{
public
Result
<
IPage
<
EquipmentSparepartSupplies
>>
sparepartList
(
MaterialSearchVO
materialSearchVO
,
@RequestParam
(
name
=
"pageNo"
,
defaultValue
=
"1"
)
Integer
pageNo
,
@RequestParam
(
name
=
"pageSize"
,
defaultValue
=
"10"
)
Integer
pageSize
,
HttpServletRequest
req
)
{
Result
<
IPage
<
EquipmentSparepartSupplies
>>
result
=
new
Result
<
IPage
<
EquipmentSparepartSupplies
>>();
Page
<
EquipmentSparepartSupplies
>
page
=
new
Page
<
EquipmentSparepartSupplies
>(
pageNo
,
pageSize
);
String
depId
=
BaseContextHandler
.
getRealDepartId
();
//临时参数
// String username = req.getParameter("username");
IPage
<
EquipmentSparepartSupplies
>
pageList
=
sparepartSuppliesService
.
queryPageByOut
(
page
,
depId
);
IPage
<
EquipmentSparepartSupplies
>
pageList
=
sparepartSuppliesService
.
queryPageByOut
(
page
,
depId
,
materialSearchVO
.
getSparepartName
()
,
materialSearchVO
.
getSparepartType
(),
materialSearchVO
.
getSparepartCode
()
);
result
.
setSuccess
(
true
);
result
.
setResult
(
pageList
);
return
result
;
...
...
sk-module-biz/src/main/java/com/skua/modules/erp/controller/PurchaseContractController.java
查看文件 @
831cef0
...
...
@@ -158,4 +158,19 @@ public class PurchaseContractController {
}
return
result
;
}
@AutoLog
(
value
=
"erp采购合同-同步入库"
)
@ApiOperation
(
value
=
"erp采购合同-同步入库"
,
notes
=
"erp采购合同-同步入库"
)
@PutMapping
(
value
=
"/syncEquipmentIn"
)
public
Result
<
String
>
syncEquipmentIn
(
@RequestParam
(
name
=
"id"
,
required
=
true
)
String
id
)
{
Result
<
String
>
result
=
new
Result
<
String
>();
try
{
PurchaseContractVO
purchaseContractVO
=
purchaseContractService
.
queryById
(
id
)
;
//调用接口,同步到入库单
purchaseContractService
.
syncEquipmentIn
(
purchaseContractVO
);
}
catch
(
Exception
e
)
{
log
.
error
(
"同步入库失败"
,
e
.
getMessage
());
result
.
setSuccess
(
true
);
}
return
result
;
}
}
...
...
sk-module-biz/src/main/java/com/skua/modules/erp/entity/ERPPurchaseContract.java
查看文件 @
831cef0
...
...
@@ -46,6 +46,7 @@ public class ERPPurchaseContract {
/**采购类型:招标采购/询价采购*/
@Excel
(
name
=
"采购类型:招标采购/询价采购"
,
width
=
15
)
@ApiModelProperty
(
value
=
"采购类型:招标采购/询价采购"
)
@Dict
(
dicCode
=
"purchase_type"
)
private
java
.
lang
.
String
purchaseType
;
/**合同编号*/
@Excel
(
name
=
"合同编号"
,
width
=
15
)
...
...
@@ -90,6 +91,9 @@ public class ERPPurchaseContract {
@ApiModelProperty
(
value
=
"申请时间"
)
private
String
applyTime
;
@Excel
(
name
=
"备注"
,
width
=
15
)
@ApiModelProperty
(
value
=
"备注"
)
private
String
remark
;
/**创建人id*/
@Excel
(
name
=
"创建人id"
,
width
=
15
)
...
...
@@ -123,4 +127,7 @@ public class ERPPurchaseContract {
@Excel
(
name
=
"删除标识,0:有效,1:删除"
,
width
=
15
)
@ApiModelProperty
(
value
=
"删除标识,0:有效,1:删除"
)
private
java
.
lang
.
Integer
delFlag
;
@ApiModelProperty
(
value
=
"删除标识,0:有效,1:删除"
)
private
String
equipmentInId
;
}
...
...
sk-module-biz/src/main/java/com/skua/modules/erp/mapper/xml/PurchasePlanMapper.xml
查看文件 @
831cef0
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.skua.modules.erp.mapper.PurchasePlanMapper"
>
<!-- 统计查询-->
<select
id=
"statisticsPage"
resultType=
"com.skua.modules.erp.entity.PurchasePlanItem"
>
select ss.
sparepart_name,ss.sparepart_type,
ss.specification,ss.measuring_unit, aaa.* from (
select ss.
id, ss.sparepart_name,ss.sparepart_type, st.item_text as 'sparepart_type_name' ,ss.sparepart_code,
ss.specification,ss.measuring_unit, aaa.* from (
select pi.sparepart_id,sum(pi.purchase_num ) as 'purchase_num' , sum(pi.total_price) 'total_price'
from erp_purchase_plan_item pi ,erp_purchase_plan pp
where
...
...
@@ -30,6 +28,7 @@
group by pi.sparepart_id
)aaa
left join equipment_sparepart_supplies ss on aaa.sparepart_id = ss.id
left join equipment_sparepart_type st on st.id = aaa.sparepart_type
</select>
...
...
sk-module-biz/src/main/java/com/skua/modules/erp/service/IEROPurchaseContractService.java
查看文件 @
831cef0
...
...
@@ -55,6 +55,11 @@ public interface IEROPurchaseContractService extends IService<ERPPurchaseContrac
*/
public
void
auditPurchaseContract
(
PurchaseContractVO
purchaseContractVO
);
/***
* 同步入库操作
* @param purchaseContractVO
* @return
*/
public
int
syncEquipmentIn
(
PurchaseContractVO
purchaseContractVO
)
throws
Exception
;
}
...
...
sk-module-biz/src/main/java/com/skua/modules/erp/service/impl/ERPPurchaseContractServiceImpl.java
查看文件 @
831cef0
package
com
.
skua
.
modules
.
erp
.
service
.
impl
;
import
com.skua.core.context.BaseContextHandler
;
import
com.skua.core.util.DateUtils
;
import
com.skua.modules.equipment.dto.EquipmentInDTO
;
import
com.skua.modules.equipment.entity.EquipmentIn
;
import
com.skua.modules.equipment.entity.EquipmentInChild
;
import
com.skua.modules.equipment.service.IEquipmentInService
;
import
com.skua.modules.equipment.vo.EquipmentInExcel
;
import
com.skua.modules.erp.entity.*
;
import
com.skua.modules.erp.mapper.ApproveRecordMapper
;
import
com.skua.modules.erp.mapper.ERPPurchaseContractMapper
;
import
com.skua.modules.erp.mapper.PurchaseMaterialMapper
;
import
com.skua.modules.erp.service.IEROPurchaseContractService
;
import
com.skua.modules.erp.vo.PurchaseContractVO
;
import
com.skua.modules.guest.util.DateUtil
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.UUID
;
/**
* 采购合同
...
...
@@ -27,6 +39,9 @@ public class ERPPurchaseContractServiceImpl extends ServiceImpl<ERPPurchaseContr
@Resource
private
ApproveRecordMapper
recordMapper
;
@Autowired
private
IEquipmentInService
equipmentInService
;
/***
* 新增purchaseContractVO
* @param purchaseContractVO
...
...
@@ -131,7 +146,56 @@ public class ERPPurchaseContractServiceImpl extends ServiceImpl<ERPPurchaseContr
recordMapper
.
insert
(
record
)
;
// 审核通过,生成入库单据、物料单
if
(
inStock
){
try
{
syncEquipmentIn
(
purchaseContractVO
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
/***
* 同步入库
* @param purchaseContractVO
* @return
*/
public
int
syncEquipmentIn
(
PurchaseContractVO
purchaseContractVO
)
throws
Exception
{
EquipmentInDTO
equipmentInDTO
=
new
EquipmentInDTO
();
// EquipmentIn equipmentIn = new EquipmentIn();
//入库类型
equipmentInDTO
.
setDepartId
(
purchaseContractVO
.
getDepartId
()
);
//所属厂站
equipmentInDTO
.
setSuppliesWarehouseId
(
purchaseContractVO
.
getInWarehouseId
()
)
;
//入库仓库
equipmentInDTO
.
setInDate
(
DateUtil
.
formatDate
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss"
));
equipmentInDTO
.
setUseBy
(
BaseContextHandler
.
getUserId
()
)
;
//经办人
equipmentInDTO
.
setChooseTime
(
DateUtil
.
formatDate
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss"
)
);
//经办时间
equipmentInDTO
.
setRemark
(
purchaseContractVO
.
getRemark
()
);
//备注
List
<
EquipmentInChild
>
equipmentInChildrenList
=
new
ArrayList
<>();
EquipmentInChild
equipmentInChild
=
new
EquipmentInChild
();
//
if
(
purchaseContractVO
.
getMaterialList
()
!=
null
){
for
(
PurchaseMaterial
purchaseMaterial
:
purchaseContractVO
.
getMaterialList
()){
equipmentInChild
=
new
EquipmentInChild
();
//
equipmentInChild
.
setSparepartId
(
purchaseMaterial
.
getSparepartId
());
//物料编号
equipmentInChild
.
setInNum
(
new
BigDecimal
(
purchaseMaterial
.
getPurchaseNum
()));
//物料类别
equipmentInChild
.
setBatchNum
(
purchaseMaterial
.
getGoodCode
()
)
;
//批次号
equipmentInChildrenList
.
add
(
equipmentInChild
)
;
}
}
equipmentInDTO
.
setEquipmentInChildList
(
equipmentInChildrenList
);
//调用接口入库
equipmentInService
.
saveEquipmentIn
(
equipmentInDTO
)
;
/* ERPPurchaseContract erpPurchaseContract = this.baseMapper.selectById(purchaseContractVO.getId());
if(erpPurchaseContract == null ){
throw new Exception("采购合同记录不存在");
}*/
purchaseContractVO
.
setEquipmentInId
(
equipmentInDTO
.
getId
()
)
;
//记录入库单号
this
.
baseMapper
.
updateById
(
purchaseContractVO
)
;
return
1
;
}
}
...
...
sk-module-biz/src/main/java/com/skua/modules/erp/vo/MaterialSearchVO.java
0 → 100644
查看文件 @
831cef0
package
com
.
skua
.
modules
.
erp
.
vo
;
import
com.skua.core.aspect.annotation.Dict
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@Accessors
(
chain
=
true
)
@ApiModel
(
value
=
"Material物料查询对象"
,
description
=
"Material物料查询对象"
)
public
class
MaterialSearchVO
{
@ApiModelProperty
(
value
=
"物料编号"
)
private
String
sparepartCode
;
@ApiModelProperty
(
value
=
"物料名称"
)
private
String
sparepartName
;
@ApiModelProperty
(
value
=
"物料类型"
)
private
String
sparepartType
;
@ApiModelProperty
(
value
=
"所属厂站"
)
private
String
departId
;
}
sk-module-biz/src/main/java/com/skua/modules/safe/controller/DangerLevelManageController.java
查看文件 @
831cef0
...
...
@@ -78,6 +78,20 @@ public class DangerLevelManageController {
result
.
setResult
(
pageList
);
return
result
;
}
@AutoLog
(
value
=
"风险分级管控清单-列表查询"
)
@ApiOperation
(
value
=
"风险分级管控清单-列表查询"
,
notes
=
"风险分级管控清单-分页列表查询"
)
@GetMapping
(
value
=
"/dangerList"
)
public
Result
<
List
<
DangerLevelManage
>>
queryByDangerList
(
@RequestParam
(
name
=
"departId"
)
String
departId
)
{
Result
<
List
<
DangerLevelManage
>>
result
=
new
Result
<
List
<
DangerLevelManage
>>();
QueryWrapper
<
DangerLevelManage
>
queryWrapper
=
new
QueryWrapper
();
//QueryGenerator.initQueryWrapper(dangerLevelManage, req.getParameterMap());
queryWrapper
.
eq
(
"depart_id"
,
departId
);
List
<
DangerLevelManage
>
pageList
=
dangerLevelManageService
.
list
(
queryWrapper
);
result
.
setSuccess
(
true
);
result
.
setResult
(
pageList
);
return
result
;
}
/**
* 添加
...
...
sk-module-biz/src/main/java/com/skua/modules/safe/controller/app/APPDangerInspectionRecordController.java
查看文件 @
831cef0
...
...
@@ -58,8 +58,9 @@ public class APPDangerInspectionRecordController {
Result
<
IPage
<
DangerInspectionRecord
>>
result
=
new
Result
<
IPage
<
DangerInspectionRecord
>>();
QueryWrapper
<
DangerInspectionRecord
>
queryWrapper
=
new
QueryWrapper
<
DangerInspectionRecord
>();
// QueryGenerator.initQueryWrapper(dangerInspectionRecord, req.getParameterMap());
Page
<
DangerInspectionRecord
>
page
=
new
Page
<
DangerInspectionRecord
>(
pageNo
,
pageSize
);
queryWrapper
.
eq
(
"danger_id"
,
dangerInspectionRecord
.
getDangerId
());
if
(
dangerInspectionRecord
.
getDangerId
()
!=
null
){
queryWrapper
.
eq
(
"danger_id"
,
dangerInspectionRecord
.
getDangerId
());
}
if
(
StringUtils
.
isNotBlank
(
dangerInspectionRecord
.
getStartTime
())){
queryWrapper
.
ge
(
"report_date"
,
dangerInspectionRecord
.
getStartTime
()
)
;
}
...
...
sk-module-equipment/src/main/java/com/skua/modules/equipment/controller/EquipmentInController.java
查看文件 @
831cef0
...
...
@@ -242,8 +242,6 @@ public class EquipmentInController {
@ApiOperation
(
value
=
"入库-添加"
,
notes
=
"入库-添加"
)
@PostMapping
(
value
=
"/add"
)
public
Result
<
Object
>
add
(
@RequestBody
EquipmentInDTO
equipmentInDTO
)
throws
Exception
{
List
<
SuppliesWarehouse
>
suppliesWarehouseList
=
suppliesWarehouseService
.
list
();
Map
<
String
,
String
>
warehouseDictMap
=
suppliesWarehouseList
.
stream
().
collect
(
Collectors
.
toMap
(
SuppliesWarehouse:
:
getId
,
SuppliesWarehouse:
:
getDepartId
));
Result
<
Object
>
result
=
new
Result
<>();
...
...
sk-module-equipment/src/main/java/com/skua/modules/equipment/entity/EquipmentIn.java
查看文件 @
831cef0
...
...
@@ -147,4 +147,20 @@ public class EquipmentIn {
@ApiModelProperty
(
value
=
"采购部门"
)
@Dict
(
dicCode
=
"departCode"
)
private
String
purchaseDepart
;
public
EquipmentIn
(
)
{
}
public
EquipmentIn
(
String
departId
,
String
inOrder
,
String
purchaseCode
,
String
purchaseId
,
String
inType
,
String
inDate
,
String
suppliesWarehouseId
,
Integer
isConfirm
,
String
chooseTime
,
String
purchaseDepart
)
{
this
.
departId
=
departId
;
this
.
inOrder
=
inOrder
;
this
.
purchaseCode
=
purchaseCode
;
this
.
purchaseId
=
purchaseId
;
this
.
inType
=
inType
;
this
.
inDate
=
inDate
;
this
.
suppliesWarehouseId
=
suppliesWarehouseId
;
this
.
isConfirm
=
isConfirm
;
this
.
chooseTime
=
chooseTime
;
this
.
purchaseDepart
=
purchaseDepart
;
}
}
...
...
sk-module-equipment/src/main/java/com/skua/modules/equipment/service/IEquipmentInService.java
查看文件 @
831cef0
...
...
@@ -2,6 +2,7 @@ package com.skua.modules.equipment.service;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Constants
;
import
com.skua.modules.equipment.dto.EquipmentInDTO
;
import
com.skua.modules.equipment.entity.EquipmentIn
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.skua.modules.equipment.vo.EquipmentInExcel
;
...
...
@@ -17,4 +18,9 @@ public interface IEquipmentInService extends IService<EquipmentIn> {
List
<
EquipmentInExcel
>
queryExport
(
@Param
(
Constants
.
WRAPPER
)
QueryWrapper
<
EquipmentIn
>
queryWrapper
);
/***
* 入库新增
* @param equipmentInDTO
*/
public
int
saveEquipmentIn
(
EquipmentInDTO
equipmentInDTO
)
throws
Exception
;
}
...
...
sk-module-equipment/src/main/java/com/skua/modules/equipment/service/impl/EquipmentInServiceImpl.java
查看文件 @
831cef0
package
com
.
skua
.
modules
.
equipment
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.google.common.collect.Maps
;
import
com.skua.core.api.vo.Result
;
import
com.skua.core.exception.JeecgBootException
;
import
com.skua.core.util.ConvertUtils
;
import
com.skua.core.util.DateUtils
;
import
com.skua.modules.equipment.dto.EquipmentInDTO
;
import
com.skua.modules.equipment.entity.EquipmentIn
;
import
com.skua.modules.equipment.entity.EquipmentInChild
;
import
com.skua.modules.equipment.entity.EquipmentSparepart
;
import
com.skua.modules.equipment.mapper.EquipmentInMapper
;
import
com.skua.modules.equipment.service.IEquipmentInChildService
;
import
com.skua.modules.equipment.service.IEquipmentInService
;
import
com.skua.modules.equipment.service.IEquipmentSparepartService
;
import
com.skua.modules.equipment.service.ISupplierManageService
;
import
com.skua.modules.equipment.vo.EquipmentInExcel
;
import
com.skua.modules.equipment.vo.EquipmentInVO
;
import
com.skua.modules.flow.utils.ObjectUtil
;
import
com.skua.modules.supplies.entity.EquipmentSparepartSupplies
;
import
com.skua.modules.supplies.entity.SuppliesWarehouse
;
import
com.skua.modules.supplies.mapper.PurchaseInfoMapper
;
import
com.skua.modules.supplies.service.IEquipmentSparepartSuppliesService
;
import
com.skua.modules.supplies.service.IPurchaseInfoDetailService
;
import
com.skua.modules.supplies.service.ISuppliesWarehouseService
;
import
com.skua.tool.util.BeanExtUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.support.TransactionTemplate
;
import
javax.annotation.Resource
;
import
java.math.BigDecimal
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.UUID
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.stream.Collectors
;
/**
* 入库
*/
@Service
public
class
EquipmentInServiceImpl
extends
ServiceImpl
<
EquipmentInMapper
,
EquipmentIn
>
implements
IEquipmentInService
{
@
Autowired
@
Resource
private
EquipmentInMapper
equipmentInMapper
;
@Autowired
private
TransactionTemplate
transactionTemplate
;
//事务
@Autowired
private
IEquipmentInChildService
iEquipmentInChildService
;
@Qualifier
(
value
=
"taskExecutor"
)
@Autowired
private
ThreadPoolTaskExecutor
taskExecutor
;
@Autowired
private
IEquipmentSparepartSuppliesService
sparepartSuppliesService
;
@Autowired
private
IEquipmentSparepartService
iEquipmentSparepartService
;
@Autowired
private
ISuppliesWarehouseService
suppliesWarehouseService
;
@Override
public
List
<
EquipmentInExcel
>
queryExport
(
QueryWrapper
<
EquipmentIn
>
queryWrapper
)
{
return
equipmentInMapper
.
queryExport
(
queryWrapper
);
}
/***
*
新增录入
* @param equipmentIn
* @
retur
n
*
入库
* @param equipmentIn
DTO
* @
throws Exceptio
n
*/
public
int
saveEquipmentIn
(
EquipmentIn
equipmentIn
){
public
int
saveEquipmentIn
(
EquipmentInDTO
equipmentInDTO
)
throws
Exception
{
List
<
SuppliesWarehouse
>
suppliesWarehouseList
=
suppliesWarehouseService
.
list
();
//供应商列表
Map
<
String
,
String
>
warehouseDictMap
=
suppliesWarehouseList
.
stream
().
collect
(
Collectors
.
toMap
(
SuppliesWarehouse:
:
getId
,
SuppliesWarehouse:
:
getDepartId
));
if
(
equipmentInDTO
.
getEquipmentInChildList
()
==
null
||
equipmentInDTO
.
getEquipmentInChildList
().
isEmpty
())
{
throw
new
JeecgBootException
(
"请选择入库备件!"
);
}
if
(
StringUtils
.
isBlank
(
equipmentInDTO
.
getSuppliesWarehouseId
()))
{
throw
new
JeecgBootException
(
"请选择入库仓库!"
);
}
/*if (StringUtils.isBlank(equipmentInDTO.getInType())) {
throw new JeecgBootException("请选择入库类型!");
}*/
// 入库单号
if
(
StringUtils
.
isEmpty
(
equipmentInDTO
.
getInOrder
()))
{
String
inOrder
=
"RK-"
+
DateUtils
.
format
(
new
Date
(),
"YYYYMMdd"
+
"-"
+
System
.
currentTimeMillis
());
equipmentInDTO
.
setInOrder
(
inOrder
);
}
// 入库表主键
String
inId
=
UUID
.
randomUUID
().
toString
().
replaceAll
(
"-"
,
""
);
equipmentInDTO
.
setId
(
inId
);
EquipmentIn
equipmentIn
=
BeanExtUtils
.
bean2Bean
(
equipmentInDTO
,
EquipmentIn
.
class
);
equipmentIn
.
setIsConfirm
(
1
);
transactionTemplate
.
execute
((
transactionStatus
->
{
// equipmentInService.save(equipmentIn);
this
.
baseMapper
.
insert
(
equipmentIn
);
return
1
;
}));
CountDownLatch
countDownLatch
=
new
CountDownLatch
(
equipmentInDTO
.
getEquipmentInChildList
().
size
());
/* //如果是采购入库
Map<String, PurchaseInfoDetail> purchaseMap = Maps.newHashMap();
if ("cg".equals(equipmentInDTO.getInType()) && StringUtils.isNotEmpty(equipmentInDTO.getPurchaseCode())) {
String purchaseId = equipmentInDTO.getPurchaseId();
PurchaseInfo purchaseInfo = purchaseInfoMapper.selectById(purchaseId);
List<PurchaseInfoDetail> purchaseInfoDetails = purchaseInfoDetailService.list( (new QueryWrapper<PurchaseInfoDetail>().eq( "purchase_info_id", purchaseInfo.getId() )) );
for (PurchaseInfoDetail purchaseInfoDetail : purchaseInfoDetails) {
purchaseMap.put(purchaseInfoDetail.getSparepartId(), purchaseInfoDetail);
}
}*/
for
(
EquipmentInChild
equipmentInChild
:
equipmentInDTO
.
getEquipmentInChildList
())
{
equipmentInChild
.
setInId
(
inId
);
taskExecutor
.
execute
(()
->
{
try
{
String
sparepartId
=
equipmentInChild
.
getSparepartId
();
String
suppliesWarehouseId
=
equipmentInDTO
.
getSuppliesWarehouseId
();
//根据物资id和仓库id获取库存
QueryWrapper
<
EquipmentSparepart
>
sparepartQueryWrapper
=
new
QueryWrapper
<>();
sparepartQueryWrapper
.
eq
(
"supplies_id"
,
sparepartId
).
eq
(
"supplies_warehouse_id"
,
suppliesWarehouseId
);
EquipmentSparepart
equipmentSparepart
=
iEquipmentSparepartService
.
getOne
(
sparepartQueryWrapper
);
if
(
ObjectUtil
.
isEmpty
(
equipmentSparepart
))
{
//物料信息
EquipmentSparepartSupplies
supplies
=
sparepartSuppliesService
.
getById
(
sparepartId
);
equipmentSparepart
=
new
EquipmentSparepart
();
BeanUtils
.
copyProperties
(
supplies
,
equipmentSparepart
);
equipmentSparepart
.
setId
(
null
);
equipmentSparepart
.
setStorageNum
(
BigDecimal
.
ZERO
);
equipmentSparepart
.
setSuppliesId
(
sparepartId
);
equipmentSparepart
.
setSuppliesWarehouseId
(
suppliesWarehouseId
);
equipmentSparepart
.
setDepartId
(
warehouseDictMap
.
get
(
suppliesWarehouseId
));
//如果没有物料库存信息,新增库存信息为0
iEquipmentSparepartService
.
saveOrUpdate
(
equipmentSparepart
);
equipmentSparepart
=
iEquipmentSparepartService
.
getOne
(
sparepartQueryWrapper
);
}
return
0
;
BigDecimal
resetStorageNum
=
equipmentSparepart
.
getStorageNum
().
add
(
equipmentInChild
.
getInNum
());
equipmentSparepart
.
setStorageNum
(
resetStorageNum
);
equipmentInChild
.
setCurStorageNum
(
resetStorageNum
);
Integer
version
=
equipmentSparepart
.
getVersion
();
String
id
=
equipmentSparepart
.
getId
();
Integer
executeRes
=
transactionTemplate
.
execute
(
transactionStatus
->
{
iEquipmentSparepartService
.
updateStorageNumById
(
id
,
resetStorageNum
.
doubleValue
(),
version
);
iEquipmentInChildService
.
saveOrUpdate
(
equipmentInChild
);
//===========
//如果是采购入库
/* if ("cg".equals(equipmentInDTO.getInType()) && StringUtils.isNotEmpty(equipmentInDTO.getPurchaseCode())) {
BigDecimal inNum = equipmentInChild.getInNum();
PurchaseInfoDetail purchaseInfoDetail = purchaseMap.get(sparepartId);
//剩余采购物料数量
Double realTimeCount = ConvertUtils.getDouble(purchaseInfoDetail.getRealTimeCount(), 0);
Double real = new BigDecimal(realTimeCount).subtract(inNum).doubleValue();
purchaseInfoDetail.setRealTimeCount(real < 0 ? "0" : ConvertUtils.getString(ConvertUtils.getDouble(real, 0, 2)));
//采购数量
String count = purchaseInfoDetail.getCount();
//已经入库数量
purchaseInfoDetail.setInCount(ConvertUtils.getString(ConvertUtils.getDouble(count, 0) - ConvertUtils.getDouble(real, 0)));
UpdateWrapper<PurchaseInfoDetail> purchaseInfoDetailUpdateWrapper = new UpdateWrapper<>();
int detailVersion = purchaseInfoDetail.getVersion();
purchaseInfoDetailUpdateWrapper.eq("version", detailVersion).eq("id", purchaseInfoDetail.getId()).set("version", detailVersion + 1);
purchaseInfoDetailService.update(purchaseInfoDetail, purchaseInfoDetailUpdateWrapper);
}*/
//=============
return
1
;
});
}
catch
(
Exception
e1
)
{
e1
.
printStackTrace
();
// log.error("异常error: {}", e1.getMessage());
}
finally
{
countDownLatch
.
countDown
();
}
});
}
countDownLatch
.
await
();
return
1
;
}
}
...
...
sk-module-equipment/src/main/java/com/skua/modules/supplies/entity/EquipmentSparepartSupplies.java
查看文件 @
831cef0
...
...
@@ -257,4 +257,15 @@ public class EquipmentSparepartSupplies {
@TableField
(
exist
=
false
)
@ApiModelProperty
(
value
=
"计划采购数量"
)
private
String
purchaseNum
;
@TableField
(
exist
=
false
)
@ApiModelProperty
(
value
=
"计划采购数量"
)
private
String
sparepartId
;
public
String
getSparepartId
()
{
return
id
;
}
}
...
...
sk-module-equipment/src/main/java/com/skua/modules/supplies/mapper/EquipmentSparepartSuppliesMapper.java
查看文件 @
831cef0
...
...
@@ -18,5 +18,7 @@ public interface EquipmentSparepartSuppliesMapper extends BaseMapper<EquipmentSp
* @param depId
* @return
*/
public
IPage
<
EquipmentSparepartSupplies
>
queryPageByOut
(
Page
<
EquipmentSparepartSupplies
>
page
,
String
depId
);
public
IPage
<
EquipmentSparepartSupplies
>
queryPageByOut
(
Page
<
EquipmentSparepartSupplies
>
page
,
@Param
(
"depId"
)
String
depId
,
@Param
(
"sparepartName"
)
String
sparepartName
,
@Param
(
"sparepartType"
)
String
sparepartType
,
@Param
(
"sparepartCode"
)
String
sparepartCode
);
}
...
...
sk-module-equipment/src/main/java/com/skua/modules/supplies/mapper/xml/EquipmentSparepartSuppliesMapper.xml
查看文件 @
831cef0
...
...
@@ -6,12 +6,22 @@
<select
id=
"queryPageByOut"
resultType=
"com.skua.modules.supplies.entity.EquipmentSparepartSupplies"
>
select st.item_text 'sparepart_type_name' , aaa.out_num, ss.* from equipment_sparepart_supplies ss
left join equipment_sparepart_type st on ss.sparepart_type = st.id
left join (
select sum(out_num) out_num ,sparepart_id from equipment_out_child
where
YEAR(create_time) = YEAR(CURRENT_DATE - INTERVAL 1 YEAR)
group by sparepart_id
) aaa on aaa.sparepart_id = ss.id
<where>
<if
test=
"sparepartName != null and sparepartName !=''"
>
and ss.sparepart_name like CONCAT('%', #{sparepartName},'%')
</if>
<if
test=
"sparepartCode != null and sparepartCode !=''"
>
and ss.sparepart_code like CONCAT('%', #{sparepartCode},'%')
</if>
<if
test=
"sparepartType != null and sparepartType !=''"
>
and ss.sparepart_type = #{sparepartType}
</if>
</where>
</select>
</mapper>
\ No newline at end of file
...
...
sk-module-equipment/src/main/java/com/skua/modules/supplies/service/IEquipmentSparepartSuppliesService.java
查看文件 @
831cef0
...
...
@@ -15,5 +15,5 @@ public interface IEquipmentSparepartSuppliesService extends IService<EquipmentSp
* @param depId
* @return
*/
public
IPage
<
EquipmentSparepartSupplies
>
queryPageByOut
(
Page
<
EquipmentSparepartSupplies
>
page
,
String
depId
);
public
IPage
<
EquipmentSparepartSupplies
>
queryPageByOut
(
Page
<
EquipmentSparepartSupplies
>
page
,
String
depId
,
String
sparepartName
,
String
sparepartType
,
String
sparepartCode
);
}
...
...
sk-module-equipment/src/main/java/com/skua/modules/supplies/service/impl/EquipmentSparepartSuppliesServiceImpl.java
查看文件 @
831cef0
...
...
@@ -20,7 +20,7 @@ public class EquipmentSparepartSuppliesServiceImpl extends ServiceImpl<Equipment
* @param depId
* @return
*/
public
IPage
<
EquipmentSparepartSupplies
>
queryPageByOut
(
Page
<
EquipmentSparepartSupplies
>
page
,
String
depId
){
return
baseMapper
.
queryPageByOut
(
page
,
depId
);
public
IPage
<
EquipmentSparepartSupplies
>
queryPageByOut
(
Page
<
EquipmentSparepartSupplies
>
page
,
String
depId
,
String
sparepartName
,
String
sparepartType
,
String
sparepartCode
){
return
baseMapper
.
queryPageByOut
(
page
,
depId
,
sparepartName
,
sparepartType
,
sparepartCode
);
}
}
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论