| | |
| | | return sb.toString(); |
| | | } |
| | | |
| | | public static String getTimeSixNumberCode(String prefix){ |
| | | public static String getTimeSixNumberCode(String prefix, String keyName){ |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String format = simpleDateFormat.format(new Date()); |
| | | String timeStr = format.replace("-", ""); |
| | | long incrNum = RedisUtil.incr("num", 1); |
| | | System.out.println(incrNum + "=============="); |
| | | long incrNum = RedisUtil.incr(keyName, 1); |
| | | if(incrNum == 1){ |
| | | RedisUtil.expire("num", 60 * 60 * 24); |
| | | RedisUtil.expire(keyName, 60 * 60 * 24); |
| | | } |
| | | String sixIncr = String.format("%06d", incrNum); |
| | | return prefix + timeStr + sixIncr; |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.service.MeasureLedgerService; |
| | | import com.yuanchu.mom.vo.Result; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | | * å端æ§å¶å¨ |
| | | * </p> |
| | | * |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2023-08-16 11:41:09 |
| | | */ |
| | | @Api(tags = "QMS管ç-->计é管ç") |
| | | @RestController |
| | | @RequestMapping("/measureLedger") |
| | | public class MeasureLedgerController { |
| | | |
| | | @Autowired |
| | | private MeasureLedgerService measureLedgerService; |
| | | |
| | | @ApiOperation(value = "计é颿µ-->åé¡µè¡¨æ ¼") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "pageNo", value = "æ¡æ°/页", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "pageSize", value = "页æ°", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "code", value = "计éç¼å·", dataTypeClass = String.class), |
| | | @ApiImplicitParam(name = "deviceName", value = "仪å¨è®¾å¤åç§°", dataTypeClass = String.class), |
| | | @ApiImplicitParam(name = "meteringUnit", value = "计éåä½", dataTypeClass = String.class) |
| | | }) |
| | | @GetMapping("/metering_table") |
| | | public Result<?> selectMeasureLedger(Integer pageNo, Integer pageSize, String code, String deviceName, String meteringUnit){ |
| | | IPage<Map<String, Object>> maps = measureLedgerService.selectMeasureLedger(new Page<Object>(pageNo, pageSize), code, deviceName, meteringUnit); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("row", maps.getRecords()); |
| | | map.put("total", maps.getTotal()); |
| | | return Result.success(map); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.pojo.MeteringPlan; |
| | | import com.yuanchu.mom.service.DeviceService; |
| | | import com.yuanchu.mom.service.MeteringPlanService; |
| | | import com.yuanchu.mom.service.UserService; |
| | | import com.yuanchu.mom.utils.JackSonUtil; |
| | | import com.yuanchu.mom.utils.Jwt; |
| | | import com.yuanchu.mom.utils.MyUtil; |
| | | import com.yuanchu.mom.vo.Result; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.stereotype.Controller; |
| | | |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | | * å端æ§å¶å¨ |
| | | * </p> |
| | | * |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2023-08-16 11:42:31 |
| | | */ |
| | | @Api(tags = "QMS管ç-->计é管ç") |
| | | @RestController |
| | | @RequestMapping("/meteringPlan") |
| | | public class MeteringPlanController { |
| | | |
| | | @Autowired |
| | | private MeteringPlanService meteringPlanService; |
| | | |
| | | @Autowired |
| | | private UserService userService; |
| | | |
| | | @Autowired |
| | | private DeviceService deviceService; |
| | | |
| | | @Autowired |
| | | private Jwt jwt; |
| | | @ApiOperation(value = "计é计å-->æ°å¢æé®") |
| | | @PostMapping("/add_plan") |
| | | public Result<?> addMeteringPlan(@RequestHeader("token") String token,@Validated @RequestBody MeteringPlan meteringPlan) throws Exception { |
| | | Map<String, String> data = JackSonUtil.unmarshal(jwt.readJWT(token).get("data"), Map.class); |
| | | String id = data.get("id").replaceAll("\"", ""); |
| | | meteringPlan.setFounder(Integer.valueOf(id)); |
| | | Integer isInsertSuccess = meteringPlanService.addMeteringPlan(meteringPlan); |
| | | if (isInsertSuccess == 1){ |
| | | return Result.success("æ°å¢æåï¼"); |
| | | } |
| | | return Result.fail("æ°å¢å¤±è´¥ï¼"); |
| | | } |
| | | |
| | | @ApiOperation(value = "计é计å-->è´è´£äººä¸ææ¡") |
| | | @GetMapping("/list_user") |
| | | public Result<?> selectUserIdAndName(){ |
| | | List<Map<String, Object>> maps = userService.listUserIdAndName(); |
| | | return Result.success(maps); |
| | | } |
| | | |
| | | @ApiOperation(value = "计é计å-->计éåä½ä¸ææ¡") |
| | | @GetMapping("/list_unit") |
| | | public Result<?> selectUnit(){ |
| | | List<Map<String, Object>> maps = meteringPlanService.selectUnit(); |
| | | return Result.success(maps); |
| | | } |
| | | |
| | | @ApiOperation(value = "计é计å-->åé¡µè¡¨æ ¼") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "pageNo", value = "æ¡æ°/页", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "pageSize", value = "页æ°", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "code", value = "计éç¼å·", dataTypeClass = String.class), |
| | | @ApiImplicitParam(name = "meteringUnit", value = "计éåä½", dataTypeClass = String.class) |
| | | }) |
| | | @GetMapping("/metering_table") |
| | | public Result<?> selectMeteringTable(Integer pageNo, Integer pageSize, String code, String meteringUnit){ |
| | | Map<String, Object> maps = meteringPlanService.selectMeteringTable(pageNo, pageSize, code, meteringUnit); |
| | | return Result.success(maps); |
| | | } |
| | | |
| | | @ApiOperation(value = "计é计å<-->计éå°è´¦ï¼æ¥ç计éå±¥å") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "measureId", value = "计éId", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "accountOrPlan", value = "true为å°è´¦|false为计å", dataTypeClass = Boolean.class, required = true), |
| | | }) |
| | | @GetMapping("/list_record") |
| | | public Result<?> standingBook(Integer measureId, Boolean accountOrPlan){ |
| | | Object maps = meteringPlanService.standingBook(measureId, accountOrPlan); |
| | | return Result.success(maps); |
| | | } |
| | | |
| | | @ApiOperation(value = "计é计åï¼æ°å¢æé®ï¼ç¹å»æ°å¢è¡åæäº¤è®¾å¤åç§°") |
| | | @GetMapping("/list_device") |
| | | public Result<?> selectOneDeviceId(){ |
| | | List<Map<String, Object>> mapList = deviceService.selectDeviceIdAndName(); |
| | | return Result.success(mapList); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.mybatis_config.MyBaseMapper; |
| | | import com.yuanchu.mom.pojo.MeasureLedger; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | | * Mapper æ¥å£ |
| | | * </p> |
| | | * |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2023-08-16 11:41:09 |
| | | */ |
| | | public interface MeasureLedgerMapper extends MyBaseMapper<MeasureLedger> { |
| | | |
| | | IPage<Map<String, Object>> selectMeasureLedger(Page<Object> page, String code, String deviceName, String meteringUnit); |
| | | |
| | | List<Map<String, Object>> standingBook(Integer measureId); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.pojo.MeteringPlan; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | | * Mapper æ¥å£ |
| | | * </p> |
| | | * |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2023-08-16 02:01:38 |
| | | */ |
| | | public interface MeteringPlanMapper extends BaseMapper<MeteringPlan> { |
| | | |
| | | List<Map<String, Object>> selectMeteringTable(Integer pageNo, Integer pageSize, String code, String meteringUnit); |
| | | |
| | | List<Map<String, Object>> selectIdPlan(Integer measureId); |
| | | |
| | | Map<String, Object> selectIdPlanIdMessage(Integer measureId); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import java.io.Serializable; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import javax.validation.constraints.NotNull; |
| | | |
| | | /** |
| | | * <p> |
| | | * |
| | | * </p> |
| | | * |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2023-08-16 11:41:09 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @ApiModel(value = "MeasureLedger对象", description = "") |
| | | public class MeasureLedger implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty(value = "主é®Id", hidden = true) |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | |
| | | @NotNull(message = "设å¤Idä¸è½ä¸ºç©ºï¼") |
| | | @ApiModelProperty(value = "设å¤Id", example = "1", required = true) |
| | | private Integer deviceId; |
| | | |
| | | @ApiModelProperty(value = "计é计åId", hidden = true) |
| | | private Integer measurePlanId; |
| | | |
| | | |
| | | @ApiModelProperty(value = "æµéèå´", example = "0.2302") |
| | | private String measuringRange; |
| | | |
| | | @NotNull(message = "计é卿ä¸è½ä¸ºç©ºï¼") |
| | | @ApiModelProperty(value = "计é卿", example = "12", required = true) |
| | | private Integer measurePeriod; |
| | | |
| | | @ApiModelProperty(value = "计éç»æ 1ï¼æ£å¸¸ï¼2ï¼å¤±å") |
| | | private Integer measureResult; |
| | | |
| | | @ApiModelProperty(value = "è®¡éæ¥æ", example = "2023-08-16", dataType = "date", required = true) |
| | | @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
| | | private LocalDate measureDate; |
| | | |
| | | @ApiModelProperty(value = "è®¡éæææ-å¼å§", example = "2023-08-16", dataType = "date", required = true) |
| | | @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
| | | private LocalDate validityBegin; |
| | | |
| | | @ApiModelProperty(value = "è®¡éæææ-ç»æ", example = "2023-08-16", dataType = "date", required = true) |
| | | @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
| | | private LocalDate validityEnd; |
| | | |
| | | @ApiModelProperty(value = "计éç¼å·", hidden = true) |
| | | private String measureNumber; |
| | | |
| | | @ApiModelProperty(value = "éä»¶", hidden = true) |
| | | private String attachment; |
| | | |
| | | @ApiModelProperty(value = "å建æ¶é´", hidden = true) |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date createTime; |
| | | |
| | | @ApiModelProperty(value = "æ´æ°æ¶é´", hidden = true) |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date updateTime; |
| | | |
| | | @ApiModelProperty(value = "é»è¾å é¤", hidden = true) |
| | | @TableLogic(value = "1", delval = "0") |
| | | private Integer state; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import java.io.Serializable; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | |
| | | /** |
| | | * <p> |
| | | * |
| | | * </p> |
| | | * |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2023-08-16 02:01:38 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @ApiModel(value = "MeteringPlan对象", description = "") |
| | | public class MeteringPlan implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty(value = "主é®Id", hidden = true) |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | |
| | | @ApiModelProperty(value = "计åç¼å·", hidden = true) |
| | | private String planNumber; |
| | | |
| | | @NotNull(message = "è¯·éæ©å建人ï¼") |
| | | @ApiModelProperty(value = "å建人", hidden = true) |
| | | private Integer founder; |
| | | |
| | | @ApiModelProperty(value = "è®¡åæ¥æå¼å§", example = "2023-07-02", dataType = "date", required = true) |
| | | @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
| | | private LocalDate planDateBegin; |
| | | |
| | | @ApiModelProperty(value = "è®¡åæ¥æç»æ", example = "2023-07-02", dataType = "date", required = true) |
| | | @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
| | | private LocalDate planDateEnd; |
| | | |
| | | @NotBlank(message = "è¯·éæ©æè¯·è¾å
¥è®¡éåä½ï¼") |
| | | @ApiModelProperty(value = "计éåä½", example = "䏿µ·è´¨æ£æ", required = true) |
| | | private String planUnit; |
| | | |
| | | @NotNull(message = "è¯·éæ©è´è´£äººï¼") |
| | | @ApiModelProperty(value = "è´è´£äºº", example = "1", required = true) |
| | | private Integer personCharge; |
| | | |
| | | @ApiModelProperty(value = "åå»ºæ¥æ", hidden = true) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Date createTime; |
| | | |
| | | @ApiModelProperty(value = "æ´æ°æ¥æ", hidden = true) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Date updateTime; |
| | | |
| | | @ApiModelProperty(value = "é»è¾å é¤", hidden = true) |
| | | @TableLogic(value = "1", delval = "0") |
| | | private Integer state; |
| | | |
| | | @TableField(exist = false) |
| | | private List<MeasureLedger> measureLedgerList; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.pojo.MeasureLedger; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | | * æå¡ç±» |
| | | * </p> |
| | | * |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2023-08-16 11:41:09 |
| | | */ |
| | | public interface MeasureLedgerService extends IService<MeasureLedger> { |
| | | |
| | | Boolean addMeasureLedger(Integer id, List<MeasureLedger> measureLedgerList); |
| | | |
| | | IPage<Map<String, Object>> selectMeasureLedger(Page<Object> page, String code, String deviceName, String meteringUnit); |
| | | |
| | | List<Map<String, Object>> standingBook(Integer measureId); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.pojo.MeteringPlan; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | | * æå¡ç±» |
| | | * </p> |
| | | * |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2023-08-16 11:42:31 |
| | | */ |
| | | public interface MeteringPlanService extends IService<MeteringPlan> { |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | Integer addMeteringPlan(MeteringPlan meteringPlan); |
| | | |
| | | List<Map<String, Object>> selectUnit(); |
| | | |
| | | Map<String, Object> selectMeteringTable(Integer pageNo, Integer pageSize, String code, String meteringUnit); |
| | | |
| | | Object standingBook(Integer measureId, Boolean accountOrPlan); |
| | | } |
| | |
| | | package com.yuanchu.mom.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.yuanchu.mom.mapper.InspectUnacceptedMapper; |
| | | import com.yuanchu.mom.pojo.InspectUnaccepted; |
| | | import com.yuanchu.mom.service.InspectUnacceptedService; |
| | | import com.yuanchu.mom.vo.Result; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.pojo.MeasureLedger; |
| | | import com.yuanchu.mom.mapper.MeasureLedgerMapper; |
| | | import com.yuanchu.mom.service.MeasureLedgerService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.yuanchu.mom.utils.MyUtil; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | | * æå¡å®ç°ç±» |
| | | * </p> |
| | | * |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2023-08-16 11:41:09 |
| | | */ |
| | | @Service |
| | | public class MeasureLedgerServiceImpl extends ServiceImpl<MeasureLedgerMapper, MeasureLedger> implements MeasureLedgerService { |
| | | |
| | | @Resource |
| | | private MeasureLedgerMapper measureLedgerMapper; |
| | | |
| | | @Override |
| | | public Boolean addMeasureLedger(Integer id, List<MeasureLedger> measureLedgerList) { |
| | | for (MeasureLedger measureLedger : measureLedgerList){ |
| | | String timeSixNumberCode = MyUtil.getTimeSixNumberCode("QCX", "QCX"); |
| | | measureLedger.setMeasurePlanId(id); |
| | | measureLedger.setMeasureNumber(timeSixNumberCode); |
| | | } |
| | | int insertSuccess = measureLedgerMapper.insertBatchSomeColumn(measureLedgerList); |
| | | return insertSuccess >= 1; |
| | | } |
| | | |
| | | @Override |
| | | public IPage<Map<String, Object>> selectMeasureLedger(Page<Object> page, String code, String deviceName, String meteringUnit) { |
| | | return measureLedgerMapper.selectMeasureLedger(page, code, deviceName, meteringUnit); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> standingBook(Integer measureId) { |
| | | return measureLedgerMapper.standingBook(measureId); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.yuanchu.mom.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.pojo.MeasureLedger; |
| | | import com.yuanchu.mom.pojo.MeteringPlan; |
| | | import com.yuanchu.mom.mapper.MeteringPlanMapper; |
| | | import com.yuanchu.mom.service.MeasureLedgerService; |
| | | import com.yuanchu.mom.service.MeteringPlanService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.yuanchu.mom.utils.JackSonUtil; |
| | | import com.yuanchu.mom.utils.MyUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | | * æå¡å®ç°ç±» |
| | | * </p> |
| | | * |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2023-08-16 11:42:31 |
| | | */ |
| | | @Service |
| | | public class MeteringPlanServiceImpl extends ServiceImpl<MeteringPlanMapper, MeteringPlan> implements MeteringPlanService { |
| | | |
| | | @Resource |
| | | private MeteringPlanMapper meteringPlanMapper; |
| | | |
| | | @Autowired |
| | | private MeasureLedgerService measureLedgerService; |
| | | |
| | | @Override |
| | | public Integer addMeteringPlan(MeteringPlan meteringPlan) { |
| | | String timeSixNumberCode = MyUtil.getTimeSixNumberCode("P", "P"); |
| | | meteringPlan.setPlanNumber(timeSixNumberCode); |
| | | int insertSuccess = meteringPlanMapper.insert(meteringPlan); |
| | | if (insertSuccess >= 1){ |
| | | Boolean aBoolean = measureLedgerService.addMeasureLedger(meteringPlan.getId(), meteringPlan.getMeasureLedgerList()); |
| | | if (aBoolean) { |
| | | return 1; |
| | | } |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> selectUnit() { |
| | | LambdaQueryWrapper<MeteringPlan> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.groupBy(MeteringPlan::getPlanUnit); |
| | | wrapper.select(MeteringPlan::getPlanUnit); |
| | | return meteringPlanMapper.selectMaps(wrapper); |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> selectMeteringTable(Integer pageNo, Integer pageSize, String code, String meteringUnit) { |
| | | List<Map<String, Object>> mapList = meteringPlanMapper.selectMeteringTable(pageNo, pageSize, code, meteringUnit); |
| | | if (!ObjectUtils.isEmpty(mapList)){ |
| | | for (Map<String, Object> map : mapList){ |
| | | int statue = 1; |
| | | try { |
| | | List<Map<String, Object>> result = JackSonUtil.unmarshal(JackSonUtil.marshal(map.get("result")), List.class); |
| | | for (Map<String, Object> mapResult : result){ |
| | | String result1 = mapResult.get("result").toString(); |
| | | if (result1.equals("n")){ |
| | | statue = 0; |
| | | break; |
| | | } |
| | | } |
| | | map.put("planStatue", statue); |
| | | map.remove("result"); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | LambdaQueryWrapper<MeteringPlan> wrapper = new LambdaQueryWrapper<>(); |
| | | if (!ObjectUtils.isEmpty(code)){ |
| | | wrapper.eq(MeteringPlan::getPlanNumber, code); |
| | | } |
| | | if (!ObjectUtils.isEmpty(meteringUnit)){ |
| | | wrapper.eq(MeteringPlan::getPlanUnit, meteringUnit); |
| | | } |
| | | Long aLong = meteringPlanMapper.selectCount(wrapper); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("row", mapList); |
| | | map.put("total", aLong); |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public Object standingBook(Integer measureId, Boolean accountOrPlan) { |
| | | if (accountOrPlan){ |
| | | return measureLedgerService.standingBook(measureId); |
| | | } else { |
| | | Map<String, Object> meteringPlan = meteringPlanMapper.selectIdPlanIdMessage(measureId); |
| | | List<Map<String, Object>> mapList = meteringPlanMapper.selectIdPlan(measureId); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("top", meteringPlan); |
| | | map.put("table", mapList); |
| | | return map; |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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="com.yuanchu.mom.mapper.MeasureLedgerMapper"> |
| | | |
| | | <select id="selectMeasureLedger" resultType="map"> |
| | | SELECT l.`id`, d.`code`, d.`name`,l.`measuring_range`, l.`measure_period`, l.`measure_result`, DATE_FORMAT(l.`measure_date`, '%Y-%m-%d') measureDate, |
| | | DATE_FORMAT(l.`validity_end`, '%Y-%m-%d') validityEnd, u.`name` founder, DATE_FORMAT(p.`create_time`, '%Y-%m-%d') createTime, |
| | | r.`name` person_charge, p.`plan_unit`, l.`measure_number` |
| | | FROM measure_ledger l, device d, metering_plan p, `user` u, `user` r |
| | | WHERE l.`device_id` = d.`id` |
| | | AND l.`state` = 1 |
| | | AND l.`measure_plan_id` = p.`id` |
| | | AND u.`id` = p.`founder` |
| | | AND r.`id` = p.`person_charge` |
| | | <if test="code != null and code != ''"> |
| | | AND d.`code` LIKE CONCAT('%', #{code}, '%') |
| | | </if> |
| | | <if test="deviceName != null and deviceName != ''"> |
| | | AND d.`name` LIKE CONCAT('%', #{deviceName}, '%') |
| | | </if> |
| | | <if test="meteringUnit != null and meteringUnit != ''"> |
| | | AND p.`plan_unit` LIKE CONCAT('%', #{meteringUnit}, '%') |
| | | </if> |
| | | ORDER BY l.`create_time` DESC |
| | | </select> |
| | | |
| | | <select id="standingBook" resultType="map"> |
| | | SELECT m.`id`, d.`code`, d.`name`, m.`measuring_range`, m.`measure_period`, m.`measure_result`, DATE_FORMAT(m.`measure_date`, '%Y-%m-%d') measureDate, |
| | | DATE_FORMAT(m.`validity_end`, '%Y-%m-%d') validityEnd, u.`name` founder, DATE_FORMAT(m.`create_time`, '%Y-%m-%d') createTime, p.`plan_unit`, |
| | | r.`name` personCharge, p.`plan_number`, DATE_FORMAT(p.`create_time`, '%Y-%m-%d') createTime, |
| | | CONCAT(p.`plan_date_begin`, ' ~ ', p.`plan_date_end`) planTime |
| | | FROM measure_ledger m, device d, metering_plan p, `user` u, `user` r |
| | | WHERE m.`state` = 1 |
| | | AND m.`id` = #{measureId} |
| | | AND u.`id` = p.`founder` |
| | | AND r.`id` = p.`person_charge` |
| | | AND m.`measure_plan_id` = p.`id` |
| | | AND m.`device_id` = d.`id` |
| | | </select> |
| | | </mapper> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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="com.yuanchu.mom.mapper.MeteringPlanMapper"> |
| | | |
| | | <resultMap id="selectMeteringTableMap" type="map"> |
| | | <id property="id" column="id"/> |
| | | <result property="planNumber" column="plan_number"/> |
| | | <result property="planDate" column="planDate"/> |
| | | <result property="founder" column="founder"/> |
| | | <result property="personCharge" column="personCharge"/> |
| | | <result property="createTime" column="createTime"/> |
| | | <collection property="result" resultMap="selectMeteringTableTwoMap" javaType="List"/> |
| | | </resultMap> |
| | | |
| | | <resultMap id="selectMeteringTableTwoMap" type="map"> |
| | | <result property="result" column="result"/> |
| | | </resultMap> |
| | | <select id="selectMeteringTable" resultMap="selectMeteringTableMap"> |
| | | SELECT s.*, IFNULL(l.`measure_result`, 'n') result |
| | | FROM (SELECT m.`id`, m.`plan_number`, CONCAT(m.`plan_date_begin`, ' ~ ', m.`plan_date_end`) planDate, |
| | | s.`name` founder, u.`name` personCharge, DATE_FORMAT(m.`create_time`, '%Y-%m-%d') createTime |
| | | FROM metering_plan m, `user` u, `user` s |
| | | WHERE u.`id` = m.`founder` |
| | | AND s.`id` = m.`person_charge` |
| | | LIMIT #{pageNo}, #{pageSize}) s |
| | | LEFT JOIN measure_ledger l |
| | | ON l.`measure_plan_id` = s.`id` |
| | | WHERE l.`state` = 1 |
| | | </select> |
| | | |
| | | <select id="selectIdPlan" resultType="map"> |
| | | SELECT m.`id`, d.`code`, d.`name`, m.`measuring_range`, m.`measure_period`, m.`measure_result`, DATE_FORMAT(m.`measure_date`, '%Y-%m-%d') measureDate, |
| | | DATE_FORMAT(m.`validity_end`, '%Y-%m-%d') validityEnd, u.`name` founder, DATE_FORMAT(m.`create_time`, '%Y-%m-%d') createTime, p.`plan_unit`, r.`name` personCharge, m.`measure_number` |
| | | FROM measure_ledger m, device d, metering_plan p, `user` u, `user` r |
| | | WHERE p.`state` = 1 |
| | | AND p.`id` = #{measureId} |
| | | AND u.`id` = p.`founder` |
| | | AND r.`id` = p.`person_charge` |
| | | AND m.`measure_plan_id` = p.`id` |
| | | AND m.`device_id` = d.`id` |
| | | </select> |
| | | |
| | | <select id="selectIdPlanIdMessage" resultType="map"> |
| | | SELECT p.`plan_number`, u.`name` founder, r.`name` person_charge, CONCAT(p.`plan_date_begin`, ' ~ ', p.`plan_date_end`) planTime, |
| | | DATE_FORMAT(p.`create_time`, '%Y-%m-%d') createTime, p.`plan_unit` |
| | | FROM metering_plan p, `user` u, `user` r |
| | | WHERE r.`id` = p.`person_charge` |
| | | AND u.`id` = p.`founder` |
| | | AND p.`state` = 1 |
| | | AND p.`id` = #{measureId} |
| | | </select> |
| | | </mapper> |
| | |
| | | @Override |
| | | public String addCon(String name, ConsignmentDto consignmentDto) { |
| | | //çæä¸ä¸ªæ¼è¿åç¼å· |
| | | String escortCode = MyUtil.getTimeSixNumberCode("YY"); |
| | | String escortCode = MyUtil.getTimeSixNumberCode("YY", "num"); |
| | | List<Consignment> consignments = consignmentMapper.selectAll(); |
| | | //妿åè´§è¡¨ä¸æ²¡ææ°æ®ä¹å¯ä»¥åè´§ |
| | | if (consignments.size() == 0) { |
| | |
| | | <openfeign.version>3.1.3</openfeign.version> |
| | | <feign-okhttp.version>11.0</feign-okhttp.version> |
| | | <shiro.version>1.5.3</shiro.version> |
| | | <velocity-engine.version>2.3</velocity-engine.version> |
| | | <freemwork.version>2.3.32</freemwork.version> |
| | | <!--æäº¤å--> |
| | | <!-- æå
å导åºçè·¯å¾ --> |
| | | <package.path>${project.build.directory}/BLOG</package.path> |
| | |
| | | <version>${mybatis-plus.version}</version> |
| | | </dependency> |
| | | |
| | | <!--代ç çæå¨æ¨¡æ¿--> |
| | | <dependency> |
| | | <groupId>org.freemarker</groupId> |
| | | <artifactId>freemarker</artifactId> |
| | | <version>${freemarker.version}</version> |
| | | </dependency> |
| | | |
| | | <!--feign--> |
| | | <dependency> |
| | | <groupId>org.springframework.cloud</groupId> |
| | |
| | | <groupId>org.apache.shiro</groupId> |
| | | <artifactId>shiro-spring-boot-starter</artifactId> |
| | | <version>${shiro.version}</version> |
| | | </dependency> |
| | | |
| | | <!-- 代ç çæå¨æ¨¡æ¿ï¼ç¨äºçæä»£ç --> |
| | | <dependency> |
| | | <groupId>org.apache.velocity</groupId> |
| | | <artifactId>velocity-engine-core</artifactId> |
| | | <version>${velocity-engine.version}</version> |
| | | </dependency> |
| | | </dependencies> |
| | | </dependencyManagement> |
| | |
| | | @ApiOperation(value = "å 餿 æ¨¡åæ°æ®", tags = "QMS管ç-->å®éªå®¤ç®¡ç") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "id", value = "æ ¹æ®è®¾å¤Idå é¤", dataTypeClass = Integer.class), |
| | | @ApiImplicitParam(name = "type", value = "设å¤ç±»å", dataTypeClass = Integer.class), |
| | | @ApiImplicitParam(name = "deviceFather", value = "æ ¹æ®è®¾å¤åç±»å é¤", dataTypeClass = String.class) |
| | | }) |
| | | @DeleteMapping("/deleteIdorFather") |
| | | public Result<?> deviceDeleteIdOrFather(Integer id, String deviceFather){ |
| | | Integer map = deviceService.deviceDeleteIdOrFather(id, deviceFather); |
| | | if (map == 1){ |
| | | public Result<?> deviceDeleteIdOrFather(Integer id, Integer type, String deviceFather){ |
| | | Integer map = deviceService.deviceDeleteIdOrFather(id, type, deviceFather); |
| | | if (map >= 1){ |
| | | return Result.success("å 餿åï¼"); |
| | | } |
| | | return Result.fail("å é¤å¤±è´¥ï¼"); |
| | |
| | | |
| | | Integer deviceDelete(Integer deviceId); |
| | | |
| | | Integer deviceDeleteIdOrFather(Integer id, String deviceFather); |
| | | Integer deviceDeleteIdOrFather(Integer id, Integer type, String deviceFather); |
| | | |
| | | List<Map<String, Object>> selectDeviceIdAndName(); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Integer deviceDeleteIdOrFather(Integer id, String deviceFather) { |
| | | public Integer deviceDeleteIdOrFather(Integer id, Integer type, String deviceFather) { |
| | | LambdaUpdateWrapper<Device> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | updateWrapper.set(Device::getState, 0); |
| | | if (id != null) { |
| | | if (id == null && deviceFather == null) { |
| | | return 0; |
| | | } else if (id != null) { |
| | | updateWrapper.eq(Device::getId, id); |
| | | } else if (deviceFather != null) { |
| | | updateWrapper.eq(Device::getType, type); |
| | | updateWrapper.eq(Device::getFather, deviceFather); |
| | | } |
| | | return deviceMapper.update(new Device(), updateWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> selectDeviceIdAndName() { |
| | | LambdaQueryWrapper<Device> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.select(Device::getId, Device::getName); |
| | | return deviceMapper.selectMaps(wrapper); |
| | | } |
| | | } |
| | |
| | | <artifactId>mybatis-plus-generator</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- 代ç çæå¨æ¨¡æ¿ï¼ç¨äºçæä»£ç --> |
| | | <!--代ç çæå¨æ¨¡æ¿--> |
| | | <dependency> |
| | | <groupId>org.apache.velocity</groupId> |
| | | <artifactId>velocity-engine-core</artifactId> |
| | | <groupId>org.freemarker</groupId> |
| | | <artifactId>freemarker</artifactId> |
| | | </dependency> |
| | | |
| | | <!--mysql--> |
| | |
| | | package com.yuanchu.mom; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.generator.FastAutoGenerator; |
| | | import com.baomidou.mybatisplus.generator.config.*; |
| | | import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy; |
| | | import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine; |
| | | import com.baomidou.mybatisplus.generator.fill.Column; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.Scanner; |
| | |
| | | // æ¼ç¤ºä¾åï¼æ§è¡ main æ¹æ³æ§å¶å°è¾å
¥æ¨¡å表åå车èªå¨çæå¯¹åºé¡¹ç®ç®å½ä¸ |
| | | public class CodeGenerator { |
| | | |
| | | public static String database_url = "jdbc:mysql://localhost:3306/mom_ocean?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai"; |
| | | public static String database_username = "root"; |
| | | public static String database_url = "jdbc:mysql://192.168.110.209:3306/mom_ocean?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai"; |
| | | public static String database_username = "user"; |
| | | public static String database_password= "123456"; |
| | | public static String author = "æ±èéµ·éç½ç»ç§ææéå
¬å¸"; |
| | | public static String model_name = "/sale-server"; // å¦æä¸ºåå¸å¼å¡«å模ååç§°ï¼å¦æä¸æ¯åå¸å¼ä¸ºç©ºå³å¯ |
| | | public static String model_name = "/inspect-server"; // å¦æä¸ºåå¸å¼å¡«å模ååç§°ï¼å¦æä¸æ¯åå¸å¼ä¸ºç©ºå³å¯ |
| | | public static String setParent = "com.yuanchu.mom"; // å
è·¯å¾ |
| | | public static void main(String[] args) { |
| | | String projectPath = System.getProperty("user.dir"); |
| | |
| | | .commentDate("yyyy-MM-dd hh:mm:ss") //æ³¨éæ¥æ |
| | | .outputDir(projectPath + model_name + "/src/main/java") // æå®è¾åºç®å½ |
| | | .disableOpenDir() //ç¦æ¢æå¼è¾åºç®å½ï¼é»è®¤æå¼ |
| | | .enableSwagger() // å¼å¯swagger |
| | | ; |
| | | }) |
| | | // å
é
ç½® |
| | |
| | | .enableLombok() //å¼å¯ Lombok |
| | | .naming(NamingStrategy.underline_to_camel) //æ°æ®åºè¡¨æ å°å°å®ä½çå½åçç¥ï¼ä¸åçº¿è½¬é©¼å³°å½ |
| | | .columnNaming(NamingStrategy.underline_to_camel) //æ°æ®åºè¡¨å段æ å°å°å®ä½çå½åçç¥ï¼ä¸åçº¿è½¬é©¼å³°å½ |
| | | .enableFileOverride() // è¦çå·²ç»çæçEntityæä»¶ |
| | | .logicDeleteColumnName("state") |
| | | .addTableFills( |
| | | new Column("create_time", FieldFill.INSERT), |
| | | new Column("update_time", FieldFill.INSERT_UPDATE) |
| | | ) |
| | | |
| | | // Mapper çç¥é
ç½® |
| | | .mapperBuilder() |
| | | .enableFileOverride() // è¦çå·²çææä»¶ |
| | | .enableFileOverride() // è¦çå·²çæMapperæä»¶ |
| | | |
| | | // Service çç¥é
ç½® |
| | | .serviceBuilder() |
| | | .enableFileOverride() // è¦çå·²çææä»¶ |
| | | .formatServiceFileName("%sService") //æ ¼å¼å service æ¥å£æä»¶åç§°ï¼%sè¿è¡å¹é
表åï¼å¦ UserService |
| | | .formatServiceImplFileName("%sServiceImpl") //æ ¼å¼å service å®ç°ç±»æä»¶åç§°ï¼%sè¿è¡å¹é
表åï¼å¦ UserServiceImpl |
| | | .enableFileOverride() // è¦çå·²çææä»¶ |
| | | |
| | | // Controller çç¥é
ç½® |
| | | .controllerBuilder() |
| | | .enableFileOverride() // è¦çå·²çææä»¶ |
| | | ; |
| | | }) |
| | | //5ãæ¨¡æ¿å¼æ |
| | | .templateEngine(new FreemarkerTemplateEngine()) //é»è®¤ |
| | | .execute(); |
| | | } |
| | | |
| | |
| | | * æ£éªæ¨¡å-->OMS管ç-->æåæ£éª-->æ°å¢(éè¦ç¨æ·Idä¸åç§°) |
| | | */ |
| | | List<Map<String, Object>> listUserIdAndName(); |
| | | |
| | | } |