68cc9b2c 康伟

kangwei :采购入库相关接口

1 个父辈 f3d6fcf1
正在显示 33 个修改的文件 包含 470 行增加110 行删除
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.skua.tool.annotation.Anonymous;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -26,6 +27,7 @@ public interface CommonSqlMapper {
Page<Map<String, Object>> queryWrapperForPage(Page<?> page, @Param("sql") String sql, @Param(Constants.WRAPPER) QueryWrapper<?> queryWrapper);
@Anonymous
List<Map<String, Object>> queryForList(@Param("sql") String sql);
List<Map<String, Object>> queryWrapperForList(@Param("sql") String sql, @Param(Constants.WRAPPER) QueryWrapper<?> queryWrapper);
......
......@@ -30,11 +30,10 @@ public class SkApplication {
"Doc: \t\thttp://" + ip + ":" + port + path + "/doc.html\n" +
"----------------------------------------------------------");
}
// @Configuration
// @Profile("dev")
// @ComponentScan(lazyInit = true)
// static class LocalConfig {
// }
}
\ No newline at end of file
}
......
......@@ -42,13 +42,6 @@ import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/**
* <pre>
* erp分销合同
* </pre>
* @author 开发者姓名
* @version V0.1, 开发时间
*/
@Slf4j
@Api(tags="erp分销合同")
@RestController("webDistributContractController")
......
......@@ -45,7 +45,6 @@ public class ErpCommonController {
@Autowired
private IEquipmentSparepartTypeService equipmentSparepartTypeService;
@AutoLog(value = "ERP-采购计划--物料列表")
@ApiOperation(value = "ERP-采购计划--物料列表", notes = "ERP-采购计划--物料列表")
@RequestMapping(value = "/sparepartList", method = RequestMethod.GET)
......
......@@ -13,10 +13,12 @@ import com.skua.core.aspect.annotation.AutoLog;
import com.skua.core.query.QueryGenerator;
import com.skua.core.util.ConvertUtils;
import com.skua.modules.erp.entity.MaterialAcceptanceForm;
import com.skua.modules.erp.entity.MaterialIN;
import com.skua.modules.erp.service.IMaterialAcceptanceFormService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.skua.modules.erp.service.IMaterialINService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
......@@ -49,7 +51,8 @@ import io.swagger.annotations.ApiOperation;
public class MaterialAcceptanceFormController {
@Autowired
private IMaterialAcceptanceFormService materialAcceptanceFormService;
@Autowired
private IMaterialINService materialINService;
/**
* <pre>
* 分页列表查询
......@@ -108,6 +111,10 @@ public class MaterialAcceptanceFormController {
materialAcceptanceForm.setConfirmStatus("9");
}
materialAcceptanceFormService.save(materialAcceptanceForm);
MaterialIN materialIN =materialINService.getById(materialAcceptanceForm.getId());
materialIN.setConfirmStatus(materialAcceptanceForm.getConfirmStatus());
materialINService.updateById( materialIN);
result.success("添加成功!");
} catch (Exception e) {
log.error(e.getMessage(),e);
......@@ -146,6 +153,9 @@ public class MaterialAcceptanceFormController {
}else {
materialAcceptanceFormService.updateById(materialAcceptanceForm);
}
MaterialIN materialIN =materialINService.getById(materialAcceptanceForm.getId());
materialIN.setConfirmStatus(materialAcceptanceForm.getConfirmStatus());
materialINService.updateById( materialIN);
//TODO 返回false说明什么?
result.success("修改成功!");
......
......@@ -167,7 +167,6 @@ public class MaterialINController {
queryWrapper.gt("audit_status" , "0");// >0
queryWrapper.ne("audit_status" , "2"); // 不等于2
}
queryWrapper.eq("confirm_status","2");
queryWrapper.orderByDesc("arrive_time");
IPage<MaterialIN> pageList = materialINService.page(page, queryWrapper);
......@@ -203,6 +202,7 @@ public class MaterialINController {
queryWrapper.eq("audit_status","3");
List<MaterialIN> pageList = materialINService.list( queryWrapper);*/
List<ArrivalRecordExcelExportVO> pageList = materialINService.queryArrivalRecordByList(materialIN);
result.setSuccess(true);
......@@ -225,15 +225,7 @@ public class MaterialINController {
return result;
}
//arrivalRecord
/**
* <pre>
* 添加
* </pre>
* @param materialIN
* @return
* @author 开发者姓名, 开发时间
* @Description: TODO(这里描述这个方法的需求变更情况)
*/
@AutoLog(value = "erp--物料(药剂)入库-添加")
@ApiOperation(value="erp--物料(药剂)入库-添加", notes="erp--物料(药剂)入库-添加")
@PostMapping(value = "/add")
......@@ -251,15 +243,7 @@ public class MaterialINController {
}
return result;
}
/**
* <pre>
* 编辑
* </pre>
* @param materialIN
* @return
* @author 开发者姓名, 开发时间
* @Description: TODO(这里描述这个方法的需求变更情况)
*/
@AutoLog(value = "erp--物料(药剂)入库-编辑")
@ApiOperation(value="erp--物料(药剂)入库-编辑", notes="erp--物料(药剂)入库-编辑")
@PutMapping(value = "/edit")
......@@ -277,15 +261,7 @@ public class MaterialINController {
}
return result;
}
/**
* <pre>
* 通过id删除
* </pre>
* @param id
* @return
* @author 开发者姓名, 开发时间
* @Description: TODO(这里描述这个方法的需求变更情况)
*/
@AutoLog(value = "erp--物料(药剂)入库-通过id删除")
@ApiOperation(value="erp--物料(药剂)入库-通过id删除", notes="erp--物料(药剂)入库-通过id删除")
@DeleteMapping(value = "/delete")
......@@ -299,15 +275,6 @@ public class MaterialINController {
return Result.ok("删除成功!");
}
/**
* <pre>
* 批量删除
* </pre>
* @param ids
* @return
* @author 开发者姓名, 开发时间
* @Description: TODO(这里描述这个方法的需求变更情况)
*/
@AutoLog(value = "erp--物料(药剂)入库-批量删除")
@ApiOperation(value="erp--物料(药剂)入库-批量删除", notes="erp--物料(药剂)入库-批量删除")
@DeleteMapping(value = "/deleteBatch")
......@@ -321,15 +288,7 @@ public class MaterialINController {
}
return result;
}
/**
* <pre>
* 通过id查询
* </pre>
* @param id
* @return
* @author 开发者姓名, 开发时间
* @Description: TODO(这里描述这个方法的需求变更情况)
*/
@AutoLog(value = "erp--物料(药剂)入库-通过id查询")
@ApiOperation(value="erp--物料(药剂)入库-通过id查询", notes="erp--物料(药剂)入库-通过id查询")
@GetMapping(value = "/queryById")
......
......@@ -14,6 +14,7 @@ import com.skua.modules.erp.service.IERPPurchaseContractService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.skua.modules.erp.vo.MaterialSearchVO;
import com.skua.modules.erp.vo.PurchaseContractVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
......@@ -83,15 +84,16 @@ public class PurchaseContractController {
@AutoLog(value = "erp采购合同-有权限的采购合同集合")
@ApiOperation(value="erp采购合同-有权限的采购合同集合", notes="erp采购合同-有权限的采购合同集合")
@GetMapping(value = "/purchaseContractList")
public Result<List<ERPPurchaseContract>> purchaseContractList() {
public Result<List<ERPPurchaseContract>> purchaseContractList(MaterialSearchVO materialSearchVO) {
Result<List<ERPPurchaseContract>> result = new Result<List<ERPPurchaseContract>>();
QueryWrapper<ERPPurchaseContract> queryWrapper = new QueryWrapper<ERPPurchaseContract> (); // QueryGenerator.initQueryWrapper(ERPPurchaseContract, req.getParameterMap());
/* queryWrapper.like("departs", BaseContextHandler.getRealDepartId());*/
/* QueryWrapper<ERPPurchaseContract> queryWrapper = new QueryWrapper<ERPPurchaseContract> (); // QueryGenerator.initQueryWrapper(ERPPurchaseContract, req.getParameterMap());
*//* queryWrapper.like("departs", BaseContextHandler.getRealDepartId());*//*
// 需要添加条件判断
queryWrapper.like("departs",BaseContextHandler.getRealDepartId());
queryWrapper.orderByDesc("create_time");
List<ERPPurchaseContract> purchaseContractList = purchaseContractService.list( queryWrapper);
//queryWrapper.like("departs",BaseContextHandler.getRealDepartId());P
queryWrapper.eq("status","3");//审核通过的数据
queryWrapper.orderByDesc("create_time");*/
List<ERPPurchaseContract> purchaseContractList = purchaseContractService.getListByDistributId( materialSearchVO);
/*Set<ERPPurchaseContract> dataList = new HashSet<>();
HashSet set = new HashSet(purchaseContractList);
......@@ -132,7 +134,7 @@ public class PurchaseContractController {
if(purchaseContractEntity ==null) {
result.error500("未找到对应实体");
}else {
String errorMsg = purchaseContractService.checkPurchaseContract(purchaseContractVO , purchaseContractEntity.getContractCode(),0);
String errorMsg = purchaseContractService.checkPurchaseContract(purchaseContractVO , purchaseContractEntity.getContractCode(),1);
if(StringUtils.isNotEmpty( errorMsg )){
result.error500( errorMsg );
}else{
......
......@@ -113,6 +113,10 @@ public class MaterialIN {
@Excel(name = "采购总价", width = 15)
@ApiModelProperty(value = "采购总价")
private String purchaseTotalPrice;
@Excel(name = "物料数量", width = 15)
@ApiModelProperty(value = "物料数量")
private String materialNum;
/**分销总价*/
@Excel(name = "分销总价", width = 15)
@ApiModelProperty(value = "分销总价")
......@@ -198,4 +202,12 @@ public class MaterialIN {
@ApiModelProperty(value = "物料类别")
private String sparepartTypeName;
@ApiModelProperty(value = "入库编号")
private String equipmentInId;
@ApiModelProperty(value = "出库编号")
private String equipmentOutId;
}
......
......@@ -25,7 +25,7 @@ import org.jeecgframework.poi.excel.annotation.Excel;
@Accessors(chain = true)
@ApiModel(value="erp_purchase_material对象", description="采购物料清单")
public class PurchaseMaterial {
/**主键*/
@TableId(type = IdType.UUID)
@ApiModelProperty(value = "主键")
......@@ -77,7 +77,7 @@ public class PurchaseMaterial {
/**备注*/
@Excel(name = "备注", width = 15)
@ApiModelProperty(value = "备注")
private java.lang.String remarks;
private java.lang.String remark;
@TableField(exist=false)
......
......@@ -2,10 +2,21 @@ package com.skua.modules.erp.mapper;
import com.skua.modules.erp.entity.ERPPurchaseContract;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.skua.modules.erp.vo.MaterialSearchVO;
import com.skua.tool.annotation.Anonymous;
import java.util.List;
/**
* 采购合同
*/
public interface ERPPurchaseContractMapper extends BaseMapper<ERPPurchaseContract> {
/***
* 根据分销编号查询采购合同列表
* @param materialSearchVO
* @return
*/
@Anonymous
List<ERPPurchaseContract> getListByDistributId(MaterialSearchVO materialSearchVO);
}
......
......@@ -8,6 +8,7 @@ import com.skua.modules.erp.entity.DistributContract;
import com.skua.modules.erp.vo.MaterialSearchVO;
import com.skua.modules.erp.vo.PurchaseMaterialVO;
import com.skua.modules.erp.vo.PurchasePlanSearchVO;
import com.skua.tool.annotation.Anonymous;
import org.apache.ibatis.annotations.Param;
import com.skua.modules.erp.entity.PurchaseMaterial;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
......@@ -64,6 +65,7 @@ public interface PurchaseMaterialMapper extends BaseMapper<PurchaseMaterial> {
* @param materialSearchVO
* @return
*/
@Anonymous
public IPage<PurchaseMaterialVO> queryPurchaseMaterialListByIn(Page<PurchaseMaterialVO> page,@Param("param") MaterialSearchVO materialSearchVO);
/***
......
......@@ -2,4 +2,13 @@
<!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.ERPPurchaseContractMapper">
</mapper>
\ No newline at end of file
<!-- 根据分销编号查询采购合同列表 -->
<select id="getListByDistributId" resultType="com.skua.modules.erp.entity.ERPPurchaseContract">
select pc.* from erp_purchase_contract pc where pc.id in (
select DISTINCT pm.contract_id from erp_purchase_material pm , erp_distribut_material dm
where dm.good_code = dm.good_code and dm.contract_id = '1849328644967497730'
)
and pc.status = 3
order by pc.create_time desc
</select>
</mapper>
......
......@@ -61,7 +61,4 @@
</where>
group by sparepart_id,purchase_contract_id,depart_id,supplier_id
</select>
</mapper>
......
......@@ -60,18 +60,16 @@
<!-- 药剂入库查询结果:物料清单-->
<select id="queryPurchaseMaterialListByIn" resultType="com.skua.modules.erp.vo.PurchaseMaterialVO">
select dm.distribut_price ,dm.distribut_total_price , st.item_text as 'sparepart_type_name',sm.supp_name as 'supplier_name',
aaa.*
select st.item_text as 'sparepart_type_name',sm.supp_name as 'supplier_name', aaa.*
from (
select pm.* ,pc.depart_id,pc.contract_code 'purchase_contract_code',pc.project_name
from erp_purchase_material pm , erp_purchase_contract pc
where pm.contract_id =pc.id and pc.id = #{param.purchaseContractId}
select pc.depart_id,pc.contract_code 'purchase_contract_code',pc.project_name ,dm.distribut_price ,dm.distribut_total_price,dm.material_num,pm.*
from erp_purchase_material pm , erp_purchase_contract pc ,erp_distribut_material dm
where pm.contract_id =pc.id and pm.good_code = dm.good_code and pc.id = #{param.purchaseContractId} and dm.contract_id = #{param.distributContractId}
<if test="param.sparepartCode != null and param.sparepartCode !=''"> and pc.departs like '%' #{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 '%' #{param.sparepartName}'%'</if>
)aaa
left join erp_distribut_material dm on (aaa.good_code = dm.good_code and aaa.depart_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,6 +20,9 @@
<if test="ev.sparepartName != null and ev.sparepartName != '' ">
AND pi.sparepart_name like '%'#{ev.sparepartName}'%'
</if>
<if test="ev.purpose != null and ev.purpose != '' ">
AND pi.purpose like '%'#{ev.purpose}'%'
</if>
<if test="ev.applyYear != null and ev.applyYear != '' ">
and pp.apply_year = #{ev.applyYear}
</if>
......@@ -66,4 +69,4 @@
</if>
</select>
<!-- and pp.depart_id in (#{ev.departs})-->
</mapper>
\ No newline at end of file
</mapper>
......
......@@ -6,6 +6,7 @@ import com.skua.modules.erp.entity.ERPPurchaseContract;
import com.baomidou.mybatisplus.extension.service.IService;
import com.skua.modules.erp.entity.PurchaseMaterial;
import com.skua.modules.erp.entity.PurchasePlanItem;
import com.skua.modules.erp.vo.MaterialSearchVO;
import com.skua.modules.erp.vo.PurchaseContractVO;
import com.skua.modules.erp.vo.PurchaseMaterialVO;
import com.skua.modules.erp.vo.PurchasePlanSearchVO;
......@@ -78,4 +79,11 @@ public interface IERPPurchaseContractService extends IService<ERPPurchaseContrac
* @return
*/
int syncEquipmentIn(PurchaseContractVO purchaseContractVO)throws Exception;
/***
* 根据分销编号查询采购合同列表
* @param materialSearchVO
* @return
*/
List<ERPPurchaseContract> getListByDistributId(MaterialSearchVO materialSearchVO);
}
......
......@@ -17,7 +17,7 @@ public interface IMaterialINService extends IService<MaterialIN> {
* 审核药剂入库单
* @param materialINVO
*/
public void auditMaterialINVO(MaterialINVO materialINVO);
String auditMaterialINVO(MaterialINVO materialINVO);
/***
* 列表查询到货记录列表
......
......@@ -49,7 +49,7 @@ public class DistributContractServiceImpl extends ServiceImpl<DistributContractM
errMsg ="操作失败,货号["+ goodsCode +"]重复!";
}
int count = 0;
if(!oldContractCode.equals(distributContractVO.getContractCode())){
if(!distributContractVO.getContractCode().equals(oldContractCode)){
count = this.baseMapper.checkContractCode(distributContractVO.getContractCode() );
if(count > checkCount ){
errMsg = "合同编号["+distributContractVO.getContractCode()+"]重复";
......@@ -137,9 +137,6 @@ public class DistributContractServiceImpl extends ServiceImpl<DistributContractM
public int checkGoodCodeAndDepartId(String goodsCode ,String departId){
return materialMapper.checkGoodCodeAndDepartId( goodsCode ,departId );
}
/***
* 删除DistributContractVOVO
* @param contractId
......@@ -149,7 +146,6 @@ public class DistributContractServiceImpl extends ServiceImpl<DistributContractM
// ge根据计划编号删除清单集合
materialMapper.delByContractId( contractId ) ;
}
/***
* 根据id查询DistributContractVOVO
* @param contractId
......@@ -158,13 +154,11 @@ public class DistributContractServiceImpl extends ServiceImpl<DistributContractM
public DistributContractVO queryById(String contractId){
DistributContract distributContract = this.baseMapper.selectById( contractId );
DistributContractVO distributContractVO = new DistributContractVO();
if(distributContract != null ){
BeanUtils.copyProperties(distributContract,distributContractVO);
List<DistributMaterial> materialList = materialMapper.queryListByContractId( contractId );
distributContractVO.setMaterialList( materialList );
}
return distributContractVO;
}
......@@ -192,11 +186,9 @@ public class DistributContractServiceImpl extends ServiceImpl<DistributContractM
if("2".equals( distributContractVO.getApproveState() )){
distributContractVO.setStatus( "2" );
}
this.baseMapper.updateById( distributContractVO ) ;
// ge根据计划编号删除清单集合
materialMapper.delByContractId(distributContractVO.getId() ) ;
if( distributContractVO.getMaterialList() != null && !distributContractVO.getMaterialList().isEmpty()){
for(DistributMaterial material : distributContractVO.getMaterialList()){
material.setId(null);
......
......@@ -9,6 +9,7 @@ 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.IERPPurchaseContractService;
import com.skua.modules.erp.vo.MaterialSearchVO;
import com.skua.modules.erp.vo.PurchaseContractVO;
import com.skua.modules.guest.util.DateUtil;
import com.skua.modules.quartz.util.BaseUtil;
......@@ -49,7 +50,8 @@ public class ERPPurchaseContractServiceImpl extends ServiceImpl<ERPPurchaseContr
public String checkPurchaseContract(PurchaseContractVO purchaseContractVO,String oldContractCode ,int checkCount){
String result = null;
int count = 0;
if(!oldContractCode.equals(purchaseContractVO.getContractCode())){
if(!purchaseContractVO.getContractCode().equals(oldContractCode)){
count = purchaseMaterialMapper.checkContractCode(purchaseContractVO.getContractCode() );
if(count > checkCount ){
result = "合同编号["+purchaseContractVO.getContractCode()+"]重复";
......@@ -190,10 +192,10 @@ public class ERPPurchaseContractServiceImpl extends ServiceImpl<ERPPurchaseContr
//purchasePlan.getApproveState() 审批状态 1通过2不通过
if("1".equals( purchaseContractVO.getApproveState() )){
purchaseContractVO.setStatus( "3" );
inStock = true;
}
if("2".equals( purchaseContractVO.getApproveState() )){
purchaseContractVO.setStatus( "4" );
inStock = true;
purchaseContractVO.setStatus( "2" );
}
this.baseMapper.updateById( purchaseContractVO ) ;
......@@ -220,6 +222,15 @@ public class ERPPurchaseContractServiceImpl extends ServiceImpl<ERPPurchaseContr
}
}
}
/***
* 根据分销编号查询采购合同列表
* @param materialSearchVO
* @return
*/
public List<ERPPurchaseContract> getListByDistributId(MaterialSearchVO materialSearchVO){
return this.baseMapper.getListByDistributId(materialSearchVO);
}
/***
* 同步入库
* @param purchaseContractVO
......@@ -229,20 +240,21 @@ public class ERPPurchaseContractServiceImpl extends ServiceImpl<ERPPurchaseContr
EquipmentInDTO equipmentInDTO = new EquipmentInDTO();
// EquipmentIn equipmentIn = new EquipmentIn();
//入库类型
equipmentInDTO.setInType("8");//统购入库
equipmentInDTO.setDepartId( purchaseContractVO.getDepartId() );//所属厂站
equipmentInDTO.setSuppliesWarehouseId( purchaseContractVO.getInWarehouseId() ) ;//入库仓库
equipmentInDTO.setInDate(DateUtil.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss"));
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();//
EquipmentInChild equipmentInChild = null;//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.setInNum( new BigDecimal(purchaseMaterial.getPurchaseNum())); //物料数量
equipmentInChild.setBatchNum(purchaseMaterial.getGoodCode() ) ;//批次号
equipmentInChildrenList.add( equipmentInChild ) ;
......@@ -262,7 +274,4 @@ public class ERPPurchaseContractServiceImpl extends ServiceImpl<ERPPurchaseContr
this.baseMapper.updateById(purchaseContractVO ) ;
return 1;
}
}
......
package com.skua.modules.erp.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.skua.core.context.BaseContextHandler;
import com.skua.core.context.SpringContextUtils;
import com.skua.modules.equipment.dto.EquipmentInDTO;
import com.skua.modules.equipment.dto.EquipmentOutDTO;
import com.skua.modules.equipment.entity.EquipmentInChild;
import com.skua.modules.equipment.service.IEquipmentInService;
import com.skua.modules.equipment.service.IEquipmentOutService;
import com.skua.modules.erp.entity.ApproveRecord;
import com.skua.modules.erp.entity.MaterialIN;
import com.skua.modules.erp.mapper.ApproveRecordMapper;
......@@ -9,11 +16,20 @@ import com.skua.modules.erp.mapper.MaterialINMapper;
import com.skua.modules.erp.service.IMaterialINService;
import com.skua.modules.erp.vo.ArrivalRecordExcelExportVO;
import com.skua.modules.erp.vo.MaterialINVO;
import com.skua.modules.guest.util.DateUtil;
import com.skua.modules.supplies.entity.SuppliesWarehouse;
import com.skua.modules.supplies.service.ISuppliesWarehouseService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
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;
/**
......@@ -24,15 +40,38 @@ public class MaterialINServiceImpl extends ServiceImpl<MaterialINMapper, Materia
@Resource
private ApproveRecordMapper recordMapper;
@Autowired
private IEquipmentInService equipmentInService;
@Autowired
private IEquipmentOutService equipmentOutService;
@Autowired
private ISuppliesWarehouseService warehouseService;
/***
* 审核药剂入库单
* @param materialINVO
*/
public void auditMaterialINVO(MaterialINVO materialINVO){
@Transactional
public String auditMaterialINVO(MaterialINVO materialINVO){
boolean inAndOutStock = false;
String errMsg = null;
QueryWrapper<SuppliesWarehouse> queryWrapper = new QueryWrapper<SuppliesWarehouse>();
queryWrapper.eq("depart_id",materialINVO.getDepartId());
warehouseService.list();
//主库数据源
JdbcTemplate masterDB = (JdbcTemplate) SpringContextUtils.getBean("master");
String warehouseSql = "select id from supplies_warehouse where depart_id = '"+materialINVO.getDepartId()+"' order by create_time desc limit 1";
String inWarehouseId = masterDB.queryForObject( warehouseSql,String.class );
if(StringUtils.isEmpty(inWarehouseId)){
String departSql = "select depart_name from sys_depart where id = '"+materialINVO.getDepartId()+"'";
String departName = masterDB.queryForObject( warehouseSql,String.class );
return "所属厂站["+departName+"]下没有找到仓库信息!";
}
//保存
//purchasePlan.getApproveState() 审批状态 1通过2不通过
if("1".equals( materialINVO.getApproveState() )){
materialINVO.setAuditStatus( "3" );
inAndOutStock = true;
}
if("2".equals( materialINVO.getApproveState() )){
materialINVO.setAuditStatus( "2" );
......@@ -42,6 +81,21 @@ public class MaterialINServiceImpl extends ServiceImpl<MaterialINMapper, Materia
//审批记录
ApproveRecord record = new ApproveRecord( "YJIN", materialINVO.getApplyUser(), materialINVO.getId(), BaseContextHandler.getUserId(), materialINVO.getApproveMessage(), materialINVO.getApproveState());
recordMapper.insert( record ) ;
// 审核通过,生成入库单据、物料单
if(inAndOutStock ){
try {
//出库
syncEquipmentOut(materialINVO);
//入库
syncEquipmentIn(materialINVO,inWarehouseId);
} catch (Exception e) {
e.printStackTrace();
}
}
return errMsg;
}
/***
......@@ -70,4 +124,60 @@ public class MaterialINServiceImpl extends ServiceImpl<MaterialINMapper, Materia
public IPage<MaterialIN> selectAuditMaterialINByPage(IPage<MaterialIN> page, MaterialIN materialIN) {
return page.setRecords(baseMapper.selectAuditMaterialINByPage(page, materialIN));
}
/***
* 出库
* @return
*/
public int syncEquipmentOut(MaterialINVO materialINVO){
EquipmentOutDTO equipmentOutDTO = new EquipmentOutDTO();
//equipmentOutService.saveEquipmentOut(equipmentOutDTO);
return 1;
}
/***
* 同步入库
* @param materialINVO
* @return
*/
public int syncEquipmentIn(MaterialINVO materialINVO,String inWarehouseId) throws Exception{
EquipmentInDTO equipmentInDTO = new EquipmentInDTO();
// EquipmentIn equipmentIn = new EquipmentIn();
//入库类型
equipmentInDTO.setInType("8");//统购入库
equipmentInDTO.setDepartId( materialINVO.getDepartId() );//所属厂站
equipmentInDTO.setSuppliesWarehouseId( inWarehouseId ) ;//入库仓库
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( materialINVO.getRemark() );//备注
List<EquipmentInChild> equipmentInChildrenList = new ArrayList<>();
EquipmentInChild equipmentInChild = new EquipmentInChild();//
equipmentInChild.setSparepartId( materialINVO.getSparepartId());//物料编号
equipmentInChild.setInNum( new BigDecimal(materialINVO.getMaterialNum())); //物料数量
equipmentInChild.setBatchNum(materialINVO.getGoodCode() ) ;//批次号
equipmentInChildrenList.add( equipmentInChild ) ;
equipmentInDTO.setEquipmentInChildList( equipmentInChildrenList );
//调用接口入库
equipmentInService.saveEquipmentIn(equipmentInDTO ) ;
/* ERPPurchaseContract erpPurchaseContract = this.baseMapper.selectById(purchaseContractVO.getId());
if(erpPurchaseContract == null ){
throw new Exception("采购合同记录不存在");
}*/
materialINVO.setEquipmentInId( equipmentInDTO.getId() ) ;//记录入库单号
log.debug("记录入库单号{"+equipmentInDTO.getId()+"},入库单号:"+equipmentInDTO.getInOrder());
this.baseMapper.updateById(materialINVO ) ;
return 1;
}
}
......
......@@ -121,7 +121,7 @@ public class PurchasePlanServiceImpl extends ServiceImpl<PurchasePlanMapper, Pur
*/
@Transactional
public void auditPurchasePlan(PurchasePlanVO purchasePlanVO){
boolean warehousing = false;//是否入库
//保存
//purchasePlan.getApproveState() 审批状态 1通过2不通过
if("1".equals( purchasePlanVO.getApproveState() )){
......@@ -129,8 +129,6 @@ public class PurchasePlanServiceImpl extends ServiceImpl<PurchasePlanMapper, Pur
}
if("2".equals( purchasePlanVO.getApproveState() )){
purchasePlanVO.setStatus( "2" );
//发送入库单据,物料库存增加
warehousing = true;
}
this.baseMapper.updateById( purchasePlanVO ) ;
......@@ -147,10 +145,6 @@ public class PurchasePlanServiceImpl extends ServiceImpl<PurchasePlanMapper, Pur
ApproveRecord record = new ApproveRecord( "CGJH", purchasePlanVO.getApplyUser(), purchasePlanVO.getId(), BaseContextHandler.getUserId(), purchasePlanVO.getApproveMessage(), purchasePlanVO.getApproveState());
recordMapper.insert( record ) ;
if(warehousing){//创建入库单据、入库物料单
}
}
/***
......
......@@ -16,6 +16,9 @@ public class MaterialSearchVO {
@ApiModelProperty(value = "采购合同编号")
private String purchaseContractId;
@ApiModelProperty(value = "分销合同编号")
private String distributContractId;
@ApiModelProperty(value = "物料编号")
private String sparepartCode;
......
......@@ -24,7 +24,6 @@ public class PurchaseContractVO extends ERPPurchaseContract {
@ApiModelProperty(value = "采购合同物料清单集合")
private List<PurchaseMaterial> materialList = null;
/**审批状态*/
@TableField(exist=false)
@ApiModelProperty(value = "审批状态 1通过2不通过")
......
......@@ -72,7 +72,7 @@ public class PurchaseMaterialVO {
/**备注*/
@Excel(name = "备注", width = 15)
@ApiModelProperty(value = "备注")
private java.lang.String remarks;
private java.lang.String remark;
@TableField(exist=false)
......
......@@ -35,6 +35,9 @@ public class PurchasePlanSearchVO {
private String sparepartAttribute;
@ApiModelProperty(value = "用途")
private String purpose;
@ApiModelProperty(value = "开始时间")
private String startTime;
......
package com.skua.modules.threedimensional.controller;
import com.skua.core.api.vo.Result;
import com.skua.core.aspect.annotation.AutoLog;
import com.skua.modules.report.vo.JnhbReportData;
import com.skua.modules.threedimensional.service.IJTDisplayScreenService;
import com.skua.modules.threedimensional.vo.SysFactoryInfoVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@Slf4j
@Api(tags = "对外展示集团大屏")
@RestController
@RequestMapping("/jtDisplayscreendata")
public class JTDisplayScreenController {
@Autowired
private IJTDisplayScreenService displayScreenService ;
@AutoLog(value = "厂站记录")
@ApiOperation(value = "厂长列表", notes = "厂长列表")
@GetMapping(value = "/factoryList")
public Result<List<SysFactoryInfoVO>> factoryList(String time) {
Result<List<SysFactoryInfoVO>> result = new Result<>();
List<SysFactoryInfoVO> list = displayScreenService.getFactoryList(time);
result.setResult(list);
return result;
}
}
......
package com.skua.modules.threedimensional.service;
import com.skua.modules.threedimensional.vo.SysFactoryInfoVO;
import java.util.List;
public interface IJTDisplayScreenService {
/***
* 厂站列表
* @param time
* @return
*/
List<SysFactoryInfoVO> getFactoryList(String time );
}
package com.skua.modules.threedimensional.service.impl;
import com.skua.common.report.ReportViewUtil;
import com.skua.core.context.SpringContextUtils;
import com.skua.core.util.DateUtils;
import com.skua.modules.threedimensional.service.IJTDisplayScreenService;
import com.skua.modules.threedimensional.vo.SysFactoryInfoVO;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 对外展示集团大屏
*/
@Service
public class JTDisplayScreenServiceImpl implements IJTDisplayScreenService {
private static String view2119 = "2119ecbf53a1d2d0708258ff67cfd9e1";
/***
*
* @return
*/
public List<SysFactoryInfoVO> getFactoryList(String time ){
List<SysFactoryInfoVO> factoryInfoVOList = null;
String startDate = time+"-01";
String endDate = time+"-31";;
String departId = null;
String yesterday = DateUtils.getYesterday();
//
String departIdSql ="select GROUP_CONCAT(fi.depart_id ) from sys_factory_info fi ,sys_depart d where fi.depart_id = d.id and d.depart_type =1 ";
String departIds = null;
String dataViewName2119 = ReportViewUtil.buildViewLike(view2119,"CSL", departIds, startDate, endDate);
System.out.println("********************************************");
System.out.println(dataViewName2119);
//主库数据源
JdbcTemplate masterDB = (JdbcTemplate) SpringContextUtils.getBean("master");
String sql = "select " + " sum(v1.CSL)/10000 " + " from "+dataViewName2119+" v1 " ;
return factoryInfoVOList;
}
}
package com.skua.modules.threedimensional.vo;
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 = "sys_factory_info对象", description = "厂区详细信息")
public class SysFactoryInfoVO {
@ApiModelProperty(value = "主键")
private String id;
@ApiModelProperty(value = "水厂名称")
private String departName;
@ApiModelProperty(value = "经度")
private String proLongitude;
@ApiModelProperty(value = "纬度")
private String proLatitude;
@ApiModelProperty(value = "昨日处理水量")
private String csl_lastDay;
@ApiModelProperty(value = "本月累计处理水量")
private String csl_month;
@ApiModelProperty(value = "日均处理水量")
private String csl_avg_day;
@ApiModelProperty(value = "本年处理水量")
private String csl_year;
}
......@@ -10,7 +10,6 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
......
......@@ -2,8 +2,10 @@ package com.skua.modules.equipment.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.skua.modules.equipment.dto.EquipmentOutDTO;
import com.skua.modules.equipment.entity.EquipmentOut;
import com.skua.modules.equipment.vo.EquipmentOutExcel;
import org.apache.kafka.common.errors.InterruptException;
import java.util.List;
......@@ -14,4 +16,11 @@ public interface IEquipmentOutService extends IService<EquipmentOut> {
List<EquipmentOutExcel> queryExport(QueryWrapper<EquipmentOut> queryWrapper);
/***
* 新增出库
* @param equipmentOutDTO
* @return
*/
String saveEquipmentOut(EquipmentOutDTO equipmentOutDTO) throws Exception;
}
......
......@@ -2,14 +2,35 @@ package com.skua.modules.equipment.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.skua.core.util.DateUtils;
import com.skua.modules.equipment.dto.EquipmentOutDTO;
import com.skua.modules.equipment.entity.EquipmentOut;
import com.skua.modules.equipment.entity.EquipmentOutChild;
import com.skua.modules.equipment.entity.EquipmentSparepart;
import com.skua.modules.equipment.mapper.EquipmentOutMapper;
import com.skua.modules.equipment.service.IEquipmentOutChildService;
import com.skua.modules.equipment.service.IEquipmentOutService;
import com.skua.modules.equipment.service.IEquipmentSparepartService;
import com.skua.modules.equipment.vo.EquipmentOutExcel;
import com.skua.modules.flow.utils.ObjectUtil;
import com.skua.modules.supplies.entity.EquipmentSparepartSupplies;
import com.skua.modules.supplies.service.IEquipmentSparepartSuppliesService;
import com.skua.tool.util.BeanExtUtils;
import com.skua.tool.util.UniqIdUtils;
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.UUID;
import java.util.concurrent.CountDownLatch;
/**
* 出库
......@@ -18,9 +39,102 @@ import java.util.List;
public class EquipmentOutServiceImpl extends ServiceImpl<EquipmentOutMapper, EquipmentOut> implements IEquipmentOutService {
@Autowired
@Qualifier("taskExecutor")
private ThreadPoolTaskExecutor taskExecutor;
@Resource
private EquipmentOutMapper equipmentOutMapper;
@Autowired
private IEquipmentOutChildService iEquipmentOutChildService;
@Autowired
private IEquipmentSparepartService iEquipmentSparepartService;
@Autowired
private TransactionTemplate transactionTemplate;
@Autowired
private IEquipmentSparepartSuppliesService sparepartSuppliesService;
@Override
public List<EquipmentOutExcel> queryExport(QueryWrapper<EquipmentOut> queryWrapper) {
return equipmentOutMapper.queryExport(queryWrapper);
}
/***
* 新增出库
* @param equipmentOutDTO
* @return
*/
public String saveEquipmentOut(EquipmentOutDTO equipmentOutDTO) throws Exception {
String errMsg = null;
if (equipmentOutDTO.getEquipmentOutChildList() == null || equipmentOutDTO.getEquipmentOutChildList().isEmpty()) {
errMsg = "请选择出库备件";
return errMsg;
}
// 出库单号
if (StringUtils.isEmpty(equipmentOutDTO.getOutOrder())) {
String outOrder = "CK-" + DateUtils.format(new Date(), "YYYYMMdd" + "-" + System.currentTimeMillis());
equipmentOutDTO.setOutOrder(outOrder);
}
// 出库表主键
String outId = UUID.randomUUID().toString().replaceAll("-", "");
equipmentOutDTO.setId(outId);
EquipmentOut equipmentOut = BeanExtUtils.bean2Bean(equipmentOutDTO, EquipmentOut.class);
equipmentOut.setInventoryUpdateTime(new Date());
this.baseMapper.insert(equipmentOut);
CountDownLatch countDownLatch = new CountDownLatch(equipmentOutDTO.getEquipmentOutChildList().size());
for (EquipmentOutChild equipmentOutChild : equipmentOutDTO.getEquipmentOutChildList()) {
equipmentOutChild.setId(UniqIdUtils.getInstance().getUniqID());
equipmentOutChild.setOutId(outId);
taskExecutor.execute(() -> {
try {
String sparepartId = equipmentOutChild.getSparepartId();
String suppliesWarehouseId = equipmentOutDTO.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);
//如果没有物料库存信息,新增库存信息为0
iEquipmentSparepartService.saveOrUpdate(equipmentSparepart);
equipmentSparepart = iEquipmentSparepartService.getOne(sparepartQueryWrapper);
}
BigDecimal resetStorageNum = equipmentSparepart.getStorageNum().subtract(equipmentOutChild.getOutNum());
if (resetStorageNum.doubleValue() < 0) {
return;
}
Integer version = equipmentSparepart.getVersion();
String id = equipmentSparepart.getId();
Integer executeRes = transactionTemplate.execute(transactionStatus -> {
int val0 = iEquipmentSparepartService.updateStorageNumById(id, resetStorageNum.doubleValue(), version);
if (val0 == 1 && iEquipmentOutChildService.saveOrUpdate(equipmentOutChild)) {
return 1;
} else {
transactionStatus.setRollbackOnly();
return 0;
}
});
// if (executeRes != null && executeRes == 1) {
//
// }
} catch (Exception e) {
e.printStackTrace();
//log.error("异常error: {}", e.getMessage());
} finally {
countDownLatch.countDown();
}
});
}
countDownLatch.await();
return errMsg ;
}
}
......
......@@ -150,6 +150,9 @@ public class MybatisInterceptor implements Interceptor {
|| "com.skua.modules.erp.mapper.DistributMaterialMapper.queryListByContractId".equals(sqlId) //采购-分销合同
|| "com.skua.modules.erp.mapper.ERPPurchaseContractMapper.selectList".equals(sqlId) //采购合同
|| "com.skua.modules.supplies.mapper.EquipmentSparepartSuppliesMapper.selectList".equals(sqlId) //物料
|| "com.skua.modules.erp.mapper.ERPPurchaseContractMapper.selectList".equals(sqlId) //采购合同列表
|| "com.skua.modules.erp.mapper.DistributContractMapper.selectList".equals(sqlId) //分销合同列表
|| "com.skua.modules.erp.mapper.ERPPurchaseContractMapper.getListByDistributId".equals(sqlId)
|| "com.skua.modules.system.datestandard.mapper.SysMonitorMetricInfoMapper.selectList".equals(sqlId) //点表
) {
log.debug("************************------sqlId------**************************" + sqlId);
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!