Lius
2024-08-12 16e35b191d910e5e586a9eae5678324bfa679408
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcProcessQuantityServiceImpl.java
@@ -12,14 +12,17 @@
import org.jeecg.modules.mdc.mapper.MdcProcessQuantityMapper;
import org.jeecg.modules.mdc.service.IMdcEquipmentService;
import org.jeecg.modules.mdc.service.IMdcProcessQuantityService;
import org.jeecg.modules.mdc.vo.MdcProcessQuantityVo;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -47,7 +50,7 @@
     * @return
     */
    @Override
    public IPage<MdcProcessQuantityDto> pageList(String userId, Page<MdcProcessQuantityDto> page, MdcProcessQuantity mdcProcessQuantity, HttpServletRequest req) {
    public IPage<MdcProcessQuantityDto> pageList(String userId, Page<MdcProcessQuantityDto> page, MdcProcessQuantityVo mdcProcessQuantity, HttpServletRequest req) {
        List<String> equipmentIds = new ArrayList<>();
        if (StringUtils.isNotEmpty(mdcProcessQuantity.getParentId()) && StringUtils.isEmpty(mdcProcessQuantity.getEquipmentId())) {
            if ("2".equals(mdcProcessQuantity.getTypeTree())) {
@@ -89,7 +92,7 @@
     * @return
     */
    @Override
    public ModelAndView exportXls(String userId, MdcProcessQuantity mdcProcessQuantity) {
    public ModelAndView exportXls(String userId, MdcProcessQuantityVo mdcProcessQuantity) {
        List<String> equipmentIds = new ArrayList<>();
        if (StringUtils.isNotEmpty(mdcProcessQuantity.getParentId()) && StringUtils.isEmpty(mdcProcessQuantity.getEquipmentId())) {
            if ("2".equals(mdcProcessQuantity.getTypeTree())) {
@@ -127,7 +130,7 @@
        //获取当前登录用户
        //update-begin---author:wangshuai ---date:20211227  for:[JTC-116]导出人写死了------------
        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("加工数量列表数据", "导出人:" + user.getRealname(), "导出信息"));
        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("加工数量列表数据", "导出人:" + user.getRealname(), "加工数量"));
        //update-end---author:wangshuai ---date:20211227  for:[JTC-116]导出人写死了------------
        mv.addObject(NormalExcelConstants.DATA_LIST, processQuantityDtos);
        return mv;
@@ -140,4 +143,45 @@
    public MdcProcessQuantityDto findById(String id) {
        return this.baseMapper.findById(id);
    }
    /**
     * 添加数据
     *
     * @param mdcProcessQuantity
     * @return
     */
    @Override
    public boolean addData(MdcProcessQuantity mdcProcessQuantity) {
        boolean result = false;
        String[] equipmentIds = mdcProcessQuantity.getEquipmentIds().split(",");
        for (String equipmentId : equipmentIds) {
            MdcProcessQuantity processQuantity = new MdcProcessQuantity();
            BeanUtils.copyProperties(mdcProcessQuantity, processQuantity);
            processQuantity.setEquipmentId(equipmentId);
            boolean b = super.save(processQuantity);
            if (b) {
                result = true;
            }
        }
        return result;
    }
    /**
     *
     * @param equipmentId
     * @param validDate
     * @return
     */
    @Override
    public BigDecimal findTemporarily(String equipmentId, String validDate) {
        BigDecimal result = BigDecimal.ZERO;
        List<MdcProcessQuantityDto> mdcProcessQuantityList = this.baseMapper.findList(equipmentId, validDate);
        if (mdcProcessQuantityList != null && !mdcProcessQuantityList.isEmpty()) {
            for (MdcProcessQuantityDto mdcProcessQuantity : mdcProcessQuantityList) {
                result = result.add(new BigDecimal(mdcProcessQuantity.getProcessQuantity()).multiply(new BigDecimal(mdcProcessQuantity.getDuration())));
            }
        }
        return result;
    }
}