e89392f5 康伟

kangwei : 补充 入库验收单审核列表接口

                导出pdf文件接口
1 个父辈 20102728
......@@ -15,6 +15,7 @@ import com.skua.core.query.QueryGenerator;
import com.skua.core.service.ISequenceService;
import com.skua.core.util.ConvertUtils;
import com.skua.modules.erp.entity.DistributContract;
import com.skua.modules.erp.entity.DistributMaterial;
import com.skua.modules.erp.entity.PurchaseMaterial;
import com.skua.modules.erp.service.IDistributContractService;
import java.util.Date;
......@@ -25,6 +26,7 @@ import com.skua.modules.erp.service.IPurchaseMaterialService;
import com.skua.modules.erp.vo.DistributContractVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
......@@ -93,8 +95,18 @@ public class DistributContractController {
public Result<DistributContractVO> add(@RequestBody DistributContractVO distributContract) {
Result<DistributContractVO> result = new Result<DistributContractVO>();
try {
distributContractService.saveDistributContractVO(distributContract);
result.success("添加成功!");
String goodsCode = checkSameGoodCode(distributContract.getMaterialList());
if (StringUtils.isNotEmpty(goodsCode)) {
result.error500("操作失败,货号["+ goodsCode +"]重复!");
}else{
String errMsg = distributContractService.saveDistributContractVO(distributContract);
if(errMsg != null ){
result.error500(errMsg);
}else {
result.success("添加成功!");
}
}
} catch (Exception e) {
log.error(e.getMessage(),e);
result.error500("操作失败");
......@@ -111,15 +123,37 @@ public class DistributContractController {
if(distributContractEntity==null) {
result.error500("未找到对应实体");
}else {
boolean ok = distributContractService.updateDistributContractVO(distributContract);
//TODO 返回false说明什么?
if(ok) {
result.success("修改成功!");
String goodsCode = checkSameGoodCode(distributContract.getMaterialList());
if (StringUtils.isNotEmpty(goodsCode)) {
result.error500("操作失败,货号["+ goodsCode +"]重复!");
}else{
String errMsg = distributContractService.updateDistributContractVO(distributContract);
if(errMsg != null ){
result.error500(errMsg);
}else{
result.success("修改成功!");
}
}
}
return result;
}
/***
* 校验是否有重复的货号
* @param materialList
* @return
*/
public String checkSameGoodCode(List<DistributMaterial> materialList){
String goodCode = "";
for( DistributMaterial material : materialList){
if(goodCode.contains( material.getGoodCode() )){
goodCode = material.getGoodCode();
break;
}
goodCode = goodCode + ","+material.getGoodCode();
}
return null;
}
@AutoLog(value = "erp分销合同-通过id删除")
@ApiOperation(value="erp分销合同-通过id删除", notes="erp分销合同-通过id删除")
......@@ -216,12 +250,15 @@ public class DistributContractController {
@AutoLog(value = "erp分销合同-根据货号查询采购合同物料清单")
@ApiOperation(value="erp分销合同-根据货号查询采购合同物料清单", notes="erp分销合同-根据货号查询采购合同物料清单")
@GetMapping(value = "/queryMaterialByGoodCode")
public Result<PurchaseMaterial> queryMaterialByGoodCode(@RequestParam(name="goodCode") String goodCode) {
public Result<PurchaseMaterial> queryMaterialByGoodCode(@RequestParam(name="goodCode") String goodCode,@RequestParam(name="departId") String departId) {
Result<PurchaseMaterial> result = new Result<PurchaseMaterial>();
List<PurchaseMaterial> purchaseMaterialList = purchaseMaterialService.queryMaterialByGoodCode(goodCode,BaseContextHandler.getRealDepartId());
result.setSuccess(true);
List<PurchaseMaterial> purchaseMaterialList = purchaseMaterialService.queryMaterialByGoodCode(goodCode,departId);
if(purchaseMaterialList != null && !purchaseMaterialList.isEmpty()){
result.setSuccess(true);
result.setResult(purchaseMaterialList.get(0));
}else{
result.error500("根据[厂站]以及[货号]未找到采购合同!");
}
return result;
}
......
......@@ -166,9 +166,9 @@ public class MaterialINController {
@AutoLog(value = "erp--物料(药剂)入库--药剂到货日验收记录")
@ApiOperation(value="erp--物料(药剂)入库-药剂到货日验收记录", notes="erp--物料(药剂)入库-药剂到货日验收记录")
@GetMapping(value = "/arrivalRecordList")
public Result<List<MaterialIN>> arrivalRecordList(MaterialIN materialIN) {
Result<List<MaterialIN>> result = new Result<List<MaterialIN>>();
QueryWrapper<MaterialIN> queryWrapper = new QueryWrapper();//QueryGenerator.initQueryWrapper(materialIN, req.getParameterMap());
public Result<List<ArrivalRecordExcelExportVO>> arrivalRecordList(MaterialIN materialIN) {
Result<List<ArrivalRecordExcelExportVO>> result = new Result<List<ArrivalRecordExcelExportVO>>();
/* QueryWrapper<MaterialIN> queryWrapper = new QueryWrapper();//QueryGenerator.initQueryWrapper(materialIN, req.getParameterMap());
if(StringUtils.isNotBlank(materialIN.getGoodCode())){
queryWrapper.like("good_code",materialIN.getGoodCode());
}
......@@ -188,7 +188,9 @@ public class MaterialINController {
queryWrapper.eq("purchase_contract_id",materialIN.getPurchaseContractId());
}
queryWrapper.eq("audit_status","3");
List<MaterialIN> pageList = materialINService.list( queryWrapper);
List<MaterialIN> pageList = materialINService.list( queryWrapper);*/
List<ArrivalRecordExcelExportVO> pageList = materialINService.queryArrivalRecordByList(materialIN);
result.setSuccess(true);
result.setResult(pageList);
return result;
......@@ -401,7 +403,7 @@ public class MaterialINController {
@AutoLog(value = "erp--药剂到货验收记录表")
@ApiOperation(value="erp--药剂到货验收记录表", notes="erp--药剂到货验收记录表")
@RequestMapping(value = "/exportArrivalRecordExcel")
@GetMapping(value = "/exportArrivalRecordExcel")
public ModelAndView exportExcel(HttpServletRequest request, HttpServletResponse response) {
MaterialIN materialIN = null;
// Step.1 组装查询条件
......@@ -429,7 +431,7 @@ public class MaterialINController {
}
@AutoLog(value = "erp--导出物资验收pdf文件")
@ApiOperation(value="erp--导出物资验收pdf文件", notes="erp--导出物资验收pdf文件")
@RequestMapping(value = "/exportArrivalRecordPDF")
@GetMapping(value = "/exportArrivalRecordPDF")
public void exportPDF(HttpServletRequest request, HttpServletResponse response) {
// Step.1 组装查询条件
//QueryWrapper<MaterialIN> queryWrapper = null;
......
......@@ -28,6 +28,10 @@ public class DistributMaterial {
@TableId(type = IdType.UUID)
@ApiModelProperty(value = "主键")
private String id;
/**部门编号冗余*/
private String departId;
/**分销合同编号*/
@Excel(name = "分销合同编号", width = 15)
@ApiModelProperty(value = "分销合同编号")
......
......@@ -22,4 +22,12 @@ public interface DistributMaterialMapper extends BaseMapper<DistributMaterial> {
* @return
*/
public int checkGoodCode(@Param("id")String id,@Param("goodCode") String goodCode);
/***
* 根据departId或code校验货号是否唯一
* @param goodsCode
* @param departId
* @return
*/
int checkGoodCodeAndDepartId(@Param("goodCode") String goodsCode, @Param("departId") String departId);
}
......
......@@ -47,7 +47,7 @@ public interface PurchaseMaterialMapper extends BaseMapper<PurchaseMaterial> {
* @param departId
* @return
*/
List<PurchaseMaterial> queryByList( @Param("goodCode")String goodCode, @Param("departId")String departId);
List<PurchaseMaterial> queryMaterialByGoodCode( @Param("goodCode")String goodCode, @Param("departId")String departId);
/***
......
......@@ -21,4 +21,10 @@
where good_code = #{goodCode}
<if test="id != null and id !=''">and id = #{id}</if>
</select>
<!-- 校验货号是否唯一 -->
<select id="checkGoodCodeAndDepartId" resultType="java.lang.Integer">
select count(1) from erp_distribut_material
where good_code = #{goodCode} and depart_id = #{departId}
</select>
</mapper>
\ No newline at end of file
......
......@@ -13,21 +13,21 @@
<where>
mi.audit_status =3
<if test="startTime != null and startTime !=''">
and mi.arrive_time &gt;= #{param.startTime}
and mi.arrive_time &gt;= #{startTime}
</if>
<if test="endTime != null param.endTime !=''">
and mi.arrive_time &lt;= #{param.endTime}
<if test="endTime != null and endTime !=''">
and mi.arrive_time &lt;= #{endTime}
</if>
<if test="goodCode != null goodCode !=''">
<if test="goodCode != null and goodCode !=''">
and mi.good_code like CONCAT('',#{goodCode},'%')
</if>
<if test="sparepartName != null sparepartName !=''">
<if test="sparepartName != null and sparepartName !=''">
and mi.sparepart_name like CONCAT('%',#{sparepartName},'%')
</if>
<if test="departId != null departId !=''">
<if test="departId != null and departId !=''">
and mi.depart_id = #{departId}
</if>
<if test="supplierId != null supplierId !=''">
<if test="supplierId != null and supplierId !=''">
and mi.supplier_id = #{supplierId}
</if>
</where>
......@@ -35,31 +35,31 @@
</select>
<!--获取入库审批列表:根据部门、采购合同、供应商、药剂分组搜索 -->
<select id="queryArrivalRecordByList" resultType="com.skua.modules.erp.vo.ArrivalRecordExcelExportVO">
<select id="selectAuditMaterialINByPage" resultType="com.skua.modules.erp.vo.ArrivalRecordExcelExportVO">
select sparepart_id , purchase_contract_id,depart_id ,supplier_id,
sum(purchase_num) 'purchase_num',measuring_unit,specification,sparepart_name,tax_amount,
purchase_price,distribut_price,sum(purchase_total_price) 'purchase_total_price',sum(distribut_total_price) 'distribut_total_price',sum(total_price_tax) 'total_price_tax'
from erp_material_in
<where>
mi.audit_status =3
<if test="startTime != null and startTime !=''">
and arrive_time &gt;= #{param.startTime}
<if test="materialIN.startTime != null and materialIN.startTime !=''">
and arrive_time &gt;= #{materialIN.startTime}
</if>
<if test="endTime != null param.endTime !=''">
and arrive_time &lt;= #{param.endTime}
<if test="materialIN.endTime != null and materialIN.endTime !=''">
and arrive_time &lt;= #{materialIN.endTime}
</if>
<if test="departId != null departId !=''">
and depart_id = #{departId}
<if test="materialIN.departId != null and materialIN.departId !=''">
and depart_id = #{materialIN.departId}
</if>
<if test="supplierId != null supplierId !=''">
and supplier_id = #{supplierId}
<if test="materialIN.supplierId != null and materialIN.supplierId !=''">
and supplier_id = #{materialIN.supplierId}
</if>
<if test="purchaseContractId != null purchaseContractId !=''">
and purchase_contract_id = #{purchaseContractId}
<if test="materialIN.purchaseContractId != null and materialIN.purchaseContractId !=''">
and purchase_contract_id = #{materialIN.purchaseContractId}
</if>
</where>
group by sparepart_id , purchase_contract_id,depart_id,supplier_id
group by sparepart_id,purchase_contract_id,depart_id,supplier_id
</select>
......
......@@ -35,16 +35,12 @@
left join ajh_supplier_manage sm on sm.id = aaa.supplier_id
</select>
<select id="queryByList" resultType="com.skua.modules.erp.entity.PurchaseMaterial">
<select id="queryMaterialByGoodCode" resultType="com.skua.modules.erp.entity.PurchaseMaterial">
select ss.sparepart_code,ss.sparepart_name, st.item_text as 'sparepart_type_name',sm.supp_name as 'supplier_name', aaa.*
from (
select m.* from erp_purchase_material m , erp_purchase_contract pc where m.contract_id = pc.id
<if test="goodCode != null and goodCode != ''">
AND m.good_code like concat('', #{goodCode}, '%')
</if>
<if test="departId != null and departId != ''">
AND pc.departs like concat('%', #{departId}, '%')
</if>
AND m.good_code = #{goodCode}
AND pc.departs like CONCAT('%', #{departId}, '%')
limit 1
) aaa
left join equipment_sparepart_supplies ss on aaa.sparepart_id = ss.id
......@@ -66,15 +62,15 @@
<select id="queryPurchaseMaterialListByIn" resultType="com.skua.modules.erp.vo.PurchaseMaterialVO">
select dm.distribut_price ,dm.distribut_total_price ,ss.sparepart_name, st.item_text as 'sparepart_type_name',sm.supp_name as 'supplier_name',
aaa.* from (
select pm.*
from erp_purchase_material pm , erp_purchase_contract pc
select pm.* ,pc.depart_id
from erp_purchase_material pm , erp_purchase_contract pc
where pm.contract_id =pc.id
<if test="param.sparepartCode != null and param.sparepartCode !=''"> and pc.departs like concat('%', #{param.departId}, '%')</if>
<if test="param.sparepartCode != null and param.sparepartCode !=''"> and pm.sparepart_code =#{param.sparepartCode}</if>
<if test="param.sparepartType != null and param.sparepartType !=''"> and pm.sparepart_type in (${param.sparepartType}) </if>
<if test="param.sparepartName != null and param.sparepartName !=''"> and pm.sparepart_name like concat('%', #{param.sparepartName}, '%')</if>
)aaa
left join erp_distribut_material dm on aaa.good_code = dm.good_code
left join erp_distribut_material dm on (aaa.good_code = dm.good_code and aaa.depart_id)
left join equipment_sparepart_supplies ss on aaa.sparepart_id = ss.id
left join equipment_sparepart_type st on st.id = aaa.sparepart_type
left join ajh_supplier_manage sm on sm.id = aaa.supplier_id
......
......@@ -20,14 +20,14 @@ public interface IDistributContractService extends IService<DistributContract> {
* 新增DistributContractVO
* @param distributContractVO
*/
public void saveDistributContractVO(DistributContractVO distributContractVO);
public String saveDistributContractVO(DistributContractVO distributContractVO);
/**
* 修改DistributContractVOVO
* @param distributContractVO
* @return
*/
public boolean updateDistributContractVO(DistributContractVO distributContractVO);
public String updateDistributContractVO(DistributContractVO distributContractVO);
/***
* 删除DistributContractVOVO
......
......@@ -69,8 +69,4 @@ public interface IERPPurchaseContractService extends IService<ERPPurchaseContrac
* @return
*/
int syncEquipmentIn(PurchaseContractVO purchaseContractVO)throws Exception;
}
......
......@@ -12,7 +12,9 @@ import com.skua.modules.erp.mapper.PurchaseMaterialMapper;
import com.skua.modules.erp.service.IDistributContractService;
import com.skua.modules.erp.vo.DistributContractVO;
import com.skua.modules.erp.vo.PurchasePlanVO;
import com.skua.modules.system.mapper.SysDepartMapper;
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;
......@@ -31,21 +33,39 @@ public class DistributContractServiceImpl extends ServiceImpl<DistributContractM
@Resource
private ApproveRecordMapper recordMapper;//申请记录
@Autowired
private SysDepartMapper departMapper;
/***
* 新增DistributContract
* @param distributContractVO
*/
public void saveDistributContractVO(DistributContractVO distributContractVO){
int count = this.baseMapper.insert( distributContractVO );
if(count > 0 && distributContractVO.getMaterialList() != null && !distributContractVO.getMaterialList().isEmpty()){
@Transactional
public String saveDistributContractVO(DistributContractVO distributContractVO){
String errMsg = null;
if(distributContractVO.getMaterialList() != null && !distributContractVO.getMaterialList().isEmpty()){
for(DistributMaterial material : distributContractVO.getMaterialList()){
material.setId(null);
material.setContractId( distributContractVO.getId() );
materialMapper.insert( material );
//根据deptid与goodscode校验
int count = checkGoodCodeAndDepartId( material.getGoodCode(),distributContractVO.getDepartId() );
if(count > 0 ){
errMsg = "所属厂站["+departMapper.selectById(distributContractVO.getDepartId()).getDepartName()+"]下的货号["+material.getGoodCode()+"]已经分销过!";
break;
}
}
}
if(errMsg != null ){
int count = this.baseMapper.insert( distributContractVO );
if(count > 0 && distributContractVO.getMaterialList() != null && !distributContractVO.getMaterialList().isEmpty()){
for(DistributMaterial material : distributContractVO.getMaterialList()){
material.setId(null);
material.setContractId( distributContractVO.getId() );
material.setDepartId(distributContractVO.getDepartId() ) ;//冗余所属厂站
materialMapper.insert( material );
}
}
}
return errMsg;
}
......@@ -54,23 +74,51 @@ public class DistributContractServiceImpl extends ServiceImpl<DistributContractM
* @param distributContractVO
* @return
*/
public boolean updateDistributContractVO(DistributContractVO distributContractVO){
int count = this.baseMapper.updateById( distributContractVO );
// ge根据计划编号删除清单集合
materialMapper.delByContractId(distributContractVO.getId() ) ;
public String updateDistributContractVO(DistributContractVO distributContractVO){
if(count > 0 && distributContractVO.getMaterialList() != null && !distributContractVO.getMaterialList().isEmpty()){
String errMsg = null;
if(distributContractVO.getMaterialList() != null && !distributContractVO.getMaterialList().isEmpty()){
for(DistributMaterial material : distributContractVO.getMaterialList()){
material.setId(null);
material.setContractId( distributContractVO.getId() );
materialMapper.insert( material );
//根据deptid与goodscode校验
int count = checkGoodCodeAndDepartId( material.getGoodCode(),distributContractVO.getDepartId() );
if(count > 1 ){
errMsg = "所属厂站["+departMapper.selectById(distributContractVO.getDepartId()).getDepartName()+"]下的货号["+material.getGoodCode()+"]已经分销过!";
break;
}
}
}
return count > 0 ? true :false;
if(errMsg != null ){
int count = this.baseMapper.updateById( distributContractVO );
// ge根据计划编号删除清单集合
materialMapper.delByContractId(distributContractVO.getId() ) ;
if(count > 0 && distributContractVO.getMaterialList() != null && !distributContractVO.getMaterialList().isEmpty()){
for(DistributMaterial material : distributContractVO.getMaterialList()){
material.setId(null);
material.setContractId( distributContractVO.getId() );
material.setDepartId(distributContractVO.getDepartId() ) ;//冗余所属厂站
materialMapper.insert( material );
}
}
}
return errMsg;
}
/***
* 根据所属厂长、以及goodcode校验是否存在
* @param goodsCode
* @param departId
* @return
*/
public int checkGoodCodeAndDepartId(String goodsCode ,String departId){
return materialMapper.checkGoodCodeAndDepartId( goodsCode ,departId );
}
/***
* 删除DistributContractVOVO
* @param contractId
*/
......
......@@ -36,7 +36,7 @@ public class PurchaseMaterialServiceImpl extends ServiceImpl<PurchaseMaterialMap
* @return
*/
public List<PurchaseMaterial> queryMaterialByGoodCode(String goodCode, String departId){
return this.baseMapper.queryByList(goodCode,departId);
return this.baseMapper.queryMaterialByGoodCode(goodCode,departId);
}
/**
* 药剂入库查询结果:采购物料清单+分销单价+分销总价
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!