futian.liu
2023-11-30 86fdf3673cd8b3f34ed57a80556512cdcabdb202
consum-base/src/main/java/com/consum/base/service/LWhFormScrappedServiceImpl.java
@@ -9,28 +9,36 @@
import com.consum.base.pojo.LWhFormScrappedGoodsInfoParam;
import com.consum.base.pojo.LWhFormScrappedGoodsModelParams;
import com.consum.base.pojo.LWhFormScrappedParam;
import com.consum.base.pojo.excel.ScrappedInfoExcelTemplate;
import com.consum.base.pojo.query.LWhFormScrappedQry;
import com.consum.base.pojo.response.FormScrappedGoodsDetailVO;
import com.consum.base.pojo.response.FormScrappedGoodsVO;
import com.consum.base.pojo.response.GoodsModelVO;
import com.consum.base.pojo.response.LWhFormScrappedExtendVO;
import com.consum.model.po.*;
import com.consum.model.po.BaseGoodsModels;
import com.consum.model.po.BaseGoodsTemplate;
import com.consum.model.po.BaseWarehouse;
import com.consum.model.po.FinSysTenantDepartment;
import com.consum.model.po.FinSysTenantUser;
import com.consum.model.po.LWhFormScrapped;
import com.consum.model.po.LWhFormScrappedGoods;
import com.consum.model.po.SDictData;
import com.iplatform.model.po.S_user_core;
import com.walker.db.page.GenericPager;
import com.walker.infrastructure.utils.StringUtils;
import com.walker.jdbc.service.BaseServiceImpl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import org.apache.commons.compress.utils.Lists;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
 * @Description 报废单
@@ -59,7 +67,7 @@
    @Autowired
    private LWhFormScrappedCoreService lWhFormScrappedCoreService;
    private static String QUERY_LIST = "SELECT fs.* FROM l_wh_form_scrapped fs left join l_wh_form_scrapped_goods fsg on fs.id = fsg.FORM_SCRAPPED_ID WHERE 1 = 1 ";
    private static String QUERY_LIST = "SELECT DISTINCT fs.* FROM l_wh_form_scrapped fs left join l_wh_form_scrapped_goods fsg on fs.id = fsg.FORM_SCRAPPED_ID WHERE 1 = 1 ";
    private static final String QUERY_BF_DETAIL_LIST = "select fs.id,fs.BUSINESS_FORM_CODE,fsg.GOODS_TEMPLATE_NAME,fsg.BASE_GOODS_MODELS_NAME,fsg.COUNTS,"
        + "fs.AGENCY_NAME,OPERATOR_NAME,DEAL_TIME from l_wh_form_scrapped fs "
