lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcPassRateController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcPassRate.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcTorqueConfig.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcPassRateMapper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcPassRateMapper.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcPassRateService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcPassRateServiceImpl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcPassRateController.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,166 @@ package org.jeecg.modules.mdc.controller; import java.util.Arrays; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.commons.lang3.StringUtils; import org.apache.shiro.SecurityUtils; import org.jeecg.common.api.vo.Result; import org.jeecg.common.system.base.controller.JeecgController; import org.jeecg.common.system.query.QueryGenerator; import org.jeecg.common.aspect.annotation.AutoLog; import lombok.extern.slf4j.Slf4j; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.modules.mdc.entity.MdcPassRate; import org.jeecg.modules.mdc.service.IMdcPassRateService; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; /** * @Description: åæ ¼ç * @Author: lius * @Date: 2023-07-18 * @Version: V1.0 */ @Slf4j @Api(tags = "åæ ¼ç") @RestController @RequestMapping("/mdc/mdcPassRate") public class MdcPassRateController extends JeecgController<MdcPassRate, IMdcPassRateService> { @Resource private IMdcPassRateService mdcPassRateService; /** * å页å表æ¥è¯¢ * * @param mdcPassRate * @param pageNo * @param pageSize * @param req * @return */ @AutoLog(value = "åæ ¼ç-å页å表æ¥è¯¢") @ApiOperation(value = "åæ ¼ç-å页å表æ¥è¯¢", notes = "åæ ¼ç-å页å表æ¥è¯¢") @GetMapping(value = "/list") public Result<?> queryPageList(MdcPassRate mdcPassRate, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) { LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); String userId = user.getId(); Page<MdcPassRate> page = new Page<MdcPassRate>(pageNo, pageSize); IPage<MdcPassRate> pageList = mdcPassRateService.pageList(userId, page, mdcPassRate, req); return Result.OK(pageList); } /** * æ·»å * * @param mdcPassRate * @return */ @AutoLog(value = "åæ ¼ç-æ·»å ") @ApiOperation(value = "åæ ¼ç-æ·»å ", notes = "åæ ¼ç-æ·»å ") @PostMapping(value = "/add") public Result<?> add(@RequestBody MdcPassRate mdcPassRate) { if (StringUtils.isBlank(mdcPassRate.getEquipmentIds())) { return Result.error("æªéæ©è®¾å¤ï¼è¯·ææ¥ï¼"); } boolean result = mdcPassRateService.addPassRate(mdcPassRate); return result ? Result.ok("æ·»å æå!") : Result.error("æ·»å 失败!"); } /** * ç¼è¾ * * @param mdcPassRate * @return */ @AutoLog(value = "åæ ¼ç-ç¼è¾") @ApiOperation(value = "åæ ¼ç-ç¼è¾", notes = "åæ ¼ç-ç¼è¾") @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST}) public Result<?> edit(@RequestBody MdcPassRate mdcPassRate) { boolean result = mdcPassRateService.updatePassRate(mdcPassRate); return result ? Result.ok("ç¼è¾æå!") : Result.error("ç¼è¾å¤±è´¥!"); } /** * éè¿idå é¤ * * @param id * @return */ @AutoLog(value = "åæ ¼ç-éè¿idå é¤") @ApiOperation(value = "åæ ¼ç-éè¿idå é¤", notes = "åæ ¼ç-éè¿idå é¤") @DeleteMapping(value = "/delete") public Result<?> delete(@RequestParam(name = "id", required = true) String id) { mdcPassRateService.removeById(id); return Result.OK("å 餿å!"); } /** * æ¹éå é¤ * * @param ids * @return */ @AutoLog(value = "åæ ¼ç-æ¹éå é¤") @ApiOperation(value = "åæ ¼ç-æ¹éå é¤", notes = "åæ ¼ç-æ¹éå é¤") @DeleteMapping(value = "/deleteBatch") public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) { this.mdcPassRateService.removeByIds(Arrays.asList(ids.split(","))); return Result.OK("æ¹éå 餿åï¼"); } /** * éè¿idæ¥è¯¢ * * @param id * @return */ @AutoLog(value = "åæ ¼ç-éè¿idæ¥è¯¢") @ApiOperation(value = "åæ ¼ç-éè¿idæ¥è¯¢", notes = "åæ ¼ç-éè¿idæ¥è¯¢") @GetMapping(value = "/queryById") public Result<?> queryById(@RequestParam(name = "id", required = true) String id) { MdcPassRate mdcPassRate = mdcPassRateService.getById(id); return Result.OK(mdcPassRate); } /** * 导åºexcel * * @param request * @param mdcPassRate */ @RequestMapping(value = "/exportXls") public ModelAndView exportXls(HttpServletRequest request, MdcPassRate mdcPassRate) { LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); String userId = user.getId(); return mdcPassRateService.exportXls(userId, mdcPassRate); } /** * éè¿excelå¯¼å ¥æ°æ® * * @param request * @param response * @return */ @RequestMapping(value = "/importExcel", method = RequestMethod.POST) public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { return super.importExcel(request, response, MdcPassRate.class); } } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcPassRate.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,107 @@ package org.jeecg.modules.mdc.entity; import java.io.Serializable; import java.math.BigDecimal; import java.util.Date; import java.util.List; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import com.fasterxml.jackson.annotation.JsonFormat; import org.jeecg.common.system.base.entity.JeecgEntity; import org.springframework.format.annotation.DateTimeFormat; import org.jeecgframework.poi.excel.annotation.Excel; /** * @Description: åæ ¼ç表 * @Author: lius * @Date: 2023-07-18 * @Version: V1.0 */ @Data @TableName("mdc_pass_rate") @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) @ApiModel(value = "mdc_pass_rate对象", description = "åæ ¼ç表") public class MdcPassRate extends JeecgEntity implements Serializable { private static final long serialVersionUID = 1863479534937744521L; /** * 设å¤ç¼å· */ @Excel(name = "设å¤ç¼å·", width = 15) @ApiModelProperty(value = "设å¤ç¼å·") private String equipmentId; /** * 设å¤åç§° */ @Excel(name = "设å¤åç§°", width = 15) @ApiModelProperty(value = "设å¤åç§°") private String equipmentName; /** * æ¥æ */ @Excel(name = "æ¥æ", width = 20, format = "yyyy-MM-dd") @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") @DateTimeFormat(pattern = "yyyy-MM-dd") @ApiModelProperty(value = "æ¥æ") private Date efficientDate; /** * å å·¥æ°é */ @Excel(name = "å å·¥æ°é", width = 15) @ApiModelProperty(value = "å å·¥æ°é") private Integer processQuantity; /** * ä¸åæ ¼æ°é */ @Excel(name = "ä¸åæ ¼æ°é", width = 15) @ApiModelProperty(value = "ä¸åæ ¼æ°é") private Integer unqualifiedQuantity; /** * åæ ¼ç */ @Excel(name = "åæ ¼ç", width = 15) @ApiModelProperty(value = "åæ ¼ç") private BigDecimal passRate; /** * 夿³¨ */ @Excel(name = "夿³¨", width = 15) @ApiModelProperty(value = "夿³¨") private String remark; /** * åå°ä¼ å ¥ 夿æ¯ä¸ªid */ @TableField(exist = false) private String parentId; /** * åå°ä¼ å ¥ 车é´å±çº§:1 é¨é¨å±çº§:2 */ @TableField(exist = false) private String typeTree; /** * é¨é¨parentId å ³èåéid */ @TableField(exist = false) private List<String> mdcSectionIds; @TableField(exist = false) private String equipmentIds; @TableField(exist = false) private String startTime; @TableField(exist = false) private String endTime; } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcTorqueConfig.java
@@ -29,6 +29,7 @@ @TableName("mdc_torque_config") @ApiModel(value = "mdc_torque_config对象", description = "æç©é 置管ç") public class MdcTorqueConfig implements Serializable { private static final long serialVersionUID = -8646261637017242975L; /** lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcPassRateMapper.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,26 @@ package org.jeecg.modules.mdc.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Param; import org.jeecg.modules.mdc.entity.MdcPassRate; /** * @Description: åæ ¼ç表 * @Author: lius * @Date: 2023-07-18 * @Version: V1.0 */ public interface MdcPassRateMapper extends BaseMapper<MdcPassRate> { /** * å页æ¥è¯¢ * * @param page * @param mdcPassRate * @return */ IPage<MdcPassRate> pageList(Page<MdcPassRate> page, @Param("mdcPassRate") MdcPassRate mdcPassRate); } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcPassRateMapper.xml
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,27 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="org.jeecg.modules.mdc.mapper.MdcPassRateMapper"> <!--å页æ¥è¯¢--> <select id="pageList" resultType="org.jeecg.modules.mdc.entity.MdcPassRate"> SELECT * FROM mdc_pass_date <where> <if test="mdcPassRate.equipmentName != null and mdcPassRate.equipmentName != '' "> AND equipment_name LIKE CONCAT(CONCAT('%',#{mdcPassRate.equipmentName}),'%') </if> <if test="mdcPassRate.equipmentId != null and mdcPassRate.equipmentId != '' "> AND equipment_id LIKE CONCAT(CONCAT('%',#{mdcPassRate.equipmentId}),'%') </if> <if test="mdcPassRate.startTime != null and mdcPassRate.endTime != null"> AND efficient_date BETWEEN #{ mdcPassRate.startTime } AND #{ mdcPassRate.endTime } </if> <if test="mdcPassRate.mdcSectionIds != null and mdcPassRate.mdcSectionIds.size() > 0 "> AND equipment_id IN <foreach collection="mdcPassRate.mdcSectionIds" item="id" index="index" open="(" close=")" separator=","> #{ id } </foreach> </if> </where> ORDER BY equipment_name ASC, efficient_date DESC </select> </mapper> lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcPassRateService.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,55 @@ package org.jeecg.modules.mdc.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import org.jeecg.modules.mdc.entity.MdcPassRate; import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; /** * @Description: åæ ¼ç表 * @Author: lius * @Date: 2023-07-18 * @Version: V1.0 */ public interface IMdcPassRateService extends IService<MdcPassRate> { /** * å页æ¥è¯¢ * * @param userId * @param page * @param mdcPassRate * @param req * @return */ IPage<MdcPassRate> pageList(String userId, Page<MdcPassRate> page, MdcPassRate mdcPassRate, HttpServletRequest req); /** * æ·»å æ°æ® * * @param mdcPassRate * @return */ boolean addPassRate(MdcPassRate mdcPassRate); /** * ç¼è¾æ°æ® * * @param mdcPassRate * @return */ boolean updatePassRate(MdcPassRate mdcPassRate); /** * å¯¼åº * * @param userId * @param mdcPassRate * @return */ ModelAndView exportXls(String userId, MdcPassRate mdcPassRate); } lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcPassRateServiceImpl.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,196 @@ package org.jeecg.modules.mdc.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.commons.lang.StringUtils; import org.apache.shiro.SecurityUtils; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.modules.mdc.entity.MdcEquipment; import org.jeecg.modules.mdc.entity.MdcPassRate; import org.jeecg.modules.mdc.entity.MdcStandardProcessDuration; import org.jeecg.modules.mdc.mapper.MdcPassRateMapper; import org.jeecg.modules.mdc.service.IMdcEquipmentService; import org.jeecg.modules.mdc.service.IMdcPassRateService; 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; /** * @Description: åæ ¼ç表 * @Author: lius * @Date: 2023-07-18 * @Version: V1.0 */ @Service public class MdcPassRateServiceImpl extends ServiceImpl<MdcPassRateMapper, MdcPassRate> implements IMdcPassRateService { @Resource private IMdcEquipmentService mdcEquipmentService; @Override public IPage<MdcPassRate> pageList(String userId, Page<MdcPassRate> page, MdcPassRate mdcPassRate, HttpServletRequest req) { List<String> equipmentIds = new ArrayList<>(); if (StringUtils.isNotEmpty(mdcPassRate.getParentId()) && StringUtils.isEmpty(mdcPassRate.getEquipmentId())) { if ("2".equals(mdcPassRate.getTypeTree())) { //é¨é¨å±çº§ equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, mdcPassRate.getParentId()); } else { //产线å±çº§ equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, mdcPassRate.getParentId()); } } else if (StringUtils.isNotEmpty(mdcPassRate.getEquipmentId())) { //åå°è®¾å¤ä¿¡æ¯ mdcPassRate.setMdcSectionIds(Collections.singletonList(mdcPassRate.getEquipmentId())); } else { //æ¥è¯¢ç¨æ·æ¥æçææè®¾å¤ä¿¡æ¯ if ("2".equals(mdcPassRate.getTypeTree())) { //é¨é¨å±çº§ equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, null); } else { //产线å±çº§ equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, null); } } if (mdcPassRate.getMdcSectionIds() == null || mdcPassRate.getMdcSectionIds().isEmpty()) { mdcPassRate.setMdcSectionIds(equipmentIds); } if (mdcPassRate.getMdcSectionIds() == null || mdcPassRate.getMdcSectionIds().isEmpty()) { return null; } return this.baseMapper.pageList(page, mdcPassRate); } /** * æ·»å æ°æ® * * @param mdcPassRate * @return */ @Override public boolean addPassRate(MdcPassRate mdcPassRate) { boolean result = false; String[] equipmentIds = mdcPassRate.getEquipmentIds().split(","); for (String equipmentId : equipmentIds) { MdcEquipment mdcEquipment = mdcEquipmentService.findEquipmentNameByEquipmentId(equipmentId); MdcPassRate passRate = new MdcPassRate(); BeanUtils.copyProperties(mdcPassRate, passRate); passRate.setEquipmentId(mdcEquipment.getEquipmentId()); passRate.setEquipmentName(mdcEquipment.getEquipmentName()); if (passRate.getProcessQuantity() == null || passRate.getProcessQuantity() == 0) { passRate.setPassRate(new BigDecimal("0")); } else { if (passRate.getUnqualifiedQuantity() == null || passRate.getUnqualifiedQuantity() == 0) { passRate.setPassRate(new BigDecimal("1")); } else { passRate.setPassRate(new BigDecimal(passRate.getUnqualifiedQuantity()).divide(new BigDecimal(passRate.getProcessQuantity())).setScale(2, BigDecimal.ROUND_HALF_UP)); } } boolean b = super.save(passRate); if (b) { result = true; } } return result; } /** * ç¼è¾æ°æ® * * @param mdcPassRate * @return */ @Override public boolean updatePassRate(MdcPassRate mdcPassRate) { if (mdcPassRate.getProcessQuantity() == null || mdcPassRate.getProcessQuantity() == 0) { mdcPassRate.setPassRate(new BigDecimal("0")); } else { if (mdcPassRate.getUnqualifiedQuantity() == null || mdcPassRate.getUnqualifiedQuantity() == 0) { mdcPassRate.setPassRate(new BigDecimal("1")); } else { mdcPassRate.setPassRate(new BigDecimal(mdcPassRate.getUnqualifiedQuantity()).divide(new BigDecimal(mdcPassRate.getProcessQuantity())).setScale(2, BigDecimal.ROUND_HALF_UP)); } } return super.updateById(mdcPassRate); } /** * å¯¼åº * * @param userId * @param mdcPassRate * @return */ @Override public ModelAndView exportXls(String userId, MdcPassRate mdcPassRate) { LambdaQueryWrapper<MdcPassRate> queryWrapper = new LambdaQueryWrapper<>(); List<String> equipmentIds = new ArrayList<>(); if (StringUtils.isNotEmpty(mdcPassRate.getParentId()) && StringUtils.isEmpty(mdcPassRate.getEquipmentId())) { if ("2".equals(mdcPassRate.getTypeTree())) { //é¨é¨å±çº§ equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, mdcPassRate.getParentId()); } else { //产线å±çº§ equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, mdcPassRate.getParentId()); } } else if (StringUtils.isNotEmpty(mdcPassRate.getEquipmentId())) { //åå°è®¾å¤ä¿¡æ¯ mdcPassRate.setMdcSectionIds(Collections.singletonList(mdcPassRate.getEquipmentId())); } else { //æ¥è¯¢ç¨æ·ææ¥æçææè®¾å¤ä¿¡æ¯ if ("2".equals(mdcPassRate.getTypeTree())) { //é¨é¨å±çº§ equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, null); } else { equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, null); } } if (mdcPassRate.getMdcSectionIds() == null || mdcPassRate.getMdcSectionIds().isEmpty()) { mdcPassRate.setMdcSectionIds(equipmentIds); } if (mdcPassRate.getMdcSectionIds() == null || mdcPassRate.getMdcSectionIds().isEmpty()) { return null; } else { queryWrapper.in(MdcPassRate::getEquipmentId, mdcPassRate.getMdcSectionIds()); } if (StringUtils.isNotEmpty(mdcPassRate.getEquipmentId())) { queryWrapper.like(MdcPassRate::getEquipmentId, mdcPassRate.getEquipmentId()); } if (StringUtils.isNotEmpty(mdcPassRate.getEquipmentName())) { queryWrapper.like(MdcPassRate::getEquipmentName, mdcPassRate.getEquipmentName()); } if (StringUtils.isNotEmpty(mdcPassRate.getStartTime()) && StringUtils.isNotEmpty(mdcPassRate.getEndTime())) { queryWrapper.between(MdcPassRate::getEfficientDate, mdcPassRate.getStartTime(), mdcPassRate.getEndTime()); } queryWrapper.orderByAsc(MdcPassRate::getEquipmentName).orderByDesc(MdcPassRate::getEfficientDate); // Step.2 AutoPoi 导åºExcel ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); List<MdcPassRate> mdcPassRates = this.baseMapper.selectList(queryWrapper); // å¯¼åºæä»¶åç§° mv.addObject(NormalExcelConstants.FILE_NAME, "åæ ¼çå表"); mv.addObject(NormalExcelConstants.CLASS, MdcPassRate.class); //è·åå½åç»å½ç¨æ· //update-begin---author:wangshuai ---date:20211227 forï¼[JTC-116]导åºäººåæ»äº------------ LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("åæ ¼çåè¡¨æ°æ®", "导åºäºº:" + user.getRealname(), "导åºä¿¡æ¯")); //update-end---author:wangshuai ---date:20211227 forï¼[JTC-116]导åºäººåæ»äº------------ mv.addObject(NormalExcelConstants.DATA_LIST, mdcPassRates); return mv; } }