package zy.cloud.wms.manager.service.impl; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.core.common.Cools; import com.core.exception.CoolException; import org.springframework.beans.factory.annotation.Autowired; import zy.cloud.wms.manager.entity.Item; import zy.cloud.wms.manager.mapper.ItemReportMapper; import zy.cloud.wms.manager.entity.ItemReport; import zy.cloud.wms.manager.service.ItemReportService; import com.baomidou.mybatisplus.service.impl.ServiceImpl; import org.springframework.stereotype.Service; import zy.cloud.wms.manager.service.ItemService; import java.util.Date; @Service("itemReportService") public class ItemReportServiceImpl extends ServiceImpl implements ItemReportService { @Autowired private ItemService itemService; /** * 初始化生成report * @param report * @param userId */ @Override public void init(ItemReport report, Long userId) { /** * 控管与参数初始化 */ Date now = new Date(); Item id = itemService.selectOne(new EntityWrapper() .eq("id", report.getItemId())); if (Cools.isEmpty(id)) { throw new CoolException("找不到该项目,请联系管理员"); } report.setItemName(id.getName()); /** * 如果前端返回原因,表示有异常,将状态设置为true */ if (report.getDeliverReason() == null || report.getDeliverReason().equals("")) { report.setDeliverIssue(false); }else { report.setDeliverIssue(true); } if (report.getQualityReason() == null || report.getQualityReason().equals("")) { report.setQualityIssue(false); }else { report.setQualityIssue(true); } if (report.getDesignReason() == null || report.getDesignReason().equals("")) { report.setDesignIssue(false); }else { report.setDesignIssue(true); } if (report.getInstallReason() == null || report.getInstallReason().equals("")) { report.setInstallIssue(false); }else { report.setInstallIssue(true); } report.setUpdateTime(now); report.setUpdateBy(userId); report.setCreateTime(now); report.setCreateBy(userId); insert(report); } }