@@ -82,11 +90,12 @@
        lWhFormScrapped.setId(lWhFormScrappedId);
        lWhFormScrapped.setBusinessFormCode(codeGeneratorService.createBusinessFormCode(CodeGeneratorEnum.Scrapped));
        lWhFormScrapped.setWarehouseType(warehouseType);
        // 公用
        Long warehouseId = null;
        //仓库名称
        String wareHouseName = null;
        if (warehouseType == 0){
        if (warehouseType == 0) {
            warehouseId = param.getWarehouseId();
            //根据仓库id查询仓库
            BaseWarehouse warehouse = this.baseWarehouseService.getById(warehouseId);
@@ -113,6 +122,7 @@
        lWhFormScrapped.setOperatorName(sysInfo.getUserName());
        lWhFormScrapped.setDealTime(param.getDealTime());
        lWhFormScrapped.setStates(0);
        lWhFormScrapped.setUploadFiles(param.getUploadFiles());
        //根据部门id查询部门
        FinSysTenantDepartment department = this.departmentService.getById(sysInfo.getSysDeptId());
        if (department != null) {
@@ -181,7 +191,7 @@
                scrappedGoodsList.add(scrappedGoods);
            }
            int flag2 = this.scrappedGoodsService.insert(scrappedGoodsList);
            int flag2 = this.scrappedGoodsService.insertBatch(scrappedGoodsList);
            if (flag2 != scrappedGoodsList.size()) {
                log.error("新增报废单物品记录 失败");
                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -265,6 +275,16 @@
            formScrappedGoodsVO.setBaseGoodsTemplateId(baseGoodsTemplateId);
            formScrappedGoodsVO.setGoodsName(lWhFormScrappedGoods.getGoodsTemplateName());
            String sql = "select CATEGORY_NAME from base_goods_template where id = :id";
            Map<String, Object> param = new HashMap<>();
            param.put("id", baseGoodsTemplateId);
            List<Map<String, Object>> goodTemplate = this.select(sql, param, new MapperUtil());
            if (!CollectionUtils.isEmpty(goodTemplate)) {
                Optional<Map<String, Object>> first = goodTemplate.stream().findFirst();
                Map<String, Object> objectMap = first.get();
                formScrappedGoodsVO.setCategoryName(objectMap.get("categoryName").toString());
            }
            List<GoodsModelVO> goodsModelList = Lists.newArrayList();
            goodsList.forEach(item -> {
                GoodsModelVO goodsModelVO = new GoodsModelVO();
@@ -344,37 +364,37 @@
        return pageUtil;
    }
    public List<Map<String, Object>> export(Long id) {
    public List<ScrappedInfoExcelTemplate> export(Long id) {
        String sql =
            "SELECT BUSINESS_FORM_CODE, fs.DEAL_TIME, OPERATOR_NAME, AGENCY_NAME, GOODS_TEMPLATE_NAME, BASE_GOODS_MODELS_NAME, DEPARTMENT_NAME, COUNTS, SCRAPPED_NAME, BEIZ "
                + "FROM l_wh_form_scrapped_goods fsg LEFT JOIN l_wh_form_scrapped fs ON fs.id = fsg.FORM_SCRAPPED_ID WHERE "
                + "fs.ID = :id and STATES = 1";
            "SELECT\n"
                + "\tBUSINESS_FORM_CODE,\n"
                + "\tfs.DEAL_TIME,\n"
                + "\tOPERATOR_NAME,\n"
                + "\tAGENCY_NAME tenantName,\n"
                + "\tGOODS_TEMPLATE_NAME templateName,\n"
                + "\tBASE_GOODS_MODELS_NAME baseModelName,\n"
                + "\tCOUNTS num,\n"
                + "\tSCRAPPED_NAME deception,\n"
                + "\tBEIZ remark\n"
                + "FROM\n"
                + "\tl_wh_form_scrapped_goods fsg\n"
                + "\tLEFT JOIN l_wh_form_scrapped fs ON fs.id = fsg.FORM_SCRAPPED_ID\n"
                + "WHERE\n"
                + "\tfs.ID = :id\n"
                + "\tAND STATES = 1";
        Map<String, Object> param = new HashMap<>();
        param.put("id", id);
        List<Map<String, Object>> select = this.select(sql, param, new MapperUtil());
        return select;
        if (CollectionUtils.isEmpty(select)) {
            return null;
        }
        List<ScrappedInfoExcelTemplate> list = Lists.newArrayList();
        select.forEach(item -> {
            ScrappedInfoExcelTemplate inventoryExcelTemplate = MapUtils.convertMapToObj(item, ScrappedInfoExcelTemplate.class);
            list.add(inventoryExcelTemplate);
        });
        return list;
    }
    /**
     * @Description 导出报废登记单
     * @Author 卢庆阳
     * @Date 2023/11/2
     */
//    public LWhFormScrappedExtendVO export(Long id, FinSysTenantUser sysInfo) {
//        LWhFormScrappedExtendVO scrappedExtend = new LWhFormScrappedExtendVO();
//        //1.查询报废单
//        LWhFormScrapped lWhFormScrapped = this.get(new LWhFormScrapped(id));
//        if (lWhFormScrapped != null) {
//            lWhFormScrapped.setDealTime(DateUtils.getDateTimeNumber(System.currentTimeMillis()));
//            lWhFormScrapped.setOperatorName(sysInfo.getUserName());
//            BeanUtils.copyProperties(lWhFormScrapped, scrappedExtend);
//        }
//        //2.查询报废单物品
//        List<LWhFormScrappedGoods> scrappedGoodsList = this.scrappedGoodsService.getByFormScrappedId(id);
//        if (!CollectionUtils.isEmpty(scrappedGoodsList)) {
//            scrappedExtend.setScrappedGoodsList(scrappedGoodsList);
//        }
//        return scrappedExtend;
//    }
}