Merge remote-tracking branch 'origin/dev' into dev
| | |
| | | return AjaxResult.error("模板内容为空"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据车间查询标准工序列表 |
| | | */ |
| | | @Operation(summary = "根据车间查询标准工序列表", description = "全量查询") |
| | | @RequiresPermissions("aps:standardProcess:listByWorkShop") |
| | | @GetMapping("/listByWorkShop") |
| | | public TableDataInfo listByWorkShop(ApsStandardProcess apsStandardProcess) |
| | | { |
| | | List<ApsStandardProcess> list = apsStandardProcessService.selectApsStandardProcessList(apsStandardProcess); |
| | | return getDataTable(list); |
| | | } |
| | | } |
| | |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody ApsWorkCalendar apsWorkCalendar) |
| | | { |
| | | ApsWorkCalendar tempCheck = new ApsWorkCalendar(); |
| | | tempCheck.setEffectiveDate(apsWorkCalendar.getEffectiveDate()); |
| | | tempCheck.setExpiringDate(apsWorkCalendar.getExpiringDate()); |
| | | tempCheck.setApplicableFactory(apsWorkCalendar.getApplicableFactory()); |
| | | List<ApsWorkCalendar> list = apsWorkCalendarService.selectApsWorkCalendarList(tempCheck); |
| | | if(!list.isEmpty()){ |
| | | return AjaxResult.error("该时间段日历已存在", list); |
| | | }else{ |
| | | return toAjax(apsWorkCalendarService.insertApsWorkCalendar(apsWorkCalendar)); |
| | | try { |
| | | ApsWorkCalendar tempCheck = new ApsWorkCalendar(); |
| | | tempCheck.setEffectiveDate(apsWorkCalendar.getEffectiveDate()); |
| | | tempCheck.setExpiringDate(apsWorkCalendar.getExpiringDate()); |
| | | tempCheck.setApplicableFactory(apsWorkCalendar.getApplicableFactory()); |
| | | tempCheck.setType(apsWorkCalendar.getType()); |
| | | List<ApsWorkCalendar> list = apsWorkCalendarService.selectApsWorkCalendarList(tempCheck); |
| | | if(!list.isEmpty()){ |
| | | return AjaxResult.error("该时间段日历已存在", list); |
| | | }else{ |
| | | apsWorkCalendarService.insertApsWorkCalendar(apsWorkCalendar); |
| | | return success(); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return error(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 修改日历管理 |
| | | */ |
| | | @RequiresPermissions("aps:calendar:edit") |
| | | // @RequiresPermissions("aps:calendar:edit") |
| | | @Log(title = "日历管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody ApsWorkCalendar apsWorkCalendar) |
| | | { |
| | | ApsWorkCalendar tempCheck = new ApsWorkCalendar(); |
| | | tempCheck.setEffectiveDate(apsWorkCalendar.getEffectiveDate()); |
| | | tempCheck.setExpiringDate(apsWorkCalendar.getExpiringDate()); |
| | | tempCheck.setApplicableFactory(apsWorkCalendar.getApplicableFactory()); |
| | | List<ApsWorkCalendar> list = apsWorkCalendarService.selectApsWorkCalendarList(tempCheck); |
| | | if(!list.isEmpty()){ |
| | | return AjaxResult.error("该时间段日历已存在", list); |
| | | }else{ |
| | | return toAjax(apsWorkCalendarService.updateApsWorkCalendar(apsWorkCalendar)); |
| | | try { |
| | | // ApsWorkCalendar tempCheck = new ApsWorkCalendar(); |
| | | // tempCheck.setEffectiveDate(apsWorkCalendar.getEffectiveDate()); |
| | | // tempCheck.setExpiringDate(apsWorkCalendar.getExpiringDate()); |
| | | // tempCheck.setApplicableFactory(apsWorkCalendar.getApplicableFactory()); |
| | | // tempCheck.setType(apsWorkCalendar.getType()); |
| | | // List<ApsWorkCalendar> list = apsWorkCalendarService.selectApsWorkCalendarList(tempCheck); |
| | | // if(!list.isEmpty()){ |
| | | // return AjaxResult.error("该时间段日历已存在", list); |
| | | // }else{ |
| | | apsWorkCalendarService.updateApsWorkCalendar(apsWorkCalendar); |
| | | return success(); |
| | | // } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return error(); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 删除日历管理 |
| | | */ |
| | | @RequiresPermissions("aps:calendar:delete") |
| | | @Log(title = "删除日历管理", businessType = BusinessType.DELETE) |
| | | @PostMapping("/deleteApsWorkCalendar") |
| | | public AjaxResult deleteApsWorkCalendar(@RequestBody ApsWorkCalendar apsWorkCalendar) |
| | | { |
| | | return toAjax(apsWorkCalendarService.deleteApsWorkCalendar(apsWorkCalendar)); |
| | | } |
| | | |
| | | /** |
| | | * 查询日历管理列表 |
| | | */ |
| | | @RequiresPermissions("aps:calendar:list") |
| | |
| | | @Excel(name = "适用工序") |
| | | private String applicableProcess; |
| | | |
| | | public void setId(Long id) |
| | | /** 节假日 */ |
| | | private Object holidays; |
| | | |
| | | /** 适用工厂/车间/工序数组 */ |
| | | private Object applicable; |
| | | |
| | | /** 适用工厂/车间/工序数组 回显 */ |
| | | private String applicableTranslate; |
| | | |
| | | public String getApplicableTranslate() { |
| | | return applicableTranslate; |
| | | } |
| | | |
| | | public void setApplicableTranslate(String applicableTranslate) { |
| | | this.applicableTranslate = applicableTranslate; |
| | | } |
| | | |
| | | public Object getHolidays() { |
| | | return holidays; |
| | | } |
| | | |
| | | public void setHolidays(Object holidays) { |
| | | this.holidays = holidays; |
| | | } |
| | | |
| | | public Object getApplicable() { |
| | | return applicable; |
| | | } |
| | | |
| | | public void setApplicable(Object applicable) { |
| | | this.applicable = applicable; |
| | | } |
| | | |
| | | public void setId(Long id) |
| | | { |
| | | this.id = id; |
| | | } |
| | |
| | | * @return 结果 |
| | | */ |
| | | public int deleteApsWorkCalendarByIds(Long[] ids); |
| | | |
| | | /** |
| | | * 删除日历管理 |
| | | * |
| | | * @param ids 需要删除的数据主键集合 |
| | | * @return 结果 |
| | | */ |
| | | public int deleteApsWorkCalendar(ApsWorkCalendar apsWorkCalendar); |
| | | } |
| | |
| | | * @return JSONArray |
| | | */ |
| | | JSONArray selectCalendarView(ApsWorkCalendar apsWorkCalendar); |
| | | |
| | | /** |
| | | * 删除日历数据 |
| | | * @param apsWorkCalendar |
| | | * @return |
| | | */ |
| | | public int deleteApsWorkCalendar(ApsWorkCalendar apsWorkCalendar); |
| | | } |
| | |
| | | List<ApsWorkCalendar> list = apsWorkCalendarMapper.selectApsWorkCalendarList(apsWorkCalendar); |
| | | for (ApsWorkCalendar apsWorkCalendarTemp : list) { |
| | | //工作日 |
| | | if("1".equals(apsWorkCalendarTemp.getType())){ |
| | | //获取日历规则 |
| | | org.postgresql.util.PGobject pgObject = (org.postgresql.util.PGobject) apsWorkCalendarTemp.getContent(); |
| | | JSONArray weekdays = (JSON.parseObject(pgObject.getValue())).getJSONArray("weekdays"); |
| | | HashMap<String, String> weekdaysMap = new HashMap<>(); |
| | | for (int i = 0; i < weekdays.size(); i++) { |
| | | weekdaysMap.put(weekdays.getJSONObject(i).getString("day"), weekdays.getJSONObject(i).getString("work")); |
| | | } |
| | | //根据effectiveDate和expiringDate算出日期范围内的每一天 |
| | | List<LocalDate> datesTemp = getDatesBetween(apsWorkCalendarTemp.getEffectiveDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), apsWorkCalendarTemp.getExpiringDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate()); |
| | | for (LocalDate dateTemp: datesTemp) { |
| | | if(baseCalendar.containsKey(dateTemp+"")){ |
| | | if ("y".equals(weekdaysMap.get(dateTemp.getDayOfWeek().getDisplayName(java.time.format.TextStyle.FULL, Locale.ENGLISH)))) { |
| | | baseCalendar.put(dateTemp+"", "工作日"); |
| | | } else if("n".equals(weekdaysMap.get(dateTemp.getDayOfWeek().getDisplayName(java.time.format.TextStyle.FULL, Locale.ENGLISH)))) { |
| | | baseCalendar.put(dateTemp+"", "休息日"); |
| | | } |
| | | org.postgresql.util.PGobject pgObjectWeekdays = (org.postgresql.util.PGobject) apsWorkCalendarTemp.getContent(); |
| | | JSONArray weekdays = (JSON.parseObject(pgObjectWeekdays.getValue())).getJSONArray("weekdays"); |
| | | HashMap<String, String> weekdaysMap = new HashMap<>(); |
| | | for (int i = 0; i < weekdays.size(); i++) { |
| | | weekdaysMap.put(weekdays.getJSONObject(i).getString("day"), weekdays.getJSONObject(i).getString("work")); |
| | | } |
| | | List<LocalDate> datesTempWeekdays = getDatesBetween(apsWorkCalendarTemp.getEffectiveDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), apsWorkCalendarTemp.getExpiringDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate()); |
| | | for (LocalDate dateTemp: datesTempWeekdays) { |
| | | if(baseCalendar.containsKey(dateTemp+"")){ |
| | | if ("y".equals(weekdaysMap.get(dateTemp.getDayOfWeek().getDisplayName(java.time.format.TextStyle.FULL, Locale.ENGLISH)))) { |
| | | baseCalendar.put(dateTemp+"", "工作日"); |
| | | } else if("n".equals(weekdaysMap.get(dateTemp.getDayOfWeek().getDisplayName(java.time.format.TextStyle.FULL, Locale.ENGLISH)))) { |
| | | baseCalendar.put(dateTemp+"", "休息日"); |
| | | } |
| | | } |
| | | }else if("2".equals(apsWorkCalendarTemp.getType())){ |
| | | //休息日 |
| | | org.postgresql.util.PGobject pgObject = (org.postgresql.util.PGobject) apsWorkCalendarTemp.getContent(); |
| | | JSONObject holidays = (JSON.parseObject(pgObject.getValue())).getJSONObject("holidays"); |
| | | List<LocalDate> datesTemp = getDatesBetween(holidays.getObject("startdate", LocalDate.class), holidays.getObject("enddate", LocalDate.class)); |
| | | for (LocalDate dateTemp: datesTemp) { |
| | | if(baseCalendar.containsKey(dateTemp+"")){ |
| | | baseCalendar.put(dateTemp+"", "节假日"); |
| | | } |
| | | //休息日 |
| | | org.postgresql.util.PGobject pgObjectHolidays = (org.postgresql.util.PGobject) apsWorkCalendarTemp.getHolidays(); |
| | | if(pgObjectHolidays!=null){ |
| | | JSONArray holidays = (JSON.parseObject(pgObjectHolidays.getValue())).getJSONArray("holidays"); |
| | | for (int i = 0; i < holidays.size(); i++){ |
| | | JSONObject h = holidays.getJSONObject(i); |
| | | List<LocalDate> datesTempHolidays = getDatesBetween(h.getObject("startdate", LocalDate.class), h.getObject("enddate", LocalDate.class)); |
| | | for (LocalDate dateTemp: datesTempHolidays) { |
| | | if(baseCalendar.containsKey(dateTemp+"")){ |
| | | baseCalendar.put(dateTemp+"", "节假日"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | return res; |
| | | } |
| | | |
| | | @Override |
| | | public int deleteApsWorkCalendar(ApsWorkCalendar apsWorkCalendar){ |
| | | return apsWorkCalendarMapper.deleteApsWorkCalendar(apsWorkCalendar); |
| | | } |
| | | |
| | | private List<LocalDate> getCalendarData(int year, int month) { |
| | | // 获取4月1号的当周的周日 |
| | | LocalDate startDate = LocalDate.of(year, month, 1) |
| | |
| | | <result property="createTime" column="create_time" /> |
| | | <result property="updateBy" column="update_by" /> |
| | | <result property="updateTime" column="update_time" /> |
| | | <result property="holidays" column="holidays" /> |
| | | <result property="applicable" column="applicable" /> |
| | | <result property="applicableTranslate" column="applicable_translate" /> |
| | | </resultMap> |
| | | |
| | | <sql id="selectApsWorkCalendarVo"> |
| | | select id, description, type, effective_date, expiring_date, content, applicable_factory, applicable_workshop, applicable_process, create_by, create_time, update_by, update_time from aps_work_calendar |
| | | select id, description, type, effective_date, expiring_date, content, applicable_factory, applicable_workshop, applicable_process, create_by, create_time, update_by, update_time, holidays, applicable, applicable_translate from aps_work_calendar |
| | | </sql> |
| | | |
| | | <select id="selectApsWorkCalendarList" parameterType="ApsWorkCalendar" resultMap="ApsWorkCalendarResult"> |
| | |
| | | <if test="type != null and type != ''"> and type = #{type}</if> |
| | | <if test="effectiveDate != null and expiringDate != null"> and ((effective_date >= #{effectiveDate} and effective_date <= #{expiringDate}) or (expiring_date >= #{effectiveDate} and expiring_date <= #{expiringDate}))</if> |
| | | <!-- <if test="content != null and content != ''"> and content = #{content}</if>--> |
| | | <if test="applicableFactory != null and applicableFactory != ''"> and applicable_factory = #{applicableFactory}</if> |
| | | <if test="applicableFactory != null and applicableFactory != ''"> |
| | | and EXISTS ( |
| | | SELECT 1 |
| | | FROM jsonb_array_elements(applicable) AS obj |
| | | WHERE obj ->> 'factory' = #{applicableFactory} |
| | | ) |
| | | </if> |
| | | <if test="applicableWorkshop != null and applicableWorkshop != ''"> and applicable_workshop = #{applicableWorkshop}</if> |
| | | <if test="applicableProcess != null and applicableProcess != ''"> and applicable_process = #{applicableProcess}</if> |
| | | </where> |
| | |
| | | <if test="createTime != null">create_time,</if> |
| | | <if test="updateBy != null">update_by,</if> |
| | | <if test="updateTime != null">update_time,</if> |
| | | <if test="holidays != null">holidays,</if> |
| | | <if test="applicable != null">applicable,</if> |
| | | <if test="applicableTranslate != null">applicable_translate,</if> |
| | | </trim> |
| | | <trim prefix="values (" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id},</if> |
| | |
| | | <if test="createTime != null">#{createTime},</if> |
| | | <if test="updateBy != null">#{updateBy},</if> |
| | | <if test="updateTime != null">#{updateTime},</if> |
| | | <if test="holidays != null">#{holidays, typeHandler=com.aps.core.typeHandler.JsonTypeHandler, jdbcType=OTHER},</if> |
| | | <if test="applicable != null">#{applicable, typeHandler=com.aps.core.typeHandler.JsonTypeHandler, jdbcType=OTHER},</if> |
| | | <if test="applicableTranslate != null">#{applicableTranslate},</if> |
| | | </trim> |
| | | </insert> |
| | | |
| | |
| | | <if test="createTime != null">create_time = #{createTime},</if> |
| | | <if test="updateBy != null">update_by = #{updateBy},</if> |
| | | <if test="updateTime != null">update_time = #{updateTime},</if> |
| | | <if test="holidays != null">holidays = #{holidays, typeHandler=com.aps.core.typeHandler.JsonTypeHandler, jdbcType=OTHER},</if> |
| | | <if test="applicable != null">applicable = #{applicable, typeHandler=com.aps.core.typeHandler.JsonTypeHandler, jdbcType=OTHER},</if> |
| | | <if test="applicableTranslate != null">applicable_translate = #{applicableTranslate},</if> |
| | | </trim> |
| | | where id = #{id} |
| | | </update> |
| | |
| | | delete from aps_work_calendar where id = #{id} |
| | | </delete> |
| | | |
| | | <delete id="deleteApsWorkCalendarByIds" parameterType="String"> |
| | | delete from aps_work_calendar where id in |
| | | <delete id="deleteApsWorkCalendarByIds" parameterType="ApsWorkCalendar"> |
| | | delete from aps_work_calendar where id in |
| | | <foreach item="id" collection="array" open="(" separator="," close=")"> |
| | | #{id} |
| | | </foreach> |
| | | </delete> |
| | | |
| | | <delete id="deleteApsWorkCalendar" parameterType="ApsWorkCalendar"> |
| | | delete from aps_work_calendar where effective_date=#{effectiveDate} and expiring_date=#{expiringDate} and applicable_factory=#{applicableFactory} and applicable_workshop=#{applicableWorkshop} and applicable_process=#{applicableProcess} |
| | | </delete> |
| | | </mapper> |
| | |
| | | create_by, |
| | | now() |
| | | FROM aps_bom_header_job |
| | | -- FROM aps_bom_header_job as a |
| | | -- LEFT JOIN aps_material_storage_management as b ON a.item_code = b.item_number |
| | | -- where b.material_type='制造件' |
| | | </insert> |
| | | |
| | | <!-- 删除 aps_bom_header 表中的数据 --> |
| | |
| | | create_by, |
| | | now() |
| | | FROM aps_bom_line_job |
| | | -- FROM aps_bom_line_job as a |
| | | -- LEFT JOIN aps_material_storage_management as b ON a.item_code = b.item_number |
| | | -- where b.material_type='制造件' |
| | | </insert> |
| | | |
| | | <!-- 删除 aps_bom_line 表中的数据 --> |