20102728 康伟

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

                导出pdf文件接口
1 个父辈 b5d77a45
正在显示 31 个修改的文件 包含 917 行增加127 行删除
......@@ -102,6 +102,29 @@
<artifactId>jsch</artifactId>
<version>0.1.55</version>
</dependency>
<!-- 导出pdf文件-->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.11</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>html2pdf</artifactId>
<version>4.0.3</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>font-asian</artifactId>
<version>7.2.3</version>
</dependency>
</dependencies>
<build>
......
......@@ -15,6 +15,7 @@ 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.erp.vo.PurchaseMaterialVO;
import com.skua.modules.quartz.util.BaseUtil;
import com.skua.modules.supplies.entity.EquipmentSparepartSupplies;
import com.skua.modules.supplies.entity.EquipmentSparepartType;
import com.skua.modules.supplies.service.IEquipmentSparepartSuppliesService;
......@@ -44,6 +45,7 @@ public class ErpCommonController {
@Autowired
private IEquipmentSparepartTypeService equipmentSparepartTypeService;
@AutoLog(value = "ERP-采购计划--物料列表")
@ApiOperation(value = "ERP-采购计划--物料列表", notes = "ERP-采购计划--物料列表")
@RequestMapping(value = "/sparepartList", method = RequestMethod.GET)
......@@ -76,6 +78,7 @@ public class ErpCommonController {
@RequestMapping(value = "/purchaseMaterialList", method = RequestMethod.GET)
public Result<IPage<PurchaseMaterial>> purchaseMaterialList(
@RequestParam(name = "goodCode") String goodCode,
@RequestParam(name = "medicament") boolean medicament,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
Result<IPage<PurchaseMaterial>> result = new Result<IPage<PurchaseMaterial>>();
......@@ -99,7 +102,38 @@ public class ErpCommonController {
Result<IPage<PurchaseMaterialVO>> result = new Result<IPage<PurchaseMaterialVO>>();
Page<PurchaseMaterialVO> page = new Page<PurchaseMaterialVO>(pageNo, pageSize);
//String departId = BaseContextHandler.getRealDepartId();//当前部门编号
materialSearchVO.setDepartId( BaseContextHandler.getRealDepartId() );
// materialSearchVO.setDepartId( BaseContextHandler.getRealDepartId() );
//如果为管理员,则跳过权限
if (!"1".equals(BaseContextHandler.get("userType"))) {
if (StringUtils.isNotEmpty( BaseContextHandler.getDeparts())) {
materialSearchVO.setDepartId( BaseUtil.quoteEach(BaseContextHandler.getDeparts() ,",")) ;//非管理员,获取权限部门集合
}else{
materialSearchVO.setDepartId(BaseContextHandler.getRealDepartId() ) ;//非管理员,获取权限部门集合
}
}
String sparepartTypeStr = "";
if(StringUtils.isNotEmpty(materialSearchVO.getSparepartType())){
//查询子集合
Set<String> sparepartTypeSet = equipmentSparepartTypeService.getAllChildrenSparepartTypeIds(materialSearchVO.getSparepartType() );
if(sparepartTypeSet.size() > 0 ){
// 使用String.join()方法转换Set为字符串,以逗号分隔
sparepartTypeStr = String.join(",", sparepartTypeSet);
}
materialSearchVO.setSparepartType(sparepartTypeStr) ;
}else{
if(materialSearchVO.isMedicament()){ //查询药剂物料清单
EquipmentSparepartType equipmentSparepartType = new EquipmentSparepartType();
equipmentSparepartType.setMedicament( materialSearchVO.isMedicament() );
List<EquipmentSparepartType> sparepartTypeList = equipmentSparepartTypeService.querySparepartTypeList(equipmentSparepartType);
if(sparepartTypeList != null && !sparepartTypeList.isEmpty()){
for(EquipmentSparepartType sparepartType : sparepartTypeList){
if(sparepartTypeStr.length() > 0 ) sparepartTypeStr+=",";
sparepartTypeStr += "'"+sparepartType.getId()+"'";
}
}
materialSearchVO.setSparepartType(sparepartTypeStr) ;
}
}
IPage<PurchaseMaterialVO> pageList = purchaseMaterialService.queryPurchaseMaterialListByIn(page,materialSearchVO);
result.setSuccess(true);
result.setResult(pageList);
......
package com.skua.modules.erp.controller;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import cn.hutool.core.date.DateUtil;
import com.skua.core.api.vo.Result;
import com.skua.core.aspect.annotation.AutoLog;
import com.skua.core.context.BaseContextHandler;
import com.skua.core.query.QueryGenerator;
import com.skua.core.util.DateUtils;
import com.skua.modules.erp.entity.ERPPurchaseContract;
import com.skua.modules.erp.service.IEROPurchaseContractService;
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.PurchaseContractVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
......@@ -38,7 +35,7 @@ import io.swagger.annotations.ApiOperation;
@RequestMapping("/web/erp/purchaseContract")
public class PurchaseContractController {
@Autowired
private IEROPurchaseContractService purchaseContractService;
private IERPPurchaseContractService purchaseContractService;
@AutoLog(value = "erp采购合同-分页列表查询")
@ApiOperation(value="erp采购合同-分页列表查询", notes="erp采购合同-分页列表查询")
......@@ -99,6 +96,8 @@ public class PurchaseContractController {
String errorGoodsCode = purchaseContractService.checkGoodCode(purchaseContractVO ,0 );
if(errorGoodsCode != null ){
result.error500("校验失败,货号[ "+errorGoodsCode+" ]已经存在!");
}else if("404".equals(errorGoodsCode)){
result.error500("校验失败,货号必填!");
}else{
purchaseContractService.savePurchaseContract(purchaseContractVO);
result.success("添加成功!");
......@@ -122,6 +121,8 @@ public class PurchaseContractController {
String errorGoodsCode = purchaseContractService.checkGoodCode(purchaseContractVO ,1 );
if(errorGoodsCode != null ){
result.error500("校验失败,货号[ "+errorGoodsCode+" ]已经存在!");
}else if("404".equals(errorGoodsCode)){
result.error500("校验失败,货号必填!");
}else{
purchaseContractService.updatePurchaseContract(purchaseContractVO);
result.success("修改成功!");
......
package com.skua.modules.erp.controller;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.URLUtil;
import com.skua.modules.erp.util.PdfUtil;
import io.swagger.annotations.Api;
import org.apache.velocity.VelocityContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
@Api(tags="erp-导出pdf文件")
@RestController
@RequestMapping("/velocity")
public class VelocityPdfController {
@GetMapping("/getPdf")
public void get(HttpServletResponse response){
response.reset();
response.setContentType("application/pdf");
String filename = System.currentTimeMillis()+".pdf";
// response.addHeader("Content-Disposition", "inline; filename=" + URLUtil.encode(filename, CharsetUtil.CHARSET_UTF_8));
response.addHeader("Content-Disposition", "attachment; filename=" + URLUtil.encode(filename, CharsetUtil.CHARSET_UTF_8));
VelocityContext context = new VelocityContext();
context.put("name", "彭也行");
context.put("gender", 1);
context.put("birthDate", DateUtil.formatDateTime(new Date()));
context.put("phone", "13666666666");
List<Map<String, Object>> eduList = new ArrayList<>();
// 小学
Map<String, Object> primarySchoolMap = new HashMap<>();
primarySchoolMap.put("name", "小学");
List<Map<String, Object>> scoreList = new ArrayList<>();
// 语文成绩
Map<String, Object> chineseScore = new HashMap<>();
chineseScore.put("subject", "语文");
chineseScore.put("num", 60);
// 数学成绩
Map<String, Object> mathScore = new HashMap<>();
mathScore.put("subject", "数学");
mathScore.put("num", 99);
scoreList.add(chineseScore);
scoreList.add(mathScore);
primarySchoolMap.put("itemList", scoreList);
primarySchoolMap.put("size", scoreList.size());
// 初中
Map<String, Object> middleSchoolMap = new HashMap<>();
middleSchoolMap.put("name", "初中");
List<Map<String, Object>> middleScoreList = new ArrayList<>();
// 语文成绩
Map<String, Object> middleChineseScore = new HashMap<>();
middleChineseScore.put("subject", "语文");
middleChineseScore.put("num", 60);
// 数学成绩
Map<String, Object> middleMathScore = new HashMap<>();
middleMathScore.put("subject", "数学");
middleMathScore.put("num", 99);
// 英语
Map<String, Object> middleEnScore = new HashMap<>();
middleEnScore.put("subject", "英语");
middleEnScore.put("num", 55);
middleScoreList.add(middleChineseScore);
middleScoreList.add(middleMathScore);
middleScoreList.add(middleEnScore);
middleScoreList.add(middleEnScore);
middleScoreList.add(middleEnScore);
middleScoreList.add(middleEnScore);
middleScoreList.add(middleEnScore);
middleScoreList.add(middleEnScore);
middleSchoolMap.put("itemList", middleScoreList);
middleSchoolMap.put("size", middleScoreList.size());
eduList.add(primarySchoolMap);
eduList.add(middleSchoolMap);
context.put("eduList", eduList);
try(ServletOutputStream outputStream = response.getOutputStream()){
PdfUtil.pdfFile(context, "static/demo.html", outputStream);
}catch (Exception e){
e.printStackTrace();
}
}
}
......@@ -28,12 +28,8 @@ public class MaterialAcceptanceForm {
/**主键*/
@TableId(type = IdType.ID_WORKER_STR)
@ApiModelProperty(value = "主键")
private String id;
/**入库单号*/
@Excel(name = "入库单号", width = 15)
@ApiModelProperty(value = "入库单号")
private String materialInId;
private String id;
/**入库单号*/
@Excel(name = "入库单号", width = 15)
@ApiModelProperty(value = "入库单号")
......@@ -82,4 +78,9 @@ public class MaterialAcceptanceForm {
@Excel(name = "备注", width = 15)
@ApiModelProperty(value = "备注")
private String remark;
@TableField(exist = false)
@ApiModelProperty(value = "到货日期")
private String arriveTime;
}
......
......@@ -46,10 +46,12 @@ public class MaterialIN {
/**采购合同*/
@Excel(name = "采购合同", width = 15)
@ApiModelProperty(value = "采购合同")
@Dict(dictTable = "erp_purchase_contract", dicCode="id", dicText = "contract_code")
private String purchaseContractId;
/**分销合同*/
@Excel(name = "分销合同", width = 15)
@ApiModelProperty(value = "分销合同")
@Dict(dictTable = "erp_distribut_contract", dicCode="id", dicText = "contract_code")
private String distributContractId;
/**到货时间*/
@Excel(name = "到货时间", width = 15)
......
......@@ -66,6 +66,8 @@ public class PurchasePlanItem implements Serializable{
@Excel(name = "计划采购数量", width = 15)
@ApiModelProperty(value = "计划采购数量")
private String purchaseNum;
/**单价*/
@Excel(name = "单价", width = 15)
@ApiModelProperty(value = "单价")
......@@ -102,4 +104,19 @@ public class PurchasePlanItem implements Serializable{
@TableField(exist=false)
@ApiModelProperty(value = "所属厂站名称")
private String departName;
@TableField(exist=false)
@ApiModelProperty(value = "计划年")
private String applyYear;
@TableField(exist=false)
@Excel(name = "已采购数量", width = 15)
@ApiModelProperty(value = "已采购数量")
private String usePurchaseNum;
public String getUsePurchaseNum() {
if(usePurchaseNum == null ) usePurchaseNum = "0";
return usePurchaseNum;
}
}
......
......@@ -2,6 +2,7 @@ package com.skua.modules.erp.mapper;
import java.util.List;
import com.skua.modules.erp.entity.MaterialIN;
import org.apache.ibatis.annotations.Param;
import com.skua.modules.erp.entity.MaterialAcceptanceForm;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
......@@ -11,4 +12,10 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface MaterialAcceptanceFormMapper extends BaseMapper<MaterialAcceptanceForm> {
/***
* 列表查询 验收单
* @param materialIN
* @return
*/
public List<MaterialAcceptanceForm> queryArrivalRecordByList(MaterialIN materialIN);
}
......
......@@ -2,6 +2,8 @@ package com.skua.modules.erp.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.skua.modules.erp.vo.ArrivalRecordExcelExportVO;
import org.apache.ibatis.annotations.Param;
import com.skua.modules.erp.entity.MaterialIN;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
......@@ -11,4 +13,18 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface MaterialINMapper extends BaseMapper<MaterialIN> {
/***
* 列表查询到货记录列表
* @param materialIN
* @return
*/
List<ArrivalRecordExcelExportVO> queryArrivalRecordByList(MaterialIN materialIN);
/***
* 获取入库审批列表:根据部门、采购合同、供应商、药剂分组搜索
* @param page
* @param materialIN
* @return
*/
public List<MaterialIN> selectAuditMaterialINByPage(IPage<MaterialIN> page, @Param("materialIN") MaterialIN materialIN);
}
......
......@@ -2,13 +2,28 @@
<!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.MaterialAcceptanceFormMapper">
<select id="queryByList" resultType="com.skua.modules.erp.vo.PurchasePlanItemVO">
select
t.arrive_time '到货日期', t.purchase_num '数量',t.measuring_unit '单位' ,
f.appearance_info '外观情况',f.matched_info '匹配情况' ,f.handle_msg '处理意见',f.sender_sign , f.receiver_sign,f.remark ,
t.sparepart_name,t.sparepart_code ,t.sparepart_type,t.specification ,t.depart_id ,
from erp_material_in t
left join erp_material_acceptance_form f on t.id = f.id
where t.supplier_id = 100 and t.depart_id = 'af880d6a13404a67825e94bc0f2f3808'
<select id="queryArrivalRecordByList" resultType="com.skua.modules.erp.entity.MaterialAcceptanceForm">
select mi.arrive_time , maf.* from erp_material_in mi ,erp_material_acceptance_form maf
where mi.id = maf.id
<where>
mi.audit_status =3
<if test="startTime != null and startTime !=''">
and mi.arrive_time &gt;= #{param.startTime}
</if>
<if test="endTime != null param.endTime !=''">
and mi.arrive_time &lt;= #{param.endTime}
</if>
<if test="departId != null departId !=''">
and mi.depart_id = #{departId}
</if>
<if test="supplierId != null supplierId !=''">
and mi.supplier_id = #{supplierId}
</if>
<if test="purchaseContractId != null purchaseContractId !=''">
and mi.purchase_contract_id = #{purchaseContractId}
</if>
</where>
order by maf.create_time asc
</select>
</mapper>
\ No newline at end of file
......
......@@ -3,9 +3,65 @@
<mapper namespace="com.skua.modules.erp.mapper.MaterialINMapper">
<!--查询 入库单 -->
<select id="queryByList" resultType="com.skua.modules.erp.entity.MaterialIN">
select t.*
from erp_material_in t
where t.supplier_id = 100 and t.depart_id = 'af880d6a13404a67825e94bc0f2f3808'
<select id="queryArrivalRecordByList" resultType="com.skua.modules.erp.vo.ArrivalRecordExcelExportVO">
select d.depart_name, pc.contract_code 'purchaseContractCode', dc.contract_code 'distributContractCode' ,ss.sparepart_name,mi.*
from erp_material_in mi
left join sys_depart d on d.id = mi.depart_id
left join erp_purchase_contract pc on pc.id = mi.purchase_contract_id
left join erp_distribut_contract dc on dc.id = mi.distribut_contract_id
left join equipment_sparepart_supplies ss on ss.id = mi.supplier_id
<where>
mi.audit_status =3
<if test="startTime != null and startTime !=''">
and mi.arrive_time &gt;= #{param.startTime}
</if>
<if test="endTime != null param.endTime !=''">
and mi.arrive_time &lt;= #{param.endTime}
</if>
<if test="goodCode != null goodCode !=''">
and mi.good_code like CONCAT('',#{goodCode},'%')
</if>
<if test="sparepartName != null sparepartName !=''">
and mi.sparepart_name like CONCAT('%',#{sparepartName},'%')
</if>
<if test="departId != null departId !=''">
and mi.depart_id = #{departId}
</if>
<if test="supplierId != null supplierId !=''">
and mi.supplier_id = #{supplierId}
</if>
</where>
</select>
<!--获取入库审批列表:根据部门、采购合同、供应商、药剂分组搜索 -->
<select id="queryArrivalRecordByList" 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>
<if test="endTime != null param.endTime !=''">
and arrive_time &lt;= #{param.endTime}
</if>
<if test="departId != null departId !=''">
and depart_id = #{departId}
</if>
<if test="supplierId != null supplierId !=''">
and supplier_id = #{supplierId}
</if>
<if test="purchaseContractId != null purchaseContractId !=''">
and purchase_contract_id = #{purchaseContractId}
</if>
</where>
group by sparepart_id , purchase_contract_id,depart_id,supplier_id
</select>
</mapper>
\ No newline at end of file
......
......@@ -69,9 +69,9 @@
select pm.*
from erp_purchase_material pm , erp_purchase_contract pc
where pm.contract_id =pc.id
and pc.departs like concat('%', #{param.departId}, '%')
<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 = #{param.sparepartType}</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
......
......@@ -3,8 +3,11 @@
<mapper namespace="com.skua.modules.erp.mapper.PurchasePlanMapper">
<!-- 统计查询-->
<select id="statisticsPage" resultType="com.skua.modules.erp.entity.PurchasePlanItem">
select ss.id, ss.sparepart_name,ss.sparepart_type, st.item_text as 'sparepart_type_name' ,ss.sparepart_attribute,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' , group_concat(DISTINCT purpose ) purpose
select ss.id, ss.sparepart_name,ss.sparepart_type, st.item_text as 'sparepart_type_name' ,ss.sparepart_attribute,ss.sparepart_code, ss.specification,ss.measuring_unit, aaa.*,
(select sum(mi.purchase_num) from erp_material_in mi
where mi.sparepart_id = aaa.sparepart_id <if test="ev.applyYear != null and ev.applyYear != '' ">and year(mi.arrive_time) = #{ev.applyYear}</if> ) 'use_purchase_num'
from (
select pp.apply_year, pi.sparepart_id,sum(pi.purchase_num ) as 'purchase_num' , sum(pi.total_price) 'total_price' , group_concat(DISTINCT purpose ) purpose
from erp_purchase_plan_item pi ,erp_purchase_plan pp
where
pp.id = pi.plan_id and pp.status = 3
......@@ -41,7 +44,7 @@
</select>
<select id="statisticsPageBySparepartId" resultType="com.skua.modules.erp.vo.PurchasePlanStatisticsVO">
select pi.purpose, pi.purchase_num ,pi.measuring_unit, pi.sparepart_name, pi.specification,pi.sparepart_type, pi.unit_price , pi.total_price , pp.*
select pi.remark, pi.purpose, pi.purchase_num ,pi.measuring_unit, pi.sparepart_name, pi.specification,pi.sparepart_type, pi.unit_price , pi.total_price , pp.*
from erp_purchase_plan_item pi ,erp_purchase_plan pp
where pp.status = 3 and pp.id = pi.plan_id and pi.sparepart_id=#{ev.sparepartId}
<if test="ev.sparepartType != null and ev.sparepartType != '' ">
......
......@@ -16,26 +16,26 @@ import java.util.List;
/**
* 采购合同
*/
public interface IEROPurchaseContractService extends IService<ERPPurchaseContract> {
public interface IERPPurchaseContractService extends IService<ERPPurchaseContract> {
/***
* 校验方法:校验是否唯一
* @param purchaseContractVO
* @param checkCount 新增= 0 ,修改checkCount=1
* @return 返回有问题的货号
*/
public String checkGoodCode(PurchaseContractVO purchaseContractVO,int checkCount );
String checkGoodCode(PurchaseContractVO purchaseContractVO,int checkCount );
/***
* 新增purchaseContractVO
* @param purchaseContractVO
*/
public void savePurchaseContract(PurchaseContractVO purchaseContractVO);
void savePurchaseContract(PurchaseContractVO purchaseContractVO);
/**
* 修改purchaseContractVO
* @param purchaseContractVO
* @return
*/
public boolean updatePurchaseContract(PurchaseContractVO purchaseContractVO);
boolean updatePurchaseContract(PurchaseContractVO purchaseContractVO);
/***
* 删除purchaseContractVO
......@@ -61,14 +61,14 @@ public interface IEROPurchaseContractService extends IService<ERPPurchaseContrac
* 审批 采购合同
* @param purchaseContractVO
*/
public void auditPurchaseContract(PurchaseContractVO purchaseContractVO);
void auditPurchaseContract(PurchaseContractVO purchaseContractVO);
/***
* 同步入库操作
* @param purchaseContractVO
* @return
*/
public int syncEquipmentIn(PurchaseContractVO purchaseContractVO)throws Exception;
int syncEquipmentIn(PurchaseContractVO purchaseContractVO)throws Exception;
......
......@@ -2,10 +2,20 @@ package com.skua.modules.erp.service;
import com.skua.modules.erp.entity.MaterialAcceptanceForm;
import com.baomidou.mybatisplus.extension.service.IService;
import com.skua.modules.erp.entity.MaterialIN;
import com.skua.modules.erp.vo.ArrivalRecordExcelExportVO;
import java.util.List;
/**
* 物料验收单
*/
public interface IMaterialAcceptanceFormService extends IService<MaterialAcceptanceForm> {
/***
* 列表查询 验收单
* @param materialIN
* @return
*/
List<MaterialAcceptanceForm> queryArrivalRecordByList(MaterialIN materialIN);
}
......
package com.skua.modules.erp.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.skua.modules.erp.entity.MaterialIN;
import com.baomidou.mybatisplus.extension.service.IService;
import com.skua.modules.erp.vo.ArrivalRecordExcelExportVO;
import com.skua.modules.erp.vo.MaterialINVO;
import java.util.List;
/**
* 物料(药剂)入库
*/
......@@ -14,4 +18,21 @@ public interface IMaterialINService extends IService<MaterialIN> {
* @param materialINVO
*/
public void auditMaterialINVO(MaterialINVO materialINVO);
/***
* 列表查询到货记录列表
* @param materialIN
* @return
*/
List<ArrivalRecordExcelExportVO> queryArrivalRecordByList(MaterialIN materialIN);
/***
* 获取入库审批列表:根据部门、采购合同、供应商、药剂分组搜索
* @param page
* @param materialIN
* @return
*/
public IPage<MaterialIN> selectAuditMaterialINByPage(IPage<MaterialIN> page, MaterialIN materialIN) ;
}
......
......@@ -8,10 +8,11 @@ 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.service.IERPPurchaseContractService;
import com.skua.modules.erp.vo.PurchaseContractVO;
import com.skua.modules.erp.vo.PurchaseMaterialVO;
import com.skua.modules.guest.util.DateUtil;
import com.skua.modules.quartz.util.BaseUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -27,7 +28,7 @@ import java.util.List;
* 采购合同
*/
@Service
public class ERPPurchaseContractServiceImpl extends ServiceImpl<ERPPurchaseContractMapper, ERPPurchaseContract> implements IEROPurchaseContractService {
public class ERPPurchaseContractServiceImpl extends ServiceImpl<ERPPurchaseContractMapper, ERPPurchaseContract> implements IERPPurchaseContractService {
@Resource
private PurchaseMaterialMapper purchaseMaterialMapper;//物料清单
......@@ -50,11 +51,15 @@ public class ERPPurchaseContractServiceImpl extends ServiceImpl<ERPPurchaseContr
int count = 0;
if( purchaseContractVO.getMaterialList()!= null && !purchaseContractVO.getMaterialList().isEmpty()){
for(PurchaseMaterial purchaseMaterial : purchaseContractVO.getMaterialList()){
if(StringUtils.isNotEmpty(purchaseMaterial.getGoodCode())){
count = purchaseMaterialMapper.checkGoodCode(purchaseMaterial.getId(),purchaseMaterial.getGoodCode());
if(count > checkCount ){
result = purchaseMaterial.getGoodCode();
break;
}
}else{
result = "404";
}
}
}
return result;
......@@ -66,13 +71,19 @@ public class ERPPurchaseContractServiceImpl extends ServiceImpl<ERPPurchaseContr
*/
public void savePurchaseContract(PurchaseContractVO purchaseContractVO){
int count = this.baseMapper.insert( purchaseContractVO );
//计算采购金额
String purchaseMoney = "0";
if(count > 0 && purchaseContractVO.getMaterialList() != null && !purchaseContractVO.getMaterialList().isEmpty()){
for(PurchaseMaterial material : purchaseContractVO.getMaterialList()){
material.setId(null);
material.setContractId( purchaseContractVO.getId() );
purchaseMaterialMapper.insert( material );
purchaseMoney = BaseUtil.add(purchaseMoney, material.getTotalPrice());
}
}
purchaseContractVO.setPurchaseMoney( purchaseMoney ) ;
this.baseMapper.updateById(purchaseContractVO ) ;
}
/**
......@@ -81,20 +92,21 @@ public class ERPPurchaseContractServiceImpl extends ServiceImpl<ERPPurchaseContr
* @return
*/
@Transactional
public boolean updatePurchaseContract(PurchaseContractVO purchaseContractVO){
int count = this.baseMapper.updateById( purchaseContractVO );
// ge根据计划编号删除清单集合
purchaseMaterialMapper.delByContractId(purchaseContractVO.getId() ) ;
if(count > 0 && purchaseContractVO.getMaterialList() != null && !purchaseContractVO.getMaterialList().isEmpty()){
//计算采购金额
String purchaseMoney = "0";
if( purchaseContractVO.getMaterialList() != null && !purchaseContractVO.getMaterialList().isEmpty()){
for(PurchaseMaterial material : purchaseContractVO.getMaterialList()){
material.setId(null);
material.setContractId( purchaseContractVO.getId() );
purchaseMaterialMapper.insert( material );
purchaseMoney = BaseUtil.add(purchaseMoney, material.getTotalPrice());
}
}
purchaseContractVO.setPurchaseMoney( purchaseMoney );
int count = this.baseMapper.updateById( purchaseContractVO );
return count > 0 ? true :false;
}
......@@ -212,6 +224,7 @@ public class ERPPurchaseContractServiceImpl extends ServiceImpl<ERPPurchaseContr
throw new Exception("采购合同记录不存在");
}*/
purchaseContractVO.setEquipmentInId( equipmentInDTO.getId() ) ;//记录入库单号
log.debug("记录入库单号{"+equipmentInDTO.getId()+"},入库单号:"+equipmentInDTO.getInOrder());
this.baseMapper.updateById(purchaseContractVO ) ;
return 1;
}
......
package com.skua.modules.erp.service.impl;
import com.skua.modules.erp.entity.MaterialAcceptanceForm;
import com.skua.modules.erp.entity.MaterialIN;
import com.skua.modules.erp.mapper.MaterialAcceptanceFormMapper;
import com.skua.modules.erp.service.IMaterialAcceptanceFormService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;
/**
* 物料验收单
*/
@Service
public class MaterialAcceptanceFormServiceImpl extends ServiceImpl<MaterialAcceptanceFormMapper, MaterialAcceptanceForm> implements IMaterialAcceptanceFormService {
/***
* 列表查询 验收单
* @param materialIN
* @return
*/
public List<MaterialAcceptanceForm> queryArrivalRecordByList(MaterialIN materialIN){
return this.baseMapper.queryArrivalRecordByList(materialIN);
}
}
......
package com.skua.modules.erp.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.skua.core.context.BaseContextHandler;
import com.skua.modules.erp.entity.ApproveRecord;
import com.skua.modules.erp.entity.MaterialIN;
import com.skua.modules.erp.mapper.ApproveRecordMapper;
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 org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import javax.annotation.Resource;
import java.util.List;
/**
* 物料(药剂)入库
......@@ -40,4 +43,31 @@ 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 ) ;
}
/***
* 列表查询到货记录列表
* @param materialIN
* @return
*/
public List<ArrivalRecordExcelExportVO> queryArrivalRecordByList(MaterialIN materialIN){
List<ArrivalRecordExcelExportVO> arrivalRecordExcelExportVOList = this.baseMapper.queryArrivalRecordByList(materialIN);
//遍历集合设置自增序号
if(arrivalRecordExcelExportVOList != null && !arrivalRecordExcelExportVOList.isEmpty()){
int index =1 ;
for( ArrivalRecordExcelExportVO excelExportVO :arrivalRecordExcelExportVOList){
excelExportVO.setIndex(index++);
}
}
return arrivalRecordExcelExportVOList;
}
/***
* 获取入库审批列表:根据部门、采购合同、供应商、药剂分组搜索
* @param page
* @param materialIN
* @return
*/
public IPage<MaterialIN> selectAuditMaterialINByPage(IPage<MaterialIN> page, MaterialIN materialIN) {
return page.setRecords(baseMapper.selectAuditMaterialINByPage(page, materialIN));
}
}
......
package com.skua.modules.erp.util;
import com.itextpdf.html2pdf.ConverterProperties;
import com.itextpdf.html2pdf.HtmlConverter;
import com.itextpdf.kernel.font.PdfFont;
import com.itextpdf.kernel.font.PdfFontFactory;
import com.itextpdf.kernel.geom.PageSize;
import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfWriter;
import com.itextpdf.layout.font.FontProvider;
import org.apache.velocity.Template;
import org.apache.velocity.app.Velocity;
import org.apache.velocity.context.Context;
import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
import java.io.OutputStream;
import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
/**
* PDF工具
*
* @author ppp
* @date 2022/8/5
*/
public class PdfUtil {
static {
// Velocity初始化
Velocity.setProperty(RuntimeConstants.OUTPUT_ENCODING, StandardCharsets.UTF_8);
Velocity.setProperty(RuntimeConstants.INPUT_ENCODING, StandardCharsets.UTF_8);
Velocity.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
Velocity.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
Velocity.init();
}
/**
* 据模板生成pfd格式文件
*
* @param context 上下文对象
* @param template pdf模板
* @param outputStream 生成ofd文件输出流
*/
public static void pdfFile(Context context, String template, OutputStream outputStream) {
try (PdfWriter pdfWriter = new PdfWriter(outputStream)) {
PdfDocument pdfDocument = new PdfDocument(pdfWriter);
pdfDocument.setDefaultPageSize(PageSize.A4);
ConverterProperties properties = new ConverterProperties();
FontProvider fontProvider = new FontProvider();
// 字体设置,解决中文不显示问题
PdfFont sysFont = PdfFontFactory.createFont("STSongStd-Light", "UniGB-UCS2-H");
fontProvider.addFont(sysFont.getFontProgram(), "UniGB-UCS2-H");
properties.setFontProvider(fontProvider);
Template pfdTemplate = Velocity.getTemplate(template, "UTF-8");
StringWriter writer = new StringWriter();
pfdTemplate.merge(context, writer);
//System.out.println("***************writer.toString()***************************");
System.out.println(writer.toString());
HtmlConverter.convertToPdf(writer.toString(), pdfDocument, properties);
pdfDocument.close();
} catch (Exception e) {
throw new RuntimeException("PFD文件生成失败", e);
}
}
}
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;
import org.jeecgframework.poi.excel.annotation.Excel;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="ArrivalRecordVO到货验收记录", description="到货验收记录")
public class ArrivalRecordExcelExportVO {
/**序号*/
@Excel(name = "序号", width = 15 ,orderNum = "1")
@ApiModelProperty(value = "序号")
private Integer index;
/**到货时间*/
@Excel(name = "到货时间", width = 15,orderNum = "2")
@ApiModelProperty(value = "到货时间")
private String arriveTime;
/**所属机构*/
@Excel(name = "使用单位", width = 15 ,orderNum = "3")
@ApiModelProperty(value = "使用单位")
private String departName;
/**药剂(物料)名称*/
@Excel(name = "药剂(物料)名称", width = 15 ,orderNum = "4")
@ApiModelProperty(value = "药剂(物料)名称")
private String sparepartName;
/**计量单位*/
@Excel(name = "计量单位", width = 15,orderNum = "5")
@ApiModelProperty(value = "计量单位")
private String measuringUnit;
/**数量*/
@Excel(name = "数量", width = 15,orderNum = "6")
@ApiModelProperty(value = "数量")
private String purchaseNum;
/**供应商编号*/
@Excel(name = "供应商编号", width = 15,orderNum = "7")
@ApiModelProperty(value = "供应商编号")
private String supplierName;
/**货号*/
@Excel(name = "货号", width = 15,orderNum = "8")
@ApiModelProperty(value = "货号")
private String goodCode;
/**分销合同*/
@Excel(name = "分销合同号", width = 15 ,orderNum = "9")
@ApiModelProperty(value = "分销合同号")
private String distributContractCode;
/**采购合同*/
@Excel(name = "采购合同", width = 15,orderNum = "10")
@ApiModelProperty(value = "采购合同")
private String purchaseContractCode;
/**采购总价*/
@Excel(name = "采购总价", width = 15 ,orderNum = "11")
@ApiModelProperty(value = "采购总价")
private String purchaseTotalPrice;
/**分销总价*/
@Excel(name = "分销总价", width = 15,orderNum = "12")
@ApiModelProperty(value = "分销总价")
private String distributTotalPrice;
}
package com.skua.modules.erp.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="ArrivalRecordVO到货验收记录", description="到货验收记录")
public class ArrivalRecordPDFVO {
/**到货时间*/
@Excel(name = "到货时间", width = 15,orderNum = "2")
@ApiModelProperty(value = "到货时间")
private String arriveTime;
/**所属机构*/
@Excel(name = "使用单位", width = 15 ,orderNum = "3")
@ApiModelProperty(value = "使用单位")
private String departName;
/**药剂(物料)名称*/
@Excel(name = "药剂(物料)名称", width = 15 ,orderNum = "4")
@ApiModelProperty(value = "药剂(物料)名称")
private String sparepartName;
/**计量单位*/
@Excel(name = "计量单位", width = 15,orderNum = "5")
@ApiModelProperty(value = "计量单位")
private String measuringUnit;
/**数量*/
@Excel(name = "数量", width = 15,orderNum = "6")
@ApiModelProperty(value = "数量")
private String purchaseNum;
/**供应商编号*/
@Excel(name = "供应商编号", width = 15,orderNum = "7")
@ApiModelProperty(value = "供应商编号")
private String supplierName;
/**货号*/
@Excel(name = "货号", width = 15,orderNum = "8")
@ApiModelProperty(value = "货号")
private String goodCode;
/**分销合同*/
@Excel(name = "分销合同号", width = 15 ,orderNum = "9")
@ApiModelProperty(value = "分销合同号")
private String distributContractCode;
/**采购合同*/
@Excel(name = "采购合同", width = 15,orderNum = "10")
@ApiModelProperty(value = "采购合同")
private String purchaseContractCode;
/**采购总价*/
@Excel(name = "采购总价", width = 15 ,orderNum = "11")
@ApiModelProperty(value = "采购总价")
private String purchaseTotalPrice;
/**分销总价*/
@Excel(name = "分销总价", width = 15,orderNum = "12")
@ApiModelProperty(value = "分销总价")
private String distributTotalPrice;
}
......@@ -23,4 +23,7 @@ public class MaterialSearchVO {
@ApiModelProperty(value = "所属厂站")
private String departId;
@ApiModelProperty(value = "是否药剂")
private boolean medicament = false;
}
......
package com.skua.modules.quartz.util;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.ParseException;
......@@ -212,6 +214,14 @@ public class BaseUtil {
date = calendar.getTime();
return date;
}
// 加法
public static String add(String a, String b) {
if(StringUtils.isNotEmpty(a) && StringUtils.isNotEmpty(b)){
return String.valueOf(Double.parseDouble(a) + Double.parseDouble(b));
}
return "0";
}
/**
* 进行加法运算
*
......
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
</head>
<body>
<div class="contianer">
<div class="bg-img-container">
</div>
<h1>模板pdf</h1>
<div class="flex-div">
<p>表1</p>
</div>
<table border="1" cellSpacing="1">
<tr>
<th>姓名</th>
<td colspan="3">$!{name}</td>
</tr>
<tr>
<th #if($!{gender}==1) class="blue" #else class="red" #end>性别</th>
<td colspan="3">
#if($!{gender}==1)
#else
#end
<input type="checkbox" checked="checked">是否
</td>
</tr>
<tr>
<th>出生日期</th>
<td>$!{birthDate}</td>
<th>联系方式</th>
<td>$!{phone}</td>
</tr>
</table>
<h1>双重For循环取值</h1>
<div class="flex-div">
<p>表2</p>
</div>
<table border="1" cellSpacing="1">
<tr>
<th>学历</th>
<th>学科</th>
<td class="gray-bg">分数</td>
</tr>
#foreach($item in $eduList)
<tr>
<th #set($len= $item.size+1) rowspan="$len">$item.name</th>
#foreach($result in $item.itemList)
<tr>
<td>$velocityCount、$result.subject</td>
<td #if($result.num > 60) class="green" #else class="red" #end>$result.num</td>
</tr>
#end
</tr>
#end
</table>
</div>
</body>
<style>
.blue {
color: #244385;
margin-left: 30px;
}
.green {
color: #52c41a;
margin-left: 30px;
}
.red {
color: #c1181e;
margin-left: 30px;
}
.flex-div {
margin: 30px 0 15px;
display: flex;
align-items: center;
}
.line {
width: 540px;
height: 0px;
border: dashed 1px #edf0f5;
}
table {
width: 700px;
border-collapse: collapse;
/*border-spacing: 0;*/
border-left: 1px solid #edf0f5;
border-top: 1px solid #edf0f5;
}
th, td {
border-right: 1px solid #edf0f5;
border-bottom: 1px solid #edf0f5;
padding: 5px 15px;
}
h1 {
text-align: center;
font-family: 'Microsoft YaHei';
line-height: 60px;
letter-spacing: 8px;
color: #244385;
}
p {
font-family: 'Microsoft YaHei';
font-size: 20px;
font-weight: normal;
color: #244385;
margin: 0 16px;
}
th {
background-color: rgba(0, 0, 0, 0.01);
width: 90px;
min-width: 90px;
max-width: 90px;
text-align: left;
text-indent: 10px;
font-family: 'Microsoft YaHei';
font-size: 16px;
font-weight: normal;
font-stretch: normal;
line-height: 48px;
letter-spacing: 2px;
color: #666666;
}
td {
font-size: 16px;
color: #000000;
text-align: left;
text-indent: 10px;
padding-right: 20px;
height: 50px;
}
table,tr, th, td {
border: solid 1px #edf0f5;
}
.gray-bg {
background-color: rgba(0, 0, 0, 0.01);
}
</style>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>送货单及物料验收单</title>
</head>
<body>
送货单及物料验收单(模版页面)
context.put("startTime", materialIN.getStartTime());//开始时间
context.put("endTime", materialIN.getEndTime());//结束时间
context.put("supplierName", "");//供应商名称
context.put("purchaseContractCode", "");//采购合同
context.put("sparepartName", "");//药剂名称
context.put("specification", "");//规格
context.put("sparepartName", "");//部门名称
dataList 列表数据
</body>
</html>
\ No newline at end of file
......@@ -22,5 +22,5 @@ public interface IEquipmentInService extends IService<EquipmentIn> {
* 入库新增
* @param equipmentInDTO
*/
public int saveEquipmentIn(EquipmentInDTO equipmentInDTO) throws Exception;
int saveEquipmentIn(EquipmentInDTO equipmentInDTO) throws Exception;
}
......
......@@ -60,98 +60,18 @@ public class EquipmentSparepartTypeController {
* 分页列表查询
*
* @param equipmentSparepartType
* @param pageNo
* @param pageSize
* @return
*/
@AutoLog(value = "设备物资类型-分页列表查询")
@ApiOperation(value = "设备物资类型-分页列表查询", notes = "设备物资类型-分页列表查询")
@AutoLog(value = "设备物资类型-树形集合")
@ApiOperation(value = "设备物资类型-树形集合", notes = "设备物资类型-树形集合")
@GetMapping(value = "/list")
public Result<List<EquipmentSparepartTypeVO>> queryPageList(EquipmentSparepartType equipmentSparepartType,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
public Result<List<EquipmentSparepartTypeVO>> queryPageList(EquipmentSparepartType equipmentSparepartType) {
Result<List<EquipmentSparepartTypeVO>> result = new Result<>();
QueryWrapper<EquipmentSparepartType> queryWrapper = new QueryWrapper<>();
queryWrapper.orderByAsc("sort");
String itemText = equipmentSparepartType.getItemText();
if (StringUtils.isNotBlank(itemText)) {
queryWrapper.like("item_text",itemText);
}
List<EquipmentSparepartType> equipmentSparepartTypeList = equipmentSparepartTypeService.list(queryWrapper);
if (equipmentSparepartType.isMedicament()) {//查询药剂类别
queryWrapper.eq("medicament",equipmentSparepartType.isMedicament());
//药剂的物料分类
List<EquipmentSparepartType> medicamentList = equipmentSparepartTypeService.list(queryWrapper);
equipmentSparepartTypeList = this.equipmentSparepartTypeListByMedicament(equipmentSparepartTypeList , medicamentList );
}
List<EquipmentSparepartTypeVO> voList = new ArrayList<>();
getTree(voList, equipmentSparepartTypeList, null);
List<EquipmentSparepartTypeVO> voList = equipmentSparepartTypeService.querySparepartTypeListByTree(equipmentSparepartType);
result.setSuccess(true);
result.setResult(voList);
return result;
}
/***
* 递归转换为tree结构
* @param voList
* @param entityList
* @param tmp
*/
private void getTree(List<EquipmentSparepartTypeVO> voList, List<EquipmentSparepartType> entityList, EquipmentSparepartTypeVO tmp) {
for (EquipmentSparepartType item : entityList) {
String parentId = item.getParentId();
EquipmentSparepartTypeVO vo = new EquipmentSparepartTypeVO(item);
if (tmp == null && org.apache.commons.lang.StringUtils.isEmpty(parentId)) {
voList.add(vo);
if (!vo.isLeaf()) {
getTree(voList, entityList, vo);
}
} else if (tmp != null && parentId != null && parentId.equals(tmp.getId())) {
tmp.getChildren().add(vo);
if (!vo.isLeaf()) {
getTree(voList, entityList, vo);
}
}
}
}
/***
* 拼装 药剂的物料分类
* @param allTypeList
* @param medicamentList
* @return
*/
private List<EquipmentSparepartType> equipmentSparepartTypeListByMedicament(List<EquipmentSparepartType> allTypeList ,List<EquipmentSparepartType> medicamentList ){
Set<EquipmentSparepartType> resultSet = new HashSet<>();
// List<EquipmentSparepartType> dataList = new ArrayList<>();
StringBuffer ancestors = new StringBuffer();
for( EquipmentSparepartType equipmentSparepartType : medicamentList){
ancestors.append(equipmentSparepartType.getAncestors()).append(",");
resultSet.add(equipmentSparepartType );
for( EquipmentSparepartType equipmentSparepartType2 : allTypeList){
// 添加下游数据
if(equipmentSparepartType2.getAncestors().contains( equipmentSparepartType.getAncestors() )){
resultSet.add(equipmentSparepartType2 );
}
}
// 将原始字符串按逗号分隔并放入LinkedHashSet中去重
Set<String> uniqueFruits = new LinkedHashSet<>(Arrays.asList(ancestors.toString().split(",")));
//添加上游数据
for(String id : uniqueFruits){
for( EquipmentSparepartType equipmentSparepartType3 : allTypeList){
if(id.equals( equipmentSparepartType3.getId() )){
resultSet.add(equipmentSparepartType3 ) ;
}
}
}
}
return new ArrayList<>(resultSet);
}
/**
* 添加
*
......
......@@ -2,7 +2,9 @@ package com.skua.modules.supplies.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.skua.modules.supplies.entity.EquipmentSparepartType;
import com.skua.modules.supplies.vo.EquipmentSparepartTypeVO;
import java.util.List;
import java.util.Set;
/**
......@@ -33,4 +35,18 @@ public interface IEquipmentSparepartTypeService extends IService<EquipmentSparep
* @param newAncestors
*/
void updateAncestors(String oldAncestors, String newAncestors);
/***
* 查询物料类别集合
* @param equipmentSparepartType
* @return
*/
List<EquipmentSparepartType> querySparepartTypeList(EquipmentSparepartType equipmentSparepartType);
/***
* 查询物料类别集合
* @param equipmentSparepartType
* @return
*/
List<EquipmentSparepartTypeVO> querySparepartTypeListByTree(EquipmentSparepartType equipmentSparepartType);
}
......
......@@ -3,7 +3,9 @@ package com.skua.modules.supplies.service.impl;
import java.util.*;
import com.skua.core.util.ConvertUtils;
import com.skua.modules.supplies.vo.EquipmentSparepartTypeVO;
import com.skua.tool.dfs.MapDFS;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -72,4 +74,95 @@ public class EquipmentSparepartTypeServiceImpl extends ServiceImpl<EquipmentSpar
this.baseMapper.updateAncestors(oldAncestors, newAncestors);
}
/***
* 查询物料类别集合-返回树结构
* @param equipmentSparepartType
* @return
*/
public List<EquipmentSparepartTypeVO> querySparepartTypeListByTree(EquipmentSparepartType equipmentSparepartType){
List<EquipmentSparepartType> equipmentSparepartTypeList = this.querySparepartTypeList(equipmentSparepartType);
List<EquipmentSparepartTypeVO> voList = new ArrayList<>();
getTree(voList, equipmentSparepartTypeList, null);
return voList;
}
/***
* 查询物料类别集合-返回列表
* @param equipmentSparepartType
* @return
*/
public List<EquipmentSparepartType> querySparepartTypeList(EquipmentSparepartType equipmentSparepartType){
QueryWrapper<EquipmentSparepartType> queryWrapper = new QueryWrapper<>();
queryWrapper.orderByAsc("sort");
String itemText = equipmentSparepartType.getItemText();
if (StringUtils.isNotBlank(itemText)) {
queryWrapper.like("item_text",itemText);
}
List<EquipmentSparepartType> equipmentSparepartTypeList = this.list(queryWrapper);
if (equipmentSparepartType.isMedicament()) {//查询药剂类别
queryWrapper.eq("medicament",equipmentSparepartType.isMedicament());
//药剂的物料分类
List<EquipmentSparepartType> medicamentList = this.list(queryWrapper);
equipmentSparepartTypeList = this.equipmentSparepartTypeListByMedicament(equipmentSparepartTypeList , medicamentList );
}
return equipmentSparepartTypeList;
}
/***
* 递归转换为tree结构
* @param voList
* @param entityList
* @param tmp
*/
private void getTree(List<EquipmentSparepartTypeVO> voList, List<EquipmentSparepartType> entityList, EquipmentSparepartTypeVO tmp) {
for (EquipmentSparepartType item : entityList) {
String parentId = item.getParentId();
EquipmentSparepartTypeVO vo = new EquipmentSparepartTypeVO(item);
if (tmp == null && org.apache.commons.lang.StringUtils.isEmpty(parentId)) {
voList.add(vo);
if (!vo.isLeaf()) {
getTree(voList, entityList, vo);
}
} else if (tmp != null && parentId != null && parentId.equals(tmp.getId())) {
tmp.getChildren().add(vo);
if (!vo.isLeaf()) {
getTree(voList, entityList, vo);
}
}
}
}
/***
* 拼装 药剂的物料分类
* @param allTypeList
* @param medicamentList
* @return
*/
private List<EquipmentSparepartType> equipmentSparepartTypeListByMedicament(List<EquipmentSparepartType> allTypeList ,List<EquipmentSparepartType> medicamentList ){
Set<EquipmentSparepartType> resultSet = new HashSet<>();
// List<EquipmentSparepartType> dataList = new ArrayList<>();
StringBuffer ancestors = new StringBuffer();
for( EquipmentSparepartType equipmentSparepartType : medicamentList){
ancestors.append(equipmentSparepartType.getAncestors()).append(",");
resultSet.add(equipmentSparepartType );
for( EquipmentSparepartType equipmentSparepartType2 : allTypeList){
// 添加下游数据
if(equipmentSparepartType2.getAncestors().contains( equipmentSparepartType.getAncestors() )){
resultSet.add(equipmentSparepartType2 );
}
}
// 将原始字符串按逗号分隔并放入LinkedHashSet中去重
Set<String> uniqueFruits = new LinkedHashSet<>(Arrays.asList(ancestors.toString().split(",")));
//添加上游数据
for(String id : uniqueFruits){
for( EquipmentSparepartType equipmentSparepartType3 : allTypeList){
if(id.equals( equipmentSparepartType3.getId() )){
resultSet.add(equipmentSparepartType3 ) ;
}
}
}
}
return new ArrayList<>(resultSet);
}
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!