diff --git a/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/mapper/WxModeMapper.java b/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/mapper/WxModeMapper.java index ba85412..c7e90a1 100644 --- a/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/mapper/WxModeMapper.java +++ b/flossom-common/flossom-common-core/src/main/java/com/flossom/common/core/mapper/WxModeMapper.java @@ -1,6 +1,7 @@ package com.flossom.common.core.mapper; import com.flossom.common.core.domain.entity.WxMode; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -60,5 +61,5 @@ public interface WxModeMapper */ public int deleteWxModeByIds(Long[] ids); - List selectListByInstrumentId(Long instrumentId); + List selectListByInstrumentId(@Param("instrumentId") Long instrumentId, @Param("liningId") Long liningId); } diff --git a/flossom-common/flossom-common-core/src/main/resources/mapper/WxModeMapper.xml b/flossom-common/flossom-common-core/src/main/resources/mapper/WxModeMapper.xml index 3f80bb7..8e99a44 100644 --- a/flossom-common/flossom-common-core/src/main/resources/mapper/WxModeMapper.xml +++ b/flossom-common/flossom-common-core/src/main/resources/mapper/WxModeMapper.xml @@ -74,8 +74,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" FROM wx_mode mo LEFT JOIN `wx_instrument_mode` imo ON imo.mode_id = mo.id - WHERE - imo.instrument_id = #{instrumentId} + + and imo.instrument_id = #{instrumentId} + and imo.lining_id = #{liningId} + ORDER BY imo.mode_sort ASC diff --git a/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/controller/WxInstrumentController.java b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/controller/WxInstrumentController.java index 46679a7..a884e0b 100644 --- a/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/controller/WxInstrumentController.java +++ b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/controller/WxInstrumentController.java @@ -134,8 +134,9 @@ public class WxInstrumentController extends BaseController { * 根据仪器ID获取仪器模式 */ @GetMapping(value = "/modeInfoList") - public R modeInfo(@NotNull(message = "仪器ID不能为空") @RequestParam("instrumentId") Long instrumentId) { - return R.ok(wxInstrumentService.getInstrumentModeByInstrumentId(instrumentId)); + public R modeInfo(@NotNull(message = "仪器ID不能为空") @RequestParam("instrumentId") Long instrumentId, + @RequestParam(value = "liningId", required = false) Long liningId) { + return R.ok(wxInstrumentService.getInstrumentModeByInstrumentId(instrumentId, liningId)); } /** diff --git a/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/controller/WxLiningController.java b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/controller/WxLiningController.java new file mode 100644 index 0000000..c4d5ffa --- /dev/null +++ b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/controller/WxLiningController.java @@ -0,0 +1,31 @@ +package com.flossom.miniProgram.controller; + +import com.flossom.common.core.domain.R; +import com.flossom.common.core.web.controller.BaseController; +import com.flossom.miniProgram.service.IWxLiningService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.validation.constraints.NotNull; + + +/** + * 膜布Controller + */ +@RestController +@RequestMapping("/lining") +public class WxLiningController extends BaseController { + + @Autowired + private IWxLiningService wxLiningService; + + /** + * 查询膜布列表 + */ + @GetMapping("/list") + public R list(@RequestParam @NotNull(message = "仪器ID不能为空") Long instrumentId) { + return R.ok(wxLiningService.selectWxLiningList(instrumentId)); + } + + +} diff --git a/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/IWxInstrumentService.java b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/IWxInstrumentService.java index a67b808..761c65a 100644 --- a/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/IWxInstrumentService.java +++ b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/IWxInstrumentService.java @@ -25,7 +25,7 @@ public interface IWxInstrumentService { List getInstrumentFileRelateByInstrumentId(Long instrumentId, Integer classify); - List getInstrumentModeByInstrumentId(Long instrumentId); + List getInstrumentModeByInstrumentId(Long instrumentId, Long liningId); WxInstrumentSerial determineSerialIsSameInstrument(String serial, Long instrumentId); diff --git a/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/IWxLiningService.java b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/IWxLiningService.java new file mode 100644 index 0000000..1e7cc2a --- /dev/null +++ b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/IWxLiningService.java @@ -0,0 +1,20 @@ +package com.flossom.miniProgram.service; + +import com.flossom.common.core.domain.entity.WxLining; + +import java.util.List; + +/** + * 膜布Service接口 + */ +public interface IWxLiningService { + + /** + * 查询膜布列表 + * + * @param wxLining 膜布 + * @return 膜布集合 + */ + public List selectWxLiningList(Long instrumentId); + +} diff --git a/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/impl/WxInstrumentServiceImpl.java b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/impl/WxInstrumentServiceImpl.java index 9ee1f03..9ff0781 100644 --- a/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/impl/WxInstrumentServiceImpl.java +++ b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/impl/WxInstrumentServiceImpl.java @@ -434,7 +434,7 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService { } @Override - public List getInstrumentModeByInstrumentId(Long instrumentId) { + public List getInstrumentModeByInstrumentId(Long instrumentId, Long liningId) { // 用户拥有的标签 WxUserTag wxUserTag = new WxUserTag(); wxUserTag.setUserId(SecurityUtils.getLoginUser().getWxUserMember().getId()); @@ -447,7 +447,7 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService { } // 查询仪器关联的所有模式 List wxModeRetList = new ArrayList<>(); - List wxModeList = wxModeMapper.selectListByInstrumentId(instrumentId); + List wxModeList = wxModeMapper.selectListByInstrumentId(instrumentId, liningId); for (WxMode wxMode : wxModeList) { // 判断每个模式是否加锁 WxModeRet wxModeRet = new WxModeRet(); diff --git a/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/impl/WxLiningServiceImpl.java b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/impl/WxLiningServiceImpl.java new file mode 100644 index 0000000..7432f4d --- /dev/null +++ b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/impl/WxLiningServiceImpl.java @@ -0,0 +1,50 @@ +package com.flossom.miniProgram.service.impl; + +import com.flossom.common.core.domain.entity.WxInstrumentLining; +import com.flossom.common.core.domain.entity.WxLining; +import com.flossom.common.core.mapper.WxInstrumentLiningMapper; +import com.flossom.common.core.mapper.WxLiningMapper; +import com.flossom.miniProgram.service.IWxLiningService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * 膜布Service业务层处理 + * + * @author flossom + * @date 2024-03-26 + */ +@Service +public class WxLiningServiceImpl implements IWxLiningService { + + @Autowired + private WxLiningMapper wxLiningMapper; + + @Autowired + private WxInstrumentLiningMapper wxInstrumentLiningMapper; + + /** + * 查询膜布列表 + * + * @param wxLining 膜布 + * @return 膜布 + */ + @Override + public List selectWxLiningList(Long instrumentId) { + WxInstrumentLining instrumentLiningQuery = new WxInstrumentLining(); + instrumentLiningQuery.setInstrumentId(instrumentId); + List wxInstrumentLiningList = wxInstrumentLiningMapper.selectWxInstrumentLiningList(instrumentLiningQuery); + if (wxInstrumentLiningList != null && wxInstrumentLiningList.size() > 0) { + List liningList = new ArrayList<>(); + for (WxInstrumentLining wxInstrumentLining : wxInstrumentLiningList) { + liningList.add(wxLiningMapper.selectWxLiningById(wxInstrumentLining.getLiningId())); + } + return liningList; + } + return null; + } + +} diff --git a/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxInstrumentServiceImpl.java b/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxInstrumentServiceImpl.java index 1437381..e4eba8e 100644 --- a/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxInstrumentServiceImpl.java +++ b/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxInstrumentServiceImpl.java @@ -1,5 +1,6 @@ package com.flossom.system.service.impl; +import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; @@ -109,6 +110,7 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService { instrumentLiningQuery.setInstrumentId(id); List instrumentLiningList = wxInstrumentLiningMapper.selectWxInstrumentLiningList(instrumentLiningQuery); if (instrumentLiningList != null) { + List liningList = new ArrayList<>(); for (WxInstrumentLining wxInstrumentLining : instrumentLiningList) { Long liningId = wxInstrumentLining.getLiningId(); WxLining wxLining = wxLiningMapper.selectWxLiningById(liningId); @@ -127,8 +129,10 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService { .map(Long::intValue) .collect(Collectors.toList()) ); + liningList.add(wxLining); } } + wxInstrumentSaveReq.setWxLiningList(liningList); } } return wxInstrumentSaveReq; @@ -280,22 +284,13 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService { wxInstrumentMode.setInstrumentId(wxInstrument.getId()); wxInstrumentMode.setModeId(modeList.get(i).longValue()); wxInstrumentMode.setModeSort(i); - wxInstrumentMode.setIsNew(0); - wxInstrumentMode.setLiningId(liningId); - wxInstrumentMode.setStatus(Status.OK.getCode()); - wxInstrumentMode.setCreateBy(SecurityUtils.getUsername()); - wxInstrumentMode.setCreateTime(DateUtils.getNowDate()); - wxInstrumentModeMapper.insertWxInstrumentMode(wxInstrumentMode); - } - } - List newModeIdList = wxLining.getNewModeIdList(); - if (newModeIdList != null && newModeIdList.size() > 0) { - for (int i = 0; i < newModeIdList.size(); i++) { - WxInstrumentMode wxInstrumentMode = new WxInstrumentMode(); - wxInstrumentMode.setInstrumentId(wxInstrument.getId()); - wxInstrumentMode.setModeId(modeIdList.get(i).longValue()); - wxInstrumentMode.setModeSort(i); - wxInstrumentMode.setIsNew(1); + if (wxLining.getNewModeIdList() != null && wxLining.getNewModeIdList().size() > 0) { + if (wxLining.getNewModeIdList().contains(modeList.get(i))) { + wxInstrumentMode.setIsNew(1); + } + }else { + wxInstrumentMode.setIsNew(0); + } wxInstrumentMode.setLiningId(liningId); wxInstrumentMode.setStatus(Status.OK.getCode()); wxInstrumentMode.setCreateBy(SecurityUtils.getUsername()); @@ -435,22 +430,13 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService { wxInstrumentMode.setInstrumentId(wxInstrument.getId()); wxInstrumentMode.setModeId(modeList.get(i).longValue()); wxInstrumentMode.setModeSort(i); - wxInstrumentMode.setIsNew(0); - wxInstrumentMode.setLiningId(liningId); - wxInstrumentMode.setStatus(Status.OK.getCode()); - wxInstrumentMode.setCreateBy(SecurityUtils.getUsername()); - wxInstrumentMode.setCreateTime(DateUtils.getNowDate()); - wxInstrumentModeMapper.insertWxInstrumentMode(wxInstrumentMode); - } - } - List newModeIdList = wxLining.getNewModeIdList(); - if (newModeIdList != null && newModeIdList.size() > 0) { - for (int i = 0; i < newModeIdList.size(); i++) { - WxInstrumentMode wxInstrumentMode = new WxInstrumentMode(); - wxInstrumentMode.setInstrumentId(wxInstrument.getId()); - wxInstrumentMode.setModeId(newModeIdList.get(i).longValue()); - wxInstrumentMode.setModeSort(i); - wxInstrumentMode.setIsNew(1); + if (wxLining.getNewModeIdList() != null && wxLining.getNewModeIdList().size() > 0) { + if (wxLining.getNewModeIdList().contains(modeList.get(i))) { + wxInstrumentMode.setIsNew(1); + } + }else { + wxInstrumentMode.setIsNew(0); + } wxInstrumentMode.setLiningId(liningId); wxInstrumentMode.setStatus(Status.OK.getCode()); wxInstrumentMode.setCreateBy(SecurityUtils.getUsername());