| | |
| | | package com.consum.base.service; |
| | | |
| | | import com.consum.base.core.utils.CurrencyUtil; |
| | | import com.consum.base.core.utils.MapUtils; |
| | | import com.consum.base.core.utils.MapperUtil; |
| | | import com.consum.base.core.utils.PageUtil; |
| | | import com.consum.base.pojo.excel.ProcureExcelTemplate; |
| | | import com.consum.base.pojo.query.FormProcureQry; |
| | | import com.consum.model.po.LWhFormProcure; |
| | | import com.walker.db.page.GenericPager; |
| | | import com.walker.infrastructure.utils.CollectionUtils; |
| | | import com.walker.infrastructure.utils.StringUtils; |
| | | import com.walker.jdbc.service.BaseServiceImpl; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import org.apache.commons.compress.utils.Lists; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * @ClassName lWhFormProcureService |
| | | * @Date 2023/10/24 |
| | | * @Description 采购单 |
| | | * @Version 1.0 |
| | | **/ |
| | | @Service |
| | | public class LWhFormProcureService extends BaseServiceImpl { |
| | | import com.consum.base.core.utils.PageUtil; |
| | | import com.consum.base.pojo.LWhFormProcureParam; |
| | | import com.consum.base.pojo.excel.ProcureExcelTemplate; |
| | | import com.consum.base.pojo.query.FormProcureQry; |
| | | import com.consum.model.po.FinSysTenantUser; |
| | | import com.consum.model.po.LWhFormProcure; |
| | | import com.iplatform.model.po.S_user_core; |
| | | import com.walker.db.page.GenericPager; |
| | | import com.walker.jdbc.service.BaseService; |
| | | |
| | | private static String QUERY_FORM_PROCURE_LIST = "SELECT * FROM L_WH_FORM_PROCURE WHERE 1 = 1"; |
| | | public interface LWhFormProcureService extends BaseService { |
| | | |
| | | public PageUtil<LWhFormProcure> queryFormProcureList(FormProcureQry param) { |
| | | HashMap<String, Object> paramts = new HashMap<>(); |
| | | StringBuilder sql = new StringBuilder(QUERY_FORM_PROCURE_LIST); |
| | | //入库单号 |
| | | if (!StringUtils.isEmpty(param.getBusinessFormCode())) { |
| | | sql.append(" and BUSINESS_FORM_CODE like :businessFormCode "); |
| | | paramts.put("businessFormCode", StringUtils.CHAR_PERCENT + param.getBusinessFormCode() + StringUtils.CHAR_PERCENT); |
| | | } |
| | | if (param.getAgencyId() != null) { |
| | | sql.append(" and AGENCY_ID like :agencyId "); |
| | | paramts.put("agencyId", param.getAgencyId() + StringUtils.CHAR_PERCENT); |
| | | } |
| | | //创建人 |
| | | if (!StringUtils.isEmpty(param.getCreateName())) { |
| | | sql.append(" and buyer_Name =:buyerName "); |
| | | paramts.put("buyerName", param.getCreateName()); |
| | | } |
| | | //状态 |
| | | if (param.getStates() != null) { |
| | | sql.append(" and states =:states "); |
| | | paramts.put("states", param.getStates()); |
| | | } |
| | | //入库时间 |
| | | if (param.getStartTime() != null) { |
| | | sql.append(" and INCOME_TIME >=:incomeTimeStart "); |
| | | paramts.put("incomeTimeStart", param.getStartTime() * 1000000); |
| | | } |
| | | if (param.getEndTime() != null) { |
| | | sql.append(" and INCOME_TIME <:incomeTimeEnd "); |
| | | paramts.put("incomeTimeEnd", param.getEndTime() * 1000000 + 240000); |
| | | } |
| | | //物品名称 |
| | | if (!StringUtils.isEmpty(param.getGoodsTemplateName())) { |
| | | sql.append( |
| | | " AND id IN (SELECT BUSINESS_ID FROM L_WH_PROCURE_MODEL procureModel LEFT JOIN BASE_GOODS_MODELS baseModel ON procureModel.BASE_GOODS_MODELS_ID=baseModel.ID LEFT JOIN BASE_GOODS_TEMPLATE baseTemp ON baseModel.GOODS_TEMPLATES_ID=baseTemp.id WHERE procureModel.BUSINESS_TYPE=1 AND baseTemp.GOODS_NAME LIKE :goodsTemplateName)"); |
| | | paramts.put("goodsTemplateName", StringUtils.CHAR_PERCENT + param.getGoodsTemplateName() + StringUtils.CHAR_PERCENT); |
| | | } |
| | | sql.append(" ORDER BY PROCURE_TIME DESC"); |
| | | GenericPager genericPager = selectSplit(sql.toString(), paramts, new LWhFormProcure()); |
| | | PageUtil pageUtil = new PageUtil(genericPager); |
| | | return pageUtil; |
| | | PageUtil<LWhFormProcure> queryFormProcureList(FormProcureQry param); |
| | | |
| | | } |
| | | /** |
| | | * 采购单明细查询 |
| | | * |
| | | * @param param |
| | | * @return |
| | | */ |
| | | GenericPager<Map<String, Object>> queryFormProcureDetailList(FormProcureQry param); |
| | | |
| | | public GenericPager<Map<String, Object>> queryFormProcureDetailList(FormProcureQry param) { |
| | | HashMap<String, Object> paramts = new HashMap<>(); |
| | | StringBuilder sql = new StringBuilder("SELECT pm.id,fp.BUSINESS_FORM_CODE,fpg.GOODS_TEMPLATE_NAME,pm.PRICE,pm.COUNTS, " |
| | | + "( pm.PRICE * pm.COUNTS ) amount,fp.AGENCY_NAME,fp.BUYER_NAME,fp.PROCURE_TIME,pm.BUSINESS_ID,pm.BASE_GOODS_MODELS_NAME FROM l_wh_procure_model pm " |
| | | + "LEFT JOIN l_wh_form_procure fp ON pm.BUSINESS_ID = fp.id " |
| | | + "LEFT JOIN l_wh_form_procure_goods fpg ON fp.id = fpg.WH_FORM_PROCURE_ID WHERE pm.BUSINESS_TYPE = 1 "); |
| | | //入库单号 |
| | | if (!StringUtils.isEmpty(param.getBusinessFormCode())) { |
| | | sql.append("and BUSINESS_FORM_CODE = :businessFormCode "); |
| | | paramts.put("businessFormCode", param.getBusinessFormCode()); |
| | | } |
| | | //物品名称 |
| | | if (!StringUtils.isEmpty(param.getGoodsTemplateName())) { |
| | | sql.append("and fpg.GOODS_TEMPLATE_NAME like :goodsTemplateName "); |
| | | paramts.put("goodsTemplateName", StringUtils.CHAR_PERCENT + param.getGoodsTemplateName() + StringUtils.CHAR_PERCENT); |
| | | } |
| | | if (param.getAgencyId() != null) { |
| | | sql.append("and AGENCY_ID like :agencyId "); |
| | | paramts.put("agencyId", param.getAgencyId() + StringUtils.CHAR_PERCENT); |
| | | } |
| | | //创建人 |
| | | if (!StringUtils.isEmpty(param.getCreateName())) { |
| | | sql.append("and buyer_Name =:buyerName "); |
| | | paramts.put("buyerName", param.getCreateName()); |
| | | } |
| | | //入库开始时间 |
| | | if (param.getStartTime() != null) { |
| | | sql.append("and INCOME_TIME >=:incomeTimeStart "); |
| | | paramts.put("incomeTimeStart", param.getStartTime() * 1000000); |
| | | } |
| | | //入库结束时间 |
| | | if (param.getEndTime() != null) { |
| | | sql.append("and INCOME_TIME <:incomeTimeEnd "); |
| | | paramts.put("incomeTimeEnd", param.getEndTime() * 1000000 + 240000); |
| | | } |
| | | //规格型号 |
| | | if (param.getBaseGoodsModelsId() != null) { |
| | | sql.append("and pm.BASE_GOODS_MODELS_ID =:baseGoodsModelsId "); |
| | | paramts.put("baseGoodsModelsId", param.getBaseGoodsModelsId()); |
| | | } |
| | | /** |
| | | * 导出 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | List<ProcureExcelTemplate> getExportList(Long id); |
| | | |
| | | sql.append("ORDER BY PROCURE_TIME DESC"); |
| | | GenericPager genericPager = selectSplit(sql.toString(), paramts, param.getPageNum(), param.getPageSize(), new MapperUtil()); |
| | | return genericPager; |
| | | |
| | | } |
| | | |
| | | public List<ProcureExcelTemplate> getExportList(Long id) { |
| | | String sql = "SELECT\n" |
| | | + "\tfp.BUSINESS_FORM_CODE,\n" |
| | | + "\tfp.AGENCY_NAME tenantName,\n" |
| | | + "\tfp.INCOME_TIME createTime,\n" |
| | | + "\tfp.INCOME_NAME operatorName,\n" |
| | | + "\tGOODS_NAME templateName,\n" |
| | | + "\tpm.BASE_GOODS_MODELS_NAME baseModelName,\n" |
| | | + "\tcounts num,\n" |
| | | + "\tprice,\n" |
| | | + "\ttotal_amount totalAmount,\n" |
| | | + "\tWAREHOUSE_NAME,\n" |
| | | + "\tBEIZ remark\n" |
| | | + "FROM\n" |
| | | + "\tl_wh_procure_model pm\n" |
| | | + "\tLEFT JOIN base_goods_models bgm ON pm.BASE_GOODS_MODELS_ID = bgm.id\n" |
| | | + "\tLEFT JOIN base_goods_template bgt ON bgm.GOODS_TEMPLATES_ID = bgt.id\n" |
| | | + "\tLEFT JOIN l_wh_form_procure fp ON fp.ID = pm.BUSINESS_ID\n" |
| | | + "WHERE\n" |
| | | + "\tpm.BUSINESS_ID = :id"; |
| | | Map<String, Object> param = new HashMap<>(); |
| | | param.put("id", id); |
| | | List<Map<String, Object>> select = this.select(sql, param, new MapperUtil()); |
| | | if (CollectionUtils.isEmpty(select)) { |
| | | return null; |
| | | } |
| | | |
| | | List<ProcureExcelTemplate> list = Lists.newArrayList(); |
| | | select.forEach(item -> { |
| | | ProcureExcelTemplate templateExcelExport = MapUtils.convertMapToObj(item, ProcureExcelTemplate.class); |
| | | templateExcelExport.setTotalAmount(CurrencyUtil.convertFenToYuan(templateExcelExport.getTotalAmount())); |
| | | templateExcelExport.setPrice(CurrencyUtil.convertFenToYuan(templateExcelExport.getPrice())); |
| | | list.add(templateExcelExport); |
| | | }); |
| | | return list; |
| | | |
| | | |
| | | } |
| | | /** |
| | | * 新增 |
| | | * |
| | | * @param param |
| | | * @param sysTenantUser |
| | | * @param currentUser |
| | | */ |
| | | void add(LWhFormProcureParam param, FinSysTenantUser sysTenantUser, S_user_core currentUser); |
| | | } |