10 changed files with 511 additions and 0 deletions
-
21src/main/java/com/xujie/sys/modules/pms/data/EamAdminData.java
-
98src/main/java/com/xujie/sys/modules/scheduling/controller/SchedulingController.java
-
15src/main/java/com/xujie/sys/modules/scheduling/entity/ClassesData.java
-
39src/main/java/com/xujie/sys/modules/scheduling/entity/SchedulingData.java
-
14src/main/java/com/xujie/sys/modules/scheduling/entity/SchedulingRecordData.java
-
37src/main/java/com/xujie/sys/modules/scheduling/mapper/SchedulingMapper.java
-
29src/main/java/com/xujie/sys/modules/scheduling/service/SchedulingService.java
-
157src/main/java/com/xujie/sys/modules/scheduling/service/impl/SchedulingServiceImpl.java
-
16src/main/resources/mapper/pms/EamMapper.xml
-
85src/main/resources/mapper/scheduling/SchedulingMapper.xml
@ -0,0 +1,98 @@ |
|||||
|
package com.xujie.sys.modules.scheduling.controller; |
||||
|
|
||||
|
import com.xujie.sys.common.utils.R; |
||||
|
import com.xujie.sys.modules.scheduling.entity.ClassesData; |
||||
|
import com.xujie.sys.modules.scheduling.entity.SchedulingData; |
||||
|
import com.xujie.sys.modules.scheduling.entity.SchedulingRecordData; |
||||
|
import com.xujie.sys.modules.scheduling.service.SchedulingService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@RestController |
||||
|
@RequestMapping("/scheduling/Scheduling1") |
||||
|
public class SchedulingController { |
||||
|
@Autowired |
||||
|
SchedulingService schedulingService; |
||||
|
|
||||
|
/** |
||||
|
* @Description TODO |
||||
|
* @Title eamFamilySave |
||||
|
* @param data |
||||
|
* @author rq |
||||
|
* @date 2023/1/29 15:13 |
||||
|
* @return Object |
||||
|
* @throw |
||||
|
*/ |
||||
|
@PostMapping(value="/saveClassesData") |
||||
|
@ResponseBody |
||||
|
public R saveClassesData(@RequestBody ClassesData data){ |
||||
|
System.out.println(data.toString()); |
||||
|
R r = schedulingService.saveClassesData(data); |
||||
|
return r; |
||||
|
} |
||||
|
|
||||
|
@PostMapping(value="/getSchedulingDataList") |
||||
|
@ResponseBody |
||||
|
public R getSchedulingDataList(@RequestBody ClassesData data){ |
||||
|
System.out.println(data.toString()); |
||||
|
List<ClassesData> list = schedulingService.getSchedulingDataList(data); |
||||
|
return R.ok().put("rows", list); |
||||
|
} |
||||
|
|
||||
|
@PostMapping(value="/delScheduling") |
||||
|
@ResponseBody |
||||
|
public R delScheduling(@RequestBody ClassesData data){ |
||||
|
System.out.println(data.toString()); |
||||
|
int i = schedulingService.delScheduling(data); |
||||
|
return R.ok(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@PostMapping(value="/getClassesList") |
||||
|
@ResponseBody |
||||
|
public R getClassesList(){ |
||||
|
List<ClassesData> list = schedulingService.getClassesList(); |
||||
|
return R.ok().put("rows",list); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@PostMapping(value="/querySchedulingList") |
||||
|
@ResponseBody |
||||
|
public R querySchedulingList(@RequestBody SchedulingData data){ |
||||
|
List<SchedulingData> list = schedulingService.querySchedulingList(data); |
||||
|
return R.ok().put("rows",list); |
||||
|
} |
||||
|
|
||||
|
@PostMapping(value="/saveSchedulingHeader") |
||||
|
@ResponseBody |
||||
|
public R saveSchedulingHeader(@RequestBody SchedulingData data){ |
||||
|
System.out.println(data.toString()); |
||||
|
R r = schedulingService.saveSchedulingHeader(data); |
||||
|
return r; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@PostMapping(value="/querySaveSchedulingRecord") |
||||
|
@ResponseBody |
||||
|
public R querySaveSchedulingRecord(@RequestBody SchedulingData data){ |
||||
|
List<SchedulingRecordData> list = schedulingService.querySaveSchedulingRecord(data); |
||||
|
return R.ok().put("rows", list); |
||||
|
} |
||||
|
|
||||
|
@PostMapping(value="/deleteSchedulingRecord") |
||||
|
@ResponseBody |
||||
|
public R deleteSchedulingRecord(@RequestBody SchedulingRecordData data){ |
||||
|
R r = schedulingService.deleteSchedulingRecord(data); |
||||
|
return r; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@PostMapping(value="/editSaveSchedulingRecord") |
||||
|
@ResponseBody |
||||
|
public R editSaveSchedulingRecord(@RequestBody SchedulingRecordData data){ |
||||
|
R r = schedulingService.editSaveSchedulingRecord(data); |
||||
|
return r; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,15 @@ |
|||||
|
package com.xujie.sys.modules.scheduling.entity; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.TableField; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
@Data |
||||
|
public class ClassesData { |
||||
|
private String code; |
||||
|
private String description; |
||||
|
private String site; |
||||
|
private String bu; |
||||
|
private String buNo; |
||||
|
@TableField(exist = false) |
||||
|
private Integer id; |
||||
|
} |
||||
@ -0,0 +1,39 @@ |
|||||
|
package com.xujie.sys.modules.scheduling.entity; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.TableField; |
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.xujie.sys.modules.pms.data.EamAdminData; |
||||
|
import lombok.Data; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
|
||||
|
@Data |
||||
|
public class SchedulingData { |
||||
|
private Integer id; |
||||
|
private String classesCode; |
||||
|
private String classesDescription; |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
||||
|
private Date date; |
||||
|
@TableField(exist = false) |
||||
|
private String bu; |
||||
|
private String site; |
||||
|
private String buNo; |
||||
|
@TableField(exist = false) |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
||||
|
private Date startDate; |
||||
|
@TableField(exist = false) |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
||||
|
private Date endDate; |
||||
|
@TableField(exist = false) |
||||
|
private Object checkbox1; |
||||
|
@TableField(exist = false) |
||||
|
private Object checkbox2; |
||||
|
@TableField(exist = false) |
||||
|
private List<EamAdminData> peopleList; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
package com.xujie.sys.modules.scheduling.entity; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
@Data |
||||
|
public class SchedulingRecordData { |
||||
|
private Integer id; |
||||
|
private String adminId; |
||||
|
private String adminName; |
||||
|
private Integer headId; |
||||
|
private String isHoliday; |
||||
|
private Integer editId; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,37 @@ |
|||||
|
package com.xujie.sys.modules.scheduling.mapper; |
||||
|
|
||||
|
import com.xujie.sys.modules.scheduling.entity.ClassesData; |
||||
|
import com.xujie.sys.modules.scheduling.entity.SchedulingData; |
||||
|
import com.xujie.sys.modules.scheduling.entity.SchedulingRecordData; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
import org.springframework.stereotype.Repository; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@Mapper |
||||
|
@Repository |
||||
|
public interface SchedulingMapper { |
||||
|
int insertClassesData(ClassesData data); |
||||
|
|
||||
|
List<ClassesData> getSchedulingDataList(ClassesData data); |
||||
|
|
||||
|
int delScheduling(ClassesData data); |
||||
|
|
||||
|
int updateClassesData(ClassesData data); |
||||
|
|
||||
|
int getSchedulingDataCount(ClassesData data); |
||||
|
|
||||
|
List<ClassesData> getClassesList(); |
||||
|
|
||||
|
List<SchedulingData> querySchedulingList(SchedulingData data); |
||||
|
|
||||
|
void saveSchedulingHeader(SchedulingData data); |
||||
|
|
||||
|
void saveSchedulingRecord(SchedulingRecordData schedulingRecordData); |
||||
|
|
||||
|
List<SchedulingRecordData> querySaveSchedulingRecord(SchedulingData data); |
||||
|
|
||||
|
int deleteSchedulingRecord(SchedulingRecordData data); |
||||
|
|
||||
|
int editSaveSchedulingRecord(SchedulingRecordData data); |
||||
|
} |
||||
@ -0,0 +1,29 @@ |
|||||
|
package com.xujie.sys.modules.scheduling.service; |
||||
|
|
||||
|
import com.xujie.sys.common.utils.R; |
||||
|
import com.xujie.sys.modules.scheduling.entity.ClassesData; |
||||
|
import com.xujie.sys.modules.scheduling.entity.SchedulingData; |
||||
|
import com.xujie.sys.modules.scheduling.entity.SchedulingRecordData; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
public interface SchedulingService { |
||||
|
R saveClassesData(ClassesData data); |
||||
|
|
||||
|
List<ClassesData> getSchedulingDataList(ClassesData data); |
||||
|
|
||||
|
int delScheduling(ClassesData data); |
||||
|
|
||||
|
List<ClassesData> getClassesList(); |
||||
|
|
||||
|
List<SchedulingData> querySchedulingList(SchedulingData data); |
||||
|
|
||||
|
R saveSchedulingHeader(SchedulingData data); |
||||
|
|
||||
|
List<SchedulingRecordData> querySaveSchedulingRecord(SchedulingData data); |
||||
|
|
||||
|
R deleteSchedulingRecord(SchedulingRecordData data); |
||||
|
|
||||
|
R editSaveSchedulingRecord(SchedulingRecordData data); |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,157 @@ |
|||||
|
package com.xujie.sys.modules.scheduling.service.impl; |
||||
|
|
||||
|
import com.xujie.sys.common.utils.R; |
||||
|
import com.xujie.sys.modules.pms.data.EamAdminData; |
||||
|
import com.xujie.sys.modules.scheduling.entity.ClassesData; |
||||
|
import com.xujie.sys.modules.scheduling.entity.SchedulingData; |
||||
|
import com.xujie.sys.modules.scheduling.entity.SchedulingRecordData; |
||||
|
import com.xujie.sys.modules.scheduling.mapper.SchedulingMapper; |
||||
|
import com.xujie.sys.modules.scheduling.service.SchedulingService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import java.util.*; |
||||
|
|
||||
|
@Service |
||||
|
public class SchedulingServiceImpl implements SchedulingService { |
||||
|
@Autowired |
||||
|
SchedulingMapper schedulingMapper; |
||||
|
@Override |
||||
|
public R saveClassesData(ClassesData data) { |
||||
|
if (!data.getBu().isEmpty()){ |
||||
|
String[] split = data.getBu().split("_"); |
||||
|
data.setSite(split[0]); |
||||
|
data.setBuNo(split[1]); |
||||
|
} |
||||
|
//判断请求 新增||更新 |
||||
|
if (data.getId()>0){ |
||||
|
int i = schedulingMapper.updateClassesData(data); |
||||
|
return R.ok(); |
||||
|
}else { |
||||
|
int count = schedulingMapper.getSchedulingDataCount(data); |
||||
|
if (count > 0) { |
||||
|
return R.error("该班次编码已存在,请勿重复添加"); |
||||
|
} |
||||
|
int i = schedulingMapper.insertClassesData(data); |
||||
|
return R.ok(); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<ClassesData> getSchedulingDataList(ClassesData data) { |
||||
|
if (!data.getBu().isEmpty()){ |
||||
|
String[] split = data.getBu().split("_"); |
||||
|
data.setSite(split[0]); |
||||
|
data.setBuNo(split[1]); |
||||
|
} |
||||
|
List<ClassesData> list = schedulingMapper.getSchedulingDataList(data); |
||||
|
return list; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public int delScheduling(ClassesData data) { |
||||
|
int i = schedulingMapper.delScheduling(data); |
||||
|
return i; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<ClassesData> getClassesList() { |
||||
|
List<ClassesData> list = schedulingMapper.getClassesList(); |
||||
|
return list; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<SchedulingData> querySchedulingList(SchedulingData data) { |
||||
|
if (!Objects.isNull(data.getBu())&&!data.getBu().equals("")){ |
||||
|
data.setSite(data.getBu().split("_")[0]); |
||||
|
data.setBuNo(data.getBu().split("_")[1]); |
||||
|
} |
||||
|
|
||||
|
List<SchedulingData> list = schedulingMapper.querySchedulingList(data); |
||||
|
return list; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional |
||||
|
public R saveSchedulingHeader(SchedulingData data) { |
||||
|
// 获得 site 和 bu |
||||
|
if (data.getBu().split("_").length >= 2 ) { |
||||
|
data.setSite(data.getBu().split("_")[0]); |
||||
|
data.setBuNo(data.getBu().split("_")[1]); |
||||
|
} else { |
||||
|
throw new RuntimeException("工厂和部门有误!"); |
||||
|
} |
||||
|
Date startDate = data.getStartDate(); |
||||
|
Date endDate = data.getEndDate(); |
||||
|
String checkbox1 = Objects.toString(data.getCheckbox1()); |
||||
|
String checkbox2 = Objects.toString(data.getCheckbox2()); |
||||
|
Calendar cal = Calendar.getInstance(); |
||||
|
cal.setTime(startDate); |
||||
|
while (!cal.getTime().after(endDate)) { |
||||
|
int day = cal.get(Calendar.DAY_OF_WEEK); |
||||
|
if ((day == Calendar.SATURDAY && !"true".equals(checkbox1))){ |
||||
|
System.out.println("进入周六判断"); |
||||
|
cal.add(Calendar.DATE, 1); |
||||
|
continue; |
||||
|
} |
||||
|
if ((day == Calendar.SUNDAY && !"true".equals(checkbox2))){ |
||||
|
System.out.println("进入周日判断"); |
||||
|
cal.add(Calendar.DATE, 1); |
||||
|
continue; |
||||
|
} |
||||
|
data.setDate(cal.getTime()); |
||||
|
|
||||
|
try { |
||||
|
//新增主表信息 |
||||
|
schedulingMapper.saveSchedulingHeader(data); |
||||
|
}catch (Exception e){ |
||||
|
System.out.println("进入catch逻辑"); |
||||
|
return R.error("保存失败,请检查是否存在重复的班次编码和日期"); |
||||
|
} |
||||
|
//设置子表参数 |
||||
|
SchedulingRecordData schedulingRecordData = new SchedulingRecordData(); |
||||
|
schedulingRecordData.setHeadId(data.getId()); |
||||
|
schedulingRecordData.setIsHoliday("N"); |
||||
|
List<EamAdminData> peopleList = data.getPeopleList(); |
||||
|
for (int i = 0;i<peopleList.size();i++){ |
||||
|
schedulingRecordData.setAdminId(peopleList.get(i).getAdminID()); |
||||
|
schedulingRecordData.setAdminName(peopleList.get(i).getAdminName()); |
||||
|
schedulingMapper.saveSchedulingRecord(schedulingRecordData); |
||||
|
} |
||||
|
cal.add(Calendar.DATE, 1); |
||||
|
} |
||||
|
|
||||
|
return R.ok(); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<SchedulingRecordData> querySaveSchedulingRecord(SchedulingData data) { |
||||
|
List<SchedulingRecordData> list = schedulingMapper.querySaveSchedulingRecord(data); |
||||
|
return list; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public R deleteSchedulingRecord(SchedulingRecordData data) { |
||||
|
int i = schedulingMapper.deleteSchedulingRecord(data); |
||||
|
return R.ok().put("msg", "删除成功"); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public R editSaveSchedulingRecord(SchedulingRecordData data) { |
||||
|
if (data.getEditId()>0){ |
||||
|
int i = schedulingMapper.editSaveSchedulingRecord(data); |
||||
|
}else { |
||||
|
SchedulingRecordData schedulingRecordData = new SchedulingRecordData(); |
||||
|
schedulingRecordData.setHeadId(data.getHeadId()); |
||||
|
schedulingRecordData.setAdminId(data.getAdminId()); |
||||
|
schedulingRecordData.setAdminName(data.getAdminName()); |
||||
|
schedulingRecordData.setIsHoliday(data.getIsHoliday()); |
||||
|
schedulingMapper.saveSchedulingRecord(schedulingRecordData); |
||||
|
} |
||||
|
return R.ok(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,85 @@ |
|||||
|
<?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.xujie.sys.modules.scheduling.mapper.SchedulingMapper"> |
||||
|
|
||||
|
<insert id="insertClassesData"> |
||||
|
insert into tpm_classes(code,description,site,bu_no) |
||||
|
values (#{code}, #{description}, #{site}, #{buNo}) |
||||
|
</insert> |
||||
|
<insert id="saveSchedulingHeader" parameterType="com.xujie.sys.modules.scheduling.entity.SchedulingData" useGeneratedKeys="true" keyProperty="id"> |
||||
|
insert into tpm_scheduling(site, bu_no,date,classes_code) |
||||
|
values (#{site},#{buNo},#{date},#{classesCode}) |
||||
|
</insert> |
||||
|
<insert id="saveSchedulingRecord"> |
||||
|
insert into tpm_scheduling_record(admin_id,admin_name,head_id,isHoliday) |
||||
|
values (#{adminId}, #{adminName}, #{headId},#{isHoliday}) |
||||
|
</insert> |
||||
|
<update id="updateClassesData"> |
||||
|
update tpm_classes set description = #{description} |
||||
|
where code = #{code} and site = #{site} and bu_no = #{buNo} |
||||
|
</update> |
||||
|
<update id="editSaveSchedulingRecord"> |
||||
|
update tpm_scheduling_record set isHoliday = #{isHoliday} |
||||
|
where id = #{id} |
||||
|
</update> |
||||
|
<delete id="delScheduling"> |
||||
|
delete from tpm_classes |
||||
|
where code = #{code} and site = #{site} and bu_no = #{buNo} |
||||
|
</delete> |
||||
|
<delete id="deleteSchedulingRecord"> |
||||
|
delete from tpm_scheduling_record |
||||
|
where id = #{id} |
||||
|
</delete> |
||||
|
<select id="getSchedulingDataList" resultType="com.xujie.sys.modules.scheduling.entity.ClassesData"> |
||||
|
select * from tpm_classes |
||||
|
<where> |
||||
|
<if test="code != null and code != ''"> |
||||
|
and code like concat('%', #{code}, '%') |
||||
|
</if> |
||||
|
<if test="description != null and description != ''"> |
||||
|
and description like concat('%', #{description}, '%') |
||||
|
</if> |
||||
|
<if test="site != null and site != ''"> |
||||
|
and site = #{site} |
||||
|
</if> |
||||
|
<if test="buNo != null and buNo != ''"> |
||||
|
and bu_no = #{buNo} |
||||
|
</if> |
||||
|
</where> |
||||
|
</select> |
||||
|
<select id="getSchedulingDataCount" resultType="java.lang.Integer"> |
||||
|
select count(*) from tpm_classes |
||||
|
where code = #{code} |
||||
|
</select> |
||||
|
<select id="getClassesList" resultType="com.xujie.sys.modules.scheduling.entity.ClassesData"> |
||||
|
select * from tpm_classes |
||||
|
</select> |
||||
|
<select id="querySchedulingList" resultType="com.xujie.sys.modules.scheduling.entity.SchedulingData"> |
||||
|
select tpm_scheduling.*, |
||||
|
tc.description as classesDescription |
||||
|
from tpm_scheduling |
||||
|
left join tpm_classes tc on tpm_scheduling.classes_code = tc.code |
||||
|
<where> |
||||
|
<if test="site != null and site != ''"> |
||||
|
and site = #{site} |
||||
|
</if> |
||||
|
<if test="buNo != null and buNo != ''"> |
||||
|
and bu_no = #{buNo} |
||||
|
</if> |
||||
|
<if test="classesCode != null and classesCode != ''"> |
||||
|
and classes_code = #{classesCode} |
||||
|
</if> |
||||
|
<if test="startDate != null"> |
||||
|
and date >= #{startDate} |
||||
|
</if> |
||||
|
<if test="endDate != null"> |
||||
|
and date <![CDATA[<=]]> #{endDate} |
||||
|
</if> |
||||
|
</where> |
||||
|
</select> |
||||
|
<select id="querySaveSchedulingRecord" resultType="com.xujie.sys.modules.scheduling.entity.SchedulingRecordData"> |
||||
|
select * from tpm_scheduling_record |
||||
|
where head_id = #{id} |
||||
|
</select> |
||||
|
</mapper> |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